From 0177cfb9248f5e82f3f92a92b77f7aac527d99ff Mon Sep 17 00:00:00 2001 From: Olof Bjerke Date: Tue, 3 Nov 2020 14:05:11 +0100 Subject: [PATCH] Add circular treemap --- .../spotfire/spotfire-api.d.ts | 4 +- examples/js-areachart-d3/static/index.html | 2 +- .../spotfire/spotfire-api.d.ts | 4 +- .../src/index.html | 2 +- .../spotfire/spotfire-api.d.ts | 4 +- examples/js-dev-barchart/src/index.html | 2 +- examples/js-dev-circular-treemap/README.md | 19 + .../development-server.js | 110 ++ examples/js-dev-circular-treemap/package.json | 16 + .../prettier.config.js | 19 + .../spotfire/mod-schema.json | 389 +++++ .../spotfire/spotfire-api.d.ts | 1529 +++++++++++++++++ .../src/circular-treemap.css | 26 + .../src/circular-treemap.js | 299 ++++ .../js-dev-circular-treemap/src/d3.min.js | 2 + examples/js-dev-circular-treemap/src/icon.svg | 5 + .../js-dev-circular-treemap/src/index.html | 23 + .../src/mod-manifest.json | 33 + .../js-dev-circular-treemap/tsconfig.json | 9 + .../spotfire/spotfire-api.d.ts | 4 +- .../js-dev-starter/spotfire/spotfire-api.d.ts | 4 +- examples/js-dev-starter/src/index.html | 2 +- .../spotfire/spotfire-api.d.ts | 4 +- .../static-files/icon.svg | 1 - .../static-files/index.html | 17 - .../static-files/main.css | 17 - .../static/index.html | 2 +- 27 files changed, 2502 insertions(+), 46 deletions(-) create mode 100644 examples/js-dev-circular-treemap/README.md create mode 100644 examples/js-dev-circular-treemap/development-server.js create mode 100644 examples/js-dev-circular-treemap/package.json create mode 100644 examples/js-dev-circular-treemap/prettier.config.js create mode 100644 examples/js-dev-circular-treemap/spotfire/mod-schema.json create mode 100644 examples/js-dev-circular-treemap/spotfire/spotfire-api.d.ts create mode 100644 examples/js-dev-circular-treemap/src/circular-treemap.css create mode 100644 examples/js-dev-circular-treemap/src/circular-treemap.js create mode 100644 examples/js-dev-circular-treemap/src/d3.min.js create mode 100644 examples/js-dev-circular-treemap/src/icon.svg create mode 100644 examples/js-dev-circular-treemap/src/index.html create mode 100644 examples/js-dev-circular-treemap/src/mod-manifest.json create mode 100644 examples/js-dev-circular-treemap/tsconfig.json delete mode 100644 examples/ts-dev-gauge-googlecharts/static-files/icon.svg delete mode 100644 examples/ts-dev-gauge-googlecharts/static-files/index.html delete mode 100644 examples/ts-dev-gauge-googlecharts/static-files/main.css diff --git a/examples/js-areachart-d3/spotfire/spotfire-api.d.ts b/examples/js-areachart-d3/spotfire/spotfire-api.d.ts index d8d0d46d..9202d538 100644 --- a/examples/js-areachart-d3/spotfire/spotfire-api.d.ts +++ b/examples/js-areachart-d3/spotfire/spotfire-api.d.ts @@ -741,7 +741,9 @@ declare interface GeneralStylingInfo { * console.log("Mod API loaded."); * }); * ``` - * [[include:initialize.md]] + * The initialize method will invoke the provided callback with an instance of the mod API, to be used by the mod developer. + * + * The initialize method needs to be invoked in order for the mod to function. Even if the mod only displays static content, the API must be initialized in order for events and export to work. * @public * @param onLoaded - Callback that is called when the mod API is initialized and ready to be interacted with. */ diff --git a/examples/js-areachart-d3/static/index.html b/examples/js-areachart-d3/static/index.html index 016acb76..38dba776 100644 --- a/examples/js-areachart-d3/static/index.html +++ b/examples/js-areachart-d3/static/index.html @@ -17,7 +17,7 @@
- + diff --git a/examples/js-dev-barchart-googlecharts/spotfire/spotfire-api.d.ts b/examples/js-dev-barchart-googlecharts/spotfire/spotfire-api.d.ts index d8d0d46d..9202d538 100644 --- a/examples/js-dev-barchart-googlecharts/spotfire/spotfire-api.d.ts +++ b/examples/js-dev-barchart-googlecharts/spotfire/spotfire-api.d.ts @@ -741,7 +741,9 @@ declare interface GeneralStylingInfo { * console.log("Mod API loaded."); * }); * ``` - * [[include:initialize.md]] + * The initialize method will invoke the provided callback with an instance of the mod API, to be used by the mod developer. + * + * The initialize method needs to be invoked in order for the mod to function. Even if the mod only displays static content, the API must be initialized in order for events and export to work. * @public * @param onLoaded - Callback that is called when the mod API is initialized and ready to be interacted with. */ diff --git a/examples/js-dev-barchart-googlecharts/src/index.html b/examples/js-dev-barchart-googlecharts/src/index.html index 53885642..4302727f 100644 --- a/examples/js-dev-barchart-googlecharts/src/index.html +++ b/examples/js-dev-barchart-googlecharts/src/index.html @@ -17,7 +17,7 @@
- + diff --git a/examples/js-dev-barchart/spotfire/spotfire-api.d.ts b/examples/js-dev-barchart/spotfire/spotfire-api.d.ts index d8d0d46d..9202d538 100644 --- a/examples/js-dev-barchart/spotfire/spotfire-api.d.ts +++ b/examples/js-dev-barchart/spotfire/spotfire-api.d.ts @@ -741,7 +741,9 @@ declare interface GeneralStylingInfo { * console.log("Mod API loaded."); * }); * ``` - * [[include:initialize.md]] + * The initialize method will invoke the provided callback with an instance of the mod API, to be used by the mod developer. + * + * The initialize method needs to be invoked in order for the mod to function. Even if the mod only displays static content, the API must be initialized in order for events and export to work. * @public * @param onLoaded - Callback that is called when the mod API is initialized and ready to be interacted with. */ diff --git a/examples/js-dev-barchart/src/index.html b/examples/js-dev-barchart/src/index.html index 204586a4..c059c089 100644 --- a/examples/js-dev-barchart/src/index.html +++ b/examples/js-dev-barchart/src/index.html @@ -21,7 +21,7 @@
- + diff --git a/examples/js-dev-circular-treemap/README.md b/examples/js-dev-circular-treemap/README.md new file mode 100644 index 00000000..318563ac --- /dev/null +++ b/examples/js-dev-circular-treemap/README.md @@ -0,0 +1,19 @@ +# Circular Treemap +This mod example is a simple circular treemap implemented with [d3](https://d3js.org/). It shows how hierarchies in mod data views can be mapped to d3 hierarchies. + +It also illustrates some basic concepts, such as using a color axis, and implementing simple marking and tooltips. + +All source code for the mod example can be found in the `src` folder. + +## Prerequisites +These instructions assume that you have [Node.js](https://nodejs.org/en/) (which includes npm) installed. + +## How to get started (with development server) +- Open a terminal at the location of this example. +- Run `npm install`. This will install necessary tools. Run this command only the first time you are building the mod and skip this step for any subsequent builds. +- Run `npm run server`. This will start a development server. +- Start editing, for example `src/circular-treemap.js`. +- In Spotfire, follow the steps of creating a new mod and connecting to the development server. + +## Working without a development server +- In Spotfire, follow the steps of creating a new mod and then browse for, and point to, the _manifest_ in the `src` folder. diff --git a/examples/js-dev-circular-treemap/development-server.js b/examples/js-dev-circular-treemap/development-server.js new file mode 100644 index 00000000..88733367 --- /dev/null +++ b/examples/js-dev-circular-treemap/development-server.js @@ -0,0 +1,110 @@ +/* +* Copyright © 2020. TIBCO Software Inc. +* This file is subject to the license terms contained +* in the license file that is distributed with this file. +*/ + +//@ts-check + +/** + * # Spotfire mods development server + * The purpose of the development server is to simplify the development of mods. The development server mimics the way the Spotfire runtime works in regards to cross origin requests and content security policies. + */ + +const liveServer = require("live-server"); +const path = require("path"); +const fs = require("fs"); +const { promisify } = require("util"); +const readFile = promisify(fs.readFile); +const readdir = promisify(fs.readdir); + +const manifestName = "mod-manifest.json"; +const rootDirectory = process.argv[2] || "./src/"; + +// The development server tries to mimic the CSP policy used by the Spotfire runtime. +const allowedExternalResources = new Set(); +let declaredExternalResourcesInManifest = []; + +main(); + +async function main() { + await readExternalResourcesFromManifest(); + + liveServer.start({ + port: 8090, + noCssInject: true, + cors: false, + // @ts-ignore + open: "/" + manifestName, + root: rootDirectory, + wait: 250, // Waits for all changes, before reloading. Defaults to 0 sec. + middleware: [cacheRedirect] + }); +} + +/** + * Read external resources from the mod manifest placed in the root directory. + */ +async function readExternalResourcesFromManifest() { + const rootDirectoryAbsolutePath = path.resolve(rootDirectory); + const files = await readdir(rootDirectoryAbsolutePath); + + if (files.find((fileName) => fileName == manifestName)) { + const manifestPath = path.join(rootDirectoryAbsolutePath, manifestName); + + await readExternalResources(); + fs.watch(manifestPath, {}, readExternalResources); + + async function readExternalResources() { + let content = await readFile(manifestPath, { encoding: "utf-8" }); + + try { + let json = JSON.parse(content); + declaredExternalResourcesInManifest = json.externalResources || []; + } catch (err) {} + } + } else { + console.warn("Could not find a mod-manifest.json in the root directory", rootDirectoryAbsolutePath); + } +} + +/** + * Middleware to manage caching and CSP headers. + * @param {any} req - request object + * @param {any} res - response object + * @param {any} next - next callback to invoke the next middleware + */ +function cacheRedirect(req, res, next) { + const isCorsRequest = req.headers.origin != undefined; + const requestFromOutsideSandbox = req.headers.origin != "null"; + + // Prevent CORS requests from the sandboxed iframe. E.g module loading will not work in embedded mode. + if (isCorsRequest && requestFromOutsideSandbox) { + allowedExternalResources.add(req.headers.origin); + + res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); + res.setHeader("Access-Control-Allow-Origin", "*"); + } + + // Turn off caching on everything to avoid stale CSP headers etc. in the browser. + // This also ensures that live server can inject its websocket snippet in .html pages it serves to the mod iframe. + res.setHeader("Cache-Control", "no-store"); + + if (req.method !== "GET") { + next(); + return; + } + + // Set same security headers in the development server as in the Spotfire runtime. + res.setHeader( + "content-security-policy", + `sandbox allow-scripts; default-src 'self' 'unsafe-eval' 'unsafe-hashes' 'unsafe-inline' blob: data: ${[ + ...allowedExternalResources.values() + , ...declaredExternalResourcesInManifest].join(" ")}` + ); + + // CSP header used by older browsers where the CSP policy is not fully supported. + res.setHeader("x-content-security-policy", "sandbox allow-scripts"); + + next(); +} diff --git a/examples/js-dev-circular-treemap/package.json b/examples/js-dev-circular-treemap/package.json new file mode 100644 index 00000000..0fc1691f --- /dev/null +++ b/examples/js-dev-circular-treemap/package.json @@ -0,0 +1,16 @@ +{ + "name": "spotfire-mod-example", + "version": "1.0.0", + "description": "", + "scripts": { + "start": "npm install && npm run server", + "server": "node development-server.js src" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "live-server": "^1.2.1" + }, + "dependencies": {} +} \ No newline at end of file diff --git a/examples/js-dev-circular-treemap/prettier.config.js b/examples/js-dev-circular-treemap/prettier.config.js new file mode 100644 index 00000000..b78a93ca --- /dev/null +++ b/examples/js-dev-circular-treemap/prettier.config.js @@ -0,0 +1,19 @@ +/* +* Copyright © 2020. TIBCO Software Inc. +* This file is subject to the license terms contained +* in the license file that is distributed with this file. +*/ + +/*global module*/ +module.exports = { + // Fit code within this line limit + printWidth: 120, + // Number of spaces it should use per tab + tabWidth: 4, + // If true, will use single instead of double quotes + singleQuote: false, + // Controls the printing of trailing commas wherever possible + trailingComma: "none", + // Controls the printing of spaces inside array and objects + bracketSpacing: true +}; diff --git a/examples/js-dev-circular-treemap/spotfire/mod-schema.json b/examples/js-dev-circular-treemap/spotfire/mod-schema.json new file mode 100644 index 00000000..625c309a --- /dev/null +++ b/examples/js-dev-circular-treemap/spotfire/mod-schema.json @@ -0,0 +1,389 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + + "definitions": { + "axis": { + "type": "object", + "title": "Axis definitions", + "description": "Specifies properties that can be used to configure Axis and ColorAxis entries.", + "required": ["mode"], + "properties": { + "mode": { + "type": "string", + "title": "Mode", + "description": "Specifies what kind of expressions this axis supports: categorical, continuous or both.", + "enum": ["continuous", "categorical", "dual"], + "examples": ["categorical"] + }, + "preferredDualMode": { + "type": "string", + "title": "Preferred mode for dual axis", + "enum": ["continuous", "categorical"], + "default": "categorical", + "description": "Specifies the mode that this axis prefers to be in. This option only applies if this axis is configured with mode 'dual'." + }, + "allowNonAggregatingMeasures": { + "type": "boolean", + "title": "Allow non-aggregating measures", + "description": "Specifies if this axis supports non-aggregating expressions (expressions without an aggregation method) when it is in continuous mode.", + "default": false + }, + "automaticConfiguration": { + "type": "object", + "title": "Automatic configuration", + "description": "Specifies how automatic configuration is made for this axis when the Mod Visualization is created.", + "additionalProperties": false, + "properties": { + "expressionHeuristics": { + "type": "string", + "title": "Expression heuristics", + "enum": ["none", "default"], + "default": "default", + "description": "Specifies the heuristics to use when this axis is assigned an initial expression. Use 'none' to skip the heuristics and leave this axis with an empty expression." + }, + "priority": { + "type": "integer", + "title": "Priority", + "default": "0", + "description": "Specifies the order in which this axis will be treated when the heuristics assigns the initial expression. A higher value means it will be treated before axes with a lower value. Two axes with the same value will be treated in undefined order." + } + } + }, + "dataTypes": { + "type": "object", + "title": "Supported Data Types", + "description": "Specifies which data types that this axis supports when in continuous mode. These settings affect which kinds of expressions that Spotfire will consider valid for this axis.", + "additionalProperties": false, + "properties": { + "allowNumeric": { + "type": "boolean", + "title": "Allow Numeric data types", + "default": true, + "description": "Specifies whether to allow expressions with numeric data types." + }, + "allowDateTime": { + "type": "boolean", + "title": "Allow the Time, Date and DateTime data types", + "default": false, + "description": "Specifies whether to allow expressions with Time, Date and DateTime data types." + }, + "allowTimeSpan": { + "type": "boolean", + "title": "Allow the TimeSpan data type", + "default": false, + "description": "Specifies whether to allow expressions with TimeSpan data type." + }, + "allowString": { + "type": "boolean", + "title": "Allow the String data type", + "default": false, + "description": "Specifies whether to allow expressions with String data type." + }, + "allowBoolean": { + "type": "boolean", + "title": "Allow the Boolean data type", + "default": false, + "description": "Specifies whether to allow expressions with Boolean data type." + } + } + }, + "dropTarget": { + "type": "object", + "title": "Drop target", + "description": "Specifies the drop target behavior for this axis.", + "additionalProperties": false, + "required": ["icon", "description"], + "properties": { + "icon": { + "type": "string", + "title": "The drop target icon", + "description": "Specifies which, from a selection of built in icons, to use as the drop target.", + "enum": [ + "XAxis", + "YAxis", + "XAxis3D", + "YAxis3D", + "ZAxis3D", + "SectorSize", + "MarkerSize", + "Size", + "Color", + "Shape", + "Line", + "TrellisPanels", + "TrellisHorizontally", + "TrellisVertically", + "Column", + "ColumnAxis", + "RowAxis", + "CellValues", + "CellValuesSum", + "Icon", + "Tile", + "Hierarchy", + "Time", + "Compare", + "TableCategories" + ], + "examples": ["XAxis"] + }, + "description": { + "type": "string", + "title": "The drop target description", + "description": "Specifies the text to display when dragging an expression or column over the drop target. Use {0} to inject the name of the item being dragged.", + "examples": ["Set {0} on the Size axis"] + } + } + } + } + } + }, + + "title": "The Spotfire mod manifest schema", + "type": "object", + "required": ["apiVersion", "version", "name", "id", "icon", "files"], + "additionalProperties": false, + "properties": { + "version": { + "type": "string", + "title": "Mod version.", + "description": "Specifies the version of this Mod.", + "default": "", + "examples": ["1.0"], + "pattern": "^(.*)$" + }, + "apiVersion": { + "type": "string", + "title": "Mod API version.", + "description": "Specifies the version of the Mod JavaScript API used by the code of this Mod.", + "default": "1.0", + "examples": ["1.0"], + "pattern": "^(.*)$" + }, + "name": { + "type": "string", + "title": "Name of the mod", + "description": "Specifies the name of this Mod. The name will be shown to the user when this Mod is handled in Spotfire.", + "default": "", + "examples": ["Spotfire mod boilerplate"], + "pattern": "^(.*)$" + }, + "icon": { + "type": "string", + "title": "Specifies the name of the file containing the svg icon to be used for this Mod.", + "default": "icon.svg" + }, + "id": { + "type": "string", + "title": "Mod ID. A unique string.", + "default": "", + "examples": ["spotfire-boilerplate-id"], + "pattern": "^(.*)$" + }, + "externalResources": { + "type": "array", + "title": "Specifies external resources loaded from the mod.", + "description": "Only declared external resources will work in the mod. A visualization mod with external resources cannot be exported using the web client.", + "items": { + "type": "string", + "examples": [ + "https://www.example.com" + ] + } + }, + "properties": { + "type": "array", + "title": "Mod Properties", + "description": "Specifies the properties that are stored in this Mods part of the Spotfire document. Use properties to store settings values.", + "default": null, + "items": { + "type": "object", + "title": "The Items Schema", + "required": ["name", "type", "defaultValue"], + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "title": "Property name", + "description": "Specifies the unique name used to refer to this property from the code.", + "default": "", + "examples": ["width"], + "pattern": "^(.*)$", + "additionalProperties": false + }, + "type": { + "type": "string", + "enum": ["integer", "double", "string", "boolean"], + "title": "Value type", + "description": "Specifies the type of values stored by this property.", + "default": "string", + "examples": ["integer"], + "pattern": "^(.*)$", + "additionalProperties": false + }, + "defaultValue": { + "type": ["string", "number", "boolean"], + "title": "Default value", + "description": "Specifies the value that this property will have when an instance of the Mod is created.", + "default": "", + "examples": ["3"], + "pattern": "^(.*)$", + "additionalProperties": false + } + } + } + }, + "dataViewDefinition": { + "type": "object", + "title": "Mod view definition", + "description": "Specifies how Spotfire computes the data consumed by the Mod.", + "default": {}, + "additionalProperties": false, + "properties": { + "colorAxis": { + "allOf": [ + { "$ref": "#/definitions/axis" }, + { + "type": "object", + "title": "ColorAxis", + "description": "Specifies that the Mod shall have a color axis.", + "properties": { + "legendItem": { + "type": "object", + "title": "Legend Item", + "description": "Specifies behavior and properties of how this axis is shown in the legend.", + "additionalProperties": false, + "properties": { + "defaultVisibility": { + "type": "string", + "title": "Default visibility", + "enum": ["visible", "hidden"], + "description": "Specifies whether to initially show or hide the item for this axis in the legend." + } + } + } + } + } + ] + }, + "axes": { + "type": "array", + "title": "The mod axes", + "description": "Specifies the axes that defines how Spotfire computes the data view consumed by the Mod.", + "items": { + "allOf": [ + { "$ref": "#/definitions/axis" }, + { + "type": "object", + "title": "Axis", + "required": ["name"], + "properties": { + "name": { + "type": "string", + "title": "Name", + "default": "X", + "description": "Specifies the unique named used to refer to this axis from the code.", + "examples": ["X"], + "pattern": "^(.*)$" + }, + "allowMultipleMeasures": { + "type": "boolean", + "title": "Allow multiple measures", + "description": "Specifies if this axis supports having multiple measure expression when it is in continuous mode.", + "default": false + }, + "placement": { + "type": "string", + "title": "Placement", + "enum": ["left", "bottom", "top", "right", "none"], + "description": "Specifies the placement of the axis tray for this axis.", + "examples": ["bottom"] + }, + "legendItem": { + "type": "object", + "title": "Legend Item", + "description": "Specifies behavior and properties of how this axis is shown in the legend.", + "additionalProperties": false, + "properties": { + "defaultVisibility": { + "type": "string", + "title": "Default visibility", + "enum": ["visible", "hidden"], + "default": "visible", + "description": "Specifies whether to initially show or hide the item for this axis in the legend." + }, + "title": { + "type": "string", + "title": "Title", + "description": "Specifies the title to show in the item for this axis in the legend." + } + } + }, + "propertyControl": { + "type": "object", + "title": "Property Control", + "description": "Specifies behavior and properties of how a control for this axis is shown in the properties dialog.", + "additionalProperties": false, + "properties": { + "visibility": { + "type": "string", + "title": "Visibility", + "enum": ["visible", "hidden"], + "default": "visible", + "description": "Specifies whether to show a control for this axis in the properties dialog." + }, + "title": { + "type": "string", + "title": "Title", + "description": "Specifies the title of the control for this axis." + } + } + } + } + } + ] + } + } + } + }, + "legend": { + "type": "object", + "title": "Legend", + "description": "Specifies properties of the Spotfire Legend for the Mod.", + "default": {}, + "additionalProperties": false, + "properties": { + "defaultPlacement": { + "type": "string", + "enum": ["left", "right"], + "title": "Default placement of the Legend", + "description": "Specifies where the Legend is initially placed. If omitted, the Legend will be placed to the right." + }, + "defaultVisibility": { + "type": "string", + "enum": ["visible", "hidden"], + "title": "Default visibility of Legend", + "description": "Specifies whether to initially show or hide the Legend. If omitted, the Legend will be shown." + } + } + }, + "files": { + "type": "array", + "title": "The files stored in the mod", + "description": "All files of a mod will be saved into Spotfire. The files array lists all files so that Spotfire can save them.\nThis list is auto generated when starting the project.", + "items": { + "type": "string", + "title": "The Items Schema", + "default": "", + "examples": [ + "index.html", + "spotfire/spotfire-api.d.ts", + "spotfire/spotfire-api.js", + "main.css", + "main.js" + ], + "pattern": "^(.*)$" + } + } + } +} diff --git a/examples/js-dev-circular-treemap/spotfire/spotfire-api.d.ts b/examples/js-dev-circular-treemap/spotfire/spotfire-api.d.ts new file mode 100644 index 00000000..9202d538 --- /dev/null +++ b/examples/js-dev-circular-treemap/spotfire/spotfire-api.d.ts @@ -0,0 +1,1529 @@ +/* +* Copyright © 2020. TIBCO Software Inc. +* This file is subject to the license terms contained +* in the license file that is distributed with this file. +*/ +export as namespace Spotfire; + +/** + * Predicate to determine if a current read operation for {@link DataView.allRows} should be aborted when there is new, non-streaming, data available. If this predicate returns true the {@link DataView.allRows} promise will be rejected and no rows will be returned. + * @public + */ +export declare type AbortPredicate = (currentRowCount: number) => boolean; + +/** + * Represents a property owned by the Spotfire document. + * These can be either document properties, data table properties or data column properties. + * @public + */ +export declare interface AnalysisProperty extends AnalysisPropertyValue { + /** + * Set the value of this instance. + * @param value - The value to set. + */ + set(value: T | T[] | null): void; +} + +/** + * Represents the data types possible to store in a document, table or column {@link AnalysisProperty}. + * @public + */ +export declare type AnalysisPropertyDataType = string | number | boolean | Date | TimeSpan | Time; + +/** + * Represents the values held by a {@link AnalysisProperty}. + * @public + */ +export declare interface AnalysisPropertyValue { + /** + * Gets the name of this instance. + */ + name: string; + /** + * Gets the value held by this instance. Will throw if the value is a list, i.e. {@link AnalysisPropertyValue.isList} returns true; + */ + value(): T2 | null; + /** + * Gets the value held by this instance. Will throw if the value is not a list, i.e. {@link AnalysisPropertyValue.isList} returns false; + */ + valueList(): T2[]; + /** + * Get the Spotfire internal data type of the property. + */ + dataType: DataType; + /** + * Gets a value indicating whether the property is a list. + */ + isList: boolean; +} + +/** + * Represents an axis of the Mod Visualization. + * @public + */ +export declare interface Axis extends AxisValues { + /** + * Sets the full axis expression to the specified `value`. + */ + setExpression(value: string): void; +} + +/** + * Represents one element of a multi-part axis expression. + * @public + */ +export declare interface AxisPart { + /** + * Gets the expression of this part. + */ + expression: string; + /** + * Gets the display name of this part. + */ + displayName: string; +} + +/** + * Represents the values held by an {@link Axis}. + * @public + */ +export declare interface AxisValues { + /** + * Gets the name of this instance. + */ + name: string; + /** + * Gets the {@link AxisPart}s that this axis has. The parts are derived from the current {@link AxisValues.expression}. + */ + parts: AxisPart[]; + /** + * Gets the full expression of this instance, including multi-part delimiters and + * surrounding "\<\>" brackets if the axis is in categorical mode. + */ + expression: string; + /** + * Gets a value indicating whether the axis is categorical or continuous. + */ + isCategorical: boolean; +} + +/** + * Represents a data column in a Spotfire data table. + * @public + */ +export declare interface Column extends ColumnValues { + /** + * Provides access to the properties of this instance. See {@link AnalysisProperty}. + */ + properties(): Readable; + /** + * Provides access to the {@link AnalysisProperty} with the specified `name`. + */ + property(name: string): Readable; +} + +/** + * Represents the values held by a {@link Column}. + * @public + */ +export declare interface ColumnValues { + /** + * Gets the name of this instance. + */ + name: string; + /** + * Gets the data type of this instance. + */ + dataType: DataType; +} + +/** + * Represents an object with methods to show a context menu. + * @public + */ +export declare interface ContextMenu { + /** + * Shows a context menu with the specified `items`. The context menu closes when the user clicks one of the + * items or outside the context menu. + * @param x - The horizontal pixel coordinate where to show the context menu. + * @param y - The vertical pixel coordinate where to show the context menu. + * @param items - Defines the content of the context menu. + * @returns A Promise that, when resolved, provides the {@link ContextMenuItem} that was clicked by the user, + * or `undefined` if the user clicked outside the context menu. + */ + show(x: number, y: number, items: ContextMenuItem[]): Promise; +} + +/** + * Represents an item in a context menu shown by calling {@link ContextMenu.show}. + * @public + */ +export declare interface ContextMenuItem { + /** + * Specifies the text to show in this item. + */ + text: string; + /** + * Specifies whether this item is enabled. + */ + enabled: boolean; + /** + * Specifies the tooltip to show for this item. If not defined, no tooltip will be shown when hovering the this item. + */ + tooltip?: string; + /** + * Specifies a value indicating whether this item is checked. If not defined, this item will not be rendered in a checked state. + */ + checked?: boolean; +} + +/** + * Provides access points to launch Spotfire controls and UI component relevant for a Mod Visualization. + * @public + */ +export declare interface Controls { + /** + * Gets an object with methods to show a context menu. + */ + contextMenu: ContextMenu; + /** + * Gets an object with methods to show and hide a Spotfire tooltip. + */ + tooltip: Tooltip; + /** + * Gets an object with methods to show and hide the Spotfire progress indicator. + */ + progress: Progress; + /** + * Gets an object that can be used to create and show a Spotfire popout dialog. + */ + popout: Popout; + /** + * Gets an object that can be used to show an error overlay native Spotfire style. + */ + errorOverlay: ErrorOverlay; +} + +/** + * Represents a data table in the Spotfire document. + * @public + */ +export declare interface DataTable extends DataTableValues { + /** + * Provides access to the columns of this instance. See {@link Column}. + */ + columns(): Readable; + /** + * Provides access to the {@link Column} with the specified `name`. + */ + column(name: string): ReadableProxy; + /** + * Provides access to the properties of this instance. See {@link AnalysisProperty}. + */ + properties(): Readable; + /** + * Provides access to the {@link AnalysisProperty} with the specified `name`. + */ + property(name: string): Readable; +} + +/** + * Represents the values held by a {@link DataTable}. + * @public + */ +export declare interface DataTableValues { + /** + * Gets the name of this instance. + */ + name: string; + /** + * Gets the number of columns in this instance. + */ + columnCount: number; +} + +/** + * Represents the data type of a value. + * @public + */ +export declare interface DataType { + /** + * Gets the name of this DataType. + */ + name: "String" | "Integer" | "LongInteger" | "Real" | "SingleReal" | "Currency" | "Boolean" | "Date" | "DateTime" | "Time" | "TimeSpan" | "Binary"; + /** + * Gets a value indicating whether the data type is numeric or not, that is, + * Integer, Currency, Real, LongInteger, or SingleReal. + */ + isNumber(): boolean; + /** + * Gets a value indicating whether the data type is represents by Date or not, that is, Date, or DateTime. + */ + isDate(): boolean; + /** + * Gets a value indicating whether the data type is represents by {@link Time} or not. + */ + isTime(): boolean; + /** + * Gets a value indicating whether the data type is represents by {@link TimeSpan} or not. + */ + isTimeSpan(): boolean; +} + +/** + * Represents a view of the data from which the visualization can be rendered. + * + * This object contains the result of the query made by Spotfire against the DataTable + * currently used by the Mod Visualization, using the Filtering, Marking, expressions + * on the Axes and other relevant settings. + * @public + */ +export declare interface DataView { + /** + * Mark a set of rows. + * The full set will be the union of all mark operations performed within one transaction (see {@link Mod.transaction}). + * All mark operations must have the same marking operation. + * @param rows - The rows to be selected. + * @param operation - Optional {@link MarkingOperation}. Default value is `Replace`. + */ + mark(rows: DataViewRow[], markingOperation?: MarkingOperation): void; + /** + * Clears the current marking + */ + clearMarking(): void; + /** + * Gets the marking information, or null if marking is not enabled. + */ + marking(): Promise; + /** + * Gets a value indicating whether the dataView has expired. + * The dataview has expired when there has been changes to the document, + * for example marking or filtering. + * When true, there will be a new dataview available on the next read. + */ + hasExpired(): Promise; + /** + * Gets any errors generated while creating the dataview. + * Returns empty array if none occurred. + */ + getErrors(): Promise; + /** + * Gets metadata for a specific categorical axis in the {@link DataView}. + * Categorical axes are defined in the manifest file as categorical or dual. + * When this method fails to return a valid axis getting the corresponding call to {@link DataViewRow.categorical} will throw an error. + * Returns null for axes with empty expressions or for dual mode axes that currently are in continuous mode. + * Throws if the axis does not exist or the axes mode is continuous. + * @param name - The axis name. + */ + categoricalAxis(name: string): Promise; + /** + * Gets metadata for a specific continuous axis in the {@link DataView}. + * Continuous axes are defined in the manifest file as continuous or dual. + * When this method fails to return a valid axis getting the corresponding call to {@link DataViewRow.continuous} will throw an error. + * Returns null for axes with empty expressions or for dual mode axes that currently are in categorical mode. + * Throws if the axis does not exist or the axes mode is categorical. + * @param name - The axis name. + */ + continuousAxis(name: string): Promise; + /** + * Gets metadata of all axes currently present in the {@link DataView}. + * Axes with empty expression are omitted. + */ + axes(): Promise; + /** + * Gets a hierarchy for a categorical axis. + * + * If the axis has an empty expression the hierarchy will contain one single root node. + * Returns null for dual mode axes that currently are in continuous mode. + * Throws if the axis does not exist or the axes mode is continuous. + * @param name - The name of the axis to get the hierarchy for. + */ + hierarchy(name: string): Promise; + /** + * Gets the total number of rows of the {@link DataView} without actually getting all the rows. Use this function to determine whether or not the mod will be able to handle the amount of data rows. + * When there are errors in the mod configuration there will be no rows available and this method will return undefined. + */ + rowCount(): Promise; + /** + * Gets all rows from the data view as one asynchronous operation. + * The allRows function has a built in cache and can be called multiple times with the same dataView and it will return the same list of rows. + * @param abortPredicate - Optional. Predicate to determine whether the operation should be aborted when there is new, non-streaming, data available. If this predicate returns true the promise will be rejected. + * The default behavior is that reading will be aborted when new non-streaming update is available. + * @returns null if reading data was aborted, otherwise a {@link DataViewRow}[]. + */ + allRows(abortPredicate?: AbortPredicate): Promise; +} + +/** + * Contains metadata computed for an {@link Axis}. + * @public + */ +export declare interface DataViewAxis { + /** + * Gets the name of this axis. + */ + name: string; + /** + * Gets a value indicating whether this axis is an instance of {@link DataViewContinuousAxis} or {@link DataViewCategoricalAxis} . + */ + isCategorical: boolean; +} + +/** + * Represents metadata computed for a categorical {@link Axis}. + * @public + */ +export declare interface DataViewCategoricalAxis extends DataViewAxis { + /** + * Gets the hierarchy of this axis. + */ + hierarchy: DataViewHierarchy; +} + +/** + * Represents a value of a categorical axis for one row in a data view. + * @public + */ +export declare interface DataViewCategoricalValue { + /** + * Gets an array representing the full path of the value in the hierarchy defined by the axis expression. + * The first element is the top level of the hierarchy and the last element is the leaf level. + */ + value(): DataViewCategoricalValuePathElement[]; + /** + * Gets a formatted string that can be used to display this value. + * This string is built by concatenating the {@link DataViewCategoricalValuePathElement.formattedValue} for each element found in the {@link DataViewCategoricalValue.value} array. + * @param separator - The separator used for concatenation. The default separator is " » ". + */ + formattedValue(separator?: string): string; + /** + * Gets the index among the leaf nodes of the associated {@link DataViewHierarchy} of this {@link DataViewCategoricalAxis}. + * This, for example, can be used to determine the position on a scale where to render the visual element. + */ + leafIndex: number; +} + +/** + * Represents an element in the `path` of a {@link DataViewCategoricalValue}. + * @public + */ +export declare interface DataViewCategoricalValuePathElement { + /** + * Gets a formatted string that can be used to display this value. + * The formatting settings in Spotfire are used to create this string. + */ + formattedValue(): string; + /** + * Gets a key that uniquely identifies this element. + * + * In many cases this will be the same as {@link DataViewCategoricalValuePathElement.formattedValue} and {@link DataViewCategoricalValuePathElement.value}. + * However there are cases when those values can contain duplicates. For instance when working with cube data, + * or when using formatters and display values. + * + * They key is suitable to be used for identifying objects when implementing rendering transitions. + * + * The key can be null when the corresponding {@link DataViewCategoricalValuePathElement.value} is null. + */ + key: string | null; + /** + * Gets the value of this element, or null if this element represents a missing or invalid data point. + * + * The type of the returned value can be determined from the {@link DataViewHierarchy.levels} in the {@link DataViewHierarchy} of + * the associated {@link DataViewCategoricalAxis}. + */ + value(): T | null; +} + +/** + * Color information for a {@link DataViewRow}. + * @public + */ +export declare interface DataViewColorInfo { + /** The hex code for the color. */ + hexCode: string; +} + +/** + * Represents metadata computed for continuous {@link Axis}. + * @public + */ +export declare interface DataViewContinuousAxis extends DataViewAxis { + /** + * Gets the data type of the values computed by this axis. + */ + dataType: DataType; +} + +/** + * Represents a value of a continuous axis for one row in a data view. + * @public + */ +export declare interface DataViewContinuousValue { + /** + * Gets the value of this instance. The type depending on the type of the + * expression on the associated {@link DataViewContinuousAxis}. + * + * This method will return `null` when the underlying data value is missing or invalid. + */ + value(): T2 | null; + /** + * Gets a formatted string that can be used to display this value. + * The formatting settings in Spotfire are used to create this string. + */ + formattedValue(): string; +} + +/** + * Represents a hierarchy for a {@link DataViewCategoricalAxis}. + * @public + */ +export declare interface DataViewHierarchy { + /** + * Gets the name of this hierarchy, the same as the associated {@link DataViewCategoricalAxis}. + */ + name: string; + /** + * Gets a value indicating whether the hierarchy is empty, i.e. the axis expression is empty, or not. + * For convenience, an empty hierarchy will have one single node that may contain all rows in the dataview. + */ + isEmpty: boolean; + /** + * Gets the levels of this hierarchy. The root node has no corresponding level. + */ + levels: DataViewHierarchyLevel[]; + /** + * Gets the total number of leaf nodes in the hierarchy. + */ + leafCount: number; + /** + * Gets the virtual root node of the hierarchy. The level of the root node is -1. Spotfire does not usually render the root node in visualization. + * @param abortPredicate - Optional. Predicate to determine whether the operation should be aborted when there is new, non-streaming, data available. If this predicate returns true the promise will be rejected. + * The default behavior is that reading will be aborted when new non-streaming update is available. + * @returns null if reading data was aborted, otherwise a {@link DataViewHierarchyNode}. + */ + root(abortPredicate?: AbortPredicate): Promise; +} + +/** + * Represents the levels of a hierarchy. + * @public + */ +export declare interface DataViewHierarchyLevel { + /** + * The name of the hierarchy level, derived from the expression on the {@link Axis}. + */ + name: string; + /** + * Gets the data type of the values in this level of the hierarchy. + */ + dataType: DataType; +} + +/** + * Represents a node in a {@link DataViewHierarchy}. + * @public + */ +export declare interface DataViewHierarchyNode { + /** + * Gets a formatted string that can be used to display this value. + * The formatting settings in Spotfire are used to create this string. + */ + formattedValue(): string; + /** + * Gets the full path, top down to this node, of the formatted values. The virtual root node is omitted. + * @param separator - The separator. The default separator is " » ". + */ + formattedPath(separator?: string): string; + /** + * Gets the key for this hierarchy node. The key is guaranteed to be unique for the node among its siblings. + * + * In many cases this will be the same as {@link DataViewHierarchyNode.formattedValue} or {@link DataViewHierarchyNode.value}. + * However there are cases when those values can contain duplicates. For instance when working with cube data, + * or when using formatters and display values. + * + * They key is suitable to be used for identifying objects when implementing rendering transitions. + * + * The key can be null when the corresponding {@link DataViewHierarchyNode.value} is null. + */ + key: string | null; + /** + * Gets the value of this node, or null if this node represents a missing or invalid data point. + * + * The type of the returned value can be determined from the {@link DataViewHierarchy.levels} in the associated {@link DataViewHierarchy}. + */ + value(): T | null; + /** + * Gets the parent of the hierarchy node, or `undefined` for root level nodes. + */ + parent?: DataViewHierarchyNode; + /** + * Gets the children of this node, or `undefined` if this node is a leaf node. + */ + children?: DataViewHierarchyNode[]; + /** + * Computes an array of all leaf nodes in the sub tree of the hierarchy spanned from this node. + */ + leaves(): DataViewHierarchyNode[]; + /** + * Gets the index of the leaf node among all leaf nodes in the hierarchy. This is undefined for non leaf nodes. + */ + leafIndex?: number; + /** + * Marks all {@link DataViewRow}s corresponding to the sub tree of the hierarchy spanned from this node. + * See {@link DataView.mark} for more details. + * @param operation - The marking operation. + */ + mark(operation?: MarkingOperation): void; + /** + * Computes the number of {@link DataViewRow}s corresponding to the sub tree of the hierarchy spanned from this node. + */ + rowCount(): number; + /** + * Computes the number of leaf nodes in the sub tree of the hierarchy spanned from this node. + */ + leafCount(): number; + /** + * Computes the number of marked {@link DataViewRow}s in the sub tree of the hierarchy spanned from this node. + */ + markedRowCount(): number; + /** + * Gets the level in the hierarchy where this node occurs. The root node of the hierarchy tree has level -1. + */ + level: number; + /** + * Computes the {@link DataViewRow}s corresponding to the sub tree of the hierarchy spanned from this node. + */ + rows(): DataViewRow[]; +} + +/** + * Represents an object that provides access to a {@link DataView}. + * @public + */ +export declare type DataViewProxy = DataViewProxyMethods & Readable; + +/** + * Represents the methods available on a {@link DataViewProxy}. + * @public + */ +export declare interface DataViewProxyMethods { + /** + * Clears the current marking + */ + clearMarking(): void; +} + +/** + * Represents a row of data in a {@link DataView}. Each row can be thought of as a data point that the mod visualization renders. + * @public + */ +export declare interface DataViewRow { + /** + * Gets a value indicating whether this row is marked. + */ + isMarked(): boolean; + /** + * Gets a {@link DataViewCategoricalValue} representing the value of the axis with the specified `axisName`. + * This method will throw an error if there is no categorical axis by that name. + * Use {@link DataView.categoricalAxis} to check the current existence of a categorical value. + * @param axisName - The name of the axis to get the value for. + */ + categorical(axisName: string): DataViewCategoricalValue; + /** + * Gets a {@link DataViewContinuousValue} representing the value of the axis with the specified `axisName`. + * This method will throw an error if there is no continuous axis by that name. + * Use {@link DataView.continuousAxis} to check the current existence of a continuous value. + * @param axisName - The name of the axis to get the value for. + */ + continuous(axisName: string): DataViewContinuousValue; + /** + * Gets the {@link DataViewColorInfo} for the row, if a color axis is defined in the mod manifest. + * The underlying data value can be retrieved by using {@link DataViewRow.categorical}("Color") or {@link DataViewRow.continuous}("Color"), depending on the mode of the color axis. + */ + color(): DataViewColorInfo; + /** + * Performs the specified marking operation in the current marking. + * + * **Note** All mark operations within one {@link Mod.transaction} must have the same {@link MarkingOperation}. + * + * See {@link DataView.mark} for more details. + * @param operation - Optional {@link MarkingOperation}. Default value is `Replace`. + */ + mark(operation?: MarkingOperation): void; +} + +/** + * Represents the type of a {@link DataView} value. The actual type that a given value has depends on the + * type of the expression on the associated axis. + * @public + */ +export declare type DataViewValueType = number | string | boolean | Date | Time | TimeSpan; + +/** + * Provides access to show an error overlay covering the entire Mod shown by Spotfire. + * @public + */ +export declare interface ErrorOverlay { + /** + * Show error message. Showing any error message will hide the Mods UI. + * @param messages - The error messages. Each message will be shown in its own paragraph. + * @param category - Optional error categorization. Useful if multiple error message are to be shown. Error messages will be sorted based on the category. + */ + show(messages: string[], category?: string): void; + /** + * Show error message. Showing any error message will hide the Mods UI. + * @param messages - The error message. + * @param category - Optional error categorization. Useful if multiple error message are to be shown. Error messages will be sorted based on the category. + */ + show(message: string, category?: string): void; + /** + * Clear the error message. If no other error messages are currently visible the Mods UI will be shown. + * @param category - Optional error categorization. + */ + hide(category?: string): void; +} + +/** + * From readableArray, an array of Readable of some value type, extract an array of this value type. + * @public + */ +export declare type ExtractValueType>> = { + [readableName in keyof readableArray]: readableArray[readableName] extends Readable ? readableNameType : never; +}; + +/** + * Represents information about a font that is used in the Mod Visualization. + * @public + */ +export declare interface FontInfo { + /** + * Gets the value to use for the `font-family` CSS property. + */ + fontFamily: string; + /** + * Gets the font size in pixels. + */ + fontSize: number; + /** + * Gets the value to use for the `font-style` CSS property. + */ + fontStyle: string; + /** + * Gets the value to use for the `font-weight` CSS property. + */ + fontWeight: string; + /** + * Gets the value to use for the `color` CSS property. + */ + color: string; +} + +/** + * Represents the general styling information that applies to the Mod Visualization. + * @public + */ +declare interface GeneralStylingInfo { + /** + * Gets and object describing the font that shall be used by the Mod Visualization. + */ + font: FontInfo; + /** + * Gets the value to use for the `background-color` CSS property of the Mod Visualization. + */ + backgroundColor: string; +} + +/** + * Initializes the Mod API. The specified `onLoaded` callback is called when the initialization is complete. + * @example + * ``` + * Spotfire.initialize(async (mod) => { + * console.log("Mod API loaded."); + * }); + * ``` + * The initialize method will invoke the provided callback with an instance of the mod API, to be used by the mod developer. + * + * The initialize method needs to be invoked in order for the mod to function. Even if the mod only displays static content, the API must be initialized in order for events and export to work. + * @public + * @param onLoaded - Callback that is called when the mod API is initialized and ready to be interacted with. + */ +export declare function initialize(onLoaded: OnLoadCallback): void; + +/** + * Represents the styling information that applies to scale lines in the Mod Visualization. + * @public + */ +declare interface LineStylingInfo { + /** + * Gets the stroke to use for scale lines. This value is valid a CSS color or the value `"none"`. + */ + stroke: string; +} + +/** + * Marking information for a {@link DataView}. + * @public + */ +export declare interface MarkingInfo { + /** The hex code for the marking. Note that when the mod has a defined color axis, the color should be retrieved via the {@link DataViewRow.color} method. */ + colorHexCode: string; + /** The name of the marking. */ + name: string; +} + +/** + * Specifies how a Marking shall be modified. + *
+ * - "Replace" - replaces the current marking.
+ * - "Add" - adds to the current marking.
+ * - "Subtract" - removes the current marking.
+ * - "Toggle" - toggles marking on each item in the set.
+ * - "Intersect" - marks the intersection of the current marking and the specified set.
+ * - "ToggleOrAdd" - will behave like toggle if all or no rows in the set are marked, otherwise it is an add operation. This is the default Spotfire behavior for control marking.
+ * 
+ * @public + */ +export declare type MarkingOperation = "Replace" | "Add" | "Subtract" | "Toggle" | "Intersect" | "ToggleOrAdd"; + +/** + * Extract from T the keys of all properties with function values. + * @public + */ +export declare type MethodKeys = { + [P in keyof T]: T[P] extends Function ? P : never; +}[keyof T]; + +/** + * Represents the entire Mod API and exposes methods for interacting with and reading data from + * the Mod Visualization and the Spotfire document. + * + * Reading content from the Mod is made by using either of the methods {@link Reader.subscribe} or {@link Reader.once} on an instance of a {@link Reader}. + * @public + */ +export declare interface Mod { + /** + * Gets an object that provides access to Spotfire document. + */ + document: SpotfireDocument; + /** + * Gets an object representing the content in the Mod Visualization and provides methods to read and/or modified it. + */ + visualization: ModVisualization; + /** + * Provides access to the {@link ModProperty} with the specified `name`. + */ + property(name: string): ReadableProxy>; + /** + * Provides read-only access to the current size of the browser window in which the Mod + * is rendered. That is, the size of the iframe created for the Mod in the Spotfire UI. + */ + windowSize(): Readable; + /** + * Creates a {@link Reader} that can be used to access content specified by the {@link Readable} parameters. + * The reader is responsible for combining multiple {@link Readable}s and scheduling a callback to be invoked + * when one or more of the {@link Readable}s have changed. + * @param readables - The {@link Readable}s that will be available in the reader. + */ + createReader>(...readables: T): Reader>; + /** + * Gets an object that allows showing Spotfire controls and other UI component, like context menus, tooltips, etc. + */ + controls: Controls; + /** + * Performs a set of synchronous modifications in an explicit transaction to the Spotfire document. + * + * Use of this method is only needed to make sure that a set of modifications are done as one transaction, thereby resulting in one undo step. + * Modifications done outside of a transaction action callback will be grouped together in an implicit transaction. + * + * @param action - callback with a set of modifications + * @param onComplete - optional callback that is called when the transaction is committed or rolled back. When there is an error argument in the callback the transaction was rolled back. + * @example + * ``` + * mod.transaction(() => { + * mod.property("X").set("new value for X"); + * mod.property("Y").set("new value for Y"); + * }, + * (error) => { + * if (error) { + * // Show error message. + * } + * else { + * // Handle success, e.g. re-enable action button. + * } + * }); + * ``` + */ + transaction(action: () => void, onComplete?: (error?: string) => void): void; + /** + * Get the Mod's render context. This function should be invoked as soon as possible in the {@link initialize} callback. + * + * If this method is called in the {@link initialize} callback, Spotfire will wait for the Mod to finish rendering during + * an export. The export will be made once the {@link RenderContext.signalRenderComplete} method has been called. + * + * If this method is not called in the {@link initialize} callback, Spotfire will _not_ wait for the Mod to finish rendering during + * an export. Instead, the Mod will be automatically exported after one second. + */ + getRenderContext(): RenderContext; + /** + * Get mod metadata - name, id, version, etc. + */ + metadata: ModMetadata; +} + +/** + * Represents that metadata of the Mod Visualization, as defined in the mod-manifest-json. + * @public + */ +export declare interface ModMetadata { + /** + * Gets the id of the Mod Visualization, as defined in the mod-manifest-json. + */ + id: string; + /** + * Gets the name of the Mod Visualization, as defined in the mod-manifest-json. + */ + name: string; + /** + * Gets the version of the Mod Visualization, as defined in the mod-manifest-json. + */ + version: string; + /** + * Gets the api version used by the Mod Visualization, as declared in the mod-manifest-json. + */ + apiVersion: string; +} + +/** + * Represents a property owned by the Mod Visualization. + * The Mod manifest defines the properties owned by the Mod Visualization. + * @public + */ +export declare interface ModProperty extends ModPropertyValue { + /** + * Set the value of this instance. + * @param value - The value to set. + */ + set(value: T): void; +} + +/** + * Represents the data types possible to store in a mod {@link ModProperty}. + * @public + */ +export declare type ModPropertyDataType = string | number | boolean; + +/** + * Represents the values held by a {@link ModProperty}. + * @public + */ +export declare interface ModPropertyValue { + /** + * Gets the name of this instance. + */ + name: string; + /** + * Gets the value held by this instance; + */ + value(): T2 | null; +} + +/** + * Represents the content in the Mod Visualization that can be read and/or modified. + * + * The content is a combination of state stored by the Mod Visualization in the Spotfire document, + * its view of the data and relevant UI properties. All values are {@link Readable} objects and are + * typically accessed using the {@link Reader} object. + * + * @public + */ +export declare interface ModVisualization { + /** + * Provides access to the {@link DataView} that the Mod Visualization is to render. + */ + data(): DataViewProxy; + /** + * Provides access to the {@link DataTable} in the Spotfire document that the Mod Visualization + * uses as its main table. + */ + mainTable(): ReadableProxy; + /** + * Sets the main {@link DataTable} in the Mod visualization. + * @param tableName - The name of the {@link DataTable} to be used as main table. + */ + setMainTable(tableName: string): void; + /** + * Sets the main {@link DataTable} in the Mod visualization. + * @param table - The {@link DataTable} object to be used as main table. + */ + setMainTable(table: DataTable): void; + /** + * Provides access to the {@link Axis} in the Mod Visualization with the specified `name`. All axes + * must be declared in the mod-manifest.json. + * @param name - The name of the {@link Axis}. + */ + axis(name: string): ReadableProxy; +} + +/** + * Represents methods that are not available on a {@link ReadableProxy}. To access these methods the {@link ReadableProxy} must be awaited. + * @public + */ +export declare type OmittedReadableProxyMethods = "value" | "valueList"; + +/** + * Represents a function that consumes the {@link Mod} API. See {@link initialize}. + * @public + */ +export declare type OnLoadCallback = (mod: Mod) => void | Promise; + +/** + * Represents a Page in a Spotfire document. + * @public + */ +export declare interface Page extends PageValues { + /** + * Sets this instance as the active page. + */ + setAsActive(): void; +} + +/** + * Represents the values held by a {@link Page}. + * @public + */ +export declare interface PageValues { + /** + * Gets the name of this instance. + */ + name: string; + /** + * Gets a value indicating whether this instance is visible. + */ + visible: boolean; + /** + * Gets the zero-based index in this instance in the page collection in the Spotfire document. + */ + index: number; +} + +/** + * Represents an object that can be used to create and show a Spotfire popout dialog. + * @public + */ +export declare interface Popout { + /** + * Shows a pop out dialog as specified by the `options` and `controls`. + * @param options - Specifies where and how to show the pop out dialog. + * @param components - A callback that shall produce the array of components that the + * pop out will show. If the pop out is shown with {@link PopoutOptions.autoClose} set to `false` + * this callback will be invoked every time the user has interacted with one of the {@link PopoutComponent}s + * so that the pop out can be re-rendered to show the result of the interaction. + */ + show(options: PopoutOptions, components: () => PopoutSection[]): PopoutDialog; + /** + * Creates a section that contains a heading and components. + * @param options - Specifies the heading and the components. + */ + section(options: PopoutSectionOptions): PopoutSection; + /** + * Gets an object with methods that create {@link PopoutComponent}s. + */ + components: PopoutComponentFactory; +} + +/** + * Represents options describing how to render a button. See {@link PopoutComponentFactory.button}. + * @public + */ +export declare interface PopoutButtonOptions { + /** + * Specifies the name that identifies the component. + */ + name: string; + /** + * Specifies the text to display in the button. + */ + text: string; +} + +/** + * Represents options describing how to render a checkbox. See {@link PopoutComponentFactory.checkbox}. + * @public + */ +export declare interface PopoutCheckboxOptions { + /** + * Specifies the name that identifies the component. + */ + name: string; + /** + * Specifies the text to display next to the checkbox. + */ + text: string; + /** + * Specifies the tooltip to display. If undefined, no tooltip is shown. + */ + tooltip?: string; + /** + * Specifies whether the checkbox is checked. + */ + checked: boolean; + /** + * Specifies whether the checkbox is enabled. + */ + enabled: boolean; +} + +/** + * Represents a component of a pop out dialog. See {@link Controls.popout}. + * @public + */ +export declare interface PopoutComponent { + /** + * Gets the type of the control. + */ + type: string; +} + +/** + * Represents the data of an event that occurs when a {@link PopoutComponent} has been changed by the user. + * @public + */ +export declare interface PopoutComponentEvent { + /** + * Gets the name that identifies the component that has been changed. + */ + name: string; + /** + * Gets the value of the component that has been changed. + */ + value?: any; +} + +/** + * Represents an object with methods that create {@link PopoutComponent}s. + * @public + */ +export declare interface PopoutComponentFactory { + /** + * Creates a component that renders as a radio button. + * @param options - Specifies how the radio button shall be rendered. + */ + radioButton(options: PopoutRadioButtonOptions): PopoutComponent; + /** + * Creates a component that renders as a checkbox. + * @param options - Specifies how the checkbox shall be rendered. + */ + checkbox(options: PopoutCheckboxOptions): PopoutComponent; + /** + * Creates a component that renders as a button. + * @param options - Specifies how the button shall be rendered. + */ + button(options: PopoutButtonOptions): PopoutComponent; +} + +/** + * Represents a pop out dialog that is shown by Spotfire. See {@link Controls.popout}. + * @public + */ +export declare interface PopoutDialog { + /** + * Closes the pop out dialog. + */ + close(): void; +} + +/** + * Represents options that specifies where and how a pop out dialog shall be shown. + * @public + */ +export declare interface PopoutOptions { + /** + * Specifies the horizontal pixel coordinate of the anchor point of the pop out dialog. + * + * The coordinate is specified relative to an origin in the top left corner of the Mod viewport. + */ + x: number; + /** + * Specifies the vertical pixel coordinate of the anchor point of the pop out dialog. + * + * The coordinate is specified relative to an origin in the top left corner of the Mod viewport. + */ + y: number; + /** + * Specifies how to position of the popout in relation to the anchor point specified by `x` and `y`. + * + * The alignment value specifies which edge of the pop out that shall be closest to the anchor point. For example, + * to show the pop out below the anchor point, specify `Top`. + */ + alignment?: "Left" | "Right" | "Top" | "Bottom"; + /** + * Specifies whether to automatically close the popout when one of the components in it is clicked. + */ + autoClose: boolean; + /** + * Specifies the callback to invoke when a component in the pop out dialog is changed. + */ + onChange(event: PopoutComponentEvent): void; + /** + * Specifies the callback to invoke when the pop out dialog has been closed. + * This callback is optional and can be left unassigned. + */ + onClosed?(): void; +} + +/** + * Represents options describing how to render a radio button. See {@link PopoutComponentFactory.radioButton}. + * @public + */ +export declare interface PopoutRadioButtonOptions { + /** + * Specifies the name that identifies the component. + */ + name: string; + /** + * Specifies the text to display next to the radio button. + */ + text: string; + /** + * Specifies the tooltip to display. If undefined, no tooltip is shown. + */ + tooltip?: string; + /** + * Specifies whether the radio button is checked. + */ + checked: boolean; + /** + * Specifies the value represented by the radio button. + */ + value: any; +} + +/** + * Represents a section of a pop out dialog. See {@link Controls.popout}. + * @public + */ +export declare interface PopoutSection { + /** + * Specifies the heading of the section + */ + heading?: string; + /** + * Specifies the components in the section + */ + children: PopoutComponent[]; +} + +/** + * Represents a section of a pop out dialog. See {@link Controls.popout}. + * @public + */ +export declare interface PopoutSectionOptions { + /** + * Specifies the heading of the section + */ + heading?: string; + /** + * Specifies the components in the section + */ + children: PopoutComponent[]; +} + +/** + * Represents an object with methods to show and hide the Spotfire progress indicator. + * @public + */ +export declare interface Progress { + /** + * Shows the progress indicator. + */ + show(): void; + /** + * Hides the progress indicator. + */ + hide(): void; +} + +/** + * Represents a value in the Mod API that can be accessed and/or modified. These values can + * be used when creating an instance of a {@link Reader} via the {@link Mod.createReader} method. + * @public + */ +export declare interface Readable extends Promise { + /** + * Used internally by the Mod api. + */ + readableID: string; + /** + * Used internally by the Mod api. + */ + __futureValue?: T; +} + +/** + * Represents an object that provides access to a node of the specified type. + * It can be used as a {@link Readable} but also acts as a proxy to the node by exposing all its methods. + * Nodes that represent model state in the Spotfire document can thus be modified without first waiting + * and materializing them in the browser. + * + * A full node will be created by using a {@link Reader}. + * @public + */ +export declare type ReadableProxy = Readable & Omit>, OmittedReadableProxyMethods>; + +/** + * The reader is responsible for combining multiple {@link Readable}s and scheduling a callback to be invoked + * when one or more of the {@link Readable}s have changed. Choose one of the appropriate methods; + * {@link Reader.once} or {@link Reader.subscribe} that suits the needs of the Mod. + * An instance of the reader is created by calling the {@link Mod.createReader} method. + * @public + */ +export declare interface Reader> { + /** + * Subscribe to changes in the content for the specified readables when the reader was created. + * @example Subscribe to changes in the {@link DataView}. + * + * ``` + * let reader = mod.createReader(mod.visualization.data()); + * reader.subscribe((dataView) => { + * console.log(await dataView.rowCount()); + * }); + * ``` + * + * @param callback - The callback function that is called every time when there is at least one new value to read. + * The callback function will not be called until the previous callback function has returned. + * @param onReadError - Optional callback function that will be called if there are errors reading the readables. + */ + subscribe(callback: (...values: T) => void, onReadError?: (error: string) => void): void; + /** + * Read the content once for the readables specified when the reader was created. + * Any current subscription for this reader will be cancelled. + * @example Read content of a mod property once. + * + * ``` + * let reader = mod.createReader(mod.property("CreatedBy")); + * reader.once((createdBy) => { + * console.log(await createdBy.value()); + * }); + * ``` + * + * @param callback - The callback function that is called once when there is at least one new value to read. + * @param onReadError - Optional callback function that will be called if there are errors reading the readables. + */ + once(callback: (...values: T) => void, onReadError?: (error: string) => void): void; + /** + * Checks if any of the readables have a new value available. If this function returns true, + * the callback in the current subscription, or a new call to {@link Reader.once} is guaranteed + * to be invoked. + * The intended use of this method is to cancel rendering of the Mod if there are new values to any of the + * readables specified when the reader was created. + */ + hasExpired(): Promise; +} + +/** + * Represents contextual information needed when rendering a Mod, either in the UI or as part of an export. + * @public + */ +export declare interface RenderContext { + /** + * Gets a value indicating whether the Mod is interactive. + * + * When this value is false the Mod is not interactive. This occurs during export, for instance to an image or to PDF. + * This property can be used to hide selected controls and to avoid animations when rendering in an export context. + */ + interactive: boolean; + /** + * Gets the image pixel ratio that shall be used when rendering rasterized images and/or using a canvas element. + */ + imagePixelRatio: number; + /** + * Gets information about the currently used theme. + */ + styling: StylingInfo; + /** + * Signals that the mod is ready to be exported. + * + * If this method is not called, Spotfire will perform export (and preview generation etc.) of the Mod without knowing + * if it has finished rendering. + * + * The default maximum allowed time for a Mod to finish rendering is 20 seconds. + */ + signalRenderComplete(): void; +} + +/** + * Represents the styling information that applies to scales in the Mod Visualization. + * @public + */ +declare interface ScaleStylingInfo { + /** + * Gets and object describing the font that shall be used in the scales of the Mod Visualization. + */ + font: FontInfo; + /** + * Gets and object describing the styling information for scale lines in the Mod Visualization. + */ + line: LineStylingInfo; + /** + * Gets and object describing the styling information for scale ticks in the Mod Visualization. + */ + tick: TickStylingInfo; +} + +/** + * Represents the size of an area in the UI, for example the size of the browser window in which the Mod + * is rendered. See {@link Mod.windowSize}. + * @public + */ +export declare interface Size { + /** + * Gets the width. + */ + width: number; + /** + * Gets the height. + */ + height: number; +} + +/** + * Represents the Spotfire document and provides access to read and modify parts of it. + * @public + */ +export declare interface SpotfireDocument { + /** + * Provides access to the {@link DataTable}s in the Spotfire document. + */ + tables(): Readable; + /** + * Provides access to the {@link DataTable} with the specified `name` in the Spotfire document. + */ + table(name: string): ReadableProxy; + /** + * Provides access to the `Document Properties` in the Spotfire Document. + */ + properties(): Readable; + /** + * Provides access to the `Document Property` with the specified `name` in the Spotfire Document. + */ + property(name: string): ReadableProxy>; + /** + * Provides access to the {@link Page}s in the Spotfire document. + */ + pages(): Readable; + /** + * Provides access to the active {@link Page} in the Spotfire document. That is, the page that is currently visible. + */ + activePage(): ReadableProxy; + /** + * Sets the specified {@link Page} as the active page. + * @param name - The name/title of the page to set as active. + */ + setActivePage(name: string): void; + /** + * Sets the specified index as the active page index. + * @param index - The index of the page to set as active. + */ + setActivePage(index: number): void; + /** + * Sets the specified {@link Page} as the active page. + * @param page - The {@link Page} object to set as active. + */ + setActivePage(page: Page): void; +} + +/** + * Represents the styling (theme) that affects the look and feel of a Mod Visualization. + * @public + */ +export declare interface StylingInfo { + /** + * Gets an object describing the general aspects of the styling, including the font and background color + * to use in the Mod Visualization. + */ + general: GeneralStylingInfo; + /** + * Gets an object describing the styling of the scales in the Mod Visualization. + */ + scales: ScaleStylingInfo; +} + +/** + * Represents the styling information that applies to scale ticks in the Mod Visualization. + * @public + */ +declare interface TickStylingInfo { + /** + * Gets the stroke to use for scale ticks. This value is valid a CSS color or the value `"none"`. + */ + stroke: string; +} + +/** + * Represents a Time property. The time has no notion of time zone. + * @public + */ +export declare interface Time { + /** The total number of milliseconds since midnight. */ + totalMilliseconds: number; + /** The millisecond part of the instance. */ + milliseconds: number; + /** The total number of seconds since midnight. */ + totalSeconds: number; + /** The second part of the instance. */ + seconds: number; + /** The total number of minutes since midnight. */ + totalMinutes: number; + /** The minute part of the instance. */ + minutes: number; + /** The total number of hours since midnight. */ + hours: number; +} + +/** + * Represents a TimeSpan property. A time span is used to measure the time between two points in time. + * @public + */ +export declare interface TimeSpan { + /** The total number of milliseconds of the instance. */ + totalMilliseconds: number; + /** The millisecond part of the instance. */ + milliseconds: number; + /** The total number of seconds of the instance. */ + totalSeconds: number; + /** The second part of the instance. */ + seconds: number; + /** The total number of minutes of the instance. */ + totalMinutes: number; + /** The minute part of the instance. */ + minutes: number; + /** The total number of hours of the instance. */ + totalHours: number; + /** The hour part of the instance. */ + hours: number; + /** The day part of the instance. */ + days: number; +} + +/** + * Represents an object with methods to show and hide a Spotfire tooltip. + * @public + */ +export declare interface Tooltip { + /** + * Shows a tooltip with the specified `content` text. + * + * The tooltip is shown using the same style and initial delay as native Spotfire visualizations. + * Once shown, the tooltip will follow the mouse around until {@link Tooltip.hide} is called. + * + * Subsequent calls to `show`can be made to update the tooltip text. + * @param content - The text to show in the tooltip. + */ + show(content: string): void; + /** + * Hides the tooltip that is currently being showed, if any. + */ + hide(): void; +} + +export { } diff --git a/examples/js-dev-circular-treemap/src/circular-treemap.css b/examples/js-dev-circular-treemap/src/circular-treemap.css new file mode 100644 index 00000000..14b33627 --- /dev/null +++ b/examples/js-dev-circular-treemap/src/circular-treemap.css @@ -0,0 +1,26 @@ +/* +* Copyright © 2020. TIBCO Software Inc. +* This file is subject to the license terms contained +* in the license file that is distributed with this file. +*/ + +/* +* Fill out the available space. +*/ +html, body { + width: 100%; + height:100%; + margin:0px; + overflow:hidden; +} + +/* +* Let circles be semi transparent by default. That way circles will look +* darker for each level in the hierarchy (provided the analysis is using +* a light theme). +*/ +circle { + fill: #333; + opacity: 0.15; + stroke: white; +} \ No newline at end of file diff --git a/examples/js-dev-circular-treemap/src/circular-treemap.js b/examples/js-dev-circular-treemap/src/circular-treemap.js new file mode 100644 index 00000000..f59abf03 --- /dev/null +++ b/examples/js-dev-circular-treemap/src/circular-treemap.js @@ -0,0 +1,299 @@ +/* + * Copyright © 2020. TIBCO Software Inc. + * This file is subject to the license terms contained + * in the license file that is distributed with this file. + */ + +//@ts-check - Get type warnings from the TypeScript language server. Remove if not wanted. +Spotfire.initialize(function (api) { + "use strict"; + + // Store svg element into which all rendering is performed. + const svg = d3.select("svg"); + + // Setup a canvas rendering context to measure strings for labels + const canvas = document.createElement("canvas"); + const labelCtx = canvas.getContext("2d"); + + // Get the render context used to signal render completion. + const renderCtx = api.getRenderContext(); + + // Setup reader/rendering loop + const reader = api.createReader(api.visualization.data(), api.windowSize()); + reader.subscribe(async (dataView, size) => { + // Do the actual rendering + await render(dataView, size); + + // Always signal to the framework that rendering has completed + // or export rendering (to PDF or dxp file thumbnail image) will hang. + renderCtx.signalRenderComplete(); + }); + + /** + * Gets a row in the data view for a hierarchy node. + * @param {Spotfire.DataViewHierarchyNode} sfNode + */ + function getRow(sfNode) { + const rows = sfNode.rows(); + + if (rows.length !== 1) { + console.log("Something is wrong: getRow called for rows.length=" + rows.length); + } + + return rows[0]; + } + + /** + * Gets the child nodes that have rows in the data view. + * @param {Spotfire.DataViewHierarchyNode} sfNode + */ + function getNonEmptyChildren(sfNode) { + return sfNode.children ? sfNode.children.filter(isNonEmptyNode) : isNonEmptyNode(sfNode); + } + + /** + * Checks if the node has any rows in the data view. + * @param {Spotfire.DataViewHierarchyNode} sfNode + */ + function isNonEmptyNode(sfNode) { + return sfNode.children ? sfNode.children.some(isNonEmptyNode) : sfNode.rows().length > 0; + } + + /** + * Gets the color for a node in the d3 hierarchy. + * @param d3node + */ + function getColor(d3node) { + if (d3node.children) { + // No color for non-leaf nodes. + return ""; + } + + return getRow(d3node.data).color().hexCode; + } + + /** + * Gets the outline color for a node in the d3 hierarchy. + * @param d3node + */ + function getOutlineColor(d3node) { + if (d3node.children) { + return ""; + } + + const row = getRow(d3node.data); + if (!row.isMarked()) { + return ""; + } + + return d3.color(row.color().hexCode).darker(); + } + + /** + * Gets the text color to use for a node in the d3 hierarchy. + * @param d3Node + */ + function getTextColor(d3Node) { + const color = d3.hsl(getColor(d3Node)); + const dark = d3.hsl("#313336"); + const light = d3.hsl("white"); + if (Math.abs(color.l - dark.l) > Math.abs(color.l - light.l)) { + return dark; + } else { + return light; + } + } + + /** + * Renders a label for a d3 hierarchy node. + */ + function addLabel(d3Node, fontSizePx) { + // Measure the text. We just use font size for height. + const text = d3Node.data.formattedValue(); + const width = labelCtx.measureText(text).width; + const textRadius = Math.sqrt(width * width + fontSizePx * fontSizePx) / 2; + + // Calculate the scale factor needed to fit the label inside the circle. + const radius = d3Node.r * 0.85; + const scale = radius / textRadius; + + if (scale * fontSizePx < 5) + { + // Text will be to small. Skip this one. + return; + } + + // Calculate the y offset. We need to push it down a bit. The offset should + // really be derived from the font/text metrics. + const baselineOffset = fontSizePx * 0.35 * scale; + + // Render the label. + svg.append("text") + .attr("transform", `translate(${d3Node.x},${d3Node.y + baselineOffset}) scale(${scale})`) + .attr("text-anchor", "middle") + .attr("pointer-events", "none") + .attr("fill", getTextColor(d3Node)) + .text(text); + } + + /** + * Clears the DOM. + */ + function clear() { + svg.selectAll("*").remove(); + } + + /** + * Function used in bailout clauses in main rendering function. Optionally shows message(s) + * to the user. + */ + function bailout(messages) { + clear(); + if (messages) { + api.controls.errorOverlay.show(messages); + } + else { + api.controls.errorOverlay.hide(); + } + } + + /** + * The main rendering function + * @param {Spotfire.DataView} dataView + * @param {Spotfire.Size} size + */ + async function render(dataView, size) { + // Clear any open tooltips + api.controls.tooltip.hide(); + + // Check for data view errors + const errors = await dataView.getErrors(); + if (errors.length > 0) { + bailout(errors); + return; + } + + const rowCount = await dataView.rowCount(); + + // Bailout for empty visualization + if (rowCount === 0) { + bailout(); + return; + } + + // Bailout if there is more data than we can gracefully render. + const maxRowCount = 5000; + if (rowCount > maxRowCount) { + bailout(`Sorry. There is currently too much data. This visualization cannot handle more than ${maxRowCount} rows, + and there are currently ${rowCount} of them. Try filtering or change the configuration.`); + return; + } + + // Get the hierarchy + const hierarchy = await dataView.hierarchy("Hierarchy"); + const sfRoot = await hierarchy.root(); + if (sfRoot === null) { + // If we get null back here, that means the framework has cancelled the rendering. + return; + } + + // Detect categorical coloring issues. In that case there are leaf nodes with more than one row. + const leaves = sfRoot.leaves(); + if (leaves.some((sfLeafNode) => sfLeafNode.rows().length > 1)) { + bailout( + "When using categorical coloring, the expression used on the color axis must also be among the expressions used on the hierarchy axis." + ); + return; + } + + const sizeAxis = await dataView.continuousAxis("Size"); + const getSize = function (sfNode) { + if (sizeAxis !== null) { + return getRow(sfNode).continuous("Size").value(); + } + + // Constant size when size axis has empty expression. + return 1; + }; + + // Wrap Spotfire hierarchy in a d3 hierarchy, and rollup size value. Pass a special children accessor + // that will filter out all nodes that do not have any data rows. + const d3Root = d3.hierarchy(sfRoot, getNonEmptyChildren).sum(function (sfNode) { + if (sfNode.children) { + // returning null for non leaf nodes makes d3 do the rollup of the sum. + return 0; + } + + // Handle nulls and negative values. We could do something better here, but + // for now just treat them as 0. + let value = getSize(sfNode); + if (value === null || value < 0) { + value = 0; + } + + return value; + }); + + // Create a pack layout + const packLayout = d3 + .pack() + .size([size.width, size.height]) + .padding(1); + + packLayout(d3Root); + + // Clear previous rendering, and hide any open error overlay. + clear(); + api.controls.errorOverlay.hide(); + + // Render the circles + const circles = svg + .attr("width", size.width) + .attr("height", size.height) + .selectAll("circle") + .data(d3Root.descendants()) + .enter() + .append("circle") + .attr("cx", (d) => d.x) + .attr("cy", (d) => d.y) + .attr("r", (d) => d.r) + .style("fill", getColor) + .style("stroke", getOutlineColor) + .style("opacity", (d) => (d.children ? "" : "1.0")); + + // Update font settings for canvas element and render labels. + const fontFamily = renderCtx.styling.general.font.fontFamily; + const fontSize = renderCtx.styling.general.font.fontSize; + labelCtx.font = "" + fontSize + "px " + fontFamily; + d3Root.leaves().forEach((d3Node) => { + addLabel(d3Node, fontSize); + }); + + // Handle mouse events for marking + svg.on("click", (e) => { + dataView.clearMarking(); + }); + + circles.on("click", (e) => { + e.data.mark(d3.event.ctrlKey ? "ToggleOrAdd" : "Replace"); + d3.event.stopPropagation(); + }); + + // Handle tooltip + circles.on("mouseenter", (e) => { + /** @type {Spotfire.DataViewHierarchyNode} */ + const sfNode = e.data; + if (sfNode.children) { + // Hide tooltip for non leaf nodes. + api.controls.tooltip.hide(); + } else { + const size = sizeAxis !== null ? getRow(sfNode).continuous("Size").formattedValue() : ""; + api.controls.tooltip.show(sfNode.formattedPath() + "\r\n" + size); + } + }); + + circles.on("mouseleave", () => { + api.controls.tooltip.hide(); + }); + } +}); diff --git a/examples/js-dev-circular-treemap/src/d3.min.js b/examples/js-dev-circular-treemap/src/d3.min.js new file mode 100644 index 00000000..11c7acae --- /dev/null +++ b/examples/js-dev-circular-treemap/src/d3.min.js @@ -0,0 +1,2 @@ +// https://d3js.org v5.14.2 Copyright 2019 Mike Bostock +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).d3=t.d3||{})}(this,function(t){"use strict";function n(t,n){return tn?1:t>=n?0:NaN}function e(t){var e;return 1===t.length&&(e=t,t=function(t,r){return n(e(t),r)}),{left:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r>>1;t(n[o],e)<0?r=o+1:i=o}return r},right:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r>>1;t(n[o],e)>0?i=o:r=o+1}return r}}}var r=e(n),i=r.right,o=r.left;function a(t,n){return[t,n]}function u(t){return null===t?NaN:+t}function c(t,n){var e,r,i=t.length,o=0,a=-1,c=0,f=0;if(null==n)for(;++a1)return f/(o-1)}function f(t,n){var e=c(t,n);return e?Math.sqrt(e):e}function s(t,n){var e,r,i,o=t.length,a=-1;if(null==n){for(;++a=e)for(r=i=e;++ae&&(r=e),i=e)for(r=i=e;++ae&&(r=e),i0)return[t];if((r=n0)for(t=Math.ceil(t/a),n=Math.floor(n/a),o=new Array(i=Math.ceil(n-t+1));++u=0?(o>=y?10:o>=_?5:o>=b?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=y?10:o>=_?5:o>=b?2:1)}function w(t,n,e){var r=Math.abs(n-t)/Math.max(0,e),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=y?i*=10:o>=_?i*=5:o>=b&&(i*=2),n=1)return+e(t[r-1],r-1,t);var r,i=(r-1)*n,o=Math.floor(i),a=+e(t[o],o,t);return a+(+e(t[o+1],o+1,t)-a)*(i-o)}}function T(t,n){var e,r,i=t.length,o=-1;if(null==n){for(;++o=e)for(r=e;++or&&(r=e)}else for(;++o=e)for(r=e;++or&&(r=e);return r}function A(t){for(var n,e,r,i=t.length,o=-1,a=0;++o=0;)for(n=(r=t[i]).length;--n>=0;)e[--a]=r[n];return e}function S(t,n){var e,r,i=t.length,o=-1;if(null==n){for(;++o=e)for(r=e;++oe&&(r=e)}else for(;++o=e)for(r=e;++oe&&(r=e);return r}function k(t){if(!(i=t.length))return[];for(var n=-1,e=S(t,E),r=new Array(e);++n=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}})}function X(t,n){for(var e,r=0,i=t.length;r0)for(var e,r,i=new Array(e),o=0;o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),$.hasOwnProperty(n)?{space:$[n],local:t}:t}function Z(t){var n=W(t);return(n.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===G&&n.documentElement.namespaceURI===G?n.createElement(t):n.createElementNS(e,t)}})(n)}function Q(){}function K(t){return null==t?Q:function(){return this.querySelector(t)}}function J(){return[]}function tt(t){return null==t?J:function(){return this.querySelectorAll(t)}}function nt(t){return function(){return this.matches(t)}}function et(t){return new Array(t.length)}function rt(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}rt.prototype={constructor:rt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,n){return this._parent.insertBefore(t,n)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var it="$";function ot(t,n,e,r,i,o){for(var a,u=0,c=n.length,f=o.length;un?1:t>=n?0:NaN}function ct(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ft(t,n){return t.style.getPropertyValue(n)||ct(t).getComputedStyle(t,null).getPropertyValue(n)}function st(t){return t.trim().split(/^|\s+/)}function lt(t){return t.classList||new ht(t)}function ht(t){this._node=t,this._names=st(t.getAttribute("class")||"")}function dt(t,n){for(var e=lt(t),r=-1,i=n.length;++r=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Mt={};(t.event=null,"undefined"!=typeof document)&&("onmouseenter"in document.documentElement||(Mt={mouseenter:"mouseover",mouseleave:"mouseout"}));function Nt(t,n,e){return t=Tt(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function Tt(n,e,r){return function(i){var o=t.event;t.event=i;try{n.call(this,this.__data__,e,r)}finally{t.event=o}}}function At(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;r=m&&(m=b+1);!(_=g[m])&&++m=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=ut);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?function(t){return function(){this.style.removeProperty(t)}}:"function"==typeof n?function(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}:function(t,n,e){return function(){this.style.setProperty(t,n,e)}})(t,n,null==e?"":e)):ft(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?function(t){return function(){delete this[t]}}:"function"==typeof n?function(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}:function(t,n){return function(){this[t]=n}})(t,n)):this.node()[t]},classed:function(t,n){var e=st(t+"");if(arguments.length<2){for(var r=lt(this.node()),i=-1,o=e.length;++i=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}(t+""),a=o.length;if(!(arguments.length<2)){for(u=n?St:At,null==e&&(e=!1),r=0;r>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?new bn(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?new bn(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=on.exec(t))?new bn(n[1],n[2],n[3],1):(n=an.exec(t))?new bn(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=un.exec(t))?gn(n[1],n[2],n[3],n[4]):(n=cn.exec(t))?gn(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=fn.exec(t))?Mn(n[1],n[2]/100,n[3]/100,1):(n=sn.exec(t))?Mn(n[1],n[2]/100,n[3]/100,n[4]):ln.hasOwnProperty(t)?vn(ln[t]):"transparent"===t?new bn(NaN,NaN,NaN,0):null}function vn(t){return new bn(t>>16&255,t>>8&255,255&t,1)}function gn(t,n,e,r){return r<=0&&(t=n=e=NaN),new bn(t,n,e,r)}function yn(t){return t instanceof Jt||(t=pn(t)),t?new bn((t=t.rgb()).r,t.g,t.b,t.opacity):new bn}function _n(t,n,e,r){return 1===arguments.length?yn(t):new bn(t,n,e,null==r?1:r)}function bn(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function mn(){return"#"+wn(this.r)+wn(this.g)+wn(this.b)}function xn(){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+")")}function wn(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Mn(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new An(t,n,e,r)}function Nn(t){if(t instanceof An)return new An(t.h,t.s,t.l,t.opacity);if(t instanceof Jt||(t=pn(t)),!t)return new An;if(t instanceof An)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,u=o-i,c=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e0&&c<1?0:a,new An(a,u,c,t.opacity)}function Tn(t,n,e,r){return 1===arguments.length?Nn(t):new An(t,n,e,null==r?1:r)}function An(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function Sn(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}Qt(Jt,pn,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:hn,formatHex:hn,formatHsl:function(){return Nn(this).formatHsl()},formatRgb:dn,toString:dn}),Qt(bn,_n,Kt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new bn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new bn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:mn,formatHex:mn,formatRgb:xn,toString:xn})),Qt(An,Tn,Kt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new An(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new An(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new bn(Sn(t>=240?t-240:t+120,i,r),Sn(t,i,r),Sn(t<120?t+240:t-120,i,r),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},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var kn=Math.PI/180,En=180/Math.PI,Cn=.96422,Pn=1,zn=.82521,Rn=4/29,Dn=6/29,qn=3*Dn*Dn,Ln=Dn*Dn*Dn;function Un(t){if(t instanceof Bn)return new Bn(t.l,t.a,t.b,t.opacity);if(t instanceof Vn)return Gn(t);t instanceof bn||(t=yn(t));var n,e,r=Hn(t.r),i=Hn(t.g),o=Hn(t.b),a=Fn((.2225045*r+.7168786*i+.0606169*o)/Pn);return r===i&&i===o?n=e=a:(n=Fn((.4360747*r+.3850649*i+.1430804*o)/Cn),e=Fn((.0139322*r+.0971045*i+.7141733*o)/zn)),new Bn(116*a-16,500*(n-a),200*(a-e),t.opacity)}function On(t,n,e,r){return 1===arguments.length?Un(t):new Bn(t,n,e,null==r?1:r)}function Bn(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function Fn(t){return t>Ln?Math.pow(t,1/3):t/qn+Rn}function Yn(t){return t>Dn?t*t*t:qn*(t-Rn)}function In(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Hn(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function jn(t){if(t instanceof Vn)return new Vn(t.h,t.c,t.l,t.opacity);if(t instanceof Bn||(t=Un(t)),0===t.a&&0===t.b)return new Vn(NaN,0=1?(e=1,n-1):Math.floor(e*n),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,u=r180||e<-180?e-360*Math.round(e/360):e):ue(isNaN(t)?n:t)}function se(t){return 1==(t=+t)?le:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):ue(isNaN(n)?e:n)}}function le(t,n){var e=n-t;return e?ce(t,e):ue(isNaN(t)?n:t)}Qt(re,ee,Kt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new re(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new re(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*kn,n=+this.l,e=isNaN(this.s)?0:this.s*n*(1-n),r=Math.cos(t),i=Math.sin(t);return new bn(255*(n+e*($n*r+Wn*i)),255*(n+e*(Zn*r+Qn*i)),255*(n+e*(Kn*r)),this.opacity)}}));var he=function t(n){var e=se(n);function r(t,n){var r=e((t=_n(t)).r,(n=_n(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=le(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function de(t){return function(n){var e,r,i=n.length,o=new Array(i),a=new Array(i),u=new Array(i);for(e=0;eo&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,c.push({i:a,x:_e(e,r)})),o=xe.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:_e(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,c),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:_e(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,c),function(t,n,e,r,o,a){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:_e(t,e)},{i:u-2,x:_e(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,c),o=a=null,function(t){for(var n,e=-1,r=c.length;++e=0&&n._call.call(null,t),n=n._next;--Ke}function hr(){rr=(er=or.now())+ir,Ke=Je=0;try{lr()}finally{Ke=0,function(){var t,n,e=Ze,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Ze=n);Qe=t,pr(r)}(),rr=0}}function dr(){var t=or.now(),n=t-er;n>nr&&(ir-=n,er=t)}function pr(t){Ke||(Je&&(Je=clearTimeout(Je)),t-rr>24?(t<1/0&&(Je=setTimeout(hr,t-or.now()-ir)),tr&&(tr=clearInterval(tr))):(tr||(er=or.now(),tr=setInterval(dr,nr)),Ke=1,ar(hr)))}function vr(t,n,e){var r=new fr;return n=null==n?0:+n,r.restart(function(e){r.stop(),t(e+n)},n,e),r}fr.prototype=sr.prototype={constructor:fr,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?ur():+e)+(null==n?0:+n),this._next||Qe===this||(Qe?Qe._next=this:Ze=this,Qe=this),this._call=t,this._time=e,pr()},stop:function(){this._call&&(this._call=null,this._time=1/0,pr())}};var gr=I("start","end","cancel","interrupt"),yr=[],_r=0,br=1,mr=2,xr=3,wr=4,Mr=5,Nr=6;function Tr(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(c){var f,s,l,h;if(e.state!==br)return u();for(f in i)if((h=i[f]).name===e.name){if(h.state===xr)return vr(o);h.state===wr?(h.state=Nr,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[f]):+f_r)throw new Error("too late; already scheduled");return e}function Sr(t,n){var e=kr(t,n);if(e.state>xr)throw new Error("too late; already running");return e}function kr(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Er(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>mr&&e.state=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?Ar:Sr;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}(e,t,n))},attr:function(t,n){var e=W(t),r="transform"===e?De:Pr;return this.attrTween(t,"function"==typeof n?(e.local?function(t,n,e){var r,i,o;return function(){var a,u,c=e(this);if(null!=c)return(a=this.getAttributeNS(t.space,t.local))===(u=c+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,c));this.removeAttributeNS(t.space,t.local)}}:function(t,n,e){var r,i,o;return function(){var a,u,c=e(this);if(null!=c)return(a=this.getAttribute(t))===(u=c+"")?null:a===r&&u===i?o:(i=u,o=n(r=a,c));this.removeAttribute(t)}})(e,r,Cr(this,"attr."+t,n)):null==n?(e.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}})(e):(e.local?function(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttributeNS(t.space,t.local);return a===o?null:a===r?i:i=n(r=a,e)}}:function(t,n,e){var r,i,o=e+"";return function(){var a=this.getAttribute(t);return a===o?null:a===r?i:i=n(r=a,e)}})(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=W(t);return this.tween(e,(r.local?function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttributeNS(t.space,t.local,n.call(this,e))}}(t,i)),e}return i._value=n,i}:function(t,n){var e,r;function i(){var i=n.apply(this,arguments);return i!==r&&(e=(r=i)&&function(t,n){return function(e){this.setAttribute(t,n.call(this,e))}}(t,i)),e}return i._value=n,i})(r,n))},style:function(t,n,e){var r="transform"==(t+="")?Re:Pr;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=ft(this,t),a=(this.style.removeProperty(t),ft(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,Rr(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=ft(this,t),u=e(this),c=u+"";return null==u&&(this.style.removeProperty(t),c=u=ft(this,t)),a===c?null:a===r&&c===i?o:(i=c,o=n(r=a,u))}}(t,r,Cr(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var c=Sr(this,t),f=c.on,s=null==c.value[a]?o||(o=Rr(n)):void 0;f===e&&i===s||(r=(e=f).copy()).on(u,i=s),c.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=ft(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(Cr(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=kr(this.node(),e).tween,o=0,a=i.length;o0&&(r=o-P),M<0?d=p-z:M>0&&(u=c-z),x=xi,B.attr("cursor",Ei.selection),I());break;default:return}bi()},!0).on("keyup.brush",function(){switch(t.event.keyCode){case 16:R&&(g=y=R=!1,I());break;case 18:x===Mi&&(w<0?f=h:w>0&&(r=o),M<0?d=p:M>0&&(u=c),x=wi,I());break;case 32:x===xi&&(t.event.altKey?(w&&(f=h-P*w,r=o+P*w),M&&(d=p-z*M,u=c+z*M),x=Mi):(w<0?f=h:w>0&&(r=o),M<0?d=p:M>0&&(u=c),x=wi),B.attr("cursor",Ei[m]),I());break;default:return}bi()},!0),Ht(t.event.view)}_i(),Er(b),s.call(b),U.start()}function Y(){var t=D(b);!R||g||y||(Math.abs(t[0]-L[0])>Math.abs(t[1]-L[1])?y=!0:g=!0),L=t,v=!0,bi(),I()}function I(){var t;switch(P=L[0]-q[0],z=L[1]-q[1],x){case xi:case mi:w&&(P=Math.max(S-r,Math.min(E-f,P)),o=r+P,h=f+P),M&&(z=Math.max(k-u,Math.min(C-d,z)),c=u+z,p=d+z);break;case wi:w<0?(P=Math.max(S-r,Math.min(E-r,P)),o=r+P,h=f):w>0&&(P=Math.max(S-f,Math.min(E-f,P)),o=r,h=f+P),M<0?(z=Math.max(k-u,Math.min(C-u,z)),c=u+z,p=d):M>0&&(z=Math.max(k-d,Math.min(C-d,z)),c=u,p=d+z);break;case Mi:w&&(o=Math.max(S,Math.min(E,r-P*w)),h=Math.max(S,Math.min(E,f+P*w))),M&&(c=Math.max(k,Math.min(C,u-z*M)),p=Math.max(k,Math.min(C,d+z*M)))}h1e-6)if(Math.abs(s*u-c*f)>1e-6&&i){var h=e-o,d=r-a,p=u*u+c*c,v=h*h+d*d,g=Math.sqrt(p),y=Math.sqrt(l),_=i*Math.tan((Wi-Math.acos((p+l-v)/(2*g*y)))/2),b=_/y,m=_/g;Math.abs(b-1)>1e-6&&(this._+="L"+(t+b*f)+","+(n+b*s)),this._+="A"+i+","+i+",0,0,"+ +(s*h>f*d)+","+(this._x1=t+m*u)+","+(this._y1=n+m*c)}else this._+="L"+(this._x1=t)+","+(this._y1=n);else;},arc:function(t,n,e,r,i,o){t=+t,n=+n,o=!!o;var a=(e=+e)*Math.cos(r),u=e*Math.sin(r),c=t+a,f=n+u,s=1^o,l=o?r-i:i-r;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+c+","+f:(Math.abs(this._x1-c)>1e-6||Math.abs(this._y1-f)>1e-6)&&(this._+="L"+c+","+f),e&&(l<0&&(l=l%Zi+Zi),l>Qi?this._+="A"+e+","+e+",0,1,"+s+","+(t-a)+","+(n-u)+"A"+e+","+e+",0,1,"+s+","+(this._x1=c)+","+(this._y1=f):l>1e-6&&(this._+="A"+e+","+e+",0,"+ +(l>=Wi)+","+s+","+(this._x1=t+e*Math.cos(i))+","+(this._y1=n+e*Math.sin(i))))},rect:function(t,n,e,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +r+"h"+-e+"Z"},toString:function(){return this._}};function oo(){}function ao(t,n){var e=new oo;if(t instanceof oo)t.each(function(t,n){e.set(n,t)});else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==n)for(;++ir!=d>r&&e<(h-f)*(r-s)/(d-s)+f&&(i=-i)}return i}function mo(t,n,e){var r,i,o,a;return function(t,n,e){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])}(t,n,e)&&(i=t[r=+(t[0]===n[0])],o=e[r],a=n[r],i<=o&&o<=a||a<=o&&o<=i)}function xo(){}var wo=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Mo(){var t=1,n=1,e=M,r=u;function i(t){var n=e(t);if(Array.isArray(n))n=n.slice().sort(go);else{var r=s(t),i=r[0],a=r[1];n=w(i,a,n),n=g(Math.floor(i/n)*n,Math.floor(a/n)*n,n)}return n.map(function(n){return o(t,n)})}function o(e,i){var o=[],u=[];return function(e,r,i){var o,u,c,f,s,l,h=new Array,d=new Array;o=u=-1,f=e[0]>=r,wo[f<<1].forEach(p);for(;++o=r,wo[c|f<<1].forEach(p);wo[f<<0].forEach(p);for(;++u=r,s=e[u*t]>=r,wo[f<<1|s<<2].forEach(p);++o=r,l=s,s=e[u*t+o+1]>=r,wo[c|f<<1|s<<2|l<<3].forEach(p);wo[f|s<<3].forEach(p)}o=-1,s=e[u*t]>=r,wo[s<<2].forEach(p);for(;++o=r,wo[s<<2|l<<3].forEach(p);function p(t){var n,e,r=[t[0][0]+o,t[0][1]+u],c=[t[1][0]+o,t[1][1]+u],f=a(r),s=a(c);(n=d[f])?(e=h[s])?(delete d[n.end],delete h[e.start],n===e?(n.ring.push(c),i(n.ring)):h[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete d[n.end],n.ring.push(c),d[n.end=s]=n):(n=h[s])?(e=d[f])?(delete h[n.start],delete d[e.end],n===e?(n.ring.push(c),i(n.ring)):h[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete h[n.start],n.ring.unshift(r),h[n.start=f]=n):h[f]=d[s]={start:f,end:s,ring:[r,c]}}wo[s<<3].forEach(p)}(e,i,function(t){r(t,e,i),function(t){for(var n=0,e=t.length,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++n0?o.push([t]):u.push(t)}),u.forEach(function(t){for(var n,e=0,r=o.length;e0&&a0&&u0&&o>0))throw new Error("invalid size");return t=r,n=o,i},i.thresholds=function(t){return arguments.length?(e="function"==typeof t?t:Array.isArray(t)?yo(vo.call(t)):yo(t),i):e},i.smooth=function(t){return arguments.length?(r=t?u:xo,i):r===u},i}function No(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(c-=t.data[u-o+a*r]),n.data[u-e+a*r]=c/Math.min(u+1,r-1+o-u,o))}function To(t,n,e){for(var r=t.width,i=t.height,o=1+(e<<1),a=0;a=e&&(u>=o&&(c-=t.data[a+(u-o)*r]),n.data[a+(u-e)*r]=c/Math.min(u+1,i-1+o-u,o))}function Ao(t){return t[0]}function So(t){return t[1]}function ko(){return 1}var Eo={},Co={},Po=34,zo=10,Ro=13;function Do(t){return new Function("d","return {"+t.map(function(t,n){return JSON.stringify(t)+": d["+n+'] || ""'}).join(",")+"}")}function qo(t){var n=Object.create(null),e=[];return t.forEach(function(t){for(var r in t)r in n||e.push(n[r]=r)}),e}function Lo(t,n){var e=t+"",r=e.length;return r9999?"+"+Lo(t,6):Lo(t,4)}(t.getUTCFullYear())+"-"+Lo(t.getUTCMonth()+1,2)+"-"+Lo(t.getUTCDate(),2)+(i?"T"+Lo(n,2)+":"+Lo(e,2)+":"+Lo(r,2)+"."+Lo(i,3)+"Z":r?"T"+Lo(n,2)+":"+Lo(e,2)+":"+Lo(r,2)+"Z":e||n?"T"+Lo(n,2)+":"+Lo(e,2)+"Z":"")}function Oo(t){var n=new RegExp('["'+t+"\n\r]"),e=t.charCodeAt(0);function r(t,n){var r,i=[],o=t.length,a=0,u=0,c=o<=0,f=!1;function s(){if(c)return Co;if(f)return f=!1,Eo;var n,r,i=a;if(t.charCodeAt(i)===Po){for(;a++=o?c=!0:(r=t.charCodeAt(a++))===zo?f=!0:r===Ro&&(f=!0,t.charCodeAt(a)===zo&&++a),t.slice(i+1,n-1).replace(/""/g,'"')}for(;a=(o=(v+y)/2))?v=o:y=o,(s=e>=(a=(g+_)/2))?g=a:_=a,i=d,!(d=d[l=s<<1|f]))return i[l]=p,t;if(u=+t._x.call(null,d.data),c=+t._y.call(null,d.data),n===u&&e===c)return p.next=d,i?i[l]=p:t._root=p,t;do{i=i?i[l]=new Array(4):t._root=new Array(4),(f=n>=(o=(v+y)/2))?v=o:y=o,(s=e>=(a=(g+_)/2))?g=a:_=a}while((l=s<<1|f)==(h=(c>=a)<<1|u>=o));return i[h]=d,i[l]=p,t}function ya(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function _a(t){return t[0]}function ba(t){return t[1]}function ma(t,n,e){var r=new xa(null==n?_a:n,null==e?ba:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function xa(t,n,e,r,i,o){this._x=t,this._y=n,this._x0=e,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function wa(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var Ma=ma.prototype=xa.prototype;function Na(t){return t.x+t.vx}function Ta(t){return t.y+t.vy}function Aa(t){return t.index}function Sa(t,n){var e=t.get(n);if(!e)throw new Error("missing: "+n);return e}function ka(t){return t.x}function Ea(t){return t.y}Ma.copy=function(){var t,n,e=new xa(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=wa(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=wa(n));return e},Ma.add=function(t){var n=+this._x.call(null,t),e=+this._y.call(null,t);return ga(this.cover(n,e),n,e,t)},Ma.addAll=function(t){var n,e,r,i,o=t.length,a=new Array(o),u=new Array(o),c=1/0,f=1/0,s=-1/0,l=-1/0;for(e=0;es&&(s=r),il&&(l=i));if(c>s||f>l)return this;for(this.cover(c,f).cover(s,l),e=0;et||t>=i||r>n||n>=o;)switch(u=(nh||(o=c.y0)>d||(a=c.x1)=y)<<1|t>=g)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-f],p[p.length-1-f]=c)}else{var _=t-+this._x.call(null,v.data),b=n-+this._y.call(null,v.data),m=_*_+b*b;if(m=(u=(p+g)/2))?p=u:g=u,(s=a>=(c=(v+y)/2))?v=c:y=c,n=d,!(d=d[l=s<<1|f]))return this;if(!d.length)break;(n[l+1&3]||n[l+2&3]||n[l+3&3])&&(e=n,h=l)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):n?(i?n[l]=i:delete n[l],(d=n[0]||n[1]||n[2]||n[3])&&d===(n[3]||n[2]||n[1]||n[0])&&!d.length&&(e?e[h]=d:this._root=d),this):(this._root=i,this)},Ma.removeAll=function(t){for(var n=0,e=t.length;n1?r[0]+r.slice(2):r,+t.slice(e+1)]}function Ra(t){return(t=za(Math.abs(t)))?t[1]:NaN}var Da,qa=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function La(t){if(!(n=qa.exec(t)))throw new Error("invalid format: "+t);var n;return new Ua({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}function Ua(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Oa(t,n){var e=za(t,n);if(!e)return t+"";var r=e[0],i=e[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}La.prototype=Ua.prototype,Ua.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Ba={"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return Oa(100*t,n)},r:Oa,s:function(t,n){var e=za(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(Da=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+za(t,Math.max(0,n+o-1))[0]},X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}};function Fa(t){return t}var Ya,Ia=Array.prototype.map,Ha=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ja(t){var n,e,r=void 0===t.grouping||void 0===t.thousands?Fa:(n=Ia.call(t.grouping,Number),e=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,u=n[0],c=0;i>0&&u>0&&(c+u+1>r&&(u=Math.max(1,r-c)),o.push(t.substring(i-=u,i+u)),!((c+=u+1)>r));)u=n[a=(a+1)%n.length];return o.reverse().join(e)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",u=void 0===t.numerals?Fa:function(t){return function(n){return n.replace(/[0-9]/g,function(n){return t[+n]})}}(Ia.call(t.numerals,String)),c=void 0===t.percent?"%":t.percent+"",f=void 0===t.minus?"-":t.minus+"",s=void 0===t.nan?"NaN":t.nan+"";function l(t){var n=(t=La(t)).fill,e=t.align,l=t.sign,h=t.symbol,d=t.zero,p=t.width,v=t.comma,g=t.precision,y=t.trim,_=t.type;"n"===_?(v=!0,_="g"):Ba[_]||(void 0===g&&(g=12),y=!0,_="g"),(d||"0"===n&&"="===e)&&(d=!0,n="0",e="=");var b="$"===h?i:"#"===h&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",m="$"===h?o:/[%p]/.test(_)?c:"",x=Ba[_],w=/[defgprs%]/.test(_);function M(t){var i,o,c,h=b,M=m;if("c"===_)M=x(t)+M,t="";else{var N=(t=+t)<0;if(t=isNaN(t)?s:x(Math.abs(t),g),y&&(t=function(t){t:for(var n,e=t.length,r=1,i=-1;r0){if(!+t[r])break t;i=0}}return i>0?t.slice(0,i)+t.slice(n+1):t}(t)),N&&0==+t&&(N=!1),h=(N?"("===l?l:f:"-"===l||"("===l?"":l)+h,M=("s"===_?Ha[8+Da/3]:"")+M+(N&&"("===l?")":""),w)for(i=-1,o=t.length;++i(c=t.charCodeAt(i))||c>57){M=(46===c?a+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}v&&!d&&(t=r(t,1/0));var T=h.length+t.length+M.length,A=T>1)+h+t+M+A.slice(T);break;default:t=A+h+t+M}return u(t)}return g=void 0===g?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,g)):Math.max(0,Math.min(20,g)),M.toString=function(){return t+""},M}return{format:l,formatPrefix:function(t,n){var e=l(((t=La(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Ra(n)/3))),i=Math.pow(10,-r),o=Ha[8+r/3];return function(t){return e(i*t)+o}}}}function Xa(n){return Ya=ja(n),t.format=Ya.format,t.formatPrefix=Ya.formatPrefix,Ya}function Va(t){return Math.max(0,-Ra(Math.abs(t)))}function Ga(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Ra(n)/3)))-Ra(Math.abs(t)))}function $a(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,Ra(n)-Ra(t))+1}function Wa(){return new Za}function Za(){this.reset()}Xa({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"}),Za.prototype={constructor:Za,reset:function(){this.s=this.t=0},add:function(t){Ka(Qa,t,this.t),Ka(this,Qa.s,this.s),this.s?this.t+=Qa.t:this.s=Qa.t},valueOf:function(){return this.s}};var Qa=new Za;function Ka(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var Ja=1e-6,tu=1e-12,nu=Math.PI,eu=nu/2,ru=nu/4,iu=2*nu,ou=180/nu,au=nu/180,uu=Math.abs,cu=Math.atan,fu=Math.atan2,su=Math.cos,lu=Math.ceil,hu=Math.exp,du=Math.log,pu=Math.pow,vu=Math.sin,gu=Math.sign||function(t){return t>0?1:t<0?-1:0},yu=Math.sqrt,_u=Math.tan;function bu(t){return t>1?0:t<-1?nu:Math.acos(t)}function mu(t){return t>1?eu:t<-1?-eu:Math.asin(t)}function xu(t){return(t=vu(t/2))*t}function wu(){}function Mu(t,n){t&&Tu.hasOwnProperty(t.type)&&Tu[t.type](t,n)}var Nu={Feature:function(t,n){Mu(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r=0?1:-1,i=r*e,o=su(n=(n*=au)/2+ru),a=vu(n),u=Ru*a,c=zu*o+u*su(i),f=u*r*vu(i);Du.add(fu(f,c)),Pu=t,zu=o,Ru=a}function Yu(t){return[fu(t[1],t[0]),mu(t[2])]}function Iu(t){var n=t[0],e=t[1],r=su(e);return[r*su(n),r*vu(n),vu(e)]}function Hu(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function ju(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function Xu(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Vu(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function Gu(t){var n=yu(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var $u,Wu,Zu,Qu,Ku,Ju,tc,nc,ec,rc,ic,oc,ac,uc,cc,fc,sc,lc,hc,dc,pc,vc,gc,yc,_c,bc,mc=Wa(),xc={point:wc,lineStart:Nc,lineEnd:Tc,polygonStart:function(){xc.point=Ac,xc.lineStart=Sc,xc.lineEnd=kc,mc.reset(),Lu.polygonStart()},polygonEnd:function(){Lu.polygonEnd(),xc.point=wc,xc.lineStart=Nc,xc.lineEnd=Tc,Du<0?($u=-(Zu=180),Wu=-(Qu=90)):mc>Ja?Qu=90:mc<-Ja&&(Wu=-90),rc[0]=$u,rc[1]=Zu},sphere:function(){$u=-(Zu=180),Wu=-(Qu=90)}};function wc(t,n){ec.push(rc=[$u=t,Zu=t]),nQu&&(Qu=n)}function Mc(t,n){var e=Iu([t*au,n*au]);if(nc){var r=ju(nc,e),i=ju([r[1],-r[0],0],r);Gu(i),i=Yu(i);var o,a=t-Ku,u=a>0?1:-1,c=i[0]*ou*u,f=uu(a)>180;f^(u*KuQu&&(Qu=o):f^(u*Ku<(c=(c+360)%360-180)&&cQu&&(Qu=n)),f?tEc($u,Zu)&&(Zu=t):Ec(t,Zu)>Ec($u,Zu)&&($u=t):Zu>=$u?(t<$u&&($u=t),t>Zu&&(Zu=t)):t>Ku?Ec($u,t)>Ec($u,Zu)&&(Zu=t):Ec(t,Zu)>Ec($u,Zu)&&($u=t)}else ec.push(rc=[$u=t,Zu=t]);nQu&&(Qu=n),nc=e,Ku=t}function Nc(){xc.point=Mc}function Tc(){rc[0]=$u,rc[1]=Zu,xc.point=wc,nc=null}function Ac(t,n){if(nc){var e=t-Ku;mc.add(uu(e)>180?e+(e>0?360:-360):e)}else Ju=t,tc=n;Lu.point(t,n),Mc(t,n)}function Sc(){Lu.lineStart()}function kc(){Ac(Ju,tc),Lu.lineEnd(),uu(mc)>Ja&&($u=-(Zu=180)),rc[0]=$u,rc[1]=Zu,nc=null}function Ec(t,n){return(n-=t)<0?n+360:n}function Cc(t,n){return t[0]-n[0]}function Pc(t,n){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nnu?t+Math.round(-t/iu)*iu:t,n]}function Vc(t,n,e){return(t%=iu)?n||e?jc($c(t),Wc(n,e)):$c(t):n||e?Wc(n,e):Xc}function Gc(t){return function(n,e){return[(n+=t)>nu?n-iu:n<-nu?n+iu:n,e]}}function $c(t){var n=Gc(t);return n.invert=Gc(-t),n}function Wc(t,n){var e=su(t),r=vu(t),i=su(n),o=vu(n);function a(t,n){var a=su(n),u=su(t)*a,c=vu(t)*a,f=vu(n),s=f*e+u*r;return[fu(c*i-s*o,u*e-f*r),mu(s*i+c*o)]}return a.invert=function(t,n){var a=su(n),u=su(t)*a,c=vu(t)*a,f=vu(n),s=f*i-c*o;return[fu(c*i+f*o,u*e+s*r),mu(s*e-u*r)]},a}function Zc(t){function n(n){return(n=t(n[0]*au,n[1]*au))[0]*=ou,n[1]*=ou,n}return t=Vc(t[0]*au,t[1]*au,t.length>2?t[2]*au:0),n.invert=function(n){return(n=t.invert(n[0]*au,n[1]*au))[0]*=ou,n[1]*=ou,n},n}function Qc(t,n,e,r,i,o){if(e){var a=su(n),u=vu(n),c=r*e;null==i?(i=n+r*iu,o=n-c/2):(i=Kc(a,i),o=Kc(a,o),(r>0?io)&&(i+=r*iu));for(var f,s=i;r>0?s>o:s1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function tf(t,n){return uu(t[0]-n[0])=0;--o)i.point((s=f[o])[0],s[1]);else r(h.x,h.p.x,-1,i);h=h.p}f=(h=h.o).z,d=!d}while(!h.v);i.lineEnd()}}}function rf(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r=0?1:-1,T=N*M,A=T>nu,S=v*x;if(of.add(fu(S*N*vu(T),g*w+S*su(T))),a+=A?M+N*iu:M,A^d>=e^b>=e){var k=ju(Iu(h),Iu(_));Gu(k);var E=ju(o,k);Gu(E);var C=(A^M>=0?-1:1)*mu(E[2]);(r>C||r===C&&(k[0]||k[1]))&&(u+=A^M>=0?1:-1)}}return(a<-Ja||a0){for(l||(i.polygonStart(),l=!0),i.lineStart(),t=0;t1&&2&c&&h.push(h.pop().concat(h.shift())),a.push(h.filter(ff))}return h}}function ff(t){return t.length>1}function sf(t,n){return((t=t.x)[0]<0?t[1]-eu-Ja:eu-t[1])-((n=n.x)[0]<0?n[1]-eu-Ja:eu-n[1])}var lf=cf(function(){return!0},function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var u=o>0?nu:-nu,c=uu(o-e);uu(c-nu)0?eu:-eu),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&c>=nu&&(uu(e-i)Ja?cu((vu(n)*(o=su(r))*vu(e)-vu(r)*(i=su(n))*vu(t))/(i*o*a)):(n+r)/2}(e,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),n=0),t.point(e=o,r=a),i=u},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}},function(t,n,e,r){var i;if(null==t)i=e*eu,r.point(-nu,i),r.point(0,i),r.point(nu,i),r.point(nu,0),r.point(nu,-i),r.point(0,-i),r.point(-nu,-i),r.point(-nu,0),r.point(-nu,i);else if(uu(t[0]-n[0])>Ja){var o=t[0]0,i=uu(n)>Ja;function o(t,e){return su(t)*su(e)>n}function a(t,e,r){var i=[1,0,0],o=ju(Iu(t),Iu(e)),a=Hu(o,o),u=o[0],c=a-u*u;if(!c)return!r&&t;var f=n*a/c,s=-n*u/c,l=ju(i,o),h=Vu(i,f);Xu(h,Vu(o,s));var d=l,p=Hu(h,d),v=Hu(d,d),g=p*p-v*(Hu(h,h)-1);if(!(g<0)){var y=yu(g),_=Vu(d,(-p-y)/v);if(Xu(_,h),_=Yu(_),!r)return _;var b,m=t[0],x=e[0],w=t[1],M=e[1];x0^_[1]<(uu(_[0]-m)nu^(m<=_[0]&&_[0]<=x)){var A=Vu(d,(-p+y)/v);return Xu(A,h),[_,Yu(A)]}}}function u(n,e){var i=r?t:nu-t,o=0;return n<-i?o|=1:n>i&&(o|=2),e<-i?o|=4:e>i&&(o|=8),o}return cf(o,function(t){var n,e,c,f,s;return{lineStart:function(){f=c=!1,s=1},point:function(l,h){var d,p=[l,h],v=o(l,h),g=r?v?0:u(l,h):v?u(l+(l<0?nu:-nu),h):0;if(!n&&(f=c=v)&&t.lineStart(),v!==c&&(!(d=a(n,p))||tf(n,d)||tf(p,d))&&(p[0]+=Ja,p[1]+=Ja,v=o(p[0],p[1])),v!==c)s=0,v?(t.lineStart(),d=a(p,n),t.point(d[0],d[1])):(d=a(n,p),t.point(d[0],d[1]),t.lineEnd()),n=d;else if(i&&n&&r^v){var y;g&e||!(y=a(p,n,!0))||(s=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])))}!v||n&&tf(n,p)||t.point(p[0],p[1]),n=p,c=v,e=g},lineEnd:function(){c&&t.lineEnd(),n=null},clean:function(){return s|(f&&c)<<1}}},function(n,r,i,o){Qc(o,t,e,i,n,r)},r?[0,-t]:[-nu,t-nu])}var df=1e9,pf=-df;function vf(t,n,e,r){function i(i,o){return t<=i&&i<=e&&n<=o&&o<=r}function o(i,o,u,f){var s=0,l=0;if(null==i||(s=a(i,u))!==(l=a(o,u))||c(i,o)<0^u>0)do{f.point(0===s||3===s?t:e,s>1?r:n)}while((s=(s+u+4)%4)!==l);else f.point(o[0],o[1])}function a(r,i){return uu(r[0]-t)0?0:3:uu(r[0]-e)0?2:1:uu(r[1]-n)0?1:0:i>0?3:2}function u(t,n){return c(t.x,n.x)}function c(t,n){var e=a(t,1),r=a(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}return function(a){var c,f,s,l,h,d,p,v,g,y,_,b=a,m=Jc(),x={point:w,lineStart:function(){x.point=M,f&&f.push(s=[]);y=!0,g=!1,p=v=NaN},lineEnd:function(){c&&(M(l,h),d&&g&&m.rejoin(),c.push(m.result()));x.point=w,g&&b.lineEnd()},polygonStart:function(){b=m,c=[],f=[],_=!0},polygonEnd:function(){var n=function(){for(var n=0,e=0,i=f.length;er&&(h-o)*(r-a)>(d-a)*(t-o)&&++n:d<=r&&(h-o)*(r-a)<(d-a)*(t-o)&&--n;return n}(),e=_&&n,i=(c=A(c)).length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&ef(c,u,n,o,a),a.polygonEnd());b=a,c=f=s=null}};function w(t,n){i(t,n)&&b.point(t,n)}function M(o,a){var u=i(o,a);if(f&&s.push([o,a]),y)l=o,h=a,d=u,y=!1,u&&(b.lineStart(),b.point(o,a));else if(u&&g)b.point(o,a);else{var c=[p=Math.max(pf,Math.min(df,p)),v=Math.max(pf,Math.min(df,v))],m=[o=Math.max(pf,Math.min(df,o)),a=Math.max(pf,Math.min(df,a))];!function(t,n,e,r,i,o){var a,u=t[0],c=t[1],f=0,s=1,l=n[0]-u,h=n[1]-c;if(a=e-u,l||!(a>0)){if(a/=l,l<0){if(a0){if(a>s)return;a>f&&(f=a)}if(a=i-u,l||!(a<0)){if(a/=l,l<0){if(a>s)return;a>f&&(f=a)}else if(l>0){if(a0)){if(a/=h,h<0){if(a0){if(a>s)return;a>f&&(f=a)}if(a=o-c,h||!(a<0)){if(a/=h,h<0){if(a>s)return;a>f&&(f=a)}else if(h>0){if(a0&&(t[0]=u+f*l,t[1]=c+f*h),s<1&&(n[0]=u+s*l,n[1]=c+s*h),!0}}}}}(c,m,t,n,e,r)?u&&(b.lineStart(),b.point(o,a),_=!1):(g||(b.lineStart(),b.point(c[0],c[1])),b.point(m[0],m[1]),u||b.lineEnd(),_=!1)}p=o,v=a,g=u}return x}}var gf,yf,_f,bf=Wa(),mf={sphere:wu,point:wu,lineStart:function(){mf.point=wf,mf.lineEnd=xf},lineEnd:wu,polygonStart:wu,polygonEnd:wu};function xf(){mf.point=mf.lineEnd=wu}function wf(t,n){gf=t*=au,yf=vu(n*=au),_f=su(n),mf.point=Mf}function Mf(t,n){t*=au;var e=vu(n*=au),r=su(n),i=uu(t-gf),o=su(i),a=r*vu(i),u=_f*e-yf*r*o,c=yf*e+_f*r*o;bf.add(fu(yu(a*a+u*u),c)),gf=t,yf=e,_f=r}function Nf(t){return bf.reset(),ku(t,mf),+bf}var Tf=[null,null],Af={type:"LineString",coordinates:Tf};function Sf(t,n){return Tf[0]=t,Tf[1]=n,Nf(Af)}var kf={Feature:function(t,n){return Cf(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r0&&(i=Sf(t[o],t[o-1]))>0&&e<=i&&r<=i&&(e+r-i)*(1-Math.pow((e-r)/i,2))Ja}).map(c)).concat(g(lu(o/d)*d,i,d).filter(function(t){return uu(t%v)>Ja}).map(f))}return _.lines=function(){return b().map(function(t){return{type:"LineString",coordinates:t}})},_.outline=function(){return{type:"Polygon",coordinates:[s(r).concat(l(a).slice(1),s(e).reverse().slice(1),l(u).reverse().slice(1))]}},_.extent=function(t){return arguments.length?_.extentMajor(t).extentMinor(t):_.extentMinor()},_.extentMajor=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],u=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),u>a&&(t=u,u=a,a=t),_.precision(y)):[[r,u],[e,a]]},_.extentMinor=function(e){return arguments.length?(n=+e[0][0],t=+e[1][0],o=+e[0][1],i=+e[1][1],n>t&&(e=n,n=t,t=e),o>i&&(e=o,o=i,i=e),_.precision(y)):[[n,o],[t,i]]},_.step=function(t){return arguments.length?_.stepMajor(t).stepMinor(t):_.stepMinor()},_.stepMajor=function(t){return arguments.length?(p=+t[0],v=+t[1],_):[p,v]},_.stepMinor=function(t){return arguments.length?(h=+t[0],d=+t[1],_):[h,d]},_.precision=function(h){return arguments.length?(y=+h,c=Lf(o,i,90),f=Uf(n,t,y),s=Lf(u,a,90),l=Uf(r,e,y),_):y},_.extentMajor([[-180,-90+Ja],[180,90-Ja]]).extentMinor([[-180,-80-Ja],[180,80+Ja]])}function Bf(t){return t}var Ff,Yf,If,Hf,jf=Wa(),Xf=Wa(),Vf={point:wu,lineStart:wu,lineEnd:wu,polygonStart:function(){Vf.lineStart=Gf,Vf.lineEnd=Zf},polygonEnd:function(){Vf.lineStart=Vf.lineEnd=Vf.point=wu,jf.add(uu(Xf)),Xf.reset()},result:function(){var t=jf/2;return jf.reset(),t}};function Gf(){Vf.point=$f}function $f(t,n){Vf.point=Wf,Ff=If=t,Yf=Hf=n}function Wf(t,n){Xf.add(Hf*t-If*n),If=t,Hf=n}function Zf(){Wf(Ff,Yf)}var Qf=1/0,Kf=Qf,Jf=-Qf,ts=Jf,ns={point:function(t,n){tJf&&(Jf=t);nts&&(ts=n)},lineStart:wu,lineEnd:wu,polygonStart:wu,polygonEnd:wu,result:function(){var t=[[Qf,Kf],[Jf,ts]];return Jf=ts=-(Kf=Qf=1/0),t}};var es,rs,is,os,as=0,us=0,cs=0,fs=0,ss=0,ls=0,hs=0,ds=0,ps=0,vs={point:gs,lineStart:ys,lineEnd:ms,polygonStart:function(){vs.lineStart=xs,vs.lineEnd=ws},polygonEnd:function(){vs.point=gs,vs.lineStart=ys,vs.lineEnd=ms},result:function(){var t=ps?[hs/ps,ds/ps]:ls?[fs/ls,ss/ls]:cs?[as/cs,us/cs]:[NaN,NaN];return as=us=cs=fs=ss=ls=hs=ds=ps=0,t}};function gs(t,n){as+=t,us+=n,++cs}function ys(){vs.point=_s}function _s(t,n){vs.point=bs,gs(is=t,os=n)}function bs(t,n){var e=t-is,r=n-os,i=yu(e*e+r*r);fs+=i*(is+t)/2,ss+=i*(os+n)/2,ls+=i,gs(is=t,os=n)}function ms(){vs.point=gs}function xs(){vs.point=Ms}function ws(){Ns(es,rs)}function Ms(t,n){vs.point=Ns,gs(es=is=t,rs=os=n)}function Ns(t,n){var e=t-is,r=n-os,i=yu(e*e+r*r);fs+=i*(is+t)/2,ss+=i*(os+n)/2,ls+=i,hs+=(i=os*t-is*n)*(is+t),ds+=i*(os+n),ps+=3*i,gs(is=t,os=n)}function Ts(t){this._context=t}Ts.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(t,n){switch(this._point){case 0:this._context.moveTo(t,n),this._point=1;break;case 1:this._context.lineTo(t,n);break;default:this._context.moveTo(t+this._radius,n),this._context.arc(t,n,this._radius,0,iu)}},result:wu};var As,Ss,ks,Es,Cs,Ps=Wa(),zs={point:wu,lineStart:function(){zs.point=Rs},lineEnd:function(){As&&Ds(Ss,ks),zs.point=wu},polygonStart:function(){As=!0},polygonEnd:function(){As=null},result:function(){var t=+Ps;return Ps.reset(),t}};function Rs(t,n){zs.point=Ds,Ss=Es=t,ks=Cs=n}function Ds(t,n){Es-=t,Cs-=n,Ps.add(yu(Es*Es+Cs*Cs)),Es=t,Cs=n}function qs(){this._string=[]}function Ls(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Us(t){return function(n){var e=new Os;for(var r in t)e[r]=t[r];return e.stream=n,e}}function Os(){}function Bs(t,n,e){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),ku(e,t.stream(ns)),n(ns.result()),null!=r&&t.clipExtent(r),t}function Fs(t,n,e){return Bs(t,function(e){var r=n[1][0]-n[0][0],i=n[1][1]-n[0][1],o=Math.min(r/(e[1][0]-e[0][0]),i/(e[1][1]-e[0][1])),a=+n[0][0]+(r-o*(e[1][0]+e[0][0]))/2,u=+n[0][1]+(i-o*(e[1][1]+e[0][1]))/2;t.scale(150*o).translate([a,u])},e)}function Ys(t,n,e){return Fs(t,[[0,0],n],e)}function Is(t,n,e){return Bs(t,function(e){var r=+n,i=r/(e[1][0]-e[0][0]),o=(r-i*(e[1][0]+e[0][0]))/2,a=-i*e[0][1];t.scale(150*i).translate([o,a])},e)}function Hs(t,n,e){return Bs(t,function(e){var r=+n,i=r/(e[1][1]-e[0][1]),o=-i*e[0][0],a=(r-i*(e[1][1]+e[0][1]))/2;t.scale(150*i).translate([o,a])},e)}qs.prototype={_radius:4.5,_circle:Ls(4.5),pointRadius:function(t){return(t=+t)!==this._radius&&(this._radius=t,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._string.push("Z"),this._point=NaN},point:function(t,n){switch(this._point){case 0:this._string.push("M",t,",",n),this._point=1;break;case 1:this._string.push("L",t,",",n);break;default:null==this._circle&&(this._circle=Ls(this._radius)),this._string.push("M",t,",",n,this._circle)}},result:function(){if(this._string.length){var t=this._string.join("");return this._string=[],t}return null}},Os.prototype={constructor:Os,point:function(t,n){this.stream.point(t,n)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var js=16,Xs=su(30*au);function Vs(t,n){return+n?function(t,n){function e(r,i,o,a,u,c,f,s,l,h,d,p,v,g){var y=f-r,_=s-i,b=y*y+_*_;if(b>4*n&&v--){var m=a+h,x=u+d,w=c+p,M=yu(m*m+x*x+w*w),N=mu(w/=M),T=uu(uu(w)-1)n||uu((y*E+_*C)/b-.5)>.3||a*h+u*d+c*p2?t[2]%360*au:0,S()):[g*ou,y*ou,_*ou]},T.angle=function(t){return arguments.length?(b=t%360*au,S()):b*ou},T.precision=function(t){return arguments.length?(a=Vs(u,N=t*t),k()):yu(N)},T.fitExtent=function(t,n){return Fs(T,t,n)},T.fitSize=function(t,n){return Ys(T,t,n)},T.fitWidth=function(t,n){return Is(T,t,n)},T.fitHeight=function(t,n){return Hs(T,t,n)},function(){return n=t.apply(this,arguments),T.invert=n.invert&&A,S()}}function Qs(t){var n=0,e=nu/3,r=Zs(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*au,e=t[1]*au):[n*ou,e*ou]},i}function Ks(t,n){var e=vu(t),r=(e+vu(n))/2;if(uu(r)0?n<-eu+Ja&&(n=-eu+Ja):n>eu-Ja&&(n=eu-Ja);var e=i/pu(ul(n),r);return[e*vu(r*t),i-e*su(r*t)]}return o.invert=function(t,n){var e=i-n,o=gu(r)*yu(t*t+e*e);return[fu(t,uu(e))/r*gu(e),2*cu(pu(i/o,1/r))-eu]},o}function fl(t,n){return[t,n]}function sl(t,n){var e=su(t),r=t===n?vu(t):(e-su(n))/(n-t),i=e/r+t;if(uu(r)=0;)n+=e[r].value;else n=1;t.value=n}function Sl(t,n){var e,r,i,o,a,u=new Pl(t),c=+t.value&&(u.value=t.value),f=[u];for(null==n&&(n=kl);e=f.pop();)if(c&&(e.value=+e.data.value),(i=n(e.data))&&(a=i.length))for(e.children=new Array(a),o=a-1;o>=0;--o)f.push(r=e.children[o]=new Pl(i[o])),r.parent=e,r.depth=e.depth+1;return u.eachBefore(Cl)}function kl(t){return t.children}function El(t){t.data=t.data.data}function Cl(t){var n=0;do{t.height=n}while((t=t.parent)&&t.height<++n)}function Pl(t){this.data=t,this.depth=this.height=0,this.parent=null}gl.invert=function(t,n){for(var e,r=n,i=r*r,o=i*i*i,a=0;a<12&&(o=(i=(r-=e=(r*(ll+hl*i+o*(dl+pl*i))-n)/(ll+3*hl*i+o*(7*dl+9*pl*i)))*r)*i*i,!(uu(e)Ja&&--i>0);return[t/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r]},ml.invert=el(mu),xl.invert=el(function(t){return 2*cu(t)}),wl.invert=function(t,n){return[-n,2*cu(hu(t))-eu]},Pl.prototype=Sl.prototype={constructor:Pl,count:function(){return this.eachAfter(Al)},each:function(t){var n,e,r,i,o=this,a=[o];do{for(n=a.reverse(),a=[];o=n.pop();)if(t(o),e=o.children)for(r=0,i=e.length;r=0;--e)i.push(n[e]);return this},sum:function(t){return this.eachAfter(function(n){for(var e=+t(n.data)||0,r=n.children,i=r&&r.length;--i>=0;)e+=r[i].value;n.value=e})},sort:function(t){return this.eachBefore(function(n){n.children&&n.children.sort(t)})},path:function(t){for(var n=this,e=function(t,n){if(t===n)return t;var e=t.ancestors(),r=n.ancestors(),i=null;for(t=e.pop(),n=r.pop();t===n;)i=t,t=e.pop(),n=r.pop();return i}(n,t),r=[n];n!==e;)n=n.parent,r.push(n);for(var i=r.length;t!==e;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,n=[t];t=t.parent;)n.push(t);return n},descendants:function(){var t=[];return this.each(function(n){t.push(n)}),t},leaves:function(){var t=[];return this.eachBefore(function(n){n.children||t.push(n)}),t},links:function(){var t=this,n=[];return t.each(function(e){e!==t&&n.push({source:e.parent,target:e})}),n},copy:function(){return Sl(this).eachBefore(El)}};var zl=Array.prototype.slice;function Rl(t){for(var n,e,r=0,i=(t=function(t){for(var n,e,r=t.length;r;)e=Math.random()*r--|0,n=t[r],t[r]=t[e],t[e]=n;return t}(zl.call(t))).length,o=[];r0&&e*e>r*r+i*i}function Ul(t,n){for(var e=0;e(a*=a)?(r=(f+a-i)/(2*f),o=Math.sqrt(Math.max(0,a/f-r*r)),e.x=t.x-r*u-o*c,e.y=t.y-r*c+o*u):(r=(f+i-a)/(2*f),o=Math.sqrt(Math.max(0,i/f-r*r)),e.x=n.x+r*u-o*c,e.y=n.y+r*c+o*u)):(e.x=n.x+e.r,e.y=n.y)}function Il(t,n){var e=t.r+n.r-1e-6,r=n.x-t.x,i=n.y-t.y;return e>0&&e*e>r*r+i*i}function Hl(t){var n=t._,e=t.next._,r=n.r+e.r,i=(n.x*e.r+e.x*n.r)/r,o=(n.y*e.r+e.y*n.r)/r;return i*i+o*o}function jl(t){this._=t,this.next=null,this.previous=null}function Xl(t){if(!(i=t.length))return 0;var n,e,r,i,o,a,u,c,f,s,l;if((n=t[0]).x=0,n.y=0,!(i>1))return n.r;if(e=t[1],n.x=-e.r,e.x=n.r,e.y=0,!(i>2))return n.r+e.r;Yl(e,n,r=t[2]),n=new jl(n),e=new jl(e),r=new jl(r),n.next=r.previous=e,e.next=n.previous=r,r.next=e.previous=n;t:for(u=3;uh&&(h=u),g=s*s*v,(d=Math.max(h/g,g/l))>p){s-=u;break}p=d}y.push(a={value:s,dice:c1?n:1)},e}(ph);var yh=function t(n){function e(t,e,r,i,o){if((a=t._squarify)&&a.ratio===n)for(var a,u,c,f,s,l=-1,h=a.length,d=t.value;++l1?n:1)},e}(ph);function _h(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function bh(t,n){return t[0]-n[0]||t[1]-n[1]}function mh(t){for(var n=t.length,e=[0,1],r=2,i=2;i1&&_h(t[e[r-2]],t[e[r-1]],t[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function xh(){return Math.random()}var wh=function t(n){function e(t,e){return t=null==t?0:+t,e=null==e?1:+e,1===arguments.length?(e=t,t=0):e-=t,function(){return n()*e+t}}return e.source=t,e}(xh),Mh=function t(n){function e(t,e){var r,i;return t=null==t?0:+t,e=null==e?1:+e,function(){var o;if(null!=r)o=r,r=null;else do{r=2*n()-1,o=2*n()-1,i=r*r+o*o}while(!i||i>1);return t+e*o*Math.sqrt(-2*Math.log(i)/i)}}return e.source=t,e}(xh),Nh=function t(n){function e(){var t=Mh.source(n).apply(this,arguments);return function(){return Math.exp(t())}}return e.source=t,e}(xh),Th=function t(n){function e(t){return function(){for(var e=0,r=0;rr&&(n=e,e=r,r=n),function(t){return Math.max(e,Math.min(r,t))}}function Yh(t,n,e){var r=t[0],i=t[1],o=n[0],a=n[1];return i2?Ih:Yh,i=o=null,l}function l(n){return isNaN(n=+n)?e:(i||(i=r(a.map(t),u,c)))(t(f(n)))}return l.invert=function(e){return f(n((o||(o=r(u,a.map(t),_e)))(e)))},l.domain=function(t){return arguments.length?(a=Ph.call(t,Lh),f===Oh||(f=Fh(a)),s()):a.slice()},l.range=function(t){return arguments.length?(u=zh.call(t),s()):u.slice()},l.rangeRound=function(t){return u=zh.call(t),c=Ne,s()},l.clamp=function(t){return arguments.length?(f=t?Fh(a):Oh,l):f!==Oh},l.interpolate=function(t){return arguments.length?(c=t,s()):c},l.unknown=function(t){return arguments.length?(e=t,l):e},function(e,r){return t=e,n=r,s()}}function Xh(t,n){return jh()(t,n)}function Vh(n,e,r,i){var o,a=w(n,e,r);switch((i=La(null==i?",f":i)).type){case"s":var u=Math.max(Math.abs(n),Math.abs(e));return null!=i.precision||isNaN(o=Ga(a,u))||(i.precision=o),t.formatPrefix(i,u);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=$a(a,Math.max(Math.abs(n),Math.abs(e))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=Va(a))||(i.precision=o-2*("%"===i.type))}return t.format(i)}function Gh(t){var n=t.domain;return t.ticks=function(t){var e=n();return m(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){var r=n();return Vh(r[0],r[r.length-1],null==t?10:t,e)},t.nice=function(e){null==e&&(e=10);var r,i=n(),o=0,a=i.length-1,u=i[o],c=i[a];return c0?r=x(u=Math.floor(u/r)*r,c=Math.ceil(c/r)*r,e):r<0&&(r=x(u=Math.ceil(u*r)/r,c=Math.floor(c*r)/r,e)),r>0?(i[o]=Math.floor(u/r)*r,i[a]=Math.ceil(c/r)*r,n(i)):r<0&&(i[o]=Math.ceil(u*r)/r,i[a]=Math.floor(c*r)/r,n(i)),t},t}function $h(t,n){var e,r=0,i=(t=t.slice()).length-1,o=t[r],a=t[i];return a0){for(;hc)break;v.push(l)}}else for(;h=1;--s)if(!((l=f*s)c)break;v.push(l)}}else v=m(h,d,Math.min(d-h,p)).map(r);return n?v.reverse():v},i.tickFormat=function(n,o){if(null==o&&(o=10===a?".0e":","),"function"!=typeof o&&(o=t.format(o)),n===1/0)return o;null==n&&(n=10);var u=Math.max(1,a*n/i.ticks().length);return function(t){var n=t/r(Math.round(e(t)));return n*a0))return u;do{u.push(a=new Date(+e)),n(e,o),t(e)}while(a=n)for(;t(n),!e(n);)n.setTime(n-1)},function(t,r){if(t>=t)if(r<0)for(;++r<=0;)for(;n(t,-1),!e(t););else for(;--r>=0;)for(;n(t,1),!e(t););})},e&&(i.count=function(n,r){return sd.setTime(+n),ld.setTime(+r),t(sd),t(ld),Math.floor(e(sd,ld))},i.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?function(n){return r(n)%t==0}:function(n){return i.count(0,n)%t==0}):i:null}),i}var dd=hd(function(){},function(t,n){t.setTime(+t+n)},function(t,n){return n-t});dd.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?hd(function(n){n.setTime(Math.floor(n/t)*t)},function(n,e){n.setTime(+n+e*t)},function(n,e){return(e-n)/t}):dd:null};var pd=dd.range,vd=6e4,gd=6048e5,yd=hd(function(t){t.setTime(t-t.getMilliseconds())},function(t,n){t.setTime(+t+1e3*n)},function(t,n){return(n-t)/1e3},function(t){return t.getUTCSeconds()}),_d=yd.range,bd=hd(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds())},function(t,n){t.setTime(+t+n*vd)},function(t,n){return(n-t)/vd},function(t){return t.getMinutes()}),md=bd.range,xd=hd(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()-t.getMinutes()*vd)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getHours()}),wd=xd.range,Md=hd(function(t){t.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*vd)/864e5},function(t){return t.getDate()-1}),Nd=Md.range;function Td(t){return hd(function(n){n.setDate(n.getDate()-(n.getDay()+7-t)%7),n.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+7*n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*vd)/gd})}var Ad=Td(0),Sd=Td(1),kd=Td(2),Ed=Td(3),Cd=Td(4),Pd=Td(5),zd=Td(6),Rd=Ad.range,Dd=Sd.range,qd=kd.range,Ld=Ed.range,Ud=Cd.range,Od=Pd.range,Bd=zd.range,Fd=hd(function(t){t.setDate(1),t.setHours(0,0,0,0)},function(t,n){t.setMonth(t.getMonth()+n)},function(t,n){return n.getMonth()-t.getMonth()+12*(n.getFullYear()-t.getFullYear())},function(t){return t.getMonth()}),Yd=Fd.range,Id=hd(function(t){t.setMonth(0,1),t.setHours(0,0,0,0)},function(t,n){t.setFullYear(t.getFullYear()+n)},function(t,n){return n.getFullYear()-t.getFullYear()},function(t){return t.getFullYear()});Id.every=function(t){return isFinite(t=Math.floor(t))&&t>0?hd(function(n){n.setFullYear(Math.floor(n.getFullYear()/t)*t),n.setMonth(0,1),n.setHours(0,0,0,0)},function(n,e){n.setFullYear(n.getFullYear()+e*t)}):null};var Hd=Id.range,jd=hd(function(t){t.setUTCSeconds(0,0)},function(t,n){t.setTime(+t+n*vd)},function(t,n){return(n-t)/vd},function(t){return t.getUTCMinutes()}),Xd=jd.range,Vd=hd(function(t){t.setUTCMinutes(0,0,0)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getUTCHours()}),Gd=Vd.range,$d=hd(function(t){t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+n)},function(t,n){return(n-t)/864e5},function(t){return t.getUTCDate()-1}),Wd=$d.range;function Zd(t){return hd(function(n){n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+7-t)%7),n.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+7*n)},function(t,n){return(n-t)/gd})}var Qd=Zd(0),Kd=Zd(1),Jd=Zd(2),tp=Zd(3),np=Zd(4),ep=Zd(5),rp=Zd(6),ip=Qd.range,op=Kd.range,ap=Jd.range,up=tp.range,cp=np.range,fp=ep.range,sp=rp.range,lp=hd(function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCMonth(t.getUTCMonth()+n)},function(t,n){return n.getUTCMonth()-t.getUTCMonth()+12*(n.getUTCFullYear()-t.getUTCFullYear())},function(t){return t.getUTCMonth()}),hp=lp.range,dp=hd(function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n)},function(t,n){return n.getUTCFullYear()-t.getUTCFullYear()},function(t){return t.getUTCFullYear()});dp.every=function(t){return isFinite(t=Math.floor(t))&&t>0?hd(function(n){n.setUTCFullYear(Math.floor(n.getUTCFullYear()/t)*t),n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},function(n,e){n.setUTCFullYear(n.getUTCFullYear()+e*t)}):null};var pp=dp.range;function vp(t){if(0<=t.y&&t.y<100){var n=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return n.setFullYear(t.y),n}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function gp(t){if(0<=t.y&&t.y<100){var n=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return n.setUTCFullYear(t.y),n}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function yp(t,n,e){return{y:t,m:n,d:e,H:0,M:0,S:0,L:0}}function _p(t){var n=t.dateTime,e=t.date,r=t.time,i=t.periods,o=t.days,a=t.shortDays,u=t.months,c=t.shortMonths,f=Ap(i),s=Sp(i),l=Ap(o),h=Sp(o),d=Ap(a),p=Sp(a),v=Ap(u),g=Sp(u),y=Ap(c),_=Sp(c),b={a:function(t){return a[t.getDay()]},A:function(t){return o[t.getDay()]},b:function(t){return c[t.getMonth()]},B:function(t){return u[t.getMonth()]},c:null,d:$p,e:$p,f:Jp,H:Wp,I:Zp,j:Qp,L:Kp,m:tv,M:nv,p:function(t){return i[+(t.getHours()>=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:Ev,s:Cv,S:ev,u:rv,U:iv,V:ov,w:av,W:uv,x:null,X:null,y:cv,Y:fv,Z:sv,"%":kv},m={a:function(t){return a[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return c[t.getUTCMonth()]},B:function(t){return u[t.getUTCMonth()]},c:null,d:lv,e:lv,f:gv,H:hv,I:dv,j:pv,L:vv,m:yv,M:_v,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:Ev,s:Cv,S:bv,u:mv,U:xv,V:wv,w:Mv,W:Nv,x:null,X:null,y:Tv,Y:Av,Z:Sv,"%":kv},x={a:function(t,n,e){var r=d.exec(n.slice(e));return r?(t.w=p[r[0].toLowerCase()],e+r[0].length):-1},A:function(t,n,e){var r=l.exec(n.slice(e));return r?(t.w=h[r[0].toLowerCase()],e+r[0].length):-1},b:function(t,n,e){var r=y.exec(n.slice(e));return r?(t.m=_[r[0].toLowerCase()],e+r[0].length):-1},B:function(t,n,e){var r=v.exec(n.slice(e));return r?(t.m=g[r[0].toLowerCase()],e+r[0].length):-1},c:function(t,e,r){return N(t,n,e,r)},d:Op,e:Op,f:jp,H:Fp,I:Fp,j:Bp,L:Hp,m:Up,M:Yp,p:function(t,n,e){var r=f.exec(n.slice(e));return r?(t.p=s[r[0].toLowerCase()],e+r[0].length):-1},q:Lp,Q:Vp,s:Gp,S:Ip,u:Ep,U:Cp,V:Pp,w:kp,W:zp,x:function(t,n,r){return N(t,e,n,r)},X:function(t,n,e){return N(t,r,n,e)},y:Dp,Y:Rp,Z:qp,"%":Xp};function w(t,n){return function(e){var r,i,o,a=[],u=-1,c=0,f=t.length;for(e instanceof Date||(e=new Date(+e));++u53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=gp(yp(o.y,0,1))).getUTCDay(),r=i>4||0===i?Kd.ceil(r):Kd(r),r=$d.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=vp(yp(o.y,0,1))).getDay(),r=i>4||0===i?Sd.ceil(r):Sd(r),r=Md.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?gp(yp(o.y,0,1)).getUTCDay():vp(yp(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,gp(o)):vp(o)}}function N(t,n,e,r){for(var i,o,a=0,u=n.length,c=e.length;a=c)return-1;if(37===(i=n.charCodeAt(a++))){if(i=n.charAt(a++),!(o=x[i in mp?n.charAt(a++):i])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}return b.x=w(e,b),b.X=w(r,b),b.c=w(n,b),m.x=w(e,m),m.X=w(r,m),m.c=w(n,m),{format:function(t){var n=w(t+="",b);return n.toString=function(){return t},n},parse:function(t){var n=M(t+="",!1);return n.toString=function(){return t},n},utcFormat:function(t){var n=w(t+="",m);return n.toString=function(){return t},n},utcParse:function(t){var n=M(t+="",!0);return n.toString=function(){return t},n}}}var bp,mp={"-":"",_:" ",0:"0"},xp=/^\s*\d+/,wp=/^%/,Mp=/[\\^$*+?|[\]().{}]/g;function Np(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o68?1900:2e3),e+r[0].length):-1}function qp(t,n,e){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(n.slice(e,e+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),e+r[0].length):-1}function Lp(t,n,e){var r=xp.exec(n.slice(e,e+1));return r?(t.q=3*r[0]-3,e+r[0].length):-1}function Up(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function Op(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function Bp(t,n,e){var r=xp.exec(n.slice(e,e+3));return r?(t.m=0,t.d=+r[0],e+r[0].length):-1}function Fp(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function Yp(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function Ip(t,n,e){var r=xp.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function Hp(t,n,e){var r=xp.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function jp(t,n,e){var r=xp.exec(n.slice(e,e+6));return r?(t.L=Math.floor(r[0]/1e3),e+r[0].length):-1}function Xp(t,n,e){var r=wp.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function Vp(t,n,e){var r=xp.exec(n.slice(e));return r?(t.Q=+r[0],e+r[0].length):-1}function Gp(t,n,e){var r=xp.exec(n.slice(e));return r?(t.s=+r[0],e+r[0].length):-1}function $p(t,n){return Np(t.getDate(),n,2)}function Wp(t,n){return Np(t.getHours(),n,2)}function Zp(t,n){return Np(t.getHours()%12||12,n,2)}function Qp(t,n){return Np(1+Md.count(Id(t),t),n,3)}function Kp(t,n){return Np(t.getMilliseconds(),n,3)}function Jp(t,n){return Kp(t,n)+"000"}function tv(t,n){return Np(t.getMonth()+1,n,2)}function nv(t,n){return Np(t.getMinutes(),n,2)}function ev(t,n){return Np(t.getSeconds(),n,2)}function rv(t){var n=t.getDay();return 0===n?7:n}function iv(t,n){return Np(Ad.count(Id(t)-1,t),n,2)}function ov(t,n){var e=t.getDay();return t=e>=4||0===e?Cd(t):Cd.ceil(t),Np(Cd.count(Id(t),t)+(4===Id(t).getDay()),n,2)}function av(t){return t.getDay()}function uv(t,n){return Np(Sd.count(Id(t)-1,t),n,2)}function cv(t,n){return Np(t.getFullYear()%100,n,2)}function fv(t,n){return Np(t.getFullYear()%1e4,n,4)}function sv(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+Np(n/60|0,"0",2)+Np(n%60,"0",2)}function lv(t,n){return Np(t.getUTCDate(),n,2)}function hv(t,n){return Np(t.getUTCHours(),n,2)}function dv(t,n){return Np(t.getUTCHours()%12||12,n,2)}function pv(t,n){return Np(1+$d.count(dp(t),t),n,3)}function vv(t,n){return Np(t.getUTCMilliseconds(),n,3)}function gv(t,n){return vv(t,n)+"000"}function yv(t,n){return Np(t.getUTCMonth()+1,n,2)}function _v(t,n){return Np(t.getUTCMinutes(),n,2)}function bv(t,n){return Np(t.getUTCSeconds(),n,2)}function mv(t){var n=t.getUTCDay();return 0===n?7:n}function xv(t,n){return Np(Qd.count(dp(t)-1,t),n,2)}function wv(t,n){var e=t.getUTCDay();return t=e>=4||0===e?np(t):np.ceil(t),Np(np.count(dp(t),t)+(4===dp(t).getUTCDay()),n,2)}function Mv(t){return t.getUTCDay()}function Nv(t,n){return Np(Kd.count(dp(t)-1,t),n,2)}function Tv(t,n){return Np(t.getUTCFullYear()%100,n,2)}function Av(t,n){return Np(t.getUTCFullYear()%1e4,n,4)}function Sv(){return"+0000"}function kv(){return"%"}function Ev(t){return+t}function Cv(t){return Math.floor(+t/1e3)}function Pv(n){return bp=_p(n),t.timeFormat=bp.format,t.timeParse=bp.parse,t.utcFormat=bp.utcFormat,t.utcParse=bp.utcParse,bp}Pv({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",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"]});var zv=Date.prototype.toISOString?function(t){return t.toISOString()}:t.utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");var Rv=+new Date("2000-01-01T00:00:00.000Z")?function(t){var n=new Date(t);return isNaN(n)?null:n}:t.utcParse("%Y-%m-%dT%H:%M:%S.%LZ"),Dv=1e3,qv=60*Dv,Lv=60*qv,Uv=24*Lv,Ov=7*Uv,Bv=30*Uv,Fv=365*Uv;function Yv(t){return new Date(t)}function Iv(t){return t instanceof Date?+t:+new Date(+t)}function Hv(t,n,r,i,o,a,u,c,f){var s=Xh(Oh,Oh),l=s.invert,h=s.domain,d=f(".%L"),p=f(":%S"),v=f("%I:%M"),g=f("%I %p"),y=f("%a %d"),_=f("%b %d"),b=f("%B"),m=f("%Y"),x=[[u,1,Dv],[u,5,5*Dv],[u,15,15*Dv],[u,30,30*Dv],[a,1,qv],[a,5,5*qv],[a,15,15*qv],[a,30,30*qv],[o,1,Lv],[o,3,3*Lv],[o,6,6*Lv],[o,12,12*Lv],[i,1,Uv],[i,2,2*Uv],[r,1,Ov],[n,1,Bv],[n,3,3*Bv],[t,1,Fv]];function M(e){return(u(e)=1?Ey:t<=-1?-Ey:Math.asin(t)}function zy(t){return t.innerRadius}function Ry(t){return t.outerRadius}function Dy(t){return t.startAngle}function qy(t){return t.endAngle}function Ly(t){return t&&t.padAngle}function Uy(t,n,e,r,i,o,a){var u=t-e,c=n-r,f=(a?o:-o)/Ay(u*u+c*c),s=f*c,l=-f*u,h=t+s,d=n+l,p=e+s,v=r+l,g=(h+p)/2,y=(d+v)/2,_=p-h,b=v-d,m=_*_+b*b,x=i-o,w=h*v-p*d,M=(b<0?-1:1)*Ay(My(0,x*x*m-w*w)),N=(w*b-_*M)/m,T=(-w*_-b*M)/m,A=(w*b+_*M)/m,S=(-w*_+b*M)/m,k=N-g,E=T-y,C=A-g,P=S-y;return k*k+E*E>C*C+P*P&&(N=A,T=S),{cx:N,cy:T,x01:-s,y01:-l,x11:N*(i/x-1),y11:T*(i/x-1)}}function Oy(t){this._context=t}function By(t){return new Oy(t)}function Fy(t){return t[0]}function Yy(t){return t[1]}function Iy(){var t=Fy,n=Yy,e=by(!0),r=null,i=By,o=null;function a(a){var u,c,f,s=a.length,l=!1;for(null==r&&(o=i(f=Ji())),u=0;u<=s;++u)!(u=s;--l)u.point(g[l],y[l]);u.lineEnd(),u.areaEnd()}v&&(g[f]=+t(h,f,c),y[f]=+e(h,f,c),u.point(n?+n(h,f,c):g[f],r?+r(h,f,c):y[f]))}if(d)return u=null,d+""||null}function f(){return Iy().defined(i).curve(a).context(o)}return c.x=function(e){return arguments.length?(t="function"==typeof e?e:by(+e),n=null,c):t},c.x0=function(n){return arguments.length?(t="function"==typeof n?n:by(+n),c):t},c.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:by(+t),c):n},c.y=function(t){return arguments.length?(e="function"==typeof t?t:by(+t),r=null,c):e},c.y0=function(t){return arguments.length?(e="function"==typeof t?t:by(+t),c):e},c.y1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:by(+t),c):r},c.lineX0=c.lineY0=function(){return f().x(t).y(e)},c.lineY1=function(){return f().x(t).y(r)},c.lineX1=function(){return f().x(n).y(e)},c.defined=function(t){return arguments.length?(i="function"==typeof t?t:by(!!t),c):i},c.curve=function(t){return arguments.length?(a=t,null!=o&&(u=a(o)),c):a},c.context=function(t){return arguments.length?(null==t?o=u=null:u=a(o=t),c):o},c}function jy(t,n){return nt?1:n>=t?0:NaN}function Xy(t){return t}Oy.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._context.lineTo(t,n)}}};var Vy=$y(By);function Gy(t){this._curve=t}function $y(t){function n(n){return new Gy(t(n))}return n._curve=t,n}function Wy(t){var n=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(t){return arguments.length?n($y(t)):n()._curve},t}function Zy(){return Wy(Iy().curve(Vy))}function Qy(){var t=Hy().curve(Vy),n=t.curve,e=t.lineX0,r=t.lineX1,i=t.lineY0,o=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return Wy(e())},delete t.lineX0,t.lineEndAngle=function(){return Wy(r())},delete t.lineX1,t.lineInnerRadius=function(){return Wy(i())},delete t.lineY0,t.lineOuterRadius=function(){return Wy(o())},delete t.lineY1,t.curve=function(t){return arguments.length?n($y(t)):n()._curve},t}function Ky(t,n){return[(n=+n)*Math.cos(t-=Math.PI/2),n*Math.sin(t)]}Gy.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(t,n){this._curve.point(n*Math.sin(t),n*-Math.cos(t))}};var Jy=Array.prototype.slice;function t_(t){return t.source}function n_(t){return t.target}function e_(t){var n=t_,e=n_,r=Fy,i=Yy,o=null;function a(){var a,u=Jy.call(arguments),c=n.apply(this,u),f=e.apply(this,u);if(o||(o=a=Ji()),t(o,+r.apply(this,(u[0]=c,u)),+i.apply(this,u),+r.apply(this,(u[0]=f,u)),+i.apply(this,u)),a)return o=null,a+""||null}return a.source=function(t){return arguments.length?(n=t,a):n},a.target=function(t){return arguments.length?(e=t,a):e},a.x=function(t){return arguments.length?(r="function"==typeof t?t:by(+t),a):r},a.y=function(t){return arguments.length?(i="function"==typeof t?t:by(+t),a):i},a.context=function(t){return arguments.length?(o=null==t?null:t,a):o},a}function r_(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n=(n+r)/2,e,n,i,r,i)}function i_(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n,e=(e+i)/2,r,e,r,i)}function o_(t,n,e,r,i){var o=Ky(n,e),a=Ky(n,e=(e+i)/2),u=Ky(r,e),c=Ky(r,i);t.moveTo(o[0],o[1]),t.bezierCurveTo(a[0],a[1],u[0],u[1],c[0],c[1])}var a_={draw:function(t,n){var e=Math.sqrt(n/ky);t.moveTo(e,0),t.arc(0,0,e,0,Cy)}},u_={draw:function(t,n){var e=Math.sqrt(n/5)/2;t.moveTo(-3*e,-e),t.lineTo(-e,-e),t.lineTo(-e,-3*e),t.lineTo(e,-3*e),t.lineTo(e,-e),t.lineTo(3*e,-e),t.lineTo(3*e,e),t.lineTo(e,e),t.lineTo(e,3*e),t.lineTo(-e,3*e),t.lineTo(-e,e),t.lineTo(-3*e,e),t.closePath()}},c_=Math.sqrt(1/3),f_=2*c_,s_={draw:function(t,n){var e=Math.sqrt(n/f_),r=e*c_;t.moveTo(0,-e),t.lineTo(r,0),t.lineTo(0,e),t.lineTo(-r,0),t.closePath()}},l_=Math.sin(ky/10)/Math.sin(7*ky/10),h_=Math.sin(Cy/10)*l_,d_=-Math.cos(Cy/10)*l_,p_={draw:function(t,n){var e=Math.sqrt(.8908130915292852*n),r=h_*e,i=d_*e;t.moveTo(0,-e),t.lineTo(r,i);for(var o=1;o<5;++o){var a=Cy*o/5,u=Math.cos(a),c=Math.sin(a);t.lineTo(c*e,-u*e),t.lineTo(u*r-c*i,c*r+u*i)}t.closePath()}},v_={draw:function(t,n){var e=Math.sqrt(n),r=-e/2;t.rect(r,r,e,e)}},g_=Math.sqrt(3),y_={draw:function(t,n){var e=-Math.sqrt(n/(3*g_));t.moveTo(0,2*e),t.lineTo(-g_*e,-e),t.lineTo(g_*e,-e),t.closePath()}},__=Math.sqrt(3)/2,b_=1/Math.sqrt(12),m_=3*(b_/2+1),x_={draw:function(t,n){var e=Math.sqrt(n/m_),r=e/2,i=e*b_,o=r,a=e*b_+e,u=-o,c=a;t.moveTo(r,i),t.lineTo(o,a),t.lineTo(u,c),t.lineTo(-.5*r-__*i,__*r+-.5*i),t.lineTo(-.5*o-__*a,__*o+-.5*a),t.lineTo(-.5*u-__*c,__*u+-.5*c),t.lineTo(-.5*r+__*i,-.5*i-__*r),t.lineTo(-.5*o+__*a,-.5*a-__*o),t.lineTo(-.5*u+__*c,-.5*c-__*u),t.closePath()}},w_=[a_,u_,s_,v_,p_,y_,x_];function M_(){}function N_(t,n,e){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+n)/6,(t._y0+4*t._y1+e)/6)}function T_(t){this._context=t}function A_(t){this._context=t}function S_(t){this._context=t}function k_(t,n){this._basis=new T_(t),this._beta=n}T_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:N_(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:N_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},A_.prototype={areaStart:M_,areaEnd:M_,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x2=t,this._y2=n;break;case 1:this._point=2,this._x3=t,this._y3=n;break;case 2:this._point=3,this._x4=t,this._y4=n,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+n)/6);break;default:N_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},S_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var e=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+n)/6;this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break;case 3:this._point=4;default:N_(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},k_.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,n=this._y,e=t.length-1;if(e>0)for(var r,i=t[0],o=n[0],a=t[e]-i,u=n[e]-o,c=-1;++c<=e;)r=c/e,this._basis.point(this._beta*t[c]+(1-this._beta)*(i+r*a),this._beta*n[c]+(1-this._beta)*(o+r*u));this._x=this._y=null,this._basis.lineEnd()},point:function(t,n){this._x.push(+t),this._y.push(+n)}};var E_=function t(n){function e(t){return 1===n?new T_(t):new k_(t,n)}return e.beta=function(n){return t(+n)},e}(.85);function C_(t,n,e){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-n),t._y2+t._k*(t._y1-e),t._x2,t._y2)}function P_(t,n){this._context=t,this._k=(1-n)/6}P_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:C_(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2,this._x1=t,this._y1=n;break;case 2:this._point=3;default:C_(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var z_=function t(n){function e(t){return new P_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function R_(t,n){this._context=t,this._k=(1-n)/6}R_.prototype={areaStart:M_,areaEnd:M_,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:C_(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var D_=function t(n){function e(t){return new R_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function q_(t,n){this._context=t,this._k=(1-n)/6}q_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:C_(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var L_=function t(n){function e(t){return new q_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function U_(t,n,e){var r=t._x1,i=t._y1,o=t._x2,a=t._y2;if(t._l01_a>Sy){var u=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,c=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*u-t._x0*t._l12_2a+t._x2*t._l01_2a)/c,i=(i*u-t._y0*t._l12_2a+t._y2*t._l01_2a)/c}if(t._l23_a>Sy){var f=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,s=3*t._l23_a*(t._l23_a+t._l12_a);o=(o*f+t._x1*t._l23_2a-n*t._l12_2a)/s,a=(a*f+t._y1*t._l23_2a-e*t._l12_2a)/s}t._context.bezierCurveTo(r,i,o,a,t._x2,t._y2)}function O_(t,n){this._context=t,this._alpha=n}O_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3;default:U_(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var B_=function t(n){function e(t){return n?new O_(t,n):new P_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function F_(t,n){this._context=t,this._alpha=n}F_.prototype={areaStart:M_,areaEnd:M_,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:U_(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Y_=function t(n){function e(t){return n?new F_(t,n):new R_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function I_(t,n){this._context=t,this._alpha=n}I_.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:U_(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var H_=function t(n){function e(t){return n?new I_(t,n):new q_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function j_(t){this._context=t}function X_(t){return t<0?-1:1}function V_(t,n,e){var r=t._x1-t._x0,i=n-t._x1,o=(t._y1-t._y0)/(r||i<0&&-0),a=(e-t._y1)/(i||r<0&&-0),u=(o*i+a*r)/(r+i);return(X_(o)+X_(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(u))||0}function G_(t,n){var e=t._x1-t._x0;return e?(3*(t._y1-t._y0)/e-n)/2:n}function $_(t,n,e){var r=t._x0,i=t._y0,o=t._x1,a=t._y1,u=(o-r)/3;t._context.bezierCurveTo(r+u,i+u*n,o-u,a-u*e,o,a)}function W_(t){this._context=t}function Z_(t){this._context=new Q_(t)}function Q_(t){this._context=t}function K_(t){this._context=t}function J_(t){var n,e,r=t.length-1,i=new Array(r),o=new Array(r),a=new Array(r);for(i[0]=0,o[0]=2,a[0]=t[0]+2*t[1],n=1;n=0;--n)i[n]=(a[n]-i[n+1])/o[n];for(o[r-1]=(t[r]+i[r-1])/2,n=0;n1)for(var e,r,i,o=1,a=t[n[0]],u=a.length;o=0;)e[n]=n;return e}function rb(t,n){return t[n]}function ib(t){var n=t.map(ob);return eb(t).sort(function(t,e){return n[t]-n[e]})}function ob(t){for(var n,e=-1,r=0,i=t.length,o=-1/0;++eo&&(o=n,r=e);return r}function ab(t){var n=t.map(ub);return eb(t).sort(function(t,e){return n[t]-n[e]})}function ub(t){for(var n,e=0,r=-1,i=t.length;++r0)){if(o/=h,h<0){if(o0){if(o>l)return;o>s&&(s=o)}if(o=r-c,h||!(o<0)){if(o/=h,h<0){if(o>l)return;o>s&&(s=o)}else if(h>0){if(o0)){if(o/=d,d<0){if(o0){if(o>l)return;o>s&&(s=o)}if(o=i-f,d||!(o<0)){if(o/=d,d<0){if(o>l)return;o>s&&(s=o)}else if(d>0){if(o0||l<1)||(s>0&&(t[0]=[c+s*h,f+s*d]),l<1&&(t[1]=[c+l*h,f+l*d]),!0)}}}}}function mb(t,n,e,r,i){var o=t[1];if(o)return!0;var a,u,c=t[0],f=t.left,s=t.right,l=f[0],h=f[1],d=s[0],p=s[1],v=(l+d)/2,g=(h+p)/2;if(p===h){if(v=r)return;if(l>d){if(c){if(c[1]>=i)return}else c=[v,e];o=[v,i]}else{if(c){if(c[1]1)if(l>d){if(c){if(c[1]>=i)return}else c=[(e-u)/a,e];o=[(i-u)/a,i]}else{if(c){if(c[1]=r)return}else c=[n,a*n+u];o=[r,a*r+u]}else{if(c){if(c[0]=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,n),this._context.lineTo(t,n);else{var e=this._x*(1-this._t)+t*this._t;this._context.lineTo(e,this._y),this._context.lineTo(e,n)}}this._x=t,this._y=n}},lb.prototype={constructor:lb,insert:function(t,n){var e,r,i;if(t){if(n.P=t,n.N=t.N,t.N&&(t.N.P=n),t.N=n,t.R){for(t=t.R;t.L;)t=t.L;t.L=n}else t.R=n;e=t}else this._?(t=vb(this._),n.P=null,n.N=t,t.P=t.L=n,e=t):(n.P=n.N=null,this._=n,e=null);for(n.L=n.R=null,n.U=e,n.C=!0,t=n;e&&e.C;)e===(r=e.U).L?(i=r.R)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.R&&(db(this,e),e=(t=e).U),e.C=!1,r.C=!0,pb(this,r)):(i=r.L)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.L&&(pb(this,e),e=(t=e).U),e.C=!1,r.C=!0,db(this,r)),e=t.U;this._.C=!1},remove:function(t){t.N&&(t.N.P=t.P),t.P&&(t.P.N=t.N),t.N=t.P=null;var n,e,r,i=t.U,o=t.L,a=t.R;if(e=o?a?vb(a):o:a,i?i.L===t?i.L=e:i.R=e:this._=e,o&&a?(r=e.C,e.C=t.C,e.L=o,o.U=e,e!==a?(i=e.U,e.U=t.U,t=e.R,i.L=t,e.R=a,a.U=e):(e.U=i,i=e,t=e.R)):(r=t.C,t=e),t&&(t.U=i),!r)if(t&&t.C)t.C=!1;else{do{if(t===this._)break;if(t===i.L){if((n=i.R).C&&(n.C=!1,i.C=!0,db(this,i),n=i.R),n.L&&n.L.C||n.R&&n.R.C){n.R&&n.R.C||(n.L.C=!1,n.C=!0,pb(this,n),n=i.R),n.C=i.C,i.C=n.R.C=!1,db(this,i),t=this._;break}}else if((n=i.L).C&&(n.C=!1,i.C=!0,pb(this,i),n=i.L),n.L&&n.L.C||n.R&&n.R.C){n.L&&n.L.C||(n.R.C=!1,n.C=!0,db(this,n),n=i.L),n.C=i.C,i.C=n.L.C=!1,pb(this,i),t=this._;break}n.C=!0,t=i,i=i.U}while(!t.C);t&&(t.C=!1)}}};var Nb,Tb=[];function Ab(){hb(this),this.x=this.y=this.arc=this.site=this.cy=null}function Sb(t){var n=t.P,e=t.N;if(n&&e){var r=n.site,i=t.site,o=e.site;if(r!==o){var a=i[0],u=i[1],c=r[0]-a,f=r[1]-u,s=o[0]-a,l=o[1]-u,h=2*(c*l-f*s);if(!(h>=-Ib)){var d=c*c+f*f,p=s*s+l*l,v=(l*d-f*p)/h,g=(c*p-s*d)/h,y=Tb.pop()||new Ab;y.arc=t,y.site=i,y.x=v+a,y.y=(y.cy=g+u)+Math.sqrt(v*v+g*g),t.circle=y;for(var _=null,b=Bb._;b;)if(y.yYb)u=u.L;else{if(!((i=o-Lb(u,a))>Yb)){r>-Yb?(n=u.P,e=u):i>-Yb?(n=u,e=u.N):n=e=u;break}if(!u.R){n=u;break}u=u.R}!function(t){Ob[t.index]={site:t,halfedges:[]}}(t);var c=Pb(t);if(Ub.insert(n,c),n||e){if(n===e)return kb(n),e=Pb(n.site),Ub.insert(c,e),c.edge=e.edge=gb(n.site,c.site),Sb(n),void Sb(e);if(e){kb(n),kb(e);var f=n.site,s=f[0],l=f[1],h=t[0]-s,d=t[1]-l,p=e.site,v=p[0]-s,g=p[1]-l,y=2*(h*g-d*v),_=h*h+d*d,b=v*v+g*g,m=[(g*_-d*b)/y+s,(h*b-v*_)/y+l];_b(e.edge,f,p,m),c.edge=gb(f,t,null,m),e.edge=gb(t,p,null,m),Sb(n),Sb(e)}else c.edge=gb(n.site,c.site)}}function qb(t,n){var e=t.site,r=e[0],i=e[1],o=i-n;if(!o)return r;var a=t.P;if(!a)return-1/0;var u=(e=a.site)[0],c=e[1],f=c-n;if(!f)return u;var s=u-r,l=1/o-1/f,h=s/f;return l?(-h+Math.sqrt(h*h-2*l*(s*s/(-2*f)-c+f/2+i-o/2)))/l+r:(r+u)/2}function Lb(t,n){var e=t.N;if(e)return qb(e,n);var r=t.site;return r[1]===n?r[0]:1/0}var Ub,Ob,Bb,Fb,Yb=1e-6,Ib=1e-12;function Hb(t,n,e){return(t[0]-e[0])*(n[1]-t[1])-(t[0]-n[0])*(e[1]-t[1])}function jb(t,n){return n[1]-t[1]||n[0]-t[0]}function Xb(t,n){var e,r,i,o=t.sort(jb).pop();for(Fb=[],Ob=new Array(t.length),Ub=new lb,Bb=new lb;;)if(i=Nb,o&&(!i||o[1]Yb||Math.abs(i[0][1]-i[1][1])>Yb)||delete Fb[o]}(a,u,c,f),function(t,n,e,r){var i,o,a,u,c,f,s,l,h,d,p,v,g=Ob.length,y=!0;for(i=0;iYb||Math.abs(v-h)>Yb)&&(c.splice(u,0,Fb.push(yb(a,d,Math.abs(p-t)Yb?[t,Math.abs(l-t)Yb?[Math.abs(h-r)Yb?[e,Math.abs(l-e)Yb?[Math.abs(h-n)=u)return null;var c=t-i.site[0],f=n-i.site[1],s=c*c+f*f;do{i=o.cells[r=a],a=null,i.halfedges.forEach(function(e){var r=o.edges[e],u=r.left;if(u!==i.site&&u||(u=r.right)){var c=t-u[0],f=n-u[1],l=c*c+f*f;lr?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}Zb.prototype=$b.prototype,t.FormatSpecifier=Ua,t.active=function(t,n){var e,r,i=t.__transition;if(i)for(r in n=null==n?null:n+"",i)if((e=i[r]).state>br&&e.name===n)return new qr([[t]],vi,n,+r);return null},t.arc=function(){var t=zy,n=Ry,e=by(0),r=null,i=Dy,o=qy,a=Ly,u=null;function c(){var c,f,s=+t.apply(this,arguments),l=+n.apply(this,arguments),h=i.apply(this,arguments)-Ey,d=o.apply(this,arguments)-Ey,p=my(d-h),v=d>h;if(u||(u=c=Ji()),lSy)if(p>Cy-Sy)u.moveTo(l*wy(h),l*Ty(h)),u.arc(0,0,l,h,d,!v),s>Sy&&(u.moveTo(s*wy(d),s*Ty(d)),u.arc(0,0,s,d,h,v));else{var g,y,_=h,b=d,m=h,x=d,w=p,M=p,N=a.apply(this,arguments)/2,T=N>Sy&&(r?+r.apply(this,arguments):Ay(s*s+l*l)),A=Ny(my(l-s)/2,+e.apply(this,arguments)),S=A,k=A;if(T>Sy){var E=Py(T/s*Ty(N)),C=Py(T/l*Ty(N));(w-=2*E)>Sy?(m+=E*=v?1:-1,x-=E):(w=0,m=x=(h+d)/2),(M-=2*C)>Sy?(_+=C*=v?1:-1,b-=C):(M=0,_=b=(h+d)/2)}var P=l*wy(_),z=l*Ty(_),R=s*wy(x),D=s*Ty(x);if(A>Sy){var q,L=l*wy(b),U=l*Ty(b),O=s*wy(m),B=s*Ty(m);if(p1?0:t<-1?ky:Math.acos(t)}((F*I+Y*H)/(Ay(F*F+Y*Y)*Ay(I*I+H*H)))/2),X=Ay(q[0]*q[0]+q[1]*q[1]);S=Ny(A,(s-X)/(j-1)),k=Ny(A,(l-X)/(j+1))}}M>Sy?k>Sy?(g=Uy(O,B,P,z,l,k,v),y=Uy(L,U,R,D,l,k,v),u.moveTo(g.cx+g.x01,g.cy+g.y01),kSy&&w>Sy?S>Sy?(g=Uy(R,D,L,U,s,-S,v),y=Uy(P,z,O,B,s,-S,v),u.lineTo(g.cx+g.x01,g.cy+g.y01),S>a,f=i+2*u>>a,s=yo(20);function l(r){var i=new Float32Array(c*f),l=new Float32Array(c*f);r.forEach(function(r,o,s){var l=+t(r,o,s)+u>>a,h=+n(r,o,s)+u>>a,d=+e(r,o,s);l>=0&&l=0&&h>a),To({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),No({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),To({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),No({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),To({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a);var d=s(i);if(!Array.isArray(d)){var p=T(i);d=w(0,p,d),(d=g(0,Math.floor(p/d)*d,d)).shift()}return Mo().thresholds(d).size([c,f])(i).map(h)}function h(t){return t.value*=Math.pow(2,-2*a),t.coordinates.forEach(d),t}function d(t){t.forEach(p)}function p(t){t.forEach(v)}function v(t){t[0]=t[0]*Math.pow(2,a)-u,t[1]=t[1]*Math.pow(2,a)-u}function y(){return c=r+2*(u=3*o)>>a,f=i+2*u>>a,l}return l.x=function(n){return arguments.length?(t="function"==typeof n?n:yo(+n),l):t},l.y=function(t){return arguments.length?(n="function"==typeof t?t:yo(+t),l):n},l.weight=function(t){return arguments.length?(e="function"==typeof t?t:yo(+t),l):e},l.size=function(t){if(!arguments.length)return[r,i];var n=Math.ceil(t[0]),e=Math.ceil(t[1]);if(!(n>=0||n>=0))throw new Error("invalid size");return r=n,i=e,y()},l.cellSize=function(t){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return a=Math.floor(Math.log(t)/Math.LN2),y()},l.thresholds=function(t){return arguments.length?(s="function"==typeof t?t:Array.isArray(t)?yo(vo.call(t)):yo(t),l):s},l.bandwidth=function(t){if(!arguments.length)return Math.sqrt(o*(o+1));if(!((t=+t)>=0))throw new Error("invalid bandwidth");return o=Math.round((Math.sqrt(4*t*t+1)-1)/2),y()},l},t.contours=Mo,t.create=function(t){return Rt(Z(t).call(document.documentElement))},t.creator=Z,t.cross=function(t,n,e){var r,i,o,u,c=t.length,f=n.length,s=new Array(c*f);for(null==e&&(e=a),r=o=0;rt?1:n>=t?0:NaN},t.deviation=f,t.dispatch=I,t.drag=function(){var n,e,r,i,o=Gt,a=$t,u=Wt,c=Zt,f={},s=I("start","drag","end"),l=0,h=0;function d(t){t.on("mousedown.drag",p).filter(c).on("touchstart.drag",y).on("touchmove.drag",_).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(){if(!i&&o.apply(this,arguments)){var u=m("mouse",a.apply(this,arguments),Bt,this,arguments);u&&(Rt(t.event.view).on("mousemove.drag",v,!0).on("mouseup.drag",g,!0),Ht(t.event.view),Yt(),r=!1,n=t.event.clientX,e=t.event.clientY,u("start"))}}function v(){if(It(),!r){var i=t.event.clientX-n,o=t.event.clientY-e;r=i*i+o*o>h}f.mouse("drag")}function g(){Rt(t.event.view).on("mousemove.drag mouseup.drag",null),jt(t.event.view,r),It(),f.mouse("end")}function y(){if(o.apply(this,arguments)){var n,e,r=t.event.changedTouches,i=a.apply(this,arguments),u=r.length;for(n=0;nc+d||if+d||ou.index){var p=c-a.x-a.vx,v=f-a.y-a.vy,g=p*p+v*v;gt.r&&(t.r=t[n].r)}function u(){if(n){var r,i,o=n.length;for(e=new Array(o),r=0;r=a)){(t.data!==n||t.next)&&(0===s&&(d+=(s=va())*s),0===l&&(d+=(l=va())*l),d1?(null==e?u.remove(t):u.set(t,d(e)),n):u.get(t)},find:function(n,e,r){var i,o,a,u,c,f=0,s=t.length;for(null==r?r=1/0:r*=r,f=0;f1?(f.on(t,e),n):f.on(t)}}},t.forceX=function(t){var n,e,r,i=pa(.1);function o(t){for(var i,o=0,a=n.length;o=.12&&i<.234&&r>=-.425&&r<-.214?u:i>=.166&&i<.234&&r>=-.214&&r<-.115?c:a).invert(t)},s.stream=function(e){return t&&n===e?t:(r=[a.stream(n=e),u.stream(e),c.stream(e)],i=r.length,t={point:function(t,n){for(var e=-1;++eEc(r[0],r[1])&&(r[1]=i[1]),Ec(i[0],r[1])>Ec(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(a=-1/0,n=0,r=o[e=o.length-1];n<=e;r=i,++n)i=o[n],(u=Ec(r[1],i[0]))>a&&(a=u,$u=i[0],Zu=r[1])}return ec=rc=null,$u===1/0||Wu===1/0?[[NaN,NaN],[NaN,NaN]]:[[$u,Wu],[Zu,Qu]]},t.geoCentroid=function(t){ic=oc=ac=uc=cc=fc=sc=lc=hc=dc=pc=0,ku(t,zc);var n=hc,e=dc,r=pc,i=n*n+e*e+r*r;return i2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90]).scale(159.155)},t.geoTransverseMercatorRaw=wl,t.gray=function(t,n){return new Bn(t,0,0,null==n?1:n)},t.hcl=Xn,t.hierarchy=Sl,t.histogram=function(){var t=v,n=s,e=M;function r(r){var o,a,u=r.length,c=new Array(u);for(o=0;ol;)h.pop(),--d;var p,v=new Array(d+1);for(o=0;o<=d;++o)(p=v[o]=[]).x0=o>0?h[o-1]:s,p.x1=o1)&&(t-=Math.floor(t));var n=Math.abs(t-.5);return sy.h=360*t-100,sy.s=1.5-1.5*n,sy.l=.8-.9*n,sy+""},t.interpolateRdBu=gg,t.interpolateRdGy=_g,t.interpolateRdPu=Fg,t.interpolateRdYlBu=mg,t.interpolateRdYlGn=wg,t.interpolateReds=iy,t.interpolateRgb=he,t.interpolateRgbBasis=pe,t.interpolateRgbBasisClosed=ve,t.interpolateRound=Ne,t.interpolateSinebow=function(t){var n;return t=(.5-t)*Math.PI,ly.r=255*(n=Math.sin(t))*n,ly.g=255*(n=Math.sin(t+hy))*n,ly.b=255*(n=Math.sin(t+dy))*n,ly+""},t.interpolateSpectral=Ng,t.interpolateString=we,t.interpolateTransformCss=Re,t.interpolateTransformSvg=De,t.interpolateTurbo=function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))))+")"},t.interpolateViridis=vy,t.interpolateWarm=cy,t.interpolateYlGn=jg,t.interpolateYlGnBu=Ig,t.interpolateYlOrBr=Vg,t.interpolateYlOrRd=$g,t.interpolateZoom=Fe,t.interrupt=Er,t.interval=function(t,n,e){var r=new fr,i=n;return null==n?(r.restart(t,n,e),r):(n=+n,e=null==e?ur():+e,r.restart(function o(a){a+=i,r.restart(o,i+=n,e),t(a)},n,e),r)},t.isoFormat=zv,t.isoParse=Rv,t.json=function(t,n){return fetch(t,n).then(fa)},t.keys=function(t){var n=[];for(var e in t)n.push(e);return n},t.lab=On,t.lch=function(t,n,e,r){return 1===arguments.length?jn(t):new Vn(e,n,t,null==r?1:r)},t.line=Iy,t.lineRadial=Zy,t.linkHorizontal=function(){return e_(r_)},t.linkRadial=function(){var t=e_(o_);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t},t.linkVertical=function(){return e_(i_)},t.local=qt,t.map=ao,t.matcher=nt,t.max=T,t.mean=function(t,n){var e,r=t.length,i=r,o=-1,a=0;if(null==n)for(;++o=r.length)return null!=t&&e.sort(t),null!=n?n(e):e;for(var c,f,s,l=-1,h=e.length,d=r[i++],p=ao(),v=a();++lr.length)return e;var a,u=i[o-1];return null!=n&&o>=r.length?a=e.entries():(a=[],e.each(function(n,e){a.push({key:e,values:t(n,o)})})),null!=u?a.sort(function(t,n){return u(t.key,n.key)}):a}(o(t,0,fo,so),0)},key:function(t){return r.push(t),e},sortKeys:function(t){return i[r.length-1]=t,e},sortValues:function(n){return t=n,e},rollup:function(t){return n=t,e}}},t.now=ur,t.pack=function(){var t=null,n=1,e=1,r=$l;function i(i){return i.x=n/2,i.y=e/2,t?i.eachBefore(Ql(t)).eachAfter(Kl(r,.5)).eachBefore(Jl(1)):i.eachBefore(Ql(Zl)).eachAfter(Kl($l,1)).eachAfter(Kl(r,i.r/Math.min(n,e))).eachBefore(Jl(Math.min(n,e)/(2*i.r))),i}return i.radius=function(n){return arguments.length?(t=Vl(n),i):t},i.size=function(t){return arguments.length?(n=+t[0],e=+t[1],i):[n,e]},i.padding=function(t){return arguments.length?(r="function"==typeof t?t:Wl(+t),i):r},i},t.packEnclose=Rl,t.packSiblings=function(t){return Xl(t),t},t.pairs=function(t,n){null==n&&(n=a);for(var e=0,r=t.length-1,i=t[0],o=new Array(r<0?0:r);e0&&(d+=l);for(null!=n?p.sort(function(t,e){return n(v[t],v[e])}):null!=e&&p.sort(function(t,n){return e(a[t],a[n])}),u=0,f=d?(y-h*b)/d:0;u0?l*f:0)+b,v[c]={data:a[c],index:u,value:l,startAngle:g,endAngle:s,padAngle:_};return v}return a.value=function(n){return arguments.length?(t="function"==typeof n?n:by(+n),a):t},a.sortValues=function(t){return arguments.length?(n=t,e=null,a):n},a.sort=function(t){return arguments.length?(e=t,n=null,a):e},a.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:by(+t),a):r},a.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:by(+t),a):i},a.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:by(+t),a):o},a},t.piecewise=function(t,n){for(var e=0,r=n.length-1,i=n[0],o=new Array(r<0?0:r);eu!=f>u&&a<(c-e)*(u-r)/(f-r)+e&&(s=!s),c=e,f=r;return s},t.polygonHull=function(t){if((e=t.length)<3)return null;var n,e,r=new Array(e),i=new Array(e);for(n=0;n=0;--n)f.push(t[r[o[n]][2]]);for(n=+u;n0?a[n-1]:r[0],n=o?[a[o-1],r]:[a[n-1],a[n]]},c.unknown=function(t){return arguments.length?(n=t,c):c},c.thresholds=function(){return a.slice()},c.copy=function(){return t().domain([e,r]).range(u).unknown(n)},kh.apply(Gh(c),arguments)},t.scaleSequential=function t(){var n=Gh(jv()(Oh));return n.copy=function(){return Xv(n,t())},Eh.apply(n,arguments)},t.scaleSequentialLog=function t(){var n=nd(jv()).domain([1,10]);return n.copy=function(){return Xv(n,t()).base(n.base())},Eh.apply(n,arguments)},t.scaleSequentialPow=Vv,t.scaleSequentialQuantile=function t(){var e=[],r=Oh;function o(t){if(!isNaN(t=+t))return r((i(e,t)-1)/(e.length-1))}return o.domain=function(t){if(!arguments.length)return e.slice();e=[];for(var r,i=0,a=t.length;i0)for(var e,r,i,o,a,u,c=0,f=t[n[0]].length;c0?(r[0]=o,r[1]=o+=i):i<0?(r[1]=a,r[0]=a+=i):(r[0]=0,r[1]=i)},t.stackOffsetExpand=function(t,n){if((r=t.length)>0){for(var e,r,i,o=0,a=t[0].length;o0){for(var e,r=0,i=t[n[0]],o=i.length;r0&&(r=(e=t[n[0]]).length)>0){for(var e,r,i,o=0,a=1;a0)throw new Error("cycle");return o}return e.id=function(n){return arguments.length?(t=Gl(n),e):t},e.parentId=function(t){return arguments.length?(n=Gl(t),e):n},e},t.style=ft,t.sum=function(t,n){var e,r=t.length,i=-1,o=0;if(null==n)for(;++i=0;--i)u.push(e=n.children[i]=new hh(r[i],i)),e.parent=n;return(a.parent=new hh(null,0)).children=[a],a}(i);if(c.eachAfter(o),c.parent.m=-c.z,c.eachBefore(a),r)i.eachBefore(u);else{var f=i,s=i,l=i;i.eachBefore(function(t){t.xs.x&&(s=t),t.depth>l.depth&&(l=t)});var h=f===s?1:t(f,s)/2,d=h-f.x,p=n/(s.x+h+d),v=e/(l.depth||1);i.eachBefore(function(t){t.x=(t.x+d)*p,t.y=t.depth*v})}return i}function o(n){var e=n.children,r=n.parent.children,i=n.i?r[n.i-1]:null;if(e){!function(t){for(var n,e=0,r=0,i=t.children,o=i.length;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(n);var o=(e[0].z+e[e.length-1].z)/2;i?(n.z=i.z+t(n._,i._),n.m=n.z-o):n.z=o}else i&&(n.z=i.z+t(n._,i._));n.parent.A=function(n,e,r){if(e){for(var i,o=n,a=n,u=e,c=o.parent.children[0],f=o.m,s=a.m,l=u.m,h=c.m;u=fh(u),o=ch(o),u&&o;)c=ch(c),(a=fh(a)).a=n,(i=u.z+l-o.z-f+t(u._,o._))>0&&(sh(lh(u,n,r),n,i),f+=i,s+=i),l+=u.m,f+=o.m,h+=c.m,s+=a.m;u&&!fh(a)&&(a.t=u,a.m+=l-s),o&&!ch(c)&&(c.t=o,c.m+=f-h,r=n)}return r}(n,i,n.parent.A||r[0])}function a(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function u(t){t.x*=n,t.y=t.depth*e}return i.separation=function(n){return arguments.length?(t=n,i):t},i.size=function(t){return arguments.length?(r=!1,n=+t[0],e=+t[1],i):r?null:[n,e]},i.nodeSize=function(t){return arguments.length?(r=!0,n=+t[0],e=+t[1],i):r?[n,e]:null},i},t.treemap=function(){var t=gh,n=!1,e=1,r=1,i=[0],o=$l,a=$l,u=$l,c=$l,f=$l;function s(t){return t.x0=t.y0=0,t.x1=e,t.y1=r,t.eachBefore(l),i=[0],n&&t.eachBefore(th),t}function l(n){var e=i[n.depth],r=n.x0+e,s=n.y0+e,l=n.x1-e,h=n.y1-e;l=e-1){var s=u[n];return s.x0=i,s.y0=o,s.x1=a,void(s.y1=c)}for(var l=f[n],h=r/2+l,d=n+1,p=e-1;d>>1;f[v]c-o){var _=(i*y+a*g)/r;t(n,d,g,i,o,_,c),t(d,e,y,_,o,a,c)}else{var b=(o*y+c*g)/r;t(n,d,g,i,o,a,b),t(d,e,y,i,b,a,c)}}(0,c,t.value,n,e,r,i)},t.treemapDice=nh,t.treemapResquarify=yh,t.treemapSlice=dh,t.treemapSliceDice=function(t,n,e,r,i){(1&t.depth?dh:nh)(t,n,e,r,i)},t.treemapSquarify=gh,t.tsv=ca,t.tsvFormat=Zo,t.tsvFormatBody=Qo,t.tsvFormatRow=Jo,t.tsvFormatRows=Ko,t.tsvFormatValue=ta,t.tsvParse=$o,t.tsvParseRows=Wo,t.utcDay=$d,t.utcDays=Wd,t.utcFriday=ep,t.utcFridays=fp,t.utcHour=Vd,t.utcHours=Gd,t.utcMillisecond=dd,t.utcMilliseconds=pd,t.utcMinute=jd,t.utcMinutes=Xd,t.utcMonday=Kd,t.utcMondays=op,t.utcMonth=lp,t.utcMonths=hp,t.utcSaturday=rp,t.utcSaturdays=sp,t.utcSecond=yd,t.utcSeconds=_d,t.utcSunday=Qd,t.utcSundays=ip,t.utcThursday=np,t.utcThursdays=cp,t.utcTuesday=Jd,t.utcTuesdays=ap,t.utcWednesday=tp,t.utcWednesdays=up,t.utcWeek=Qd,t.utcWeeks=ip,t.utcYear=dp,t.utcYears=pp,t.values=function(t){var n=[];for(var e in t)n.push(t[e]);return n},t.variance=c,t.version="5.14.2",t.voronoi=function(){var t=fb,n=sb,e=null;function r(r){return new Xb(r.map(function(e,i){var o=[Math.round(t(e,i,r)/Yb)*Yb,Math.round(n(e,i,r)/Yb)*Yb];return o.index=i,o.data=e,o}),e)}return r.polygons=function(t){return r(t).polygons()},r.links=function(t){return r(t).links()},r.triangles=function(t){return r(t).triangles()},r.x=function(n){return arguments.length?(t="function"==typeof n?n:cb(+n),r):t},r.y=function(t){return arguments.length?(n="function"==typeof t?t:cb(+t),r):n},r.extent=function(t){return arguments.length?(e=null==t?null:[[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]],r):e&&[[e[0][0],e[0][1]],[e[1][0],e[1][1]]]},r.size=function(t){return arguments.length?(e=null==t?null:[[0,0],[+t[0],+t[1]]],r):e&&[e[1][0]-e[0][0],e[1][1]-e[0][1]]},r},t.window=ct,t.xml=la,t.zip=function(){return k(arguments)},t.zoom=function(){var n,e,r=Jb,i=tm,o=im,a=em,u=rm,c=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],s=250,l=Fe,h=I("start","zoom","end"),d=500,p=150,v=0;function g(t){t.property("__zoom",nm).on("wheel.zoom",M).on("mousedown.zoom",N).on("dblclick.zoom",T).filter(u).on("touchstart.zoom",A).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(t,n){return(n=Math.max(c[0],Math.min(c[1],n)))===t.k?t:new $b(n,t.x,t.y)}function _(t,n,e){var r=n[0]-e[0]*t.k,i=n[1]-e[1]*t.k;return r===t.x&&i===t.y?t:new $b(t.k,r,i)}function b(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function m(t,n,e){t.on("start.zoom",function(){x(this,arguments).start()}).on("interrupt.zoom end.zoom",function(){x(this,arguments).end()}).tween("zoom",function(){var t=this,r=arguments,o=x(t,r),a=i.apply(t,r),u=null==e?b(a):"function"==typeof e?e.apply(t,r):e,c=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),f=t.__zoom,s="function"==typeof n?n.apply(t,r):n,h=l(f.invert(u).concat(c/f.k),s.invert(u).concat(c/s.k));return function(t){if(1===t)t=s;else{var n=h(t),e=c/n[2];t=new $b(e,u[0]-n[0]*e,u[1]-n[1]*e)}o.zoom(null,t)}})}function x(t,n,e){return!e&&t.__zooming||new w(t,n)}function w(t,n){this.that=t,this.args=n,this.active=0,this.extent=i.apply(t,n),this.taps=0}function M(){if(r.apply(this,arguments)){var t=x(this,arguments),n=this.__zoom,e=Math.max(c[0],Math.min(c[1],n.k*Math.pow(2,a.apply(this,arguments)))),i=Bt(this);if(t.wheel)t.mouse[0][0]===i[0]&&t.mouse[0][1]===i[1]||(t.mouse[1]=n.invert(t.mouse[0]=i)),clearTimeout(t.wheel);else{if(n.k===e)return;t.mouse=[i,n.invert(i)],Er(this),t.start()}Kb(),t.wheel=setTimeout(function(){t.wheel=null,t.end()},p),t.zoom("mouse",o(_(y(n,e),t.mouse[0],t.mouse[1]),t.extent,f))}}function N(){if(!e&&r.apply(this,arguments)){var n=x(this,arguments,!0),i=Rt(t.event.view).on("mousemove.zoom",function(){if(Kb(),!n.moved){var e=t.event.clientX-u,r=t.event.clientY-c;n.moved=e*e+r*r>v}n.zoom("mouse",o(_(n.that.__zoom,n.mouse[0]=Bt(n.that),n.mouse[1]),n.extent,f))},!0).on("mouseup.zoom",function(){i.on("mousemove.zoom mouseup.zoom",null),jt(t.event.view,n.moved),Kb(),n.end()},!0),a=Bt(this),u=t.event.clientX,c=t.event.clientY;Ht(t.event.view),Qb(),n.mouse=[a,this.__zoom.invert(a)],Er(this),n.start()}}function T(){if(r.apply(this,arguments)){var n=this.__zoom,e=Bt(this),a=n.invert(e),u=n.k*(t.event.shiftKey?.5:2),c=o(_(y(n,u),e,a),i.apply(this,arguments),f);Kb(),s>0?Rt(this).transition().duration(s).call(m,c,e):Rt(this).call(g.transform,c)}}function A(){if(r.apply(this,arguments)){var e,i,o,a,u=t.event.touches,c=u.length,f=x(this,arguments,t.event.changedTouches.length===c);for(Qb(),i=0;i + + + + \ No newline at end of file diff --git a/examples/js-dev-circular-treemap/src/index.html b/examples/js-dev-circular-treemap/src/index.html new file mode 100644 index 00000000..a2e3cc09 --- /dev/null +++ b/examples/js-dev-circular-treemap/src/index.html @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + diff --git a/examples/js-dev-circular-treemap/src/mod-manifest.json b/examples/js-dev-circular-treemap/src/mod-manifest.json new file mode 100644 index 00000000..b921ce9b --- /dev/null +++ b/examples/js-dev-circular-treemap/src/mod-manifest.json @@ -0,0 +1,33 @@ +{ + "apiVersion": "1.0", + "version": "1.0", + "name": "Circular Treemap", + "id": "js-dev-circular-treemap", + "icon": "icon.svg", + "dataViewDefinition": { + "colorAxis": { + "mode": "dual", + "preferredDualMode": "continuous", + "dropTarget": { + "icon": "Color", + "description": "Color by {0}" + } + }, + "axes": [ + { + "name": "Hierarchy", + "mode": "categorical" + }, + { + "name": "Size", + "mode": "continuous" + } + ] + }, + "files": [ + "index.html", + "circular-treemap.js", + "circular-treemap.css", + "d3.min.js" + ] +} diff --git a/examples/js-dev-circular-treemap/tsconfig.json b/examples/js-dev-circular-treemap/tsconfig.json new file mode 100644 index 00000000..542245b1 --- /dev/null +++ b/examples/js-dev-circular-treemap/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "allowJs": true, + "outDir": "", + "target": "ES2019", + "lib": ["es2019", "dom"] + }, + "include": ["./src/**/*.js", "./spotfire/*.d.ts", "./src/**/*.d.ts", "./node_modules/**/*.d.ts"] +} diff --git a/examples/js-dev-starter-ie11/spotfire/spotfire-api.d.ts b/examples/js-dev-starter-ie11/spotfire/spotfire-api.d.ts index d8d0d46d..9202d538 100644 --- a/examples/js-dev-starter-ie11/spotfire/spotfire-api.d.ts +++ b/examples/js-dev-starter-ie11/spotfire/spotfire-api.d.ts @@ -741,7 +741,9 @@ declare interface GeneralStylingInfo { * console.log("Mod API loaded."); * }); * ``` - * [[include:initialize.md]] + * The initialize method will invoke the provided callback with an instance of the mod API, to be used by the mod developer. + * + * The initialize method needs to be invoked in order for the mod to function. Even if the mod only displays static content, the API must be initialized in order for events and export to work. * @public * @param onLoaded - Callback that is called when the mod API is initialized and ready to be interacted with. */ diff --git a/examples/js-dev-starter/spotfire/spotfire-api.d.ts b/examples/js-dev-starter/spotfire/spotfire-api.d.ts index d8d0d46d..9202d538 100644 --- a/examples/js-dev-starter/spotfire/spotfire-api.d.ts +++ b/examples/js-dev-starter/spotfire/spotfire-api.d.ts @@ -741,7 +741,9 @@ declare interface GeneralStylingInfo { * console.log("Mod API loaded."); * }); * ``` - * [[include:initialize.md]] + * The initialize method will invoke the provided callback with an instance of the mod API, to be used by the mod developer. + * + * The initialize method needs to be invoked in order for the mod to function. Even if the mod only displays static content, the API must be initialized in order for events and export to work. * @public * @param onLoaded - Callback that is called when the mod API is initialized and ready to be interacted with. */ diff --git a/examples/js-dev-starter/src/index.html b/examples/js-dev-starter/src/index.html index bd2d4936..01ca1c45 100644 --- a/examples/js-dev-starter/src/index.html +++ b/examples/js-dev-starter/src/index.html @@ -17,7 +17,7 @@
- + diff --git a/examples/ts-dev-gauge-googlecharts/spotfire/spotfire-api.d.ts b/examples/ts-dev-gauge-googlecharts/spotfire/spotfire-api.d.ts index d8d0d46d..9202d538 100644 --- a/examples/ts-dev-gauge-googlecharts/spotfire/spotfire-api.d.ts +++ b/examples/ts-dev-gauge-googlecharts/spotfire/spotfire-api.d.ts @@ -741,7 +741,9 @@ declare interface GeneralStylingInfo { * console.log("Mod API loaded."); * }); * ``` - * [[include:initialize.md]] + * The initialize method will invoke the provided callback with an instance of the mod API, to be used by the mod developer. + * + * The initialize method needs to be invoked in order for the mod to function. Even if the mod only displays static content, the API must be initialized in order for events and export to work. * @public * @param onLoaded - Callback that is called when the mod API is initialized and ready to be interacted with. */ diff --git a/examples/ts-dev-gauge-googlecharts/static-files/icon.svg b/examples/ts-dev-gauge-googlecharts/static-files/icon.svg deleted file mode 100644 index eaa7d569..00000000 --- a/examples/ts-dev-gauge-googlecharts/static-files/icon.svg +++ /dev/null @@ -1 +0,0 @@ -Mods_icons \ No newline at end of file diff --git a/examples/ts-dev-gauge-googlecharts/static-files/index.html b/examples/ts-dev-gauge-googlecharts/static-files/index.html deleted file mode 100644 index 4416560e..00000000 --- a/examples/ts-dev-gauge-googlecharts/static-files/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Gauge - - - - - - - - -
- - diff --git a/examples/ts-dev-gauge-googlecharts/static-files/main.css b/examples/ts-dev-gauge-googlecharts/static-files/main.css deleted file mode 100644 index 555ec048..00000000 --- a/examples/ts-dev-gauge-googlecharts/static-files/main.css +++ /dev/null @@ -1,17 +0,0 @@ -* { - box-sizing: border-box; -} - -body { - margin: 0; - overflow: hidden; - height: 100vh; - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; -} - -#chart_div td { - border-radius: 50%; -} diff --git a/examples/ts-dev-gauge-googlecharts/static/index.html b/examples/ts-dev-gauge-googlecharts/static/index.html index a49fe3fd..683c8b9b 100644 --- a/examples/ts-dev-gauge-googlecharts/static/index.html +++ b/examples/ts-dev-gauge-googlecharts/static/index.html @@ -16,7 +16,7 @@ - +