diff --git a/VideoStream/__init__.py b/VideoStream/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/VideoStream/__pycache__/__init__.cpython-39.pyc b/VideoStream/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..f2bce41 Binary files /dev/null and b/VideoStream/__pycache__/__init__.cpython-39.pyc differ diff --git a/VideoStream/__pycache__/asgi.cpython-39.pyc b/VideoStream/__pycache__/asgi.cpython-39.pyc new file mode 100644 index 0000000..7b76538 Binary files /dev/null and b/VideoStream/__pycache__/asgi.cpython-39.pyc differ diff --git a/VideoStream/__pycache__/settings.cpython-39.pyc b/VideoStream/__pycache__/settings.cpython-39.pyc new file mode 100644 index 0000000..e4839a5 Binary files /dev/null and b/VideoStream/__pycache__/settings.cpython-39.pyc differ diff --git a/VideoStream/__pycache__/urls.cpython-39.pyc b/VideoStream/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000..4017eca Binary files /dev/null and b/VideoStream/__pycache__/urls.cpython-39.pyc differ diff --git a/VideoStream/__pycache__/wsgi.cpython-39.pyc b/VideoStream/__pycache__/wsgi.cpython-39.pyc new file mode 100644 index 0000000..197a19f Binary files /dev/null and b/VideoStream/__pycache__/wsgi.cpython-39.pyc differ diff --git a/VideoStream/asgi.py b/VideoStream/asgi.py new file mode 100644 index 0000000..a519d29 --- /dev/null +++ b/VideoStream/asgi.py @@ -0,0 +1,28 @@ +import os + +from channels.auth import AuthMiddlewareStack +from channels.routing import ProtocolTypeRouter, URLRouter +from channels.security.websocket import AllowedHostsOriginValidator +from django.core.asgi import get_asgi_application +from django.urls import path + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "VideoStream.settings") +# Initialize Django ASGI application early to ensure the AppRegistry +# is populated before importing code that may import ORM models. +django_asgi_app = get_asgi_application() + +from server.views import VideoStreamConsumer + +application = ProtocolTypeRouter({ + # Django's ASGI application to handle traditional HTTP requests + "http": django_asgi_app, + + # WebSocket chat handler + "websocket": AllowedHostsOriginValidator( + AuthMiddlewareStack( + URLRouter([ + path("", VideoStreamConsumer.as_asgi()), + ]) + ) + ), +}) \ No newline at end of file diff --git a/VideoStream/settings.py b/VideoStream/settings.py new file mode 100644 index 0000000..8374dae --- /dev/null +++ b/VideoStream/settings.py @@ -0,0 +1,157 @@ +""" +Django settings for VideoStream project. + +Generated by 'django-admin startproject' using Django 4.1. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.1/ref/settings/ +""" + +from pathlib import Path +import os +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-v70=a$+6rwm8zctj#g_@@djpty@01m1ob_kj5ex13$pn)-1loq' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] + +# Application definition + +INSTALLED_APPS = [ + 'channels', + 'corsheaders', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'server.apps.ServerConfig', + 'django.contrib.humanize', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'VideoStream.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'VideoStream.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/4.1/topics/i18n/ + + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'Asia/Ho_Chi_Minh' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.1/howto/static-files/ + +# Default primary key field type +# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + +STATIC_URL = '/server/static/' +STATIC_ROOT = os.path.join(BASE_DIR, 'static') + +STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" + +CORS_ALLOW_ALL_ORIGINS = True +CSRF_TRUSTED_ORIGINS = ['http://127.0.0.1:8000','http://localhost:8000/'] +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + +# Uncomment this line if you want to force HTTPS when deploying to production +# SECURE_SSL_REDIRECT = True + +# Channels +ASGI_APPLICATION = 'routing.application' +CHANNEL_LAYERS={ + "default": { + "BACKEND": "channels.layers.InMemoryChannelLayer" + } +} + +# CHANNEL_LAYERS = { +# "default": { +# "BACKEND": "channels_redis.core.RedisChannelLayer", +# "CONFIG": { +# "hosts": [("127.0.0.1", 6379)], +# }, +# }, +# } \ No newline at end of file diff --git a/VideoStream/urls.py b/VideoStream/urls.py new file mode 100644 index 0000000..6b0aee4 --- /dev/null +++ b/VideoStream/urls.py @@ -0,0 +1,24 @@ +"""VideoStream URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.1/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path, include +from django.conf.urls.static import static +from django.conf import settings +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('server.urls')), +]+static(settings.STATIC_URL, + document_root=settings.STATIC_ROOT) \ No newline at end of file diff --git a/VideoStream/wsgi.py b/VideoStream/wsgi.py new file mode 100644 index 0000000..19bcc40 --- /dev/null +++ b/VideoStream/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for VideoStream project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'VideoStream.settings') + +application = get_wsgi_application() diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..bf059a1 Binary files /dev/null and b/db.sqlite3 differ diff --git a/dlib-19.22.99-cp39-cp39-win_amd64.whl b/dlib-19.22.99-cp39-cp39-win_amd64.whl new file mode 100644 index 0000000..b1ce6b8 Binary files /dev/null and b/dlib-19.22.99-cp39-cp39-win_amd64.whl differ diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..1a91fe6 --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'VideoStream.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/ngrok.ipynb b/ngrok.ipynb new file mode 100644 index 0000000..bca654a --- /dev/null +++ b/ngrok.ipynb @@ -0,0 +1,52 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + " \"http://localhost:7000\">" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from pyngrok import ngrok\n", + "ngrok.kill()\n", + "# You can get your authtoken from https://dashboard.ngrok.com/auth\n", + "auth_token = '2MBBpglFtyIYedSYhqf3J9qadxk_3aCaoe72L8oBJZbm8kmMo' # I prepared this for you, but you can get your own\n", + "ngrok.set_auth_token(auth_token)\n", + "\n", + "ngrok.connect(8000) # You can change the port number if you want" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.7" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..dc40e2a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,25 @@ +boost==0.1 +cmake==3.25.0 +Click>=6.0 + +Django==4.1 +django-cors-headers +DateTime==4.5 + +numpy==1.23.3 +opencv-python==4.5.3.56 +#dlib==19.23.0 +./dlib-19.22.99-cp39-cp39-win_amd64.whl + +imutils==0.5.3 +requests>=2.20.0 +tensorflow==2.7.2 +keras==2.7.0 +Pillow==9.0.1 +requests-html==0.10.0 +channels==4.0.0 +daphne==2.5.0 +whitenoise==6.4.0 +psycopg2-binary +protobuf==3.20.* +pyngrok==5.2.1 \ No newline at end of file diff --git a/server/__init__.py b/server/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/__pycache__/__init__.cpython-39.pyc b/server/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..304b991 Binary files /dev/null and b/server/__pycache__/__init__.cpython-39.pyc differ diff --git a/server/__pycache__/admin.cpython-39.pyc b/server/__pycache__/admin.cpython-39.pyc new file mode 100644 index 0000000..7f0c9c5 Binary files /dev/null and b/server/__pycache__/admin.cpython-39.pyc differ diff --git a/server/__pycache__/apps.cpython-39.pyc b/server/__pycache__/apps.cpython-39.pyc new file mode 100644 index 0000000..008a4c7 Binary files /dev/null and b/server/__pycache__/apps.cpython-39.pyc differ diff --git a/server/__pycache__/models.cpython-39.pyc b/server/__pycache__/models.cpython-39.pyc new file mode 100644 index 0000000..043b45d Binary files /dev/null and b/server/__pycache__/models.cpython-39.pyc differ diff --git a/server/__pycache__/urls.cpython-39.pyc b/server/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000..3829c41 Binary files /dev/null and b/server/__pycache__/urls.cpython-39.pyc differ diff --git a/server/__pycache__/views.cpython-39.pyc b/server/__pycache__/views.cpython-39.pyc new file mode 100644 index 0000000..8acb2db Binary files /dev/null and b/server/__pycache__/views.cpython-39.pyc differ diff --git a/server/admin.py b/server/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/server/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/server/apps.py b/server/apps.py new file mode 100644 index 0000000..2b5d1d9 --- /dev/null +++ b/server/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ServerConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'server' diff --git a/server/migrations/__init__.py b/server/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/migrations/__pycache__/__init__.cpython-39.pyc b/server/migrations/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..b2f7bf4 Binary files /dev/null and b/server/migrations/__pycache__/__init__.cpython-39.pyc differ diff --git a/server/models.py b/server/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/server/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/server/models/_mini_XCEPTION.102-0.66.hdf5 b/server/models/_mini_XCEPTION.102-0.66.hdf5 new file mode 100644 index 0000000..4d6900b Binary files /dev/null and b/server/models/_mini_XCEPTION.102-0.66.hdf5 differ diff --git a/server/models/shape_predictor_68_face_landmarks.dat b/server/models/shape_predictor_68_face_landmarks.dat new file mode 100644 index 0000000..e0ec20d Binary files /dev/null and b/server/models/shape_predictor_68_face_landmarks.dat differ diff --git a/server/static/server/c3/.bmp.yml b/server/static/server/c3/.bmp.yml new file mode 100644 index 0000000..3fc6e0c --- /dev/null +++ b/server/static/server/c3/.bmp.yml @@ -0,0 +1,7 @@ +--- +version: 0.7.20 +commit: 'chore(version): bump to v%.%.%' +files: + src/core.ts: 'version: ''%.%.%''' + package.json: '"version": "%.%.%"' + component.json: '"version": "%.%.%"' diff --git a/server/static/server/c3/.circleci/config.yml b/server/static/server/c3/.circleci/config.yml new file mode 100644 index 0000000..f8f0c64 --- /dev/null +++ b/server/static/server/c3/.circleci/config.yml @@ -0,0 +1,85 @@ +version: 2 + +node12: &node12 + working_directory: ~/c3 + docker: + - image: circleci/node:12-browsers + +node14: &node14 + working_directory: ~/c3 + docker: + - image: circleci/node:14-browsers + +restore_modules_cache: &restore_modules_cache + restore_cache: + keys: + - npm-4-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - npm-4- + +save_modules_cache: &save_modules_cache + save_cache: + key: npm-4-{{ checksum "package.json" }} + paths: ./node_modules + +install_and_test: &install_and_test + steps: + - checkout + - run: + name: Display versions + command: | + echo "node $(node -v)" + echo "npm v$(npm --version)" + echo "$(google-chrome --version)" + - *restore_modules_cache + - run: + name: Installing Dependencies + command: yarn + - *save_modules_cache + - run: yarn test + - run: yarn codecov + - store_artifacts: + path: htdocs + destination: htdocs + - run: npx status-back -s -c circleci/htdocs -r c3js/c3 "preview build succes!" "https://${CIRCLE_BUILD_NUM}-11496279-gh.circle-artifacts.com/0/htdocs/index.html" + +jobs: + test_on_node12: + <<: *node12 + <<: *install_and_test + + test_on_node14: + <<: *node14 + <<: *install_and_test + + docs: + docker: + - image: circleci/ruby:2.4-node + env: + BUNDLE_PATH: vendor/bundle + steps: + - checkout + - restore_cache: + key: deps-bundle-{{ checksum "Gemfile.lock" }} + - run: bundle install + - save_cache: + key: deps-bundle-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + - *restore_modules_cache + - run: yarn + - *save_modules_cache + - run: yarn build + - run: yarn copy-to-docs + - run: yarn build:docs + - store_artifacts: + path: build + destination: docs + +workflows: + version: 2 + test: + jobs: + - test_on_node12 + - test_on_node14 + - docs diff --git a/server/static/server/c3/.editorconfig b/server/static/server/c3/.editorconfig new file mode 100644 index 0000000..b3f8732 --- /dev/null +++ b/server/static/server/c3/.editorconfig @@ -0,0 +1,22 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.yml] +indent_size = 2 + +[*.json] +indent_size = 2 + +[*.haml] +indent_size = 2 + +[*.html] +indent_size = 2 diff --git a/server/static/server/c3/.github/ISSUE_TEMPLATE.md b/server/static/server/c3/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..facdb6f --- /dev/null +++ b/server/static/server/c3/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,21 @@ + + +* **C3 version**: +* **D3 version**: +* **Browser**: +* **OS**: diff --git a/server/static/server/c3/.github/PULL_REQUEST_TEMPLATE.md b/server/static/server/c3/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..0380778 --- /dev/null +++ b/server/static/server/c3/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ + diff --git a/server/static/server/c3/.gitignore b/server/static/server/c3/.gitignore new file mode 100644 index 0000000..86c9876 --- /dev/null +++ b/server/static/server/c3/.gitignore @@ -0,0 +1,35 @@ +# npm modules +node_modules +bower_components +d3.js +d3.min.js +components +package-lock.json + +# build +/htdocs/js/c3.js +/htdocs/js/c3.min.js +/htdocs/js/c3.esm.js +/htdocs/css/c3.css +/htdocs/css/c3.min.css +/build + +# sass +.sass-cache + +# jetbrains +.idea/ + +# coverage report +/coverage + +# OS related +.DS_Store + +# IDE related +.idea +.iml + +# bundle +.bundle/config +vendor/bundle diff --git a/server/static/server/c3/.jshintrc b/server/static/server/c3/.jshintrc new file mode 100644 index 0000000..bff1a04 --- /dev/null +++ b/server/static/server/c3/.jshintrc @@ -0,0 +1,27 @@ +{ + "esversion": 6, + "eqeqeq": true, + "curly": true, + "strict": false, + "trailing": true, + "white": true, + "maxlen": 210, + "undef": true, + "unused": true, + "indent": 2, + "eqnull": true, + "expr": true, + "newcap": false, + "loopfunc": true, + "bitwise": false, + "asi": true, + "laxbreak": true, + + "browser": true, + "jasmine": true, + + "globals": { + "d3": false, + "require": false + } +} diff --git a/server/static/server/c3/.prettierrc.json b/server/static/server/c3/.prettierrc.json new file mode 100644 index 0000000..f8dec5b --- /dev/null +++ b/server/static/server/c3/.prettierrc.json @@ -0,0 +1,5 @@ +{ + "tabWidth": 2, + "semi": false, + "singleQuote": true +} diff --git a/server/static/server/c3/.travis.yml b/server/static/server/c3/.travis.yml new file mode 100644 index 0000000..f819093 --- /dev/null +++ b/server/static/server/c3/.travis.yml @@ -0,0 +1,19 @@ +language: ruby +rvm: + - 2.4 + +branches: + only: + - master + +script: + - bundle exec middleman build + +deploy: + provider: pages + skip-cleanup: true + local-dir: build + github-token: $GITHUB_TOKEN + keep-history: true + on: + branch: master diff --git a/server/static/server/c3/CONTRIBUTING.md b/server/static/server/c3/CONTRIBUTING.md new file mode 100644 index 0000000..c915405 --- /dev/null +++ b/server/static/server/c3/CONTRIBUTING.md @@ -0,0 +1,71 @@ +## Filing an issue + +Before filing an issue, please [search the queue](https://github.com/c3js/c3/issues) to make sure it hasn't already been reported. + +If a bug, please include the following — + +1. What version of C3? +1. What browsers have you confirmed it in? +1. Can you isolate the issue by providing a jsFiddle demonstrating it in a minimalist capacity? + +Please *do not* ask for support using the issue queue. For support, please ask [on chat](https://gitter.im/c3js/c3) or [the mailing list](groups.google.com/forum/#!forum/c3js). + +## Setup + 1. **Clone the repo from GitHub** + + git clone https://github.com/c3js/c3.git + cd c3 + + 2. **Acquire build dependencies.** Make sure you have [Node.js](http://nodejs.org/) installed on your workstation. This is only needed to _build_ C3 from sources. C3 itself has no dependency on Node.js once it is built. Now run: + + npm install -g grunt-cli + npm install + + The first `npm` command sets up the popular [Grunt](http://gruntjs.com/) build tool. You might need to run this command with `sudo` if you're on Linux or Mac OS X, or in an Administrator command prompt on Windows. The second `npm` command fetches the remaining build dependencies. + +## Building C3 from sources + npm run build + + +## Distribution + npm run dist + +Now you'll find the built files in `c3.js`, `c3.min.js`, `c3.css` & `c3.min.css`. + +## Running the tests + npm run test + +This command will automatically run the specification suite and report its results. + +If you want to see specs running live in browser (e.g., for debugging), simply open `http://localhost:9876/` in your browser when phantomjs starts. + +## Building the document site (c3js.org) + +First you need ruby and [bundler][] to build the documentation site. + +**Note:** Currently the site doesn't build with ruby 2.5.x, so you need ruby 2.4.4 or below. ([rbenv][] is useful for switching between ruby versions.) + +```console +$ gem install bundler +``` + +Then you need to install bundler dependencies. + +```console +$ bundle install +``` + +Then hit the following command to build the site. + +```console +$ npm run watch:docs +``` + +Then access `http://0.0.0.0:4567`. + +## Contributing your changes + +Add something about PRs here, indicate that PRs should not bump the version number & the build output files (`c3.js`, `c3.min.js`, `c3.css` & `c3.min.css`) should be excluded + +[bundler]: https://bundler.io +[rbenv]: https://github.com/rbenv/rbenv diff --git a/server/static/server/c3/Gemfile b/server/static/server/c3/Gemfile new file mode 100644 index 0000000..f368e0a --- /dev/null +++ b/server/static/server/c3/Gemfile @@ -0,0 +1,15 @@ +# If you have OpenSSL installed, we recommend updating +# the following line to use "https" +source 'http://rubygems.org' + +gem "middleman", "~>3.2.2" + +# Live-reloading plugin +gem "middleman-livereload", "~> 3.1.0" + +# Sync plugin +gem 'middleman-sync', '3.0.12' +gem 'unf' + +# For faster file watcher updates on Windows: +gem "wdm", "~> 0.1.0", :platforms => [:mswin, :mingw] diff --git a/server/static/server/c3/Gemfile.lock b/server/static/server/c3/Gemfile.lock new file mode 100644 index 0000000..32ef354 --- /dev/null +++ b/server/static/server/c3/Gemfile.lock @@ -0,0 +1,285 @@ +GEM + remote: http://rubygems.org/ + specs: + CFPropertyList (2.3.5) + activemodel (3.2.22.5) + activesupport (= 3.2.22.5) + builder (~> 3.0.0) + activesupport (3.2.22.5) + i18n (~> 0.6, >= 0.6.4) + multi_json (~> 1.0) + asset_sync (1.0.0) + activemodel + fog (>= 1.8.0) + builder (3.0.4) + chunky_png (1.3.8) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.12.2) + compass (1.0.3) + chunky_png (~> 1.2) + compass-core (~> 1.0.2) + compass-import-once (~> 1.0.5) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + sass (>= 3.3.13, < 3.5) + compass-core (1.0.3) + multi_json (~> 1.0) + sass (>= 3.3.0, < 3.5) + compass-import-once (1.0.5) + sass (>= 3.2, < 3.5) + em-websocket (0.5.1) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0.6.0) + eventmachine (1.2.3) + eventmachine (1.2.3-x86-mingw32) + excon (0.71.0) + execjs (1.4.1) + multi_json (~> 1.0) + ffi (1.11.1) + ffi (1.11.1-x86-mingw32) + fission (0.5.0) + CFPropertyList (~> 2.2) + fog (1.40.0) + fog-aliyun (>= 0.1.0) + fog-atmos + fog-aws (>= 0.6.0) + fog-brightbox (~> 0.4) + fog-cloudatcost (~> 0.1.0) + fog-core (~> 1.43) + fog-digitalocean (>= 0.3.0) + fog-dnsimple (~> 1.0) + fog-dynect (~> 0.0.2) + fog-ecloud (~> 0.1) + fog-google (<= 0.1.0) + fog-json + fog-local + fog-openstack + fog-powerdns (>= 0.1.1) + fog-profitbricks + fog-rackspace + fog-radosgw (>= 0.0.2) + fog-riakcs + fog-sakuracloud (>= 0.0.4) + fog-serverlove + fog-softlayer + fog-storm_on_demand + fog-terremark + fog-vmfusion + fog-voxel + fog-vsphere (>= 0.4.0) + fog-xenserver + fog-xml (~> 0.1.1) + ipaddress (~> 0.5) + json (>= 1.8, < 2.0) + fog-aliyun (0.1.0) + fog-core (~> 1.27) + fog-json (~> 1.0) + ipaddress (~> 0.8) + xml-simple (~> 1.1) + fog-atmos (0.1.0) + fog-core + fog-xml + fog-aws (1.3.0) + fog-core (~> 1.38) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-brightbox (0.11.0) + fog-core (~> 1.22) + fog-json + inflecto (~> 0.0.2) + fog-cloudatcost (0.1.2) + fog-core (~> 1.36) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-core (1.44.3) + builder + excon (~> 0.49) + formatador (~> 0.2) + fog-digitalocean (0.3.0) + fog-core (~> 1.42) + fog-json (>= 1.0) + fog-xml (>= 0.1) + ipaddress (>= 0.5) + fog-dnsimple (1.0.0) + fog-core (~> 1.38) + fog-json (~> 1.0) + fog-dynect (0.0.3) + fog-core + fog-json + fog-xml + fog-ecloud (0.3.0) + fog-core + fog-xml + fog-google (0.1.0) + fog-core + fog-json + fog-xml + fog-json (1.0.2) + fog-core (~> 1.0) + multi_json (~> 1.10) + fog-local (0.3.1) + fog-core (~> 1.27) + fog-openstack (0.1.20) + fog-core (>= 1.40) + fog-json (>= 1.0) + ipaddress (>= 0.8) + fog-powerdns (0.1.1) + fog-core (~> 1.27) + fog-json (~> 1.0) + fog-xml (~> 0.1) + fog-profitbricks (3.0.0) + fog-core (~> 1.42) + fog-json (~> 1.0) + fog-rackspace (0.1.5) + fog-core (>= 1.35) + fog-json (>= 1.0) + fog-xml (>= 0.1) + ipaddress (>= 0.8) + fog-radosgw (0.0.5) + fog-core (>= 1.21.0) + fog-json + fog-xml (>= 0.0.1) + fog-riakcs (0.1.0) + fog-core + fog-json + fog-xml + fog-sakuracloud (1.7.5) + fog-core + fog-json + fog-serverlove (0.1.2) + fog-core + fog-json + fog-softlayer (1.1.4) + fog-core + fog-json + fog-storm_on_demand (0.1.1) + fog-core + fog-json + fog-terremark (0.1.0) + fog-core + fog-xml + fog-vmfusion (0.1.0) + fission + fog-core + fog-voxel (0.1.0) + fog-core + fog-xml + fog-vsphere (1.10.0) + fog-core + rbvmomi (~> 1.9) + fog-xenserver (0.3.0) + fog-core + fog-xml + fog-xml (0.1.3) + fog-core + nokogiri (>= 1.5.11, < 2.0.0) + formatador (0.2.5) + haml (5.0.1) + temple (>= 0.8.0) + tilt + hike (1.2.3) + http_parser.rb (0.6.0) + i18n (0.6.11) + inflecto (0.0.2) + ipaddress (0.8.3) + json (1.8.6) + kramdown (1.13.2) + listen (1.3.1) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + rb-kqueue (>= 0.2) + middleman (3.2.2) + coffee-script (~> 2.2.0) + compass (>= 0.12.2) + execjs (~> 1.4.0) + haml (>= 3.1.6) + kramdown (~> 1.2) + middleman-core (= 3.2.2) + middleman-sprockets (>= 3.1.2) + sass (>= 3.1.20) + uglifier (~> 2.4.0) + middleman-core (3.2.2) + activesupport (~> 3.2.6) + bundler (~> 1.1) + i18n (~> 0.6.9) + listen (~> 1.1) + rack (>= 1.4.5) + rack-test (~> 0.6.1) + thor (>= 0.15.2, < 2.0) + tilt (~> 1.4.1) + middleman-livereload (3.1.1) + em-websocket (>= 0.2.0) + middleman-core (>= 3.0.2) + multi_json (~> 1.0) + rack-livereload + middleman-sprockets (3.3.3) + middleman-core (>= 3.2) + sprockets (~> 2.2) + sprockets-helpers (~> 1.1.0) + sprockets-sass (~> 1.1.0) + middleman-sync (3.0.12) + asset_sync (~> 1.0.0) + middleman-core (>= 3.0.0) + mini_portile2 (2.4.0) + multi_json (1.13.1) + nokogiri (1.10.8) + mini_portile2 (~> 2.4.0) + nokogiri (1.10.8-x86-mingw32) + mini_portile2 (~> 2.4.0) + rack (1.6.12) + rack-livereload (0.3.16) + rack + rack-test (0.6.3) + rack (>= 1.0) + rb-fsevent (0.9.8) + rb-inotify (0.9.8) + ffi (>= 0.5.0) + rb-kqueue (0.2.5) + ffi (>= 0.5.0) + rbvmomi (1.11.2) + builder (~> 3.0) + json (>= 1.8) + nokogiri (~> 1.5) + trollop (~> 2.1) + sass (3.4.24) + sprockets (2.12.5) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-helpers (1.1.0) + sprockets (~> 2.0) + sprockets-sass (1.1.0) + sprockets (~> 2.0) + tilt (~> 1.1) + temple (0.8.0) + thor (0.19.4) + tilt (1.4.1) + trollop (2.1.2) + uglifier (2.4.0) + execjs (>= 0.3.0) + json (>= 1.8.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.4) + unf_ext (0.0.7.4-x86-mingw32) + wdm (0.1.1) + xml-simple (1.1.5) + +PLATFORMS + ruby + x86-mingw32 + +DEPENDENCIES + middleman (~> 3.2.2) + middleman-livereload (~> 3.1.0) + middleman-sync (= 3.0.12) + unf + wdm (~> 0.1.0) + +BUNDLED WITH + 1.17.3 diff --git a/server/static/server/c3/LICENSE b/server/static/server/c3/LICENSE new file mode 100644 index 0000000..29ce9cb --- /dev/null +++ b/server/static/server/c3/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Masayuki Tanaka + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/server/static/server/c3/MAINTAINANCE.md b/server/static/server/c3/MAINTAINANCE.md new file mode 100644 index 0000000..805cdc6 --- /dev/null +++ b/server/static/server/c3/MAINTAINANCE.md @@ -0,0 +1,33 @@ +# Release process + +If you don't have `bmp` command installed, first install `bmp` ruby gem: + + gem install bmp + +When master is ready for the next release, hit the command: + + bmp -p + +This automatically updates all the version numbers with a new one in the repository. + +Then hit the command: + + npm run dist + +This builds the scripts and stylesheets. Then hit: + + bmp -c + +This commits all the changes (including the built assets) and git-tags a new version (like v0.4.16): + +Then publish it to the npm registry (you need admin access to c3 module): + + npm publish + +At this point, the new version is available through npm. + +Then push master and the tag to github: + + git push origin master vX.Y.Z + +That's all. diff --git a/server/static/server/c3/README.md b/server/static/server/c3/README.md new file mode 100644 index 0000000..4e81f3c --- /dev/null +++ b/server/static/server/c3/README.md @@ -0,0 +1,61 @@ +# c3 + +[![CircleCI](https://circleci.com/gh/c3js/c3.svg?style=shield)](https://circleci.com/gh/c3js/c3) +[![license](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/c3js/c3/blob/master/LICENSE) +[![codecov.io](https://codecov.io/github/c3js/c3/coverage.svg?branch=master)](https://codecov.io/github/c3js/c3?branch=master) + +[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/c3/badge?style=rounded)](https://www.jsdelivr.com/package/npm/c3) + +> c3 is a D3-based reusable chart library that enables deeper integration of charts into web applications. + +Follow the link for more information: [http://c3js.org](http://c3js.org/) + +## Documentation + ++ [Getting Started](http://c3js.org/gettingstarted.html) ++ [Examples](http://c3js.org/examples.html) ++ [Full API Reference](https://c3js.org/reference.html) + +Additional samples can be found in this repository: ++ [https://github.com/c3js/c3/tree/master/htdocs/samples](https://github.com/c3js/c3/tree/master/htdocs/samples) + +You can run these samples as: +``` +$ npm run serve-static +``` + +## Google Group +For general C3.js-related discussion, please visit our [Google Group at https://groups.google.com/forum/#!forum/c3js](https://groups.google.com/forum/#!forum/c3js). + +## Gitter +[![Join the chat at https://gitter.im/c3js/c3](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/c3js/c3?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +## Using the issue queue +The [issue queue](https://github.com/c3js/c3/issues) is to be used for reporting defects and problems with C3.js, in addition to feature requests and ideas. It is **not** a catch-all support forum. **For general support enquiries, please use the [Google Group](https://groups.google.com/forum/#!forum/c3js) at https://groups.google.com/forum/#!forum/c3js.** All questions involving the interplay between C3.js and any other library (such as AngularJS) should be posted there first! + +Before reporting an issue, please do the following: + +1. [Search for existing issues](https://github.com/c3js/c3/issues) to ensure you're not posting a duplicate. + +1. [Search the Google Group](https://groups.google.com/forum/#!forum/c3js) to ensure it hasn't been addressed there already. + +1. Create a JSFiddle or Plunkr highlighting the issue. Please don't include any unnecessary dependencies so we can isolate that the issue is in fact with C3. *Please be advised that custom CSS can modify C3.js output!* + +1. When posting the issue, please use a descriptive title and include the version of C3 (or, if cloning from Git, the commit hash — C3 is under active development and the master branch contains the latest dev commits!), along with any platform/browser/OS information that may be relevant. + +## Pull requests +Pull requests are welcome, though please post an issue first to see whether such a change is desirable. +If you choose to submit a pull request, please do not bump the version number unless asked to, and please include test cases for any new features. Squash all your commits as well, please. + +## Playground +Please fork this fiddle: + ++ http://jsfiddle.net/7kYJu/4742/ + +## Dependency + ++ [D3.js](https://github.com/mbostock/d3) `^5.0.0` + +## License + +MIT diff --git a/server/static/server/c3/bower.json b/server/static/server/c3/bower.json new file mode 100644 index 0000000..58cd17e --- /dev/null +++ b/server/static/server/c3/bower.json @@ -0,0 +1,23 @@ +{ + "name": "c3", + "main": ["c3.css", "c3.js"], + "homepage": "https://github.com/c3js/c3", + "authors": ["Masayuki Tanaka "], + "description": "D3-based reusable chart library", + "keywords": ["chart", "d3"], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "htdocs", + "spec", + "src/**/*.js", + "package.json", + "component.json", + "Gruntfile.*" + ], + "dependencies": { + "d3": "^5.0.0" + } +} diff --git a/server/static/server/c3/c3.css b/server/static/server/c3/c3.css new file mode 100644 index 0000000..2087cc1 --- /dev/null +++ b/server/static/server/c3/c3.css @@ -0,0 +1,241 @@ +/*-- Chart --*/ +.c3 svg { + font: 10px sans-serif; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} + +.c3 path, .c3 line { + fill: none; + stroke: #000; +} + +.c3 text { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; +} + +.c3-legend-item-tile, +.c3-xgrid-focus, +.c3-ygrid, +.c3-event-rect, +.c3-bars path { + shape-rendering: crispEdges; +} + +.c3-chart-arc path { + stroke: #fff; +} + +.c3-chart-arc rect { + stroke: white; + stroke-width: 1; +} + +.c3-chart-arc text { + fill: #fff; + font-size: 13px; +} + +/*-- Axis --*/ +/*-- Grid --*/ +.c3-grid line { + stroke: #aaa; +} + +.c3-grid text { + fill: #aaa; +} + +.c3-xgrid, .c3-ygrid { + stroke-dasharray: 3 3; +} + +/*-- Text on Chart --*/ +.c3-text.c3-empty { + fill: #808080; + font-size: 2em; +} + +/*-- Line --*/ +.c3-line { + stroke-width: 1px; +} + +/*-- Point --*/ +.c3-circle { + fill: currentColor; +} + +.c3-circle._expanded_ { + stroke-width: 1px; + stroke: white; +} + +.c3-selected-circle { + fill: white; + stroke-width: 2px; +} + +/*-- Bar --*/ +.c3-bar { + stroke-width: 0; +} + +.c3-bar._expanded_ { + fill-opacity: 1; + fill-opacity: 0.75; +} + +/*-- Focus --*/ +.c3-target.c3-focused { + opacity: 1; +} + +.c3-target.c3-focused path.c3-line, .c3-target.c3-focused path.c3-step { + stroke-width: 2px; +} + +.c3-target.c3-defocused { + opacity: 0.3 !important; +} + +/*-- Region --*/ +.c3-region { + fill: steelblue; + fill-opacity: 0.1; +} +.c3-region text { + fill-opacity: 1; +} + +/*-- Brush --*/ +.c3-brush .extent { + fill-opacity: 0.1; +} + +/*-- Select - Drag --*/ +/*-- Legend --*/ +.c3-legend-item { + font-size: 12px; +} + +.c3-legend-item-hidden { + opacity: 0.15; +} + +.c3-legend-background { + opacity: 0.75; + fill: white; + stroke: lightgray; + stroke-width: 1; +} + +/*-- Title --*/ +.c3-title { + font: 14px sans-serif; +} + +/*-- Tooltip --*/ +.c3-tooltip-container { + z-index: 10; +} + +.c3-tooltip { + border-collapse: collapse; + border-spacing: 0; + background-color: #fff; + empty-cells: show; + -webkit-box-shadow: 7px 7px 12px -9px #777777; + -moz-box-shadow: 7px 7px 12px -9px #777777; + box-shadow: 7px 7px 12px -9px #777777; + opacity: 0.9; +} + +.c3-tooltip tr { + border: 1px solid #CCC; +} + +.c3-tooltip th { + background-color: #aaa; + font-size: 14px; + padding: 2px 5px; + text-align: left; + color: #FFF; +} + +.c3-tooltip td { + font-size: 13px; + padding: 3px 6px; + background-color: #fff; + border-left: 1px dotted #999; +} + +.c3-tooltip td > span { + display: inline-block; + width: 10px; + height: 10px; + margin-right: 6px; +} + +.c3-tooltip .value { + text-align: right; +} + +/*-- Area --*/ +.c3-area { + stroke-width: 0; + opacity: 0.2; +} + +/*-- Arc --*/ +.c3-chart-arcs-title { + dominant-baseline: middle; + font-size: 1.3em; +} + +.c3-chart-arcs .c3-chart-arcs-background { + fill: #e0e0e0; + stroke: #FFF; +} + +.c3-chart-arcs .c3-chart-arcs-gauge-unit { + fill: #000; + font-size: 16px; +} + +.c3-chart-arcs .c3-chart-arcs-gauge-max { + fill: #777; +} + +.c3-chart-arcs .c3-chart-arcs-gauge-min { + fill: #777; +} + +.c3-chart-arc .c3-gauge-value { + fill: #000; + /* font-size: 28px !important;*/ +} + +.c3-chart-arc.c3-target g path { + opacity: 1; +} + +.c3-chart-arc.c3-target.c3-focused g path { + opacity: 1; +} + +/*-- Zoom --*/ +.c3-drag-zoom.enabled { + pointer-events: all !important; + visibility: visible; +} + +.c3-drag-zoom.disabled { + pointer-events: none !important; + visibility: hidden; +} + +.c3-drag-zoom .extent { + fill-opacity: 0.1; +} diff --git a/server/static/server/c3/c3.esm.js b/server/static/server/c3/c3.esm.js new file mode 100644 index 0000000..08e476c --- /dev/null +++ b/server/static/server/c3/c3.esm.js @@ -0,0 +1,14027 @@ +/* @license C3.js v0.7.18 | (c) C3 Team and other contributors | http://c3js.org/ */ +import * as d3 from 'd3'; + +function ChartInternal(api) { + var $$ = this; + // Note: This part will be replaced by rollup-plugin-modify + // When bundling esm output. Beware of changing this line. + // TODO: Maybe we should check that the modification by rollup-plugin-modify + // is valid during unit tests. + $$.d3 = window.d3 + ? window.d3 + : typeof require !== 'undefined' + ? require('d3') + : undefined; + $$.api = api; + $$.config = $$.getDefaultConfig(); + $$.data = {}; + $$.cache = {}; + $$.axes = {}; +} + +/** + * The Chart class + * + * The methods of this class is the public APIs of the chart object. + */ +function Chart(config) { + this.internal = new ChartInternal(this); + this.internal.loadConfig(config); + + this.internal.beforeInit(config); + this.internal.init(); + this.internal.afterInit(config) + + // bind "this" to nested API + ;(function bindThis(fn, target, argThis) { + Object.keys(fn).forEach(function(key) { + target[key] = fn[key].bind(argThis); + if (Object.keys(fn[key]).length > 0) { + bindThis(fn[key], target[key], argThis); + } + }); + })(Chart.prototype, this, this); +} + +var asHalfPixel = function(n) { + return Math.ceil(n) + 0.5 +}; +var ceil10 = function(v) { + return Math.ceil(v / 10) * 10 +}; +var diffDomain = function(d) { + return d[1] - d[0] +}; +var getOption = function(options, key, defaultValue) { + return isDefined(options[key]) ? options[key] : defaultValue +}; +var getPathBox = function(path) { + var box = getBBox(path), + items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)], + minX = items[0].x, + minY = Math.min(items[0].y, items[1].y); + return { x: minX, y: minY, width: box.width, height: box.height } +}; +var getBBox = function(element) { + try { + return element.getBBox() + } catch (ignore) { + // Firefox will throw an exception if getBBox() is called whereas the + // element is rendered with display:none + // See https://github.com/c3js/c3/issues/2692 + + // The previous code was using `getBoundingClientRect` which was returning + // everything at 0 in this case so let's reproduce this behavior here. + + return { x: 0, y: 0, width: 0, height: 0 } + } +}; +var hasValue = function(dict, value) { + var found = false; + Object.keys(dict).forEach(function(key) { + if (dict[key] === value) { + found = true; + } + }); + return found +}; +var isArray = function(o) { + return Array.isArray(o) +}; +var isDefined = function(v) { + return typeof v !== 'undefined' +}; +var isEmpty = function(o) { + return ( + typeof o === 'undefined' || + o === null || + (isString(o) && o.length === 0) || + (typeof o === 'object' && Object.keys(o).length === 0) + ) +}; +var isFunction = function(o) { + return typeof o === 'function' +}; +var isNumber = function(o) { + return typeof o === 'number' +}; +var isString = function(o) { + return typeof o === 'string' +}; +var isUndefined = function(v) { + return typeof v === 'undefined' +}; +var isValue = function(v) { + return v || v === 0 +}; +var notEmpty = function(o) { + return !isEmpty(o) +}; +var sanitise = function(str) { + return typeof str === 'string' + ? str.replace(//g, '>') + : str +}; +var flattenArray = function(arr) { + return Array.isArray(arr) ? [].concat(...arr) : [] +}; +/** + * Returns whether the point is within the given box. + * + * @param {Array} point An [x,y] coordinate + * @param {Object} box An object with {x, y, width, height} keys + * @param {Number} sensitivity An offset to ease check on very small boxes + */ +var isWithinBox = function(point, box, sensitivity = 0) { + const xStart = box.x - sensitivity; + const xEnd = box.x + box.width + sensitivity; + const yStart = box.y + box.height + sensitivity; + const yEnd = box.y - sensitivity; + + return ( + xStart < point[0] && point[0] < xEnd && yEnd < point[1] && point[1] < yStart + ) +}; + +/** + * Returns Internet Explorer version number (or false if no Internet Explorer used). + * + * @param string agent Optional parameter to specify user agent + */ +var getIEVersion = function(agent) { + // https://stackoverflow.com/questions/19999388/check-if-user-is-using-ie + if (typeof agent === 'undefined') { + agent = window.navigator.userAgent; + } + + let pos = agent.indexOf('MSIE '); // up to IE10 + if (pos > 0) { + return parseInt(agent.substring(pos + 5, agent.indexOf('.', pos)), 10) + } + + pos = agent.indexOf('Trident/'); // IE11 + if (pos > 0) { + pos = agent.indexOf('rv:'); + return parseInt(agent.substring(pos + 3, agent.indexOf('.', pos)), 10) + } + + return false +}; + +/** + * Returns whether the used browser is Internet Explorer. + * + * @param {Number} version Optional parameter to specify IE version + */ +var isIE = function(version) { + const ver = getIEVersion(); + + if (typeof version === 'undefined') { + return !!ver + } + + return version === ver +}; + +function AxisInternal(component, params) { + var internal = this; + internal.component = component; + internal.params = params || {}; + + internal.d3 = component.d3; + internal.scale = internal.d3.scaleLinear(); + internal.range; + internal.orient = 'bottom'; + internal.innerTickSize = 6; + internal.outerTickSize = this.params.withOuterTick ? 6 : 0; + internal.tickPadding = 3; + internal.tickValues = null; + internal.tickFormat; + internal.tickArguments; + + internal.tickOffset = 0; + internal.tickCulling = true; + internal.tickCentered; + internal.tickTextCharSize; + internal.tickTextRotate = internal.params.tickTextRotate; + internal.tickLength; + + internal.axis = internal.generateAxis(); +} + +AxisInternal.prototype.axisX = function(selection, x, tickOffset) { + selection.attr('transform', function(d) { + return 'translate(' + Math.ceil(x(d) + tickOffset) + ', 0)' + }); +}; +AxisInternal.prototype.axisY = function(selection, y) { + selection.attr('transform', function(d) { + return 'translate(0,' + Math.ceil(y(d)) + ')' + }); +}; +AxisInternal.prototype.scaleExtent = function(domain) { + var start = domain[0], + stop = domain[domain.length - 1]; + return start < stop ? [start, stop] : [stop, start] +}; +AxisInternal.prototype.generateTicks = function(scale) { + var internal = this; + var i, + domain, + ticks = []; + if (scale.ticks) { + return scale.ticks.apply(scale, internal.tickArguments) + } + domain = scale.domain(); + for (i = Math.ceil(domain[0]); i < domain[1]; i++) { + ticks.push(i); + } + if (ticks.length > 0 && ticks[0] > 0) { + ticks.unshift(ticks[0] - (ticks[1] - ticks[0])); + } + return ticks +}; +AxisInternal.prototype.copyScale = function() { + var internal = this; + var newScale = internal.scale.copy(), + domain; + if (internal.params.isCategory) { + domain = internal.scale.domain(); + newScale.domain([domain[0], domain[1] - 1]); + } + return newScale +}; +AxisInternal.prototype.textFormatted = function(v) { + var internal = this, + formatted = internal.tickFormat ? internal.tickFormat(v) : v; + return typeof formatted !== 'undefined' ? formatted : '' +}; +AxisInternal.prototype.updateRange = function() { + var internal = this; + internal.range = internal.scale.rangeExtent + ? internal.scale.rangeExtent() + : internal.scaleExtent(internal.scale.range()); + return internal.range +}; +AxisInternal.prototype.updateTickTextCharSize = function(tick) { + var internal = this; + if (internal.tickTextCharSize) { + return internal.tickTextCharSize + } + var size = { + h: 11.5, + w: 5.5 + }; + tick + .select('text') + .text(function(d) { + return internal.textFormatted(d) + }) + .each(function(d) { + var box = getBBox(this), + text = internal.textFormatted(d), + h = box.height, + w = text ? box.width / text.length : undefined; + if (h && w) { + size.h = h; + size.w = w; + } + }) + .text(''); + internal.tickTextCharSize = size; + return size +}; +AxisInternal.prototype.isVertical = function() { + return this.orient === 'left' || this.orient === 'right' +}; +AxisInternal.prototype.tspanData = function(d, i, scale) { + var internal = this; + var splitted = internal.params.tickMultiline + ? internal.splitTickText(d, scale) + : [].concat(internal.textFormatted(d)); + + if (internal.params.tickMultiline && internal.params.tickMultilineMax > 0) { + splitted = internal.ellipsify(splitted, internal.params.tickMultilineMax); + } + + return splitted.map(function(s) { + return { index: i, splitted: s, length: splitted.length } + }) +}; +AxisInternal.prototype.splitTickText = function(d, scale) { + var internal = this, + tickText = internal.textFormatted(d), + maxWidth = internal.params.tickWidth, + subtext, + spaceIndex, + textWidth, + splitted = []; + + if (Object.prototype.toString.call(tickText) === '[object Array]') { + return tickText + } + + if (!maxWidth || maxWidth <= 0) { + maxWidth = internal.isVertical() + ? 95 + : internal.params.isCategory + ? Math.ceil(scale(1) - scale(0)) - 12 + : 110; + } + + function split(splitted, text) { + spaceIndex = undefined; + for (var i = 1; i < text.length; i++) { + if (text.charAt(i) === ' ') { + spaceIndex = i; + } + subtext = text.substr(0, i + 1); + textWidth = internal.tickTextCharSize.w * subtext.length; + // if text width gets over tick width, split by space index or crrent index + if (maxWidth < textWidth) { + return split( + splitted.concat(text.substr(0, spaceIndex ? spaceIndex : i)), + text.slice(spaceIndex ? spaceIndex + 1 : i) + ) + } + } + return splitted.concat(text) + } + + return split(splitted, tickText + '') +}; +AxisInternal.prototype.ellipsify = function(splitted, max) { + if (splitted.length <= max) { + return splitted + } + + var ellipsified = splitted.slice(0, max); + var remaining = 3; + for (var i = max - 1; i >= 0; i--) { + var available = ellipsified[i].length; + + ellipsified[i] = ellipsified[i] + .substr(0, available - remaining) + .padEnd(available, '.'); + + remaining -= available; + + if (remaining <= 0) { + break + } + } + + return ellipsified +}; +AxisInternal.prototype.updateTickLength = function() { + var internal = this; + internal.tickLength = + Math.max(internal.innerTickSize, 0) + internal.tickPadding; +}; +AxisInternal.prototype.lineY2 = function(d) { + var internal = this, + tickPosition = + internal.scale(d) + (internal.tickCentered ? 0 : internal.tickOffset); + return internal.range[0] < tickPosition && tickPosition < internal.range[1] + ? internal.innerTickSize + : 0 +}; +AxisInternal.prototype.textY = function() { + var internal = this, + rotate = internal.tickTextRotate; + return rotate + ? 11.5 - 2.5 * (rotate / 15) * (rotate > 0 ? 1 : -1) + : internal.tickLength +}; +AxisInternal.prototype.textTransform = function() { + var internal = this, + rotate = internal.tickTextRotate; + return rotate ? 'rotate(' + rotate + ')' : '' +}; +AxisInternal.prototype.textTextAnchor = function() { + var internal = this, + rotate = internal.tickTextRotate; + return rotate ? (rotate > 0 ? 'start' : 'end') : 'middle' +}; +AxisInternal.prototype.tspanDx = function() { + var internal = this, + rotate = internal.tickTextRotate; + return rotate ? 8 * Math.sin(Math.PI * (rotate / 180)) : 0 +}; +AxisInternal.prototype.tspanDy = function(d, i) { + var internal = this, + dy = internal.tickTextCharSize.h; + if (i === 0) { + if (internal.isVertical()) { + dy = -((d.length - 1) * (internal.tickTextCharSize.h / 2) - 3); + } else { + dy = '.71em'; + } + } + return dy +}; + +AxisInternal.prototype.generateAxis = function() { + var internal = this, + d3 = internal.d3, + params = internal.params; + function axis(g, transition) { + var self; + g.each(function() { + var g = (axis.g = d3.select(this)); + + var scale0 = this.__chart__ || internal.scale, + scale1 = (this.__chart__ = internal.copyScale()); + + var ticksValues = internal.tickValues + ? internal.tickValues + : internal.generateTicks(scale1), + ticks = g.selectAll('.tick').data(ticksValues, scale1), + tickEnter = ticks + .enter() + .insert('g', '.domain') + .attr('class', 'tick') + .style('opacity', 1e-6), + // MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks. + tickExit = ticks.exit().remove(), + tickUpdate = ticks.merge(tickEnter), + tickTransform, + tickX, + tickY; + + if (params.isCategory) { + internal.tickOffset = Math.ceil((scale1(1) - scale1(0)) / 2); + tickX = internal.tickCentered ? 0 : internal.tickOffset; + tickY = internal.tickCentered ? internal.tickOffset : 0; + } else { + internal.tickOffset = tickX = 0; + } + + internal.updateRange(); + internal.updateTickLength(); + internal.updateTickTextCharSize(g.select('.tick')); + + var lineUpdate = tickUpdate + .select('line') + .merge(tickEnter.append('line')), + textUpdate = tickUpdate.select('text').merge(tickEnter.append('text')); + + var tspans = tickUpdate + .selectAll('text') + .selectAll('tspan') + .data(function(d, i) { + return internal.tspanData(d, i, scale1) + }), + tspanEnter = tspans.enter().append('tspan'), + tspanUpdate = tspanEnter.merge(tspans).text(function(d) { + return d.splitted + }); + tspans.exit().remove(); + + var path = g.selectAll('.domain').data([0]), + pathUpdate = path + .enter() + .append('path') + .merge(path) + .attr('class', 'domain'); + + // TODO: each attr should be one function and change its behavior by internal.orient, probably + switch (internal.orient) { + case 'bottom': { + tickTransform = internal.axisX; + lineUpdate + .attr('x1', tickX) + .attr('x2', tickX) + .attr('y2', function(d, i) { + return internal.lineY2(d, i) + }); + textUpdate + .attr('x', 0) + .attr('y', function(d, i) { + return internal.textY(d, i) + }) + .attr('transform', function(d, i) { + return internal.textTransform(d, i) + }) + .style('text-anchor', function(d, i) { + return internal.textTextAnchor(d, i) + }); + tspanUpdate + .attr('x', 0) + .attr('dy', function(d, i) { + return internal.tspanDy(d, i) + }) + .attr('dx', function(d, i) { + return internal.tspanDx(d, i) + }); + pathUpdate.attr( + 'd', + 'M' + + internal.range[0] + + ',' + + internal.outerTickSize + + 'V0H' + + internal.range[1] + + 'V' + + internal.outerTickSize + ); + break + } + case 'top': { + // TODO: rotated tick text + tickTransform = internal.axisX; + lineUpdate + .attr('x1', tickX) + .attr('x2', tickX) + .attr('y2', function(d, i) { + return -1 * internal.lineY2(d, i) + }); + textUpdate + .attr('x', 0) + .attr('y', function(d, i) { + return ( + -1 * internal.textY(d, i) - + (params.isCategory ? 2 : internal.tickLength - 2) + ) + }) + .attr('transform', function(d, i) { + return internal.textTransform(d, i) + }) + .style('text-anchor', function(d, i) { + return internal.textTextAnchor(d, i) + }); + tspanUpdate + .attr('x', 0) + .attr('dy', function(d, i) { + return internal.tspanDy(d, i) + }) + .attr('dx', function(d, i) { + return internal.tspanDx(d, i) + }); + pathUpdate.attr( + 'd', + 'M' + + internal.range[0] + + ',' + + -internal.outerTickSize + + 'V0H' + + internal.range[1] + + 'V' + + -internal.outerTickSize + ); + break + } + case 'left': { + tickTransform = internal.axisY; + lineUpdate + .attr('x2', -internal.innerTickSize) + .attr('y1', tickY) + .attr('y2', tickY); + textUpdate + .attr('x', -internal.tickLength) + .attr('y', internal.tickOffset) + .style('text-anchor', 'end'); + tspanUpdate + .attr('x', -internal.tickLength) + .attr('dy', function(d, i) { + return internal.tspanDy(d, i) + }); + pathUpdate.attr( + 'd', + 'M' + + -internal.outerTickSize + + ',' + + internal.range[0] + + 'H0V' + + internal.range[1] + + 'H' + + -internal.outerTickSize + ); + break + } + case 'right': { + tickTransform = internal.axisY; + lineUpdate + .attr('x2', internal.innerTickSize) + .attr('y1', tickY) + .attr('y2', tickY); + textUpdate + .attr('x', internal.tickLength) + .attr('y', internal.tickOffset) + .style('text-anchor', 'start'); + tspanUpdate.attr('x', internal.tickLength).attr('dy', function(d, i) { + return internal.tspanDy(d, i) + }); + pathUpdate.attr( + 'd', + 'M' + + internal.outerTickSize + + ',' + + internal.range[0] + + 'H0V' + + internal.range[1] + + 'H' + + internal.outerTickSize + ); + break + } + } + if (scale1.rangeBand) { + var x = scale1, + dx = x.rangeBand() / 2; + scale0 = scale1 = function(d) { + return x(d) + dx + }; + } else if (scale0.rangeBand) { + scale0 = scale1; + } else { + tickExit.call(tickTransform, scale1, internal.tickOffset); + } + tickEnter.call(tickTransform, scale0, internal.tickOffset); + self = (transition ? tickUpdate.transition(transition) : tickUpdate) + .style('opacity', 1) + .call(tickTransform, scale1, internal.tickOffset); + }); + return self + } + axis.scale = function(x) { + if (!arguments.length) { + return internal.scale + } + internal.scale = x; + return axis + }; + axis.orient = function(x) { + if (!arguments.length) { + return internal.orient + } + internal.orient = + x in { top: 1, right: 1, bottom: 1, left: 1 } ? x + '' : 'bottom'; + return axis + }; + axis.tickFormat = function(format) { + if (!arguments.length) { + return internal.tickFormat + } + internal.tickFormat = format; + return axis + }; + axis.tickCentered = function(isCentered) { + if (!arguments.length) { + return internal.tickCentered + } + internal.tickCentered = isCentered; + return axis + }; + axis.tickOffset = function() { + return internal.tickOffset + }; + axis.tickInterval = function() { + var interval, length; + if (params.isCategory) { + interval = internal.tickOffset * 2; + } else { + length = + axis.g + .select('path.domain') + .node() + .getTotalLength() - + internal.outerTickSize * 2; + interval = length / axis.g.selectAll('line').size(); + } + return interval === Infinity ? 0 : interval + }; + axis.ticks = function() { + if (!arguments.length) { + return internal.tickArguments + } + internal.tickArguments = arguments; + return axis + }; + axis.tickCulling = function(culling) { + if (!arguments.length) { + return internal.tickCulling + } + internal.tickCulling = culling; + return axis + }; + axis.tickValues = function(x) { + if (typeof x === 'function') { + internal.tickValues = function() { + return x(internal.scale.domain()) + }; + } else { + if (!arguments.length) { + return internal.tickValues + } + internal.tickValues = x; + } + return axis + }; + return axis +}; + +var CLASS = { + target: 'c3-target', + chart: 'c3-chart', + chartLine: 'c3-chart-line', + chartLines: 'c3-chart-lines', + chartBar: 'c3-chart-bar', + chartBars: 'c3-chart-bars', + chartText: 'c3-chart-text', + chartTexts: 'c3-chart-texts', + chartArc: 'c3-chart-arc', + chartArcs: 'c3-chart-arcs', + chartArcsTitle: 'c3-chart-arcs-title', + chartArcsBackground: 'c3-chart-arcs-background', + chartArcsGaugeUnit: 'c3-chart-arcs-gauge-unit', + chartArcsGaugeMax: 'c3-chart-arcs-gauge-max', + chartArcsGaugeMin: 'c3-chart-arcs-gauge-min', + selectedCircle: 'c3-selected-circle', + selectedCircles: 'c3-selected-circles', + eventRect: 'c3-event-rect', + eventRects: 'c3-event-rects', + eventRectsSingle: 'c3-event-rects-single', + eventRectsMultiple: 'c3-event-rects-multiple', + zoomRect: 'c3-zoom-rect', + brush: 'c3-brush', + dragZoom: 'c3-drag-zoom', + focused: 'c3-focused', + defocused: 'c3-defocused', + region: 'c3-region', + regions: 'c3-regions', + title: 'c3-title', + tooltipContainer: 'c3-tooltip-container', + tooltip: 'c3-tooltip', + tooltipName: 'c3-tooltip-name', + shape: 'c3-shape', + shapes: 'c3-shapes', + line: 'c3-line', + lines: 'c3-lines', + bar: 'c3-bar', + bars: 'c3-bars', + circle: 'c3-circle', + circles: 'c3-circles', + arc: 'c3-arc', + arcLabelLine: 'c3-arc-label-line', + arcs: 'c3-arcs', + area: 'c3-area', + areas: 'c3-areas', + empty: 'c3-empty', + text: 'c3-text', + texts: 'c3-texts', + gaugeValue: 'c3-gauge-value', + grid: 'c3-grid', + gridLines: 'c3-grid-lines', + xgrid: 'c3-xgrid', + xgrids: 'c3-xgrids', + xgridLine: 'c3-xgrid-line', + xgridLines: 'c3-xgrid-lines', + xgridFocus: 'c3-xgrid-focus', + ygrid: 'c3-ygrid', + ygrids: 'c3-ygrids', + ygridLine: 'c3-ygrid-line', + ygridLines: 'c3-ygrid-lines', + colorScale: 'c3-colorscale', + stanfordElements: 'c3-stanford-elements', + stanfordLine: 'c3-stanford-line', + stanfordLines: 'c3-stanford-lines', + stanfordRegion: 'c3-stanford-region', + stanfordRegions: 'c3-stanford-regions', + stanfordText: 'c3-stanford-text', + stanfordTexts: 'c3-stanford-texts', + axis: 'c3-axis', + axisX: 'c3-axis-x', + axisXLabel: 'c3-axis-x-label', + axisY: 'c3-axis-y', + axisYLabel: 'c3-axis-y-label', + axisY2: 'c3-axis-y2', + axisY2Label: 'c3-axis-y2-label', + legendBackground: 'c3-legend-background', + legendItem: 'c3-legend-item', + legendItemEvent: 'c3-legend-item-event', + legendItemTile: 'c3-legend-item-tile', + legendItemHidden: 'c3-legend-item-hidden', + legendItemFocused: 'c3-legend-item-focused', + dragarea: 'c3-dragarea', + EXPANDED: '_expanded_', + SELECTED: '_selected_', + INCLUDED: '_included_' +}; + +class Axis { + constructor(owner) { + this.owner = owner; + this.d3 = owner.d3; + this.internal = AxisInternal; + } +} +Axis.prototype.init = function init() { + var $$ = this.owner, + config = $$.config, + main = $$.main; + $$.axes.x = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisX) + .attr('clip-path', config.axis_x_inner ? '' : $$.clipPathForXAxis) + .attr('transform', $$.getTranslate('x')) + .style('visibility', config.axis_x_show ? 'visible' : 'hidden'); + $$.axes.x + .append('text') + .attr('class', CLASS.axisXLabel) + .attr('transform', config.axis_rotated ? 'rotate(-90)' : '') + .style('text-anchor', this.textAnchorForXAxisLabel.bind(this)); + $$.axes.y = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisY) + .attr('clip-path', config.axis_y_inner ? '' : $$.clipPathForYAxis) + .attr('transform', $$.getTranslate('y')) + .style('visibility', config.axis_y_show ? 'visible' : 'hidden'); + $$.axes.y + .append('text') + .attr('class', CLASS.axisYLabel) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .style('text-anchor', this.textAnchorForYAxisLabel.bind(this)); + + $$.axes.y2 = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisY2) + // clip-path? + .attr('transform', $$.getTranslate('y2')) + .style('visibility', config.axis_y2_show ? 'visible' : 'hidden'); + $$.axes.y2 + .append('text') + .attr('class', CLASS.axisY2Label) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .style('text-anchor', this.textAnchorForY2AxisLabel.bind(this)); +}; +Axis.prototype.getXAxis = function getXAxis( + scale, + orient, + tickFormat, + tickValues, + withOuterTick, + withoutTransition, + withoutRotateTickText +) { + var $$ = this.owner, + config = $$.config, + axisParams = { + isCategory: $$.isCategorized(), + withOuterTick: withOuterTick, + tickMultiline: config.axis_x_tick_multiline, + tickMultilineMax: config.axis_x_tick_multiline + ? Number(config.axis_x_tick_multilineMax) + : 0, + tickWidth: config.axis_x_tick_width, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_x_tick_rotate, + withoutTransition: withoutTransition + }, + axis = new this.internal(this, axisParams).axis.scale(scale).orient(orient); + + if ($$.isTimeSeries() && tickValues && typeof tickValues !== 'function') { + tickValues = tickValues.map(function(v) { + return $$.parseDate(v) + }); + } + + // Set tick + axis.tickFormat(tickFormat).tickValues(tickValues); + if ($$.isCategorized()) { + axis.tickCentered(config.axis_x_tick_centered); + if (isEmpty(config.axis_x_tick_culling)) { + config.axis_x_tick_culling = false; + } + } + + return axis +}; +Axis.prototype.updateXAxisTickValues = function updateXAxisTickValues( + targets, + axis +) { + var $$ = this.owner, + config = $$.config, + tickValues; + if (config.axis_x_tick_fit || config.axis_x_tick_count) { + tickValues = this.generateTickValues( + $$.mapTargetsToUniqueXs(targets), + config.axis_x_tick_count, + $$.isTimeSeries() + ); + } + if (axis) { + axis.tickValues(tickValues); + } else { + $$.xAxis.tickValues(tickValues); + $$.subXAxis.tickValues(tickValues); + } + return tickValues +}; +Axis.prototype.getYAxis = function getYAxis( + axisId, + scale, + orient, + tickValues, + withOuterTick, + withoutTransition, + withoutRotateTickText +) { + const $$ = this.owner; + const config = $$.config; + + let tickFormat = config[`axis_${axisId}_tick_format`]; + if (!tickFormat && $$.isAxisNormalized(axisId)) { + tickFormat = x => `${x}%`; + } + + const axis = new this.internal(this, { + withOuterTick: withOuterTick, + withoutTransition: withoutTransition, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate + }).axis + .scale(scale) + .orient(orient); + + if (tickFormat) { + axis.tickFormat(tickFormat); + } + + if ($$.isTimeSeriesY()) { + axis.ticks(config.axis_y_tick_time_type, config.axis_y_tick_time_interval); + } else { + axis.tickValues(tickValues); + } + return axis +}; +Axis.prototype.getId = function getId(id) { + var config = this.owner.config; + return id in config.data_axes ? config.data_axes[id] : 'y' +}; +Axis.prototype.getXAxisTickFormat = function getXAxisTickFormat() { + // #2251 previously set any negative values to a whole number, + // however both should be truncated according to the users format specification + var $$ = this.owner, + config = $$.config; + let format = $$.isTimeSeries() + ? $$.defaultAxisTimeFormat + : $$.isCategorized() + ? $$.categoryName + : function(v) { + return v + }; + + if (config.axis_x_tick_format) { + if (isFunction(config.axis_x_tick_format)) { + format = config.axis_x_tick_format; + } else if ($$.isTimeSeries()) { + format = function(date) { + return date ? $$.axisTimeFormat(config.axis_x_tick_format)(date) : '' + }; + } + } + return isFunction(format) + ? function(v) { + return format.call($$, v) + } + : format +}; +Axis.prototype.getTickValues = function getTickValues(tickValues, axis) { + return tickValues ? tickValues : axis ? axis.tickValues() : undefined +}; +Axis.prototype.getXAxisTickValues = function getXAxisTickValues() { + return this.getTickValues( + this.owner.config.axis_x_tick_values, + this.owner.xAxis + ) +}; +Axis.prototype.getYAxisTickValues = function getYAxisTickValues() { + return this.getTickValues( + this.owner.config.axis_y_tick_values, + this.owner.yAxis + ) +}; +Axis.prototype.getY2AxisTickValues = function getY2AxisTickValues() { + return this.getTickValues( + this.owner.config.axis_y2_tick_values, + this.owner.y2Axis + ) +}; +Axis.prototype.getLabelOptionByAxisId = function getLabelOptionByAxisId( + axisId +) { + var $$ = this.owner, + config = $$.config, + option; + if (axisId === 'y') { + option = config.axis_y_label; + } else if (axisId === 'y2') { + option = config.axis_y2_label; + } else if (axisId === 'x') { + option = config.axis_x_label; + } + return option +}; +Axis.prototype.getLabelText = function getLabelText(axisId) { + var option = this.getLabelOptionByAxisId(axisId); + return isString(option) ? option : option ? option.text : null +}; +Axis.prototype.setLabelText = function setLabelText(axisId, text) { + var $$ = this.owner, + config = $$.config, + option = this.getLabelOptionByAxisId(axisId); + if (isString(option)) { + if (axisId === 'y') { + config.axis_y_label = text; + } else if (axisId === 'y2') { + config.axis_y2_label = text; + } else if (axisId === 'x') { + config.axis_x_label = text; + } + } else if (option) { + option.text = text; + } +}; +Axis.prototype.getLabelPosition = function getLabelPosition( + axisId, + defaultPosition +) { + var option = this.getLabelOptionByAxisId(axisId), + position = + option && typeof option === 'object' && option.position + ? option.position + : defaultPosition; + return { + isInner: position.indexOf('inner') >= 0, + isOuter: position.indexOf('outer') >= 0, + isLeft: position.indexOf('left') >= 0, + isCenter: position.indexOf('center') >= 0, + isRight: position.indexOf('right') >= 0, + isTop: position.indexOf('top') >= 0, + isMiddle: position.indexOf('middle') >= 0, + isBottom: position.indexOf('bottom') >= 0 + } +}; +Axis.prototype.getXAxisLabelPosition = function getXAxisLabelPosition() { + return this.getLabelPosition( + 'x', + this.owner.config.axis_rotated ? 'inner-top' : 'inner-right' + ) +}; +Axis.prototype.getYAxisLabelPosition = function getYAxisLabelPosition() { + return this.getLabelPosition( + 'y', + this.owner.config.axis_rotated ? 'inner-right' : 'inner-top' + ) +}; +Axis.prototype.getY2AxisLabelPosition = function getY2AxisLabelPosition() { + return this.getLabelPosition( + 'y2', + this.owner.config.axis_rotated ? 'inner-right' : 'inner-top' + ) +}; +Axis.prototype.getLabelPositionById = function getLabelPositionById(id) { + return id === 'y2' + ? this.getY2AxisLabelPosition() + : id === 'y' + ? this.getYAxisLabelPosition() + : this.getXAxisLabelPosition() +}; +Axis.prototype.textForXAxisLabel = function textForXAxisLabel() { + return this.getLabelText('x') +}; +Axis.prototype.textForYAxisLabel = function textForYAxisLabel() { + return this.getLabelText('y') +}; +Axis.prototype.textForY2AxisLabel = function textForY2AxisLabel() { + return this.getLabelText('y2') +}; +Axis.prototype.xForAxisLabel = function xForAxisLabel(forHorizontal, position) { + var $$ = this.owner; + if (forHorizontal) { + return position.isLeft ? 0 : position.isCenter ? $$.width / 2 : $$.width + } else { + return position.isBottom + ? -$$.height + : position.isMiddle + ? -$$.height / 2 + : 0 + } +}; +Axis.prototype.dxForAxisLabel = function dxForAxisLabel( + forHorizontal, + position +) { + if (forHorizontal) { + return position.isLeft ? '0.5em' : position.isRight ? '-0.5em' : '0' + } else { + return position.isTop ? '-0.5em' : position.isBottom ? '0.5em' : '0' + } +}; +Axis.prototype.textAnchorForAxisLabel = function textAnchorForAxisLabel( + forHorizontal, + position +) { + if (forHorizontal) { + return position.isLeft ? 'start' : position.isCenter ? 'middle' : 'end' + } else { + return position.isBottom ? 'start' : position.isMiddle ? 'middle' : 'end' + } +}; +Axis.prototype.xForXAxisLabel = function xForXAxisLabel() { + return this.xForAxisLabel( + !this.owner.config.axis_rotated, + this.getXAxisLabelPosition() + ) +}; +Axis.prototype.xForYAxisLabel = function xForYAxisLabel() { + return this.xForAxisLabel( + this.owner.config.axis_rotated, + this.getYAxisLabelPosition() + ) +}; +Axis.prototype.xForY2AxisLabel = function xForY2AxisLabel() { + return this.xForAxisLabel( + this.owner.config.axis_rotated, + this.getY2AxisLabelPosition() + ) +}; +Axis.prototype.dxForXAxisLabel = function dxForXAxisLabel() { + return this.dxForAxisLabel( + !this.owner.config.axis_rotated, + this.getXAxisLabelPosition() + ) +}; +Axis.prototype.dxForYAxisLabel = function dxForYAxisLabel() { + return this.dxForAxisLabel( + this.owner.config.axis_rotated, + this.getYAxisLabelPosition() + ) +}; +Axis.prototype.dxForY2AxisLabel = function dxForY2AxisLabel() { + return this.dxForAxisLabel( + this.owner.config.axis_rotated, + this.getY2AxisLabelPosition() + ) +}; +Axis.prototype.dyForXAxisLabel = function dyForXAxisLabel() { + var $$ = this.owner, + config = $$.config, + position = this.getXAxisLabelPosition(); + if (config.axis_rotated) { + return position.isInner + ? '1.2em' + : -25 - ($$.config.axis_x_inner ? 0 : this.getMaxTickWidth('x')) + } else { + return position.isInner ? '-0.5em' : $$.getHorizontalAxisHeight('x') - 10 + } +}; +Axis.prototype.dyForYAxisLabel = function dyForYAxisLabel() { + var $$ = this.owner, + position = this.getYAxisLabelPosition(); + if ($$.config.axis_rotated) { + return position.isInner ? '-0.5em' : '3em' + } else { + return position.isInner + ? '1.2em' + : -10 - ($$.config.axis_y_inner ? 0 : this.getMaxTickWidth('y') + 10) + } +}; +Axis.prototype.dyForY2AxisLabel = function dyForY2AxisLabel() { + var $$ = this.owner, + position = this.getY2AxisLabelPosition(); + if ($$.config.axis_rotated) { + return position.isInner ? '1.2em' : '-2.2em' + } else { + return position.isInner + ? '-0.5em' + : 15 + ($$.config.axis_y2_inner ? 0 : this.getMaxTickWidth('y2') + 15) + } +}; +Axis.prototype.textAnchorForXAxisLabel = function textAnchorForXAxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel( + !$$.config.axis_rotated, + this.getXAxisLabelPosition() + ) +}; +Axis.prototype.textAnchorForYAxisLabel = function textAnchorForYAxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel( + $$.config.axis_rotated, + this.getYAxisLabelPosition() + ) +}; +Axis.prototype.textAnchorForY2AxisLabel = function textAnchorForY2AxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel( + $$.config.axis_rotated, + this.getY2AxisLabelPosition() + ) +}; +Axis.prototype.getMaxTickWidth = function getMaxTickWidth( + id, + withoutRecompute +) { + var $$ = this.owner, + maxWidth = 0, + targetsToShow, + scale, + axis, + dummy, + svg; + if (withoutRecompute && $$.currentMaxTickWidths[id]) { + return $$.currentMaxTickWidths[id] + } + if ($$.svg) { + targetsToShow = $$.filterTargetsToShow($$.data.targets); + if (id === 'y') { + scale = $$.y.copy().domain($$.getYDomain(targetsToShow, 'y')); + axis = this.getYAxis( + id, + scale, + $$.yOrient, + $$.yAxisTickValues, + false, + true, + true + ); + } else if (id === 'y2') { + scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); + axis = this.getYAxis( + id, + scale, + $$.y2Orient, + $$.y2AxisTickValues, + false, + true, + true + ); + } else { + scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); + axis = this.getXAxis( + scale, + $$.xOrient, + $$.xAxisTickFormat, + $$.xAxisTickValues, + false, + true, + true + ); + this.updateXAxisTickValues(targetsToShow, axis); + } + dummy = $$.d3 + .select('body') + .append('div') + .classed('c3', true) + ;(svg = dummy + .append('svg') + .style('visibility', 'hidden') + .style('position', 'fixed') + .style('top', 0) + .style('left', 0)), + svg + .append('g') + .call(axis) + .each(function() { + $$.d3 + .select(this) + .selectAll('text') + .each(function() { + var box = getBBox(this); + if (maxWidth < box.width) { + maxWidth = box.width; + } + }); + dummy.remove(); + }); + } + $$.currentMaxTickWidths[id] = + maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; + return $$.currentMaxTickWidths[id] +}; + +Axis.prototype.updateLabels = function updateLabels(withTransition) { + var $$ = this.owner; + var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), + axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel), + axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label) + ;(withTransition ? axisXLabel.transition() : axisXLabel) + .attr('x', this.xForXAxisLabel.bind(this)) + .attr('dx', this.dxForXAxisLabel.bind(this)) + .attr('dy', this.dyForXAxisLabel.bind(this)) + .text(this.textForXAxisLabel.bind(this)) + ;(withTransition ? axisYLabel.transition() : axisYLabel) + .attr('x', this.xForYAxisLabel.bind(this)) + .attr('dx', this.dxForYAxisLabel.bind(this)) + .attr('dy', this.dyForYAxisLabel.bind(this)) + .text(this.textForYAxisLabel.bind(this)) + ;(withTransition ? axisY2Label.transition() : axisY2Label) + .attr('x', this.xForY2AxisLabel.bind(this)) + .attr('dx', this.dxForY2AxisLabel.bind(this)) + .attr('dy', this.dyForY2AxisLabel.bind(this)) + .text(this.textForY2AxisLabel.bind(this)); +}; +Axis.prototype.getPadding = function getPadding( + padding, + key, + defaultValue, + domainLength +) { + var p = typeof padding === 'number' ? padding : padding[key]; + if (!isValue(p)) { + return defaultValue + } + if (padding.unit === 'ratio') { + return padding[key] * domainLength + } + // assume padding is pixels if unit is not specified + return this.convertPixelsToAxisPadding(p, domainLength) +}; +Axis.prototype.convertPixelsToAxisPadding = function convertPixelsToAxisPadding( + pixels, + domainLength +) { + var $$ = this.owner, + length = $$.config.axis_rotated ? $$.width : $$.height; + return domainLength * (pixels / length) +}; +Axis.prototype.generateTickValues = function generateTickValues( + values, + tickCount, + forTimeSeries +) { + var tickValues = values, + targetCount, + start, + end, + count, + interval, + i, + tickValue; + if (tickCount) { + targetCount = isFunction(tickCount) ? tickCount() : tickCount; + // compute ticks according to tickCount + if (targetCount === 1) { + tickValues = [values[0]]; + } else if (targetCount === 2) { + tickValues = [values[0], values[values.length - 1]]; + } else if (targetCount > 2) { + count = targetCount - 2; + start = values[0]; + end = values[values.length - 1]; + interval = (end - start) / (count + 1); + // re-construct unique values + tickValues = [start]; + for (i = 0; i < count; i++) { + tickValue = +start + interval * (i + 1); + tickValues.push(forTimeSeries ? new Date(tickValue) : tickValue); + } + tickValues.push(end); + } + } + if (!forTimeSeries) { + tickValues = tickValues.sort(function(a, b) { + return a - b + }); + } + return tickValues +}; +Axis.prototype.generateTransitions = function generateTransitions(duration) { + var $$ = this.owner, + axes = $$.axes; + return { + axisX: duration ? axes.x.transition().duration(duration) : axes.x, + axisY: duration ? axes.y.transition().duration(duration) : axes.y, + axisY2: duration ? axes.y2.transition().duration(duration) : axes.y2, + axisSubX: duration ? axes.subx.transition().duration(duration) : axes.subx + } +}; +Axis.prototype.redraw = function redraw(duration, isHidden) { + var $$ = this.owner, + transition = duration ? $$.d3.transition().duration(duration) : null; + $$.axes.x.style('opacity', isHidden ? 0 : 1).call($$.xAxis, transition); + $$.axes.y.style('opacity', isHidden ? 0 : 1).call($$.yAxis, transition); + $$.axes.y2.style('opacity', isHidden ? 0 : 1).call($$.y2Axis, transition); + $$.axes.subx.style('opacity', isHidden ? 0 : 1).call($$.subXAxis, transition); +}; + +var c3 = { + version: '0.7.18', + chart: { + fn: Chart.prototype, + internal: { + fn: ChartInternal.prototype, + axis: { + fn: Axis.prototype, + internal: { + fn: AxisInternal.prototype + } + } + } + }, + generate: function(config) { + return new Chart(config) + } +}; + +ChartInternal.prototype.beforeInit = function() { + // can do something +}; +ChartInternal.prototype.afterInit = function() { + // can do something +}; +ChartInternal.prototype.init = function() { + var $$ = this, + config = $$.config; + + $$.initParams(); + + if (config.data_url) { + $$.convertUrlToData( + config.data_url, + config.data_mimeType, + config.data_headers, + config.data_keys, + $$.initWithData + ); + } else if (config.data_json) { + $$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); + } else if (config.data_rows) { + $$.initWithData($$.convertRowsToData(config.data_rows)); + } else if (config.data_columns) { + $$.initWithData($$.convertColumnsToData(config.data_columns)); + } else { + throw Error('url or json or rows or columns is required.') + } +}; + +ChartInternal.prototype.initParams = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config; + + // MEMO: clipId needs to be unique because it conflicts when multiple charts exist + $$.clipId = 'c3-' + new Date().valueOf() + '-clip'; + $$.clipIdForXAxis = $$.clipId + '-xaxis'; + $$.clipIdForYAxis = $$.clipId + '-yaxis'; + $$.clipIdForGrid = $$.clipId + '-grid'; + $$.clipIdForSubchart = $$.clipId + '-subchart'; + $$.clipPath = $$.getClipPath($$.clipId); + $$.clipPathForXAxis = $$.getClipPath($$.clipIdForXAxis); + $$.clipPathForYAxis = $$.getClipPath($$.clipIdForYAxis); + $$.clipPathForGrid = $$.getClipPath($$.clipIdForGrid); + $$.clipPathForSubchart = $$.getClipPath($$.clipIdForSubchart); + + $$.dragStart = null; + $$.dragging = false; + $$.flowing = false; + $$.cancelClick = false; + $$.mouseover = undefined; + $$.transiting = false; + + $$.color = $$.generateColor(); + $$.levelColor = $$.generateLevelColor(); + + $$.dataTimeParse = (config.data_xLocaltime ? d3.timeParse : d3.utcParse)( + $$.config.data_xFormat + ); + $$.axisTimeFormat = config.axis_x_localtime ? d3.timeFormat : d3.utcFormat; + $$.defaultAxisTimeFormat = function(date) { + if (date.getMilliseconds()) { + return d3.timeFormat('.%L')(date) + } + if (date.getSeconds()) { + return d3.timeFormat(':%S')(date) + } + if (date.getMinutes()) { + return d3.timeFormat('%I:%M')(date) + } + if (date.getHours()) { + return d3.timeFormat('%I %p')(date) + } + if (date.getDay() && date.getDate() !== 1) { + return d3.timeFormat('%-m/%-d')(date) + } + if (date.getDate() !== 1) { + return d3.timeFormat('%-m/%-d')(date) + } + if (date.getMonth()) { + return d3.timeFormat('%-m/%-d')(date) + } + return d3.timeFormat('%Y/%-m/%-d')(date) + }; + $$.hiddenTargetIds = []; + $$.hiddenLegendIds = []; + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; + + $$.xOrient = config.axis_rotated + ? config.axis_x_inner + ? 'right' + : 'left' + : config.axis_x_inner + ? 'top' + : 'bottom'; + $$.yOrient = config.axis_rotated + ? config.axis_y_inner + ? 'top' + : 'bottom' + : config.axis_y_inner + ? 'right' + : 'left'; + $$.y2Orient = config.axis_rotated + ? config.axis_y2_inner + ? 'bottom' + : 'top' + : config.axis_y2_inner + ? 'left' + : 'right'; + $$.subXOrient = config.axis_rotated ? 'left' : 'bottom'; + + $$.isLegendRight = config.legend_position === 'right'; + $$.isLegendInset = config.legend_position === 'inset'; + $$.isLegendTop = + config.legend_inset_anchor === 'top-left' || + config.legend_inset_anchor === 'top-right'; + $$.isLegendLeft = + config.legend_inset_anchor === 'top-left' || + config.legend_inset_anchor === 'bottom-left'; + $$.legendStep = 0; + $$.legendItemWidth = 0; + $$.legendItemHeight = 0; + + $$.currentMaxTickWidths = { + x: 0, + y: 0, + y2: 0 + }; + + $$.rotated_padding_left = 30; + $$.rotated_padding_right = config.axis_rotated && !config.axis_x_show ? 0 : 30; + $$.rotated_padding_top = 5; + + $$.withoutFadeIn = {}; + + $$.intervalForObserveInserted = undefined; + + $$.axes.subx = d3.selectAll([]); // needs when excluding subchart.js +}; + +ChartInternal.prototype.initChartElements = function() { + if (this.initBar) { + this.initBar(); + } + if (this.initLine) { + this.initLine(); + } + if (this.initArc) { + this.initArc(); + } + if (this.initGauge) { + this.initGauge(); + } + if (this.initText) { + this.initText(); + } +}; + +ChartInternal.prototype.initWithData = function(data) { + var $$ = this, + d3 = $$.d3, + config = $$.config; + var defs, + main, + binding = true; + + $$.axis = new Axis($$); + + if (!config.bindto) { + $$.selectChart = d3.selectAll([]); + } else if (typeof config.bindto.node === 'function') { + $$.selectChart = config.bindto; + } else { + $$.selectChart = d3.select(config.bindto); + } + if ($$.selectChart.empty()) { + $$.selectChart = d3 + .select(document.createElement('div')) + .style('opacity', 0); + $$.observeInserted($$.selectChart); + binding = false; + } + $$.selectChart.html('').classed('c3', true); + + // Init data as targets + $$.data.xs = {}; + $$.data.targets = $$.convertDataToTargets(data); + + if (config.data_filter) { + $$.data.targets = $$.data.targets.filter(config.data_filter); + } + + // Set targets to hide if needed + if (config.data_hide) { + $$.addHiddenTargetIds( + config.data_hide === true + ? $$.mapToIds($$.data.targets) + : config.data_hide + ); + } + if (config.legend_hide) { + $$.addHiddenLegendIds( + config.legend_hide === true + ? $$.mapToIds($$.data.targets) + : config.legend_hide + ); + } + + if ($$.isStanfordGraphType()) { + $$.initStanfordData(); + } + + // Init sizes and scales + $$.updateSizes(); + $$.updateScales(); + + // Set domains for each scale + $$.x.domain(d3.extent($$.getXDomain($$.data.targets))); + $$.y.domain($$.getYDomain($$.data.targets, 'y')); + $$.y2.domain($$.getYDomain($$.data.targets, 'y2')); + $$.subX.domain($$.x.domain()); + $$.subY.domain($$.y.domain()); + $$.subY2.domain($$.y2.domain()); + + // Save original x domain for zoom update + $$.orgXDomain = $$.x.domain(); + + /*-- Basic Elements --*/ + + // Define svgs + $$.svg = $$.selectChart + .append('svg') + .style('overflow', 'hidden') + .on('mouseenter', function() { + return config.onmouseover.call($$) + }) + .on('mouseleave', function() { + return config.onmouseout.call($$) + }); + + if ($$.config.svg_classname) { + $$.svg.attr('class', $$.config.svg_classname); + } + + // Define defs + defs = $$.svg.append('defs'); + $$.clipChart = $$.appendClip(defs, $$.clipId); + $$.clipXAxis = $$.appendClip(defs, $$.clipIdForXAxis); + $$.clipYAxis = $$.appendClip(defs, $$.clipIdForYAxis); + $$.clipGrid = $$.appendClip(defs, $$.clipIdForGrid); + $$.clipSubchart = $$.appendClip(defs, $$.clipIdForSubchart); + $$.updateSvgSize(); + + // Define regions + main = $$.main = $$.svg.append('g').attr('transform', $$.getTranslate('main')); + + if ($$.initPie) { + $$.initPie(); + } + if ($$.initDragZoom) { + $$.initDragZoom(); + } + if (config.subchart_show && $$.initSubchart) { + $$.initSubchart(); + } + if ($$.initTooltip) { + $$.initTooltip(); + } + if ($$.initLegend) { + $$.initLegend(); + } + if ($$.initTitle) { + $$.initTitle(); + } + if ($$.initZoom) { + $$.initZoom(); + } + if ($$.isStanfordGraphType()) { + $$.drawColorScale(); + } + + // Update selection based on size and scale + // TODO: currently this must be called after initLegend because of update of sizes, but it should be done in initSubchart. + if (config.subchart_show && $$.initSubchartBrush) { + $$.initSubchartBrush(); + } + + /*-- Main Region --*/ + + // text when empty + main + .append('text') + .attr('class', CLASS.text + ' ' + CLASS.empty) + .attr('text-anchor', 'middle') // horizontal centering of text at x position in all browsers. + .attr('dominant-baseline', 'middle'); // vertical centering of text at y position in all browsers, except IE. + + // Regions + $$.initRegion(); + + // Grids + $$.initGrid(); + + // Define g for chart area + main + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.chart); + + // Grid lines + if (config.grid_lines_front) { + $$.initGridLines(); + } + + $$.initStanfordElements(); + + // Cover whole with rects for events + $$.initEventRect(); + + // Define g for chart + $$.initChartElements(); + + // Add Axis + $$.axis.init(); + + // Set targets + $$.updateTargets($$.data.targets); + + // Set default extent if defined + if (config.axis_x_selection) { + $$.brush.selectionAsValue($$.getDefaultSelection()); + } + + // Draw with targets + if (binding) { + $$.updateDimension(); + $$.config.oninit.call($$); + $$.redraw({ + withTransition: false, + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransitionForAxis: false + }); + } + + // Bind to resize event + $$.bindResize(); + + // Bind to window focus event + $$.bindWindowFocus(); + + // export element of the chart + $$.api.element = $$.selectChart.node(); +}; + +ChartInternal.prototype.smoothLines = function(el, type) { + var $$ = this; + if (type === 'grid') { + el.each(function() { + var g = $$.d3.select(this), + x1 = g.attr('x1'), + x2 = g.attr('x2'), + y1 = g.attr('y1'), + y2 = g.attr('y2'); + g.attr({ + x1: Math.ceil(x1), + x2: Math.ceil(x2), + y1: Math.ceil(y1), + y2: Math.ceil(y2) + }); + }); + } +}; + +ChartInternal.prototype.updateSizes = function() { + var $$ = this, + config = $$.config; + var legendHeight = $$.legend ? $$.getLegendHeight() : 0, + legendWidth = $$.legend ? $$.getLegendWidth() : 0, + legendHeightForBottom = + $$.isLegendRight || $$.isLegendInset ? 0 : legendHeight, + hasArc = $$.hasArcType(), + xAxisHeight = + config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), + subchartHeight = + config.subchart_show && !hasArc + ? config.subchart_size_height + xAxisHeight + : 0; + + $$.currentWidth = $$.getCurrentWidth(); + $$.currentHeight = $$.getCurrentHeight(); + + // for main + $$.margin = config.axis_rotated + ? { + top: $$.getHorizontalAxisHeight('y2') + $$.getCurrentPaddingTop(), + right: hasArc ? 0 : $$.getCurrentPaddingRight(), + bottom: + $$.getHorizontalAxisHeight('y') + + legendHeightForBottom + + $$.getCurrentPaddingBottom(), + left: subchartHeight + (hasArc ? 0 : $$.getCurrentPaddingLeft()) + } + : { + top: 4 + $$.getCurrentPaddingTop(), // for top tick text + right: hasArc ? 0 : $$.getCurrentPaddingRight(), + bottom: + xAxisHeight + + subchartHeight + + legendHeightForBottom + + $$.getCurrentPaddingBottom(), + left: hasArc ? 0 : $$.getCurrentPaddingLeft() + }; + + // for subchart + $$.margin2 = config.axis_rotated + ? { + top: $$.margin.top, + right: NaN, + bottom: 20 + legendHeightForBottom, + left: $$.rotated_padding_left + } + : { + top: $$.currentHeight - subchartHeight - legendHeightForBottom, + right: NaN, + bottom: xAxisHeight + legendHeightForBottom, + left: $$.margin.left + }; + + // for legend + $$.margin3 = { + top: 0, + right: NaN, + bottom: 0, + left: 0 + }; + if ($$.updateSizeForLegend) { + $$.updateSizeForLegend(legendHeight, legendWidth); + } + + $$.width = $$.currentWidth - $$.margin.left - $$.margin.right; + $$.height = $$.currentHeight - $$.margin.top - $$.margin.bottom; + if ($$.width < 0) { + $$.width = 0; + } + if ($$.height < 0) { + $$.height = 0; + } + + $$.width2 = config.axis_rotated + ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right + : $$.width; + $$.height2 = config.axis_rotated + ? $$.height + : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; + if ($$.width2 < 0) { + $$.width2 = 0; + } + if ($$.height2 < 0) { + $$.height2 = 0; + } + + // for arc + $$.arcWidth = $$.width - ($$.isLegendRight ? legendWidth + 10 : 0); + $$.arcHeight = $$.height - ($$.isLegendRight ? 0 : 10); + if ($$.hasType('gauge') && !config.gauge_fullCircle) { + $$.arcHeight += $$.height - $$.getGaugeLabelHeight(); + } + if ($$.updateRadius) { + $$.updateRadius(); + } + + if ($$.isLegendRight && hasArc) { + $$.margin3.left = $$.arcWidth / 2 + $$.radiusExpanded * 1.1; + } +}; + +ChartInternal.prototype.updateTargets = function(targets) { + var $$ = this, + config = $$.config; + + /*-- Main --*/ + + //-- Text --// + $$.updateTargetsForText(targets); + + //-- Bar --// + $$.updateTargetsForBar(targets); + + //-- Line --// + $$.updateTargetsForLine(targets); + + //-- Arc --// + if ($$.hasArcType() && $$.updateTargetsForArc) { + $$.updateTargetsForArc(targets); + } + + /*-- Sub --*/ + + if (config.subchart_show && $$.updateTargetsForSubchart) { + $$.updateTargetsForSubchart(targets); + } + + // Fade-in each chart + $$.showTargets(); +}; +ChartInternal.prototype.showTargets = function() { + var $$ = this; + $$.svg + .selectAll('.' + CLASS.target) + .filter(function(d) { + return $$.isTargetToShow(d.id) + }) + .transition() + .duration($$.config.transition_duration) + .style('opacity', 1); +}; + +ChartInternal.prototype.redraw = function(options, transitions) { + var $$ = this, + main = $$.main, + d3 = $$.d3, + config = $$.config; + var areaIndices = $$.getShapeIndices($$.isAreaType), + barIndices = $$.getShapeIndices($$.isBarType), + lineIndices = $$.getShapeIndices($$.isLineType); + var withY, + withSubchart, + withTransition, + withTransitionForExit, + withTransitionForAxis, + withTransform, + withUpdateXDomain, + withUpdateOrgXDomain, + withTrimXDomain, + withLegend, + withEventRect, + withDimension, + withUpdateXAxis; + var hideAxis = $$.hasArcType(); + var drawArea, drawBar, drawLine, xForText, yForText; + var duration, durationForExit, durationForAxis; + var transitionsToWait, waitForDraw, flow, transition; + var targetsToShow = $$.filterTargetsToShow($$.data.targets), + tickValues, + i, + intervalForCulling, + xDomainForZoom; + var xv = $$.xv.bind($$), + cx, + cy; + + options = options || {}; + withY = getOption(options, 'withY', true); + withSubchart = getOption(options, 'withSubchart', true); + withTransition = getOption(options, 'withTransition', true); + withTransform = getOption(options, 'withTransform', false); + withUpdateXDomain = getOption(options, 'withUpdateXDomain', false); + withUpdateOrgXDomain = getOption(options, 'withUpdateOrgXDomain', false); + withTrimXDomain = getOption(options, 'withTrimXDomain', true); + withUpdateXAxis = getOption(options, 'withUpdateXAxis', withUpdateXDomain); + withLegend = getOption(options, 'withLegend', false); + withEventRect = getOption(options, 'withEventRect', true); + withDimension = getOption(options, 'withDimension', true); + withTransitionForExit = getOption( + options, + 'withTransitionForExit', + withTransition + ); + withTransitionForAxis = getOption( + options, + 'withTransitionForAxis', + withTransition + ); + + duration = withTransition ? config.transition_duration : 0; + durationForExit = withTransitionForExit ? duration : 0; + durationForAxis = withTransitionForAxis ? duration : 0; + + transitions = transitions || $$.axis.generateTransitions(durationForAxis); + + // update legend and transform each g + if (withLegend && config.legend_show) { + $$.updateLegend($$.mapToIds($$.data.targets), options, transitions); + } else if (withDimension) { + // need to update dimension (e.g. axis.y.tick.values) because y tick values should change + // no need to update axis in it because they will be updated in redraw() + $$.updateDimension(true); + } + + // MEMO: needed for grids calculation + if ($$.isCategorized() && targetsToShow.length === 0) { + $$.x.domain([0, $$.axes.x.selectAll('.tick').size()]); + } + + if (targetsToShow.length) { + $$.updateXDomain( + targetsToShow, + withUpdateXDomain, + withUpdateOrgXDomain, + withTrimXDomain + ); + if (!config.axis_x_tick_values) { + tickValues = $$.axis.updateXAxisTickValues(targetsToShow); + } + } else { + $$.xAxis.tickValues([]); + $$.subXAxis.tickValues([]); + } + + if (config.zoom_rescale && !options.flow) { + xDomainForZoom = $$.x.orgDomain(); + } + + $$.y.domain($$.getYDomain(targetsToShow, 'y', xDomainForZoom)); + $$.y2.domain($$.getYDomain(targetsToShow, 'y2', xDomainForZoom)); + + if (!config.axis_y_tick_values && config.axis_y_tick_count) { + $$.yAxis.tickValues( + $$.axis.generateTickValues($$.y.domain(), config.axis_y_tick_count) + ); + } + if (!config.axis_y2_tick_values && config.axis_y2_tick_count) { + $$.y2Axis.tickValues( + $$.axis.generateTickValues($$.y2.domain(), config.axis_y2_tick_count) + ); + } + + // axes + $$.axis.redraw(durationForAxis, hideAxis); + + // Update axis label + $$.axis.updateLabels(withTransition); + + // show/hide if manual culling needed + if ((withUpdateXDomain || withUpdateXAxis) && targetsToShow.length) { + if (config.axis_x_tick_culling && tickValues) { + for (i = 1; i < tickValues.length; i++) { + if (tickValues.length / i < config.axis_x_tick_culling_max) { + intervalForCulling = i; + break + } + } + $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').each(function(e) { + var index = tickValues.indexOf(e); + if (index >= 0) { + d3.select(this).style( + 'display', + index % intervalForCulling ? 'none' : 'block' + ); + } + }); + } else { + $$.svg + .selectAll('.' + CLASS.axisX + ' .tick text') + .style('display', 'block'); + } + } + + // setup drawer - MEMO: these must be called after axis updated + drawArea = $$.generateDrawArea + ? $$.generateDrawArea(areaIndices, false) + : undefined; + drawBar = $$.generateDrawBar ? $$.generateDrawBar(barIndices) : undefined; + drawLine = $$.generateDrawLine + ? $$.generateDrawLine(lineIndices, false) + : undefined; + xForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, true); + yForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, false); + + // update circleY based on updated parameters + $$.updateCircleY(); + // generate circle x/y functions depending on updated params + cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$); + cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); + + // Update sub domain + if (withY) { + $$.subY.domain($$.getYDomain(targetsToShow, 'y')); + $$.subY2.domain($$.getYDomain(targetsToShow, 'y2')); + } + + // xgrid focus + $$.updateXgridFocus(); + + // Data empty label positioning and text. + main + .select('text.' + CLASS.text + '.' + CLASS.empty) + .attr('x', $$.width / 2) + .attr('y', $$.height / 2) + .text(config.data_empty_label_text) + .transition() + .style('opacity', targetsToShow.length ? 0 : 1); + + // event rect + if (withEventRect) { + $$.redrawEventRect(); + } + + // grid + $$.updateGrid(duration); + + $$.updateStanfordElements(duration); + + // rect for regions + $$.updateRegion(duration); + + // bars + $$.updateBar(durationForExit); + + // lines, areas and circles + $$.updateLine(durationForExit); + $$.updateArea(durationForExit); + $$.updateCircle(cx, cy); + + // text + if ($$.hasDataLabel()) { + $$.updateText(xForText, yForText, durationForExit); + } + + // title + if ($$.redrawTitle) { + $$.redrawTitle(); + } + + // arc + if ($$.redrawArc) { + $$.redrawArc(duration, durationForExit, withTransform); + } + + // subchart + if (config.subchart_show && $$.redrawSubchart) { + $$.redrawSubchart( + withSubchart, + transitions, + duration, + durationForExit, + areaIndices, + barIndices, + lineIndices + ); + } + + if ($$.isStanfordGraphType()) { + $$.drawColorScale(); + } + + // circles for select + main + .selectAll('.' + CLASS.selectedCircles) + .filter($$.isBarType.bind($$)) + .selectAll('circle') + .remove(); + + if (options.flow) { + flow = $$.generateFlow({ + targets: targetsToShow, + flow: options.flow, + duration: options.flow.duration, + drawBar: drawBar, + drawLine: drawLine, + drawArea: drawArea, + cx: cx, + cy: cy, + xv: xv, + xForText: xForText, + yForText: yForText + }); + } + + if (duration && $$.isTabVisible()) { + // Only use transition if tab visible. See #938. + // transition should be derived from one transition + transition = d3.transition().duration(duration); + transitionsToWait = [] + ;[ + $$.redrawBar(drawBar, true, transition), + $$.redrawLine(drawLine, true, transition), + $$.redrawArea(drawArea, true, transition), + $$.redrawCircle(cx, cy, true, transition), + $$.redrawText(xForText, yForText, options.flow, true, transition), + $$.redrawRegion(true, transition), + $$.redrawGrid(true, transition) + ].forEach(function(transitions) { + transitions.forEach(function(transition) { + transitionsToWait.push(transition); + }); + }); + // Wait for end of transitions to call flow and onrendered callback + waitForDraw = $$.generateWait(); + transitionsToWait.forEach(function(t) { + waitForDraw.add(t); + }); + waitForDraw(function() { + if (flow) { + flow(); + } + if (config.onrendered) { + config.onrendered.call($$); + } + }); + } else { + $$.redrawBar(drawBar); + $$.redrawLine(drawLine); + $$.redrawArea(drawArea); + $$.redrawCircle(cx, cy); + $$.redrawText(xForText, yForText, options.flow); + $$.redrawRegion(); + $$.redrawGrid(); + if (flow) { + flow(); + } + if (config.onrendered) { + config.onrendered.call($$); + } + } + + // update fadein condition + $$.mapToIds($$.data.targets).forEach(function(id) { + $$.withoutFadeIn[id] = true; + }); +}; + +ChartInternal.prototype.updateAndRedraw = function(options) { + var $$ = this, + config = $$.config, + transitions; + options = options || {}; + // same with redraw + options.withTransition = getOption(options, 'withTransition', true); + options.withTransform = getOption(options, 'withTransform', false); + options.withLegend = getOption(options, 'withLegend', false); + // NOT same with redraw + options.withUpdateXDomain = getOption(options, 'withUpdateXDomain', true); + options.withUpdateOrgXDomain = getOption( + options, + 'withUpdateOrgXDomain', + true + ); + options.withTransitionForExit = false; + options.withTransitionForTransform = getOption( + options, + 'withTransitionForTransform', + options.withTransition + ); + // MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called) + $$.updateSizes(); + // MEMO: called in updateLegend in redraw if withLegend + if (!(options.withLegend && config.legend_show)) { + transitions = $$.axis.generateTransitions( + options.withTransitionForAxis ? config.transition_duration : 0 + ); + // Update scales + $$.updateScales(); + $$.updateSvgSize(); + // Update g positions + $$.transformAll(options.withTransitionForTransform, transitions); + } + // Draw with new sizes & scales + $$.redraw(options, transitions); +}; +ChartInternal.prototype.redrawWithoutRescale = function() { + this.redraw({ + withY: false, + withSubchart: false, + withEventRect: false, + withTransitionForAxis: false + }); +}; + +ChartInternal.prototype.isTimeSeries = function() { + return this.config.axis_x_type === 'timeseries' +}; +ChartInternal.prototype.isCategorized = function() { + return this.config.axis_x_type.indexOf('categor') >= 0 +}; +ChartInternal.prototype.isCustomX = function() { + var $$ = this, + config = $$.config; + return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)) +}; + +ChartInternal.prototype.isTimeSeriesY = function() { + return this.config.axis_y_type === 'timeseries' +}; + +ChartInternal.prototype.getTranslate = function(target) { + var $$ = this, + config = $$.config, + x, + y; + if (target === 'main') { + x = asHalfPixel($$.margin.left); + y = asHalfPixel($$.margin.top); + } else if (target === 'context') { + x = asHalfPixel($$.margin2.left); + y = asHalfPixel($$.margin2.top); + } else if (target === 'legend') { + x = $$.margin3.left; + y = $$.margin3.top; + } else if (target === 'x') { + x = 0; + y = config.axis_rotated ? 0 : $$.height; + } else if (target === 'y') { + x = 0; + y = config.axis_rotated ? $$.height : 0; + } else if (target === 'y2') { + x = config.axis_rotated ? 0 : $$.width; + y = config.axis_rotated ? 1 : 0; + } else if (target === 'subx') { + x = 0; + y = config.axis_rotated ? 0 : $$.height2; + } else if (target === 'arc') { + x = $$.arcWidth / 2; + y = $$.arcHeight / 2 - ($$.hasType('gauge') ? 6 : 0); // to prevent wrong display of min and max label + } + return 'translate(' + x + ',' + y + ')' +}; +ChartInternal.prototype.initialOpacity = function(d) { + return d.value !== null && this.withoutFadeIn[d.id] ? 1 : 0 +}; +ChartInternal.prototype.initialOpacityForCircle = function(d) { + return d.value !== null && this.withoutFadeIn[d.id] + ? this.opacityForCircle(d) + : 0 +}; +ChartInternal.prototype.opacityForCircle = function(d) { + var isPointShouldBeShown = isFunction(this.config.point_show) + ? this.config.point_show(d) + : this.config.point_show; + var opacity = isPointShouldBeShown || this.isStanfordType(d) ? 1 : 0; + return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0 +}; +ChartInternal.prototype.opacityForText = function() { + return this.hasDataLabel() ? 1 : 0 +}; +ChartInternal.prototype.xx = function(d) { + return d ? this.x(d.x) : null +}; +ChartInternal.prototype.xvCustom = function(d, xyValue) { + var $$ = this, + value = xyValue ? d[xyValue] : d.value; + if ($$.isTimeSeries()) { + value = $$.parseDate(d.value); + } else if ($$.isCategorized() && typeof d.value === 'string') { + value = $$.config.axis_x_categories.indexOf(d.value); + } + return Math.ceil($$.x(value)) +}; +ChartInternal.prototype.yvCustom = function(d, xyValue) { + var $$ = this, + yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y, + value = xyValue ? d[xyValue] : d.value; + return Math.ceil(yScale(value)) +}; +ChartInternal.prototype.xv = function(d) { + var $$ = this, + value = d.value; + if ($$.isTimeSeries()) { + value = $$.parseDate(d.value); + } else if ($$.isCategorized() && typeof d.value === 'string') { + value = $$.config.axis_x_categories.indexOf(d.value); + } + return Math.ceil($$.x(value)) +}; +ChartInternal.prototype.yv = function(d) { + var $$ = this, + yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y; + return Math.ceil(yScale(d.value)) +}; +ChartInternal.prototype.subxx = function(d) { + return d ? this.subX(d.x) : null +}; + +ChartInternal.prototype.transformMain = function(withTransition, transitions) { + var $$ = this, + xAxis, + yAxis, + y2Axis; + if (transitions && transitions.axisX) { + xAxis = transitions.axisX; + } else { + xAxis = $$.main.select('.' + CLASS.axisX); + if (withTransition) { + xAxis = xAxis.transition(); + } + } + if (transitions && transitions.axisY) { + yAxis = transitions.axisY; + } else { + yAxis = $$.main.select('.' + CLASS.axisY); + if (withTransition) { + yAxis = yAxis.transition(); + } + } + if (transitions && transitions.axisY2) { + y2Axis = transitions.axisY2; + } else { + y2Axis = $$.main.select('.' + CLASS.axisY2); + if (withTransition) { + y2Axis = y2Axis.transition(); + } + } +(withTransition ? $$.main.transition() : $$.main).attr( + 'transform', + $$.getTranslate('main') + ); + xAxis.attr('transform', $$.getTranslate('x')); + yAxis.attr('transform', $$.getTranslate('y')); + y2Axis.attr('transform', $$.getTranslate('y2')); + $$.main + .select('.' + CLASS.chartArcs) + .attr('transform', $$.getTranslate('arc')); +}; +ChartInternal.prototype.transformAll = function(withTransition, transitions) { + var $$ = this; + $$.transformMain(withTransition, transitions); + if ($$.config.subchart_show) { + $$.transformContext(withTransition, transitions); + } + if ($$.legend) { + $$.transformLegend(withTransition); + } +}; + +ChartInternal.prototype.updateSvgSize = function() { + var $$ = this, + brush = $$.svg.select(`.${CLASS.brush} .overlay`); + $$.svg.attr('width', $$.currentWidth).attr('height', $$.currentHeight); + $$.svg + .selectAll(['#' + $$.clipId, '#' + $$.clipIdForGrid]) + .select('rect') + .attr('width', $$.width) + .attr('height', $$.height); + $$.svg + .select('#' + $$.clipIdForXAxis) + .select('rect') + .attr('x', $$.getXAxisClipX.bind($$)) + .attr('y', $$.getXAxisClipY.bind($$)) + .attr('width', $$.getXAxisClipWidth.bind($$)) + .attr('height', $$.getXAxisClipHeight.bind($$)); + $$.svg + .select('#' + $$.clipIdForYAxis) + .select('rect') + .attr('x', $$.getYAxisClipX.bind($$)) + .attr('y', $$.getYAxisClipY.bind($$)) + .attr('width', $$.getYAxisClipWidth.bind($$)) + .attr('height', $$.getYAxisClipHeight.bind($$)); + $$.svg + .select('#' + $$.clipIdForSubchart) + .select('rect') + .attr('width', $$.width) + .attr('height', (brush.size() && brush.attr('height')) || 0); + // MEMO: parent div's height will be bigger than svg when + $$.selectChart.style('max-height', $$.currentHeight + 'px'); +}; + +ChartInternal.prototype.updateDimension = function(withoutAxis) { + var $$ = this; + if (!withoutAxis) { + if ($$.config.axis_rotated) { + $$.axes.x.call($$.xAxis); + $$.axes.subx.call($$.subXAxis); + } else { + $$.axes.y.call($$.yAxis); + $$.axes.y2.call($$.y2Axis); + } + } + $$.updateSizes(); + $$.updateScales(); + $$.updateSvgSize(); + $$.transformAll(false); +}; + +ChartInternal.prototype.observeInserted = function(selection) { + var $$ = this, + observer; + if (typeof MutationObserver === 'undefined') { + window.console.error('MutationObserver not defined.'); + return + } + observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.type === 'childList' && mutation.previousSibling) { + observer.disconnect(); + // need to wait for completion of load because size calculation requires the actual sizes determined after that completion + $$.intervalForObserveInserted = window.setInterval(function() { + // parentNode will NOT be null when completed + if (selection.node().parentNode) { + window.clearInterval($$.intervalForObserveInserted); + $$.updateDimension(); + if ($$.brush) { + $$.brush.update(); + } + $$.config.oninit.call($$); + $$.redraw({ + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransition: false, + withTransitionForTransform: false, + withLegend: true + }); + selection.transition().style('opacity', 1); + } + }, 10); + } + }); + }); + observer.observe(selection.node(), { + attributes: true, + childList: true, + characterData: true + }); +}; + +/** + * Binds handlers to the window resize event. + */ +ChartInternal.prototype.bindResize = function() { + var $$ = this, + config = $$.config; + + $$.resizeFunction = $$.generateResize(); // need to call .remove + + $$.resizeFunction.add(function() { + config.onresize.call($$); + }); + if (config.resize_auto) { + $$.resizeFunction.add(function() { + if ($$.resizeTimeout !== undefined) { + window.clearTimeout($$.resizeTimeout); + } + $$.resizeTimeout = window.setTimeout(function() { + delete $$.resizeTimeout; + $$.updateAndRedraw({ + withUpdateXDomain: false, + withUpdateOrgXDomain: false, + withTransition: false, + withTransitionForTransform: false, + withLegend: true + }); + if ($$.brush) { + $$.brush.update(); + } + }, 100); + }); + } + $$.resizeFunction.add(function() { + config.onresized.call($$); + }); + + $$.resizeIfElementDisplayed = function() { + // if element not displayed skip it + if ($$.api == null || !$$.api.element.offsetParent) { + return + } + + $$.resizeFunction(); + }; + + if (window.attachEvent) { + window.attachEvent('onresize', $$.resizeIfElementDisplayed); + } else if (window.addEventListener) { + window.addEventListener('resize', $$.resizeIfElementDisplayed, false); + } else { + // fallback to this, if this is a very old browser + var wrapper = window.onresize; + if (!wrapper) { + // create a wrapper that will call all charts + wrapper = $$.generateResize(); + } else if (!wrapper.add || !wrapper.remove) { + // there is already a handler registered, make sure we call it too + wrapper = $$.generateResize(); + wrapper.add(window.onresize); + } + // add this graph to the wrapper, we will be removed if the user calls destroy + wrapper.add($$.resizeFunction); + window.onresize = function() { + // if element not displayed skip it + if (!$$.api.element.offsetParent) { + return + } + + wrapper(); + }; + } +}; + +/** + * Binds handlers to the window focus event. + */ +ChartInternal.prototype.bindWindowFocus = function() { + if (this.windowFocusHandler) { + // The handler is already set + return + } + + this.windowFocusHandler = () => { + this.redraw(); + }; + + window.addEventListener('focus', this.windowFocusHandler); +}; + +/** + * Unbinds from the window focus event. + */ +ChartInternal.prototype.unbindWindowFocus = function() { + window.removeEventListener('focus', this.windowFocusHandler); + delete this.windowFocusHandler; +}; + +ChartInternal.prototype.generateResize = function() { + var resizeFunctions = []; + + function callResizeFunctions() { + resizeFunctions.forEach(function(f) { + f(); + }); + } + callResizeFunctions.add = function(f) { + resizeFunctions.push(f); + }; + callResizeFunctions.remove = function(f) { + for (var i = 0; i < resizeFunctions.length; i++) { + if (resizeFunctions[i] === f) { + resizeFunctions.splice(i, 1); + break + } + } + }; + return callResizeFunctions +}; + +ChartInternal.prototype.endall = function(transition, callback) { + var n = 0; + transition + .each(function() { + ++n; + }) + .on('end', function() { + if (!--n) { + callback.apply(this, arguments); + } + }); +}; +ChartInternal.prototype.generateWait = function() { + var $$ = this; + var transitionsToWait = [], + f = function(callback) { + var timer = setInterval(function() { + if (!$$.isTabVisible()) { + return + } + + var done = 0; + transitionsToWait.forEach(function(t) { + if (t.empty()) { + done += 1; + return + } + try { + t.transition(); + } catch (e) { + done += 1; + } + }); + if (done === transitionsToWait.length) { + clearInterval(timer); + if (callback) { + callback(); + } + } + }, 50); + }; + f.add = function(transition) { + transitionsToWait.push(transition); + }; + return f +}; + +ChartInternal.prototype.parseDate = function(date) { + var $$ = this, + parsedDate; + if (date instanceof Date) { + parsedDate = date; + } else if (typeof date === 'string') { + parsedDate = $$.dataTimeParse(date); + } else if (typeof date === 'object') { + parsedDate = new Date(+date); + } else if (typeof date === 'number' && !isNaN(date)) { + parsedDate = new Date(+date); + } + if (!parsedDate || isNaN(+parsedDate)) { + window.console.error("Failed to parse x '" + date + "' to Date object"); + } + return parsedDate +}; + +ChartInternal.prototype.isTabVisible = function() { + return !document.hidden +}; + +ChartInternal.prototype.getPathBox = getPathBox; +ChartInternal.prototype.CLASS = CLASS; + +/* jshint ignore:start */ +(function() { + if (!('SVGPathSeg' in window)) { + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg + window.SVGPathSeg = function(type, typeAsLetter, owningPathSegList) { + this.pathSegType = type; + this.pathSegTypeAsLetter = typeAsLetter; + this._owningPathSegList = owningPathSegList; + }; + + window.SVGPathSeg.prototype.classname = 'SVGPathSeg'; + + window.SVGPathSeg.PATHSEG_UNKNOWN = 0; + window.SVGPathSeg.PATHSEG_CLOSEPATH = 1; + window.SVGPathSeg.PATHSEG_MOVETO_ABS = 2; + window.SVGPathSeg.PATHSEG_MOVETO_REL = 3; + window.SVGPathSeg.PATHSEG_LINETO_ABS = 4; + window.SVGPathSeg.PATHSEG_LINETO_REL = 5; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; + window.SVGPathSeg.PATHSEG_ARC_ABS = 10; + window.SVGPathSeg.PATHSEG_ARC_REL = 11; + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; + + // Notify owning PathSegList on any changes so they can be synchronized back to the path element. + window.SVGPathSeg.prototype._segmentChanged = function() { + if (this._owningPathSegList) this._owningPathSegList.segmentChanged(this); + }; + + window.SVGPathSegClosePath = function(owningPathSegList) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CLOSEPATH, + 'z', + owningPathSegList + ); + }; + window.SVGPathSegClosePath.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegClosePath.prototype.toString = function() { + return '[object SVGPathSegClosePath]' + }; + window.SVGPathSegClosePath.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + }; + window.SVGPathSegClosePath.prototype.clone = function() { + return new window.SVGPathSegClosePath(undefined) + }; + + window.SVGPathSegMovetoAbs = function(owningPathSegList, x, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_MOVETO_ABS, + 'M', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegMovetoAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegMovetoAbs.prototype.toString = function() { + return '[object SVGPathSegMovetoAbs]' + }; + window.SVGPathSegMovetoAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegMovetoAbs.prototype.clone = function() { + return new window.SVGPathSegMovetoAbs(undefined, this._x, this._y) + }; + Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegMovetoRel = function(owningPathSegList, x, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_MOVETO_REL, + 'm', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegMovetoRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegMovetoRel.prototype.toString = function() { + return '[object SVGPathSegMovetoRel]' + }; + window.SVGPathSegMovetoRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegMovetoRel.prototype.clone = function() { + return new window.SVGPathSegMovetoRel(undefined, this._x, this._y) + }; + Object.defineProperty(window.SVGPathSegMovetoRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegMovetoRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoAbs = function(owningPathSegList, x, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_ABS, + 'L', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegLinetoAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoAbs.prototype.toString = function() { + return '[object SVGPathSegLinetoAbs]' + }; + window.SVGPathSegLinetoAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegLinetoAbs.prototype.clone = function() { + return new window.SVGPathSegLinetoAbs(undefined, this._x, this._y) + }; + Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoRel = function(owningPathSegList, x, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_REL, + 'l', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegLinetoRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoRel.prototype.toString = function() { + return '[object SVGPathSegLinetoRel]' + }; + window.SVGPathSegLinetoRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegLinetoRel.prototype.clone = function() { + return new window.SVGPathSegLinetoRel(undefined, this._x, this._y) + }; + Object.defineProperty(window.SVGPathSegLinetoRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegLinetoRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegCurvetoCubicAbs = function( + owningPathSegList, + x, + y, + x1, + y1, + x2, + y2 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, + 'C', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoCubicAbs.prototype.toString = function() { + return '[object SVGPathSegCurvetoCubicAbs]' + }; + window.SVGPathSegCurvetoCubicAbs.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoCubicAbs.prototype.clone = function() { + return new window.SVGPathSegCurvetoCubicAbs( + undefined, + this._x, + this._y, + this._x1, + this._y1, + this._x2, + this._y2 + ) + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x1', { + get: function() { + return this._x1 + }, + set: function(x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y1', { + get: function() { + return this._y1 + }, + set: function(y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x2', { + get: function() { + return this._x2 + }, + set: function(x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y2', { + get: function() { + return this._y2 + }, + set: function(y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegCurvetoCubicRel = function( + owningPathSegList, + x, + y, + x1, + y1, + x2, + y2 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, + 'c', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoCubicRel.prototype.toString = function() { + return '[object SVGPathSegCurvetoCubicRel]' + }; + window.SVGPathSegCurvetoCubicRel.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoCubicRel.prototype.clone = function() { + return new window.SVGPathSegCurvetoCubicRel( + undefined, + this._x, + this._y, + this._x1, + this._y1, + this._x2, + this._y2 + ) + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x1', { + get: function() { + return this._x1 + }, + set: function(x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y1', { + get: function() { + return this._y1 + }, + set: function(y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x2', { + get: function() { + return this._x2 + }, + set: function(x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y2', { + get: function() { + return this._y2 + }, + set: function(y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegCurvetoQuadraticAbs = function( + owningPathSegList, + x, + y, + x1, + y1 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, + 'Q', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoQuadraticAbs.prototype.toString = function() { + return '[object SVGPathSegCurvetoQuadraticAbs]' + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype.clone = function() { + return new window.SVGPathSegCurvetoQuadraticAbs( + undefined, + this._x, + this._y, + this._x1, + this._y1 + ) + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticAbs.prototype, + 'x1', + { + get: function() { + return this._x1 + }, + set: function(x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticAbs.prototype, + 'y1', + { + get: function() { + return this._y1 + }, + set: function(y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegCurvetoQuadraticRel = function( + owningPathSegList, + x, + y, + x1, + y1 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, + 'q', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + }; + window.SVGPathSegCurvetoQuadraticRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoQuadraticRel.prototype.toString = function() { + return '[object SVGPathSegCurvetoQuadraticRel]' + }; + window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoQuadraticRel.prototype.clone = function() { + return new window.SVGPathSegCurvetoQuadraticRel( + undefined, + this._x, + this._y, + this._x1, + this._y1 + ) + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticRel.prototype, + 'x1', + { + get: function() { + return this._x1 + }, + set: function(x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticRel.prototype, + 'y1', + { + get: function() { + return this._y1 + }, + set: function(y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegArcAbs = function( + owningPathSegList, + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_ARC_ABS, + 'A', + owningPathSegList + ); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + }; + window.SVGPathSegArcAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegArcAbs.prototype.toString = function() { + return '[object SVGPathSegArcAbs]' + }; + window.SVGPathSegArcAbs.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._r1 + + ' ' + + this._r2 + + ' ' + + this._angle + + ' ' + + (this._largeArcFlag ? '1' : '0') + + ' ' + + (this._sweepFlag ? '1' : '0') + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegArcAbs.prototype.clone = function() { + return new window.SVGPathSegArcAbs( + undefined, + this._x, + this._y, + this._r1, + this._r2, + this._angle, + this._largeArcFlag, + this._sweepFlag + ) + }; + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'r1', { + get: function() { + return this._r1 + }, + set: function(r1) { + this._r1 = r1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'r2', { + get: function() { + return this._r2 + }, + set: function(r2) { + this._r2 = r2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'angle', { + get: function() { + return this._angle + }, + set: function(angle) { + this._angle = angle; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'largeArcFlag', { + get: function() { + return this._largeArcFlag + }, + set: function(largeArcFlag) { + this._largeArcFlag = largeArcFlag; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'sweepFlag', { + get: function() { + return this._sweepFlag + }, + set: function(sweepFlag) { + this._sweepFlag = sweepFlag; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegArcRel = function( + owningPathSegList, + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_ARC_REL, + 'a', + owningPathSegList + ); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + }; + window.SVGPathSegArcRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegArcRel.prototype.toString = function() { + return '[object SVGPathSegArcRel]' + }; + window.SVGPathSegArcRel.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._r1 + + ' ' + + this._r2 + + ' ' + + this._angle + + ' ' + + (this._largeArcFlag ? '1' : '0') + + ' ' + + (this._sweepFlag ? '1' : '0') + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegArcRel.prototype.clone = function() { + return new window.SVGPathSegArcRel( + undefined, + this._x, + this._y, + this._r1, + this._r2, + this._angle, + this._largeArcFlag, + this._sweepFlag + ) + }; + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'r1', { + get: function() { + return this._r1 + }, + set: function(r1) { + this._r1 = r1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'r2', { + get: function() { + return this._r2 + }, + set: function(r2) { + this._r2 = r2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'angle', { + get: function() { + return this._angle + }, + set: function(angle) { + this._angle = angle; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'largeArcFlag', { + get: function() { + return this._largeArcFlag + }, + set: function(largeArcFlag) { + this._largeArcFlag = largeArcFlag; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'sweepFlag', { + get: function() { + return this._sweepFlag + }, + set: function(sweepFlag) { + this._sweepFlag = sweepFlag; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoHorizontalAbs = function(owningPathSegList, x) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, + 'H', + owningPathSegList + ); + this._x = x; + }; + window.SVGPathSegLinetoHorizontalAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoHorizontalAbs.prototype.toString = function() { + return '[object SVGPathSegLinetoHorizontalAbs]' + }; + window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + }; + window.SVGPathSegLinetoHorizontalAbs.prototype.clone = function() { + return new window.SVGPathSegLinetoHorizontalAbs(undefined, this._x) + }; + Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoHorizontalRel = function(owningPathSegList, x) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, + 'h', + owningPathSegList + ); + this._x = x; + }; + window.SVGPathSegLinetoHorizontalRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoHorizontalRel.prototype.toString = function() { + return '[object SVGPathSegLinetoHorizontalRel]' + }; + window.SVGPathSegLinetoHorizontalRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + }; + window.SVGPathSegLinetoHorizontalRel.prototype.clone = function() { + return new window.SVGPathSegLinetoHorizontalRel(undefined, this._x) + }; + Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoVerticalAbs = function(owningPathSegList, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, + 'V', + owningPathSegList + ); + this._y = y; + }; + window.SVGPathSegLinetoVerticalAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoVerticalAbs.prototype.toString = function() { + return '[object SVGPathSegLinetoVerticalAbs]' + }; + window.SVGPathSegLinetoVerticalAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._y + }; + window.SVGPathSegLinetoVerticalAbs.prototype.clone = function() { + return new window.SVGPathSegLinetoVerticalAbs(undefined, this._y) + }; + Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoVerticalRel = function(owningPathSegList, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, + 'v', + owningPathSegList + ); + this._y = y; + }; + window.SVGPathSegLinetoVerticalRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoVerticalRel.prototype.toString = function() { + return '[object SVGPathSegLinetoVerticalRel]' + }; + window.SVGPathSegLinetoVerticalRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._y + }; + window.SVGPathSegLinetoVerticalRel.prototype.clone = function() { + return new window.SVGPathSegLinetoVerticalRel(undefined, this._y) + }; + Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegCurvetoCubicSmoothAbs = function( + owningPathSegList, + x, + y, + x2, + y2 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, + 'S', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString = function() { + return '[object SVGPathSegCurvetoCubicSmoothAbs]' + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone = function() { + return new window.SVGPathSegCurvetoCubicSmoothAbs( + undefined, + this._x, + this._y, + this._x2, + this._y2 + ) + }; + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothAbs.prototype, + 'x', + { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothAbs.prototype, + 'y', + { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothAbs.prototype, + 'x2', + { + get: function() { + return this._x2 + }, + set: function(x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothAbs.prototype, + 'y2', + { + get: function() { + return this._y2 + }, + set: function(y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegCurvetoCubicSmoothRel = function( + owningPathSegList, + x, + y, + x2, + y2 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, + 's', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString = function() { + return '[object SVGPathSegCurvetoCubicSmoothRel]' + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone = function() { + return new window.SVGPathSegCurvetoCubicSmoothRel( + undefined, + this._x, + this._y, + this._x2, + this._y2 + ) + }; + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothRel.prototype, + 'x', + { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothRel.prototype, + 'y', + { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothRel.prototype, + 'x2', + { + get: function() { + return this._x2 + }, + set: function(x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothRel.prototype, + 'y2', + { + get: function() { + return this._y2 + }, + set: function(y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegCurvetoQuadraticSmoothAbs = function( + owningPathSegList, + x, + y + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, + 'T', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString = function() { + return '[object SVGPathSegCurvetoQuadraticSmoothAbs]' + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone = function() { + return new window.SVGPathSegCurvetoQuadraticSmoothAbs( + undefined, + this._x, + this._y + ) + }; + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, + 'x', + { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, + 'y', + { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegCurvetoQuadraticSmoothRel = function( + owningPathSegList, + x, + y + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, + 't', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString = function() { + return '[object SVGPathSegCurvetoQuadraticSmoothRel]' + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone = function() { + return new window.SVGPathSegCurvetoQuadraticSmoothRel( + undefined, + this._x, + this._y + ) + }; + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, + 'x', + { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, + 'y', + { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + } + ); + + // Add createSVGPathSeg* functions to window.SVGPathElement. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-Interfacewindow.SVGPathElement. + window.SVGPathElement.prototype.createSVGPathSegClosePath = function() { + return new window.SVGPathSegClosePath(undefined) + }; + window.SVGPathElement.prototype.createSVGPathSegMovetoAbs = function(x, y) { + return new window.SVGPathSegMovetoAbs(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegMovetoRel = function(x, y) { + return new window.SVGPathSegMovetoRel(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoAbs = function(x, y) { + return new window.SVGPathSegLinetoAbs(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoRel = function(x, y) { + return new window.SVGPathSegLinetoRel(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function( + x, + y, + x1, + y1, + x2, + y2 + ) { + return new window.SVGPathSegCurvetoCubicAbs( + undefined, + x, + y, + x1, + y1, + x2, + y2 + ) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function( + x, + y, + x1, + y1, + x2, + y2 + ) { + return new window.SVGPathSegCurvetoCubicRel( + undefined, + x, + y, + x1, + y1, + x2, + y2 + ) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function( + x, + y, + x1, + y1 + ) { + return new window.SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function( + x, + y, + x1, + y1 + ) { + return new window.SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1) + }; + window.SVGPathElement.prototype.createSVGPathSegArcAbs = function( + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) { + return new window.SVGPathSegArcAbs( + undefined, + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) + }; + window.SVGPathElement.prototype.createSVGPathSegArcRel = function( + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) { + return new window.SVGPathSegArcRel( + undefined, + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function( + x + ) { + return new window.SVGPathSegLinetoHorizontalAbs(undefined, x) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function( + x + ) { + return new window.SVGPathSegLinetoHorizontalRel(undefined, x) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function( + y + ) { + return new window.SVGPathSegLinetoVerticalAbs(undefined, y) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function( + y + ) { + return new window.SVGPathSegLinetoVerticalRel(undefined, y) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function( + x, + y, + x2, + y2 + ) { + return new window.SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function( + x, + y, + x2, + y2 + ) { + return new window.SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function( + x, + y + ) { + return new window.SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function( + x, + y + ) { + return new window.SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y) + }; + + if (!('getPathSegAtLength' in window.SVGPathElement.prototype)) { + // Add getPathSegAtLength to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength + // This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm. + window.SVGPathElement.prototype.getPathSegAtLength = function(distance) { + if (distance === undefined || !isFinite(distance)) + throw 'Invalid arguments.' + + var measurementElement = document.createElementNS( + 'http://www.w3.org/2000/svg', + 'path' + ); + measurementElement.setAttribute('d', this.getAttribute('d')); + var lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; + + // If the path is empty, return 0. + if (lastPathSegment <= 0) return 0 + + do { + measurementElement.pathSegList.removeItem(lastPathSegment); + if (distance > measurementElement.getTotalLength()) break + lastPathSegment--; + } while (lastPathSegment > 0) + return lastPathSegment + }; + } + } + + if (!('SVGPathSegList' in window)) { + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList + window.SVGPathSegList = function(pathElement) { + this._pathElement = pathElement; + this._list = this._parsePath(this._pathElement.getAttribute('d')); + + // Use a MutationObserver to catch changes to the path's "d" attribute. + this._mutationObserverConfig = { + attributes: true, + attributeFilter: ['d'] + }; + this._pathElementMutationObserver = new MutationObserver( + this._updateListFromPathMutations.bind(this) + ); + this._pathElementMutationObserver.observe( + this._pathElement, + this._mutationObserverConfig + ); + }; + + window.SVGPathSegList.prototype.classname = 'SVGPathSegList'; + + Object.defineProperty(window.SVGPathSegList.prototype, 'numberOfItems', { + get: function() { + this._checkPathSynchronizedToList(); + return this._list.length + }, + enumerable: true + }); + + // Add the pathSegList accessors to window.SVGPathElement. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData + Object.defineProperty(window.SVGPathElement.prototype, 'pathSegList', { + get: function() { + if (!this._pathSegList) + this._pathSegList = new window.SVGPathSegList(this); + return this._pathSegList + }, + enumerable: true + }); + // FIXME: The following are not implemented and simply return window.SVGPathElement.pathSegList. + Object.defineProperty( + window.SVGPathElement.prototype, + 'normalizedPathSegList', + { + get: function() { + return this.pathSegList + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathElement.prototype, + 'animatedPathSegList', + { + get: function() { + return this.pathSegList + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathElement.prototype, + 'animatedNormalizedPathSegList', + { + get: function() { + return this.pathSegList + }, + enumerable: true + } + ); + + // Process any pending mutations to the path element and update the list as needed. + // This should be the first call of all public functions and is needed because + // MutationObservers are not synchronous so we can have pending asynchronous mutations. + window.SVGPathSegList.prototype._checkPathSynchronizedToList = function() { + this._updateListFromPathMutations( + this._pathElementMutationObserver.takeRecords() + ); + }; + + window.SVGPathSegList.prototype._updateListFromPathMutations = function( + mutationRecords + ) { + if (!this._pathElement) return + var hasPathMutations = false; + mutationRecords.forEach(function(record) { + if (record.attributeName == 'd') hasPathMutations = true; + }); + if (hasPathMutations) + this._list = this._parsePath(this._pathElement.getAttribute('d')); + }; + + // Serialize the list and update the path's 'd' attribute. + window.SVGPathSegList.prototype._writeListToPath = function() { + this._pathElementMutationObserver.disconnect(); + this._pathElement.setAttribute( + 'd', + window.SVGPathSegList._pathSegArrayAsString(this._list) + ); + this._pathElementMutationObserver.observe( + this._pathElement, + this._mutationObserverConfig + ); + }; + + // When a path segment changes the list needs to be synchronized back to the path element. + window.SVGPathSegList.prototype.segmentChanged = function(pathSeg) { + this._writeListToPath(); + }; + + window.SVGPathSegList.prototype.clear = function() { + this._checkPathSynchronizedToList(); + + this._list.forEach(function(pathSeg) { + pathSeg._owningPathSegList = null; + }); + this._list = []; + this._writeListToPath(); + }; + + window.SVGPathSegList.prototype.initialize = function(newItem) { + this._checkPathSynchronizedToList(); + + this._list = [newItem]; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem + }; + + window.SVGPathSegList.prototype._checkValidIndex = function(index) { + if (isNaN(index) || index < 0 || index >= this.numberOfItems) + throw 'INDEX_SIZE_ERR' + }; + + window.SVGPathSegList.prototype.getItem = function(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + return this._list[index] + }; + + window.SVGPathSegList.prototype.insertItemBefore = function( + newItem, + index + ) { + this._checkPathSynchronizedToList(); + + // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + if (index > this.numberOfItems) index = this.numberOfItems; + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.splice(index, 0, newItem); + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem + }; + + window.SVGPathSegList.prototype.replaceItem = function(newItem, index) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._checkValidIndex(index); + this._list[index] = newItem; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem + }; + + window.SVGPathSegList.prototype.removeItem = function(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + var item = this._list[index]; + this._list.splice(index, 1); + this._writeListToPath(); + return item + }; + + window.SVGPathSegList.prototype.appendItem = function(newItem) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.push(newItem); + newItem._owningPathSegList = this; + // TODO: Optimize this to just append to the existing attribute. + this._writeListToPath(); + return newItem + }; + + window.SVGPathSegList._pathSegArrayAsString = function(pathSegArray) { + var string = ''; + var first = true; + pathSegArray.forEach(function(pathSeg) { + if (first) { + first = false; + string += pathSeg._asPathString(); + } else { + string += ' ' + pathSeg._asPathString(); + } + }); + return string + }; + + // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. + window.SVGPathSegList.prototype._parsePath = function(string) { + if (!string || string.length == 0) return [] + + var owningPathSegList = this; + + var Builder = function() { + this.pathSegList = []; + }; + + Builder.prototype.appendSegment = function(pathSeg) { + this.pathSegList.push(pathSeg); + }; + + var Source = function(string) { + this._string = string; + this._currentIndex = 0; + this._endIndex = this._string.length; + this._previousCommand = window.SVGPathSeg.PATHSEG_UNKNOWN; + + this._skipOptionalSpaces(); + }; + + Source.prototype._isCurrentSpace = function() { + var character = this._string[this._currentIndex]; + return ( + character <= ' ' && + (character == ' ' || + character == '\n' || + character == '\t' || + character == '\r' || + character == '\f') + ) + }; + + Source.prototype._skipOptionalSpaces = function() { + while (this._currentIndex < this._endIndex && this._isCurrentSpace()) + this._currentIndex++; + return this._currentIndex < this._endIndex + }; + + Source.prototype._skipOptionalSpacesOrDelimiter = function() { + if ( + this._currentIndex < this._endIndex && + !this._isCurrentSpace() && + this._string.charAt(this._currentIndex) != ',' + ) + return false + if (this._skipOptionalSpaces()) { + if ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == ',' + ) { + this._currentIndex++; + this._skipOptionalSpaces(); + } + } + return this._currentIndex < this._endIndex + }; + + Source.prototype.hasMoreData = function() { + return this._currentIndex < this._endIndex + }; + + Source.prototype.peekSegmentType = function() { + var lookahead = this._string[this._currentIndex]; + return this._pathSegTypeFromChar(lookahead) + }; + + Source.prototype._pathSegTypeFromChar = function(lookahead) { + switch (lookahead) { + case 'Z': + case 'z': + return window.SVGPathSeg.PATHSEG_CLOSEPATH + case 'M': + return window.SVGPathSeg.PATHSEG_MOVETO_ABS + case 'm': + return window.SVGPathSeg.PATHSEG_MOVETO_REL + case 'L': + return window.SVGPathSeg.PATHSEG_LINETO_ABS + case 'l': + return window.SVGPathSeg.PATHSEG_LINETO_REL + case 'C': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS + case 'c': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL + case 'Q': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS + case 'q': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL + case 'A': + return window.SVGPathSeg.PATHSEG_ARC_ABS + case 'a': + return window.SVGPathSeg.PATHSEG_ARC_REL + case 'H': + return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS + case 'h': + return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL + case 'V': + return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS + case 'v': + return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL + case 'S': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS + case 's': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL + case 'T': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS + case 't': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL + default: + return window.SVGPathSeg.PATHSEG_UNKNOWN + } + }; + + Source.prototype._nextCommandHelper = function( + lookahead, + previousCommand + ) { + // Check for remaining coordinates in the current command. + if ( + (lookahead == '+' || + lookahead == '-' || + lookahead == '.' || + (lookahead >= '0' && lookahead <= '9')) && + previousCommand != window.SVGPathSeg.PATHSEG_CLOSEPATH + ) { + if (previousCommand == window.SVGPathSeg.PATHSEG_MOVETO_ABS) + return window.SVGPathSeg.PATHSEG_LINETO_ABS + if (previousCommand == window.SVGPathSeg.PATHSEG_MOVETO_REL) + return window.SVGPathSeg.PATHSEG_LINETO_REL + return previousCommand + } + return window.SVGPathSeg.PATHSEG_UNKNOWN + }; + + Source.prototype.initialCommandIsMoveTo = function() { + // If the path is empty it is still valid, so return true. + if (!this.hasMoreData()) return true + var command = this.peekSegmentType(); + // Path must start with moveTo. + return ( + command == window.SVGPathSeg.PATHSEG_MOVETO_ABS || + command == window.SVGPathSeg.PATHSEG_MOVETO_REL + ) + }; + + // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF + Source.prototype._parseNumber = function() { + var exponent = 0; + var integer = 0; + var frac = 1; + var decimal = 0; + var sign = 1; + var expsign = 1; + + var startIndex = this._currentIndex; + + this._skipOptionalSpaces(); + + // Read the sign. + if ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '+' + ) + this._currentIndex++; + else if ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '-' + ) { + this._currentIndex++; + sign = -1; + } + + if ( + this._currentIndex == this._endIndex || + ((this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9') && + this._string.charAt(this._currentIndex) != '.') + ) + // The first character of a number must be one of [0-9+-.]. + return undefined + + // Read the integer part, build right-to-left. + var startIntPartIndex = this._currentIndex; + while ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9' + ) + this._currentIndex++; // Advance to first non-digit. + + if (this._currentIndex != startIntPartIndex) { + var scanIntPartIndex = this._currentIndex - 1; + var multiplier = 1; + while (scanIntPartIndex >= startIntPartIndex) { + integer += + multiplier * (this._string.charAt(scanIntPartIndex--) - '0'); + multiplier *= 10; + } + } + + // Read the decimals. + if ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '.' + ) { + this._currentIndex++; + + // There must be a least one digit following the . + if ( + this._currentIndex >= this._endIndex || + this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9' + ) + return undefined + while ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9' + ) { + frac *= 10; + decimal += (this._string.charAt(this._currentIndex) - '0') / frac; + this._currentIndex += 1; + } + } + + // Read the exponent part. + if ( + this._currentIndex != startIndex && + this._currentIndex + 1 < this._endIndex && + (this._string.charAt(this._currentIndex) == 'e' || + this._string.charAt(this._currentIndex) == 'E') && + this._string.charAt(this._currentIndex + 1) != 'x' && + this._string.charAt(this._currentIndex + 1) != 'm' + ) { + this._currentIndex++; + + // Read the sign of the exponent. + if (this._string.charAt(this._currentIndex) == '+') { + this._currentIndex++; + } else if (this._string.charAt(this._currentIndex) == '-') { + this._currentIndex++; + expsign = -1; + } + + // There must be an exponent. + if ( + this._currentIndex >= this._endIndex || + this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9' + ) + return undefined + + while ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9' + ) { + exponent *= 10; + exponent += this._string.charAt(this._currentIndex) - '0'; + this._currentIndex++; + } + } + + var number = integer + decimal; + number *= sign; + + if (exponent) number *= Math.pow(10, expsign * exponent); + + if (startIndex == this._currentIndex) return undefined + + this._skipOptionalSpacesOrDelimiter(); + + return number + }; + + Source.prototype._parseArcFlag = function() { + if (this._currentIndex >= this._endIndex) return undefined + var flag = false; + var flagChar = this._string.charAt(this._currentIndex++); + if (flagChar == '0') flag = false; + else if (flagChar == '1') flag = true; + else return undefined + + this._skipOptionalSpacesOrDelimiter(); + return flag + }; + + Source.prototype.parseSegment = function() { + var lookahead = this._string[this._currentIndex]; + var command = this._pathSegTypeFromChar(lookahead); + if (command == window.SVGPathSeg.PATHSEG_UNKNOWN) { + // Possibly an implicit command. Not allowed if this is the first command. + if (this._previousCommand == window.SVGPathSeg.PATHSEG_UNKNOWN) + return null + command = this._nextCommandHelper(lookahead, this._previousCommand); + if (command == window.SVGPathSeg.PATHSEG_UNKNOWN) return null + } else { + this._currentIndex++; + } + + this._previousCommand = command; + + switch (command) { + case window.SVGPathSeg.PATHSEG_MOVETO_REL: + return new window.SVGPathSegMovetoRel( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_MOVETO_ABS: + return new window.SVGPathSegMovetoAbs( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_REL: + return new window.SVGPathSegLinetoRel( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_ABS: + return new window.SVGPathSegLinetoAbs( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: + return new window.SVGPathSegLinetoHorizontalRel( + owningPathSegList, + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: + return new window.SVGPathSegLinetoHorizontalAbs( + owningPathSegList, + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: + return new window.SVGPathSegLinetoVerticalRel( + owningPathSegList, + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: + return new window.SVGPathSegLinetoVerticalAbs( + owningPathSegList, + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_CLOSEPATH: + this._skipOptionalSpaces(); + return new window.SVGPathSegClosePath(owningPathSegList) + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicRel( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1, + points.x2, + points.y2 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicAbs( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1, + points.x2, + points.y2 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + var points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicSmoothRel( + owningPathSegList, + points.x, + points.y, + points.x2, + points.y2 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + var points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicSmoothAbs( + owningPathSegList, + points.x, + points.y, + points.x2, + points.y2 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoQuadraticRel( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoQuadraticAbs( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + return new window.SVGPathSegCurvetoQuadraticSmoothRel( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + return new window.SVGPathSegCurvetoQuadraticSmoothAbs( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_ARC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegArcRel( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1, + points.arcAngle, + points.arcLarge, + points.arcSweep + ) + case window.SVGPathSeg.PATHSEG_ARC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegArcAbs( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1, + points.arcAngle, + points.arcLarge, + points.arcSweep + ) + default: + throw 'Unknown path seg type.' + } + }; + + var builder = new Builder(); + var source = new Source(string); + + if (!source.initialCommandIsMoveTo()) return [] + while (source.hasMoreData()) { + var pathSeg = source.parseSegment(); + if (!pathSeg) return [] + builder.appendSegment(pathSeg); + } + + return builder.pathSegList + }; + } +})(); + +// String.padEnd polyfill for IE11 +// +// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd +if (!String.prototype.padEnd) { + String.prototype.padEnd = function padEnd(targetLength, padString) { + targetLength = targetLength >> 0; //floor if number or convert non-number to 0; + padString = String(typeof padString !== 'undefined' ? padString : ' '); + if (this.length > targetLength) { + return String(this) + } else { + targetLength = targetLength - this.length; + if (targetLength > padString.length) { + padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed + } + return String(this) + padString.slice(0, targetLength) + } + }; +} + +// Object.assign polyfill for IE11 +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill +if (typeof Object.assign !== 'function') { + // Must be writable: true, enumerable: false, configurable: true + Object.defineProperty(Object, 'assign', { + value: function assign(target, varArgs) { + if (target === null || target === undefined) { + throw new TypeError('Cannot convert undefined or null to object') + } + + var to = Object(target); + + for (var index = 1; index < arguments.length; index++) { + var nextSource = arguments[index]; + + if (nextSource !== null && nextSource !== undefined) { + for (var nextKey in nextSource) { + // Avoid bugs when hasOwnProperty is shadowed + if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { + to[nextKey] = nextSource[nextKey]; + } + } + } + } + return to + }, + writable: true, + configurable: true + }); +} + +/* jshint ignore:end */ + +Chart.prototype.axis = function() {}; +Chart.prototype.axis.labels = function(labels) { + var $$ = this.internal; + if (arguments.length) { + Object.keys(labels).forEach(function(axisId) { + $$.axis.setLabelText(axisId, labels[axisId]); + }); + $$.axis.updateLabels(); + } + // TODO: return some values? +}; +Chart.prototype.axis.max = function(max) { + var $$ = this.internal, + config = $$.config; + if (arguments.length) { + if (typeof max === 'object') { + if (isValue(max.x)) { + config.axis_x_max = max.x; + } + if (isValue(max.y)) { + config.axis_y_max = max.y; + } + if (isValue(max.y2)) { + config.axis_y2_max = max.y2; + } + } else { + config.axis_y_max = config.axis_y2_max = max; + } + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } else { + return { + x: config.axis_x_max, + y: config.axis_y_max, + y2: config.axis_y2_max + } + } +}; +Chart.prototype.axis.min = function(min) { + var $$ = this.internal, + config = $$.config; + if (arguments.length) { + if (typeof min === 'object') { + if (isValue(min.x)) { + config.axis_x_min = min.x; + } + if (isValue(min.y)) { + config.axis_y_min = min.y; + } + if (isValue(min.y2)) { + config.axis_y2_min = min.y2; + } + } else { + config.axis_y_min = config.axis_y2_min = min; + } + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } else { + return { + x: config.axis_x_min, + y: config.axis_y_min, + y2: config.axis_y2_min + } + } +}; +Chart.prototype.axis.range = function(range) { + if (arguments.length) { + if (isDefined(range.max)) { + this.axis.max(range.max); + } + if (isDefined(range.min)) { + this.axis.min(range.min); + } + } else { + return { + max: this.axis.max(), + min: this.axis.min() + } + } +}; + +Chart.prototype.axis.types = function(types) { + const $$ = this.internal; + if (types === undefined) { + return { + y: $$.config.axis_y_type, + y2: $$.config.axis_y2_type + } + } else { + if (isDefined(types.y)) { + $$.config.axis_y_type = types.y; + } + + if (isDefined(types.y2)) { + $$.config.axis_y2_type = types.y2; + } + + $$.updateScales(); + $$.redraw(); + } +}; + +Chart.prototype.category = function(i, category) { + var $$ = this.internal, + config = $$.config; + if (arguments.length > 1) { + config.axis_x_categories[i] = category; + $$.redraw(); + } + return config.axis_x_categories[i] +}; +Chart.prototype.categories = function(categories) { + var $$ = this.internal, + config = $$.config; + if (!arguments.length) { + return config.axis_x_categories + } + config.axis_x_categories = categories; + $$.redraw(); + return config.axis_x_categories +}; + +Chart.prototype.resize = function(size) { + var $$ = this.internal, + config = $$.config; + config.size_width = size ? size.width : null; + config.size_height = size ? size.height : null; + this.flush(); +}; + +Chart.prototype.flush = function() { + var $$ = this.internal; + $$.updateAndRedraw({ + withLegend: true, + withTransition: false, + withTransitionForTransform: false + }); +}; + +Chart.prototype.destroy = function() { + var $$ = this.internal; + + window.clearInterval($$.intervalForObserveInserted); + + if ($$.resizeTimeout !== undefined) { + window.clearTimeout($$.resizeTimeout); + } + + if (window.detachEvent) { + window.detachEvent('onresize', $$.resizeIfElementDisplayed); + } else if (window.removeEventListener) { + window.removeEventListener('resize', $$.resizeIfElementDisplayed); + } else { + var wrapper = window.onresize; + // check if no one else removed our wrapper and remove our resizeFunction from it + if (wrapper && wrapper.add && wrapper.remove) { + wrapper.remove($$.resizeFunction); + } + } + + // Removes the inner resize functions + $$.resizeFunction.remove(); + + // Unbinds from the window focus event + $$.unbindWindowFocus(); + + $$.selectChart.classed('c3', false).html(''); + + // MEMO: this is needed because the reference of some elements will not be released, then memory leak will happen. + Object.keys($$).forEach(function(key) { + $$[key] = null; + }); + + return null +}; + +// TODO: fix +Chart.prototype.color = function(id) { + var $$ = this.internal; + return $$.color(id) // more patterns +}; + +Chart.prototype.data = function(targetIds) { + var targets = this.internal.data.targets; + return typeof targetIds === 'undefined' + ? targets + : targets.filter(function(t) { + return [].concat(targetIds).indexOf(t.id) >= 0 + }) +}; +Chart.prototype.data.shown = function(targetIds) { + return this.internal.filterTargetsToShow(this.data(targetIds)) +}; + +/** + * Get values of the data loaded in the chart. + * + * @param {String|Array} targetId This API returns the value of specified target. + * @param flat + * @return {Array} Data values + */ +Chart.prototype.data.values = function(targetId, flat = true) { + let values = null; + + if (targetId) { + const targets = this.data(targetId); + if (targets && isArray(targets)) { + values = targets.reduce((ret, v) => { + const dataValue = v.values.map(d => d.value); + if (flat) { + ret = ret.concat(dataValue); + } else { + ret.push(dataValue); + } + return ret + }, []); + } + } + + return values +}; +Chart.prototype.data.names = function(names) { + this.internal.clearLegendItemTextBoxCache(); + return this.internal.updateDataAttributes('names', names) +}; +Chart.prototype.data.colors = function(colors) { + return this.internal.updateDataAttributes('colors', colors) +}; +Chart.prototype.data.axes = function(axes) { + return this.internal.updateDataAttributes('axes', axes) +}; + +Chart.prototype.data.stackNormalized = function(normalized) { + if (normalized === undefined) { + return this.internal.isStackNormalized() + } + + this.internal.config.data_stack_normalize = !!normalized; + this.internal.redraw(); +}; + +Chart.prototype.donut = function() {}; + +Chart.prototype.donut.padAngle = function(padAngle) { + if (padAngle === undefined) { + return this.internal.config.donut_padAngle + } + this.internal.config.donut_padAngle = padAngle; + this.flush(); +}; + +Chart.prototype.flow = function(args) { + var $$ = this.internal, + targets, + data, + notfoundIds = [], + orgDataCount = $$.getMaxDataCount(), + dataCount, + domain, + baseTarget, + baseValue, + length = 0, + tail = 0, + diff, + to; + + if (args.json) { + data = $$.convertJsonToData(args.json, args.keys); + } else if (args.rows) { + data = $$.convertRowsToData(args.rows); + } else if (args.columns) { + data = $$.convertColumnsToData(args.columns); + } else { + return + } + targets = $$.convertDataToTargets(data, true); + + // Update/Add data + $$.data.targets.forEach(function(t) { + var found = false, + i, + j; + for (i = 0; i < targets.length; i++) { + if (t.id === targets[i].id) { + found = true; + + if (t.values[t.values.length - 1]) { + tail = t.values[t.values.length - 1].index + 1; + } + length = targets[i].values.length; + + for (j = 0; j < length; j++) { + targets[i].values[j].index = tail + j; + if (!$$.isTimeSeries()) { + targets[i].values[j].x = tail + j; + } + } + t.values = t.values.concat(targets[i].values); + + targets.splice(i, 1); + break + } + } + if (!found) { + notfoundIds.push(t.id); + } + }); + + // Append null for not found targets + $$.data.targets.forEach(function(t) { + var i, j; + for (i = 0; i < notfoundIds.length; i++) { + if (t.id === notfoundIds[i]) { + tail = t.values[t.values.length - 1].index + 1; + for (j = 0; j < length; j++) { + t.values.push({ + id: t.id, + index: tail + j, + x: $$.isTimeSeries() ? $$.getOtherTargetX(tail + j) : tail + j, + value: null + }); + } + } + } + }); + + // Generate null values for new target + if ($$.data.targets.length) { + targets.forEach(function(t) { + var i, + missing = []; + for (i = $$.data.targets[0].values[0].index; i < tail; i++) { + missing.push({ + id: t.id, + index: i, + x: $$.isTimeSeries() ? $$.getOtherTargetX(i) : i, + value: null + }); + } + t.values.forEach(function(v) { + v.index += tail; + if (!$$.isTimeSeries()) { + v.x += tail; + } + }); + t.values = missing.concat(t.values); + }); + } + $$.data.targets = $$.data.targets.concat(targets); // add remained + + // check data count because behavior needs to change when it's only one + dataCount = $$.getMaxDataCount(); + baseTarget = $$.data.targets[0]; + baseValue = baseTarget.values[0]; + + // Update length to flow if needed + if (isDefined(args.to)) { + length = 0; + to = $$.isTimeSeries() ? $$.parseDate(args.to) : args.to; + baseTarget.values.forEach(function(v) { + if (v.x < to) { + length++; + } + }); + } else if (isDefined(args.length)) { + length = args.length; + } + + // If only one data, update the domain to flow from left edge of the chart + if (!orgDataCount) { + if ($$.isTimeSeries()) { + if (baseTarget.values.length > 1) { + diff = baseTarget.values[baseTarget.values.length - 1].x - baseValue.x; + } else { + diff = baseValue.x - $$.getXDomain($$.data.targets)[0]; + } + } else { + diff = 1; + } + domain = [baseValue.x - diff, baseValue.x]; + $$.updateXDomain(null, true, true, false, domain); + } else if (orgDataCount === 1) { + if ($$.isTimeSeries()) { + diff = + (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2; + domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)]; + $$.updateXDomain(null, true, true, false, domain); + } + } + + // Set targets + $$.updateTargets($$.data.targets); + + // Redraw with new targets + $$.redraw({ + flow: { + index: baseValue.index, + length: length, + duration: isValue(args.duration) + ? args.duration + : $$.config.transition_duration, + done: args.done, + orgDataCount: orgDataCount + }, + withLegend: true, + withTransition: orgDataCount > 1, + withTrimXDomain: false, + withUpdateXAxis: true + }); +}; + +ChartInternal.prototype.generateFlow = function(args) { + var $$ = this, + config = $$.config, + d3 = $$.d3; + + return function() { + var targets = args.targets, + flow = args.flow, + drawBar = args.drawBar, + drawLine = args.drawLine, + drawArea = args.drawArea, + cx = args.cx, + cy = args.cy, + xv = args.xv, + xForText = args.xForText, + yForText = args.yForText, + duration = args.duration; + + var translateX, + scaleX = 1, + transform, + flowIndex = flow.index, + flowLength = flow.length, + flowStart = $$.getValueOnIndex($$.data.targets[0].values, flowIndex), + flowEnd = $$.getValueOnIndex( + $$.data.targets[0].values, + flowIndex + flowLength + ), + orgDomain = $$.x.domain(), + domain, + durationForFlow = flow.duration || duration, + done = flow.done || function() {}, + wait = $$.generateWait(); + + var xgrid, + xgridLines, + mainRegion, + mainText, + mainBar, + mainLine, + mainArea, + mainCircle; + + // set flag + $$.flowing = true; + + // remove head data after rendered + $$.data.targets.forEach(function(d) { + d.values.splice(0, flowLength); + }); + + // update x domain to generate axis elements for flow + domain = $$.updateXDomain(targets, true, true); + // update elements related to x scale + if ($$.updateXGrid) { + $$.updateXGrid(true); + } + + xgrid = $$.xgrid || d3.selectAll([]); // xgrid needs to be obtained after updateXGrid + xgridLines = $$.xgridLines || d3.selectAll([]); + mainRegion = $$.mainRegion || d3.selectAll([]); + mainText = $$.mainText || d3.selectAll([]); + mainBar = $$.mainBar || d3.selectAll([]); + mainLine = $$.mainLine || d3.selectAll([]); + mainArea = $$.mainArea || d3.selectAll([]); + mainCircle = $$.mainCircle || d3.selectAll([]); + + // generate transform to flow + if (!flow.orgDataCount) { + // if empty + if ($$.data.targets[0].values.length !== 1) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } else { + if ($$.isTimeSeries()) { + flowStart = $$.getValueOnIndex($$.data.targets[0].values, 0); + flowEnd = $$.getValueOnIndex( + $$.data.targets[0].values, + $$.data.targets[0].values.length - 1 + ); + translateX = $$.x(flowStart.x) - $$.x(flowEnd.x); + } else { + translateX = diffDomain(domain) / 2; + } + } + } else if ( + flow.orgDataCount === 1 || + (flowStart && flowStart.x) === (flowEnd && flowEnd.x) + ) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } else { + if ($$.isTimeSeries()) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } else { + translateX = $$.x(flowStart.x) - $$.x(flowEnd.x); + } + } + scaleX = diffDomain(orgDomain) / diffDomain(domain); + transform = 'translate(' + translateX + ',0) scale(' + scaleX + ',1)'; + + $$.hideXGridFocus(); + + var flowTransition = d3 + .transition() + .ease(d3.easeLinear) + .duration(durationForFlow); + wait.add($$.xAxis($$.axes.x, flowTransition)); + wait.add(mainBar.transition(flowTransition).attr('transform', transform)); + wait.add(mainLine.transition(flowTransition).attr('transform', transform)); + wait.add(mainArea.transition(flowTransition).attr('transform', transform)); + wait.add(mainCircle.transition(flowTransition).attr('transform', transform)); + wait.add(mainText.transition(flowTransition).attr('transform', transform)); + wait.add( + mainRegion + .filter($$.isRegionOnX) + .transition(flowTransition) + .attr('transform', transform) + ); + wait.add(xgrid.transition(flowTransition).attr('transform', transform)); + wait.add(xgridLines.transition(flowTransition).attr('transform', transform)); + wait(function() { + var i, + shapes = [], + texts = []; + + // remove flowed elements + if (flowLength) { + for (i = 0; i < flowLength; i++) { + shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); + texts.push('.' + CLASS.text + '-' + (flowIndex + i)); + } + $$.svg + .selectAll('.' + CLASS.shapes) + .selectAll(shapes) + .remove(); + $$.svg + .selectAll('.' + CLASS.texts) + .selectAll(texts) + .remove(); + $$.svg.select('.' + CLASS.xgrid).remove(); + } + + // draw again for removing flowed elements and reverting attr + xgrid + .attr('transform', null) + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', $$.xgridAttr.opacity); + xgridLines.attr('transform', null); + xgridLines + .select('line') + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv); + xgridLines + .select('text') + .attr('x', config.axis_rotated ? $$.width : 0) + .attr('y', xv); + mainBar.attr('transform', null).attr('d', drawBar); + mainLine.attr('transform', null).attr('d', drawLine); + mainArea.attr('transform', null).attr('d', drawArea); + mainCircle + .attr('transform', null) + .attr('cx', cx) + .attr('cy', cy); + mainText + .attr('transform', null) + .attr('x', xForText) + .attr('y', yForText) + .style('fill-opacity', $$.opacityForText.bind($$)); + mainRegion.attr('transform', null); + mainRegion + .filter($$.isRegionOnX) + .attr('x', $$.regionX.bind($$)) + .attr('width', $$.regionWidth.bind($$)); + + // callback for end of flow + done(); + + $$.flowing = false; + }); + } +}; + +Chart.prototype.focus = function(targetIds) { + var $$ = this.internal, + candidates; + + targetIds = $$.mapToTargetIds(targetIds) + ;(candidates = $$.svg.selectAll( + $$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)) + )), + this.revert(); + this.defocus(); + candidates.classed(CLASS.focused, true).classed(CLASS.defocused, false); + if ($$.hasArcType()) { + $$.expandArc(targetIds); + } + $$.toggleFocusLegend(targetIds, true); + + $$.focusedTargetIds = targetIds; + $$.defocusedTargetIds = $$.defocusedTargetIds.filter(function(id) { + return targetIds.indexOf(id) < 0 + }); +}; + +Chart.prototype.defocus = function(targetIds) { + var $$ = this.internal, + candidates; + + targetIds = $$.mapToTargetIds(targetIds) + ;(candidates = $$.svg.selectAll( + $$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)) + )), + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, true); + if ($$.hasArcType()) { + $$.unexpandArc(targetIds); + } + $$.toggleFocusLegend(targetIds, false); + + $$.focusedTargetIds = $$.focusedTargetIds.filter(function(id) { + return targetIds.indexOf(id) < 0 + }); + $$.defocusedTargetIds = targetIds; +}; + +Chart.prototype.revert = function(targetIds) { + var $$ = this.internal, + candidates; + + targetIds = $$.mapToTargetIds(targetIds); + candidates = $$.svg.selectAll($$.selectorTargets(targetIds)); // should be for all targets + + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, false); + if ($$.hasArcType()) { + $$.unexpandArc(targetIds); + } + if ($$.config.legend_show) { + $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$))); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .filter(function() { + return $$.d3.select(this).classed(CLASS.legendItemFocused) + }) + .classed(CLASS.legendItemFocused, false); + } + + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; +}; + +Chart.prototype.xgrids = function(grids) { + var $$ = this.internal, + config = $$.config; + if (!grids) { + return config.grid_x_lines + } + config.grid_x_lines = grids; + $$.redrawWithoutRescale(); + return config.grid_x_lines +}; +Chart.prototype.xgrids.add = function(grids) { + var $$ = this.internal; + return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : [])) +}; +Chart.prototype.xgrids.remove = function(params) { + // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, true); +}; + +Chart.prototype.ygrids = function(grids) { + var $$ = this.internal, + config = $$.config; + if (!grids) { + return config.grid_y_lines + } + config.grid_y_lines = grids; + $$.redrawWithoutRescale(); + return config.grid_y_lines +}; +Chart.prototype.ygrids.add = function(grids) { + var $$ = this.internal; + return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : [])) +}; +Chart.prototype.ygrids.remove = function(params) { + // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, false); +}; + +Chart.prototype.groups = function(groups) { + var $$ = this.internal, + config = $$.config; + if (isUndefined(groups)) { + return config.data_groups + } + config.data_groups = groups; + $$.redraw(); + return config.data_groups +}; + +Chart.prototype.legend = function() {}; +Chart.prototype.legend.show = function(targetIds) { + var $$ = this.internal; + $$.showLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({ withLegend: true }); +}; +Chart.prototype.legend.hide = function(targetIds) { + var $$ = this.internal; + $$.hideLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({ withLegend: false }); +}; + +Chart.prototype.load = function(args) { + var $$ = this.internal, + config = $$.config; + // update xs if specified + if (args.xs) { + $$.addXs(args.xs); + } + // update names if exists + if ('names' in args) { + Chart.prototype.data.names.bind(this)(args.names); + } + // update classes if exists + if ('classes' in args) { + Object.keys(args.classes).forEach(function(id) { + config.data_classes[id] = args.classes[id]; + }); + } + // update categories if exists + if ('categories' in args && $$.isCategorized()) { + config.axis_x_categories = args.categories; + } + // update axes if exists + if ('axes' in args) { + Object.keys(args.axes).forEach(function(id) { + config.data_axes[id] = args.axes[id]; + }); + } + // update colors if exists + if ('colors' in args) { + Object.keys(args.colors).forEach(function(id) { + config.data_colors[id] = args.colors[id]; + }); + } + // use cache if exists + if ('cacheIds' in args && $$.hasCaches(args.cacheIds)) { + $$.load($$.getCaches(args.cacheIds), args.done); + return + } + // unload if needed + if (args.unload) { + // TODO: do not unload if target will load (included in url/rows/columns) + $$.unload( + $$.mapToTargetIds(args.unload === true ? null : args.unload), + function() { + $$.loadFromArgs(args); + } + ); + } else { + $$.loadFromArgs(args); + } +}; + +Chart.prototype.unload = function(args) { + var $$ = this.internal; + args = args || {}; + if (args instanceof Array) { + args = { ids: args }; + } else if (typeof args === 'string') { + args = { ids: [args] }; + } + $$.unload($$.mapToTargetIds(args.ids), function() { + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + if (args.done) { + args.done(); + } + }); +}; + +Chart.prototype.pie = function() {}; + +Chart.prototype.pie.padAngle = function(padAngle) { + if (padAngle === undefined) { + return this.internal.config.pie_padAngle + } + this.internal.config.pie_padAngle = padAngle; + this.flush(); +}; + +Chart.prototype.regions = function(regions) { + var $$ = this.internal, + config = $$.config; + if (!regions) { + return config.regions + } + config.regions = regions; + $$.redrawWithoutRescale(); + return config.regions +}; +Chart.prototype.regions.add = function(regions) { + var $$ = this.internal, + config = $$.config; + if (!regions) { + return config.regions + } + config.regions = config.regions.concat(regions); + $$.redrawWithoutRescale(); + return config.regions +}; +Chart.prototype.regions.remove = function(options) { + var $$ = this.internal, + config = $$.config, + duration, + classes, + regions; + + options = options || {}; + duration = getOption(options, 'duration', config.transition_duration); + classes = getOption(options, 'classes', [CLASS.region]); + + regions = $$.main.select('.' + CLASS.regions).selectAll( + classes.map(function(c) { + return '.' + c + }) + ) + ;(duration ? regions.transition().duration(duration) : regions) + .style('opacity', 0) + .remove(); + + config.regions = config.regions.filter(function(region) { + var found = false; + if (!region['class']) { + return true + } + region['class'].split(' ').forEach(function(c) { + if (classes.indexOf(c) >= 0) { + found = true; + } + }); + return !found + }); + + return config.regions +}; + +Chart.prototype.selected = function(targetId) { + var $$ = this.internal, + d3 = $$.d3; + return $$.main + .selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)) + .selectAll('.' + CLASS.shape) + .filter(function() { + return d3.select(this).classed(CLASS.SELECTED) + }) + .nodes() + .map(function(d) { + var data = d.__data__; + return data.data ? data.data : data + }) +}; +Chart.prototype.select = function(ids, indices, resetOther) { + var $$ = this.internal, + d3 = $$.d3, + config = $$.config; + if (!config.data_selection_enabled) { + return + } + $$.main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function(d, i) { + var shape = d3.select(this), + id = d.data ? d.data.id : d.id, + toggle = $$.getToggle(this, d).bind($$), + isTargetId = + config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, + isTargetIndex = !indices || indices.indexOf(i) >= 0, + isSelected = shape.classed(CLASS.SELECTED); + // line/area selection not supported yet + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { + return + } + if (isTargetId && isTargetIndex) { + if (config.data_selection_isselectable(d) && !isSelected) { + toggle(true, shape.classed(CLASS.SELECTED, true), d, i); + } + } else if (isDefined(resetOther) && resetOther) { + if (isSelected) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + } + }); +}; +Chart.prototype.unselect = function(ids, indices) { + var $$ = this.internal, + d3 = $$.d3, + config = $$.config; + if (!config.data_selection_enabled) { + return + } + $$.main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function(d, i) { + var shape = d3.select(this), + id = d.data ? d.data.id : d.id, + toggle = $$.getToggle(this, d).bind($$), + isTargetId = + config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, + isTargetIndex = !indices || indices.indexOf(i) >= 0, + isSelected = shape.classed(CLASS.SELECTED); + // line/area selection not supported yet + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { + return + } + if (isTargetId && isTargetIndex) { + if (config.data_selection_isselectable(d)) { + if (isSelected) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + } + } + }); +}; + +Chart.prototype.show = function(targetIds, options) { + var $$ = this.internal, + targets; + + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + + $$.removeHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + + targets + .transition() + .style('display', isIE() ? 'block' : 'initial', 'important') + .style('opacity', 1, 'important') + .call($$.endall, function() { + targets.style('opacity', null).style('opacity', 1); + }); + + if (options.withLegend) { + $$.showLegend(targetIds); + } + + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); +}; + +Chart.prototype.hide = function(targetIds, options) { + var $$ = this.internal, + targets; + + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + + $$.addHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + + targets + .transition() + .style('opacity', 0, 'important') + .call($$.endall, function() { + targets.style('opacity', null).style('opacity', 0); + targets.style('display', 'none'); + }); + + if (options.withLegend) { + $$.hideLegend(targetIds); + } + + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); +}; + +Chart.prototype.toggle = function(targetIds, options) { + var that = this, + $$ = this.internal; + $$.mapToTargetIds(targetIds).forEach(function(targetId) { + $$.isTargetToShow(targetId) + ? that.hide(targetId, options) + : that.show(targetId, options); + }); +}; + +Chart.prototype.subchart = function() {}; + +Chart.prototype.subchart.isShown = function() { + const $$ = this.internal; + + return $$.config.subchart_show +}; + +Chart.prototype.subchart.show = function() { + const $$ = this.internal; + + if ($$.config.subchart_show) { + return + } + + $$.config.subchart_show = true; + + // insert DOM + $$.initSubchart(); + + // update dimensions with sub chart now visible + $$.updateDimension(); + + // insert brush (depends on sizes previously updated) + $$.initSubchartBrush(); + + // attach data + $$.updateTargetsForSubchart($$.getTargets()); + + // reset fade-in state + $$.mapToIds($$.data.targets).forEach(function(id) { + $$.withoutFadeIn[id] = false; + }); + + // redraw chart ! + $$.updateAndRedraw(); + + // update visible targets ! + $$.showTargets(); +}; + +Chart.prototype.subchart.hide = function() { + const $$ = this.internal; + + if (!$$.config.subchart_show) { + return + } + + $$.config.subchart_show = false; + + // remove DOM + $$.removeSubchart(); + + // re-render chart + $$.redraw(); +}; + +Chart.prototype.tooltip = function() {}; +Chart.prototype.tooltip.show = function(args) { + var $$ = this.internal, + targets, + data, + mouse = {}; + + // determine mouse position on the chart + if (args.mouse) { + mouse = args.mouse; + } else { + // determine focus data + if (args.data) { + data = args.data; + } else if (typeof args.x !== 'undefined') { + if (args.id) { + targets = $$.data.targets.filter(function(t) { + return t.id === args.id + }); + } else { + targets = $$.data.targets; + } + data = $$.filterByX(targets, args.x).slice(0, 1)[0]; + } + mouse = data ? $$.getMousePosition(data) : null; + } + + // emulate mouse events to show + $$.dispatchEvent('mousemove', mouse); + + $$.config.tooltip_onshow.call($$, data); +}; +Chart.prototype.tooltip.hide = function() { + // TODO: get target data by checking the state of focus + this.internal.dispatchEvent('mouseout', 0); + + this.internal.config.tooltip_onhide.call(this); +}; + +Chart.prototype.transform = function(type, targetIds) { + var $$ = this.internal, + options = + ['pie', 'donut'].indexOf(type) >= 0 ? { withTransform: true } : null; + $$.transformTo(targetIds, type, options); +}; + +ChartInternal.prototype.transformTo = function( + targetIds, + type, + optionsForRedraw +) { + var $$ = this, + withTransitionForAxis = !$$.hasArcType(), + options = optionsForRedraw || { + withTransitionForAxis: withTransitionForAxis + }; + options.withTransitionForTransform = false; + $$.transiting = false; + $$.setTargetType(targetIds, type); + $$.updateTargets($$.data.targets); // this is needed when transforming to arc + $$.updateAndRedraw(options); +}; + +Chart.prototype.x = function(x) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetX($$.data.targets, x); + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + return $$.data.xs +}; +Chart.prototype.xs = function(xs) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetXs($$.data.targets, xs); + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + return $$.data.xs +}; + +Chart.prototype.zoom = function(domain) { + var $$ = this.internal; + if (domain) { + if ($$.isTimeSeries()) { + domain = domain.map(function(x) { + return $$.parseDate(x) + }); + } + if ($$.config.subchart_show) { + $$.brush.selectionAsValue(domain, true); + } else { + $$.updateXDomain(null, true, false, false, domain); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } + $$.config.zoom_onzoom.call(this, $$.x.orgDomain()); + return domain + } else { + return $$.x.domain() + } +}; +Chart.prototype.zoom.enable = function(enabled) { + var $$ = this.internal; + $$.config.zoom_enabled = enabled; + $$.updateAndRedraw(); +}; +Chart.prototype.unzoom = function() { + var $$ = this.internal; + if ($$.config.subchart_show) { + $$.brush.clear(); + } else { + $$.updateXDomain(null, true, false, false, $$.subX.domain()); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } +}; + +Chart.prototype.zoom.max = function(max) { + var $$ = this.internal, + config = $$.config, + d3 = $$.d3; + if (max === 0 || max) { + config.zoom_x_max = d3.max([$$.orgXDomain[1], max]); + } else { + return config.zoom_x_max + } +}; + +Chart.prototype.zoom.min = function(min) { + var $$ = this.internal, + config = $$.config, + d3 = $$.d3; + if (min === 0 || min) { + config.zoom_x_min = d3.min([$$.orgXDomain[0], min]); + } else { + return config.zoom_x_min + } +}; + +Chart.prototype.zoom.range = function(range) { + if (arguments.length) { + if (isDefined(range.max)) { + this.domain.max(range.max); + } + if (isDefined(range.min)) { + this.domain.min(range.min); + } + } else { + return { + max: this.domain.max(), + min: this.domain.min() + } + } +}; + +ChartInternal.prototype.initPie = function() { + var $$ = this, + d3 = $$.d3; + $$.pie = d3 + .pie() + .padAngle(this.getPadAngle.bind(this)) + .value(function(d) { + return d.values.reduce(function(a, b) { + return a + b.value + }, 0) + }); + + let orderFct = $$.getOrderFunction(); + + // we need to reverse the returned order if asc or desc to have the slice in expected order. + if (orderFct && ($$.isOrderAsc() || $$.isOrderDesc())) { + let defaultSort = orderFct; + orderFct = (t1, t2) => defaultSort(t1, t2) * -1; + } + + $$.pie.sort(orderFct || null); +}; + +ChartInternal.prototype.updateRadius = function() { + var $$ = this, + config = $$.config, + w = config.gauge_width || config.donut_width, + gaugeArcWidth = + $$.filterTargetsToShow($$.data.targets).length * + $$.config.gauge_arcs_minWidth; + $$.radiusExpanded = + (Math.min($$.arcWidth, $$.arcHeight) / 2) * ($$.hasType('gauge') ? 0.85 : 1); + $$.radius = $$.radiusExpanded * 0.95; + $$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6; + $$.innerRadius = + $$.hasType('donut') || $$.hasType('gauge') + ? $$.radius * $$.innerRadiusRatio + : 0; + $$.gaugeArcWidth = w + ? w + : gaugeArcWidth <= $$.radius - $$.innerRadius + ? $$.radius - $$.innerRadius + : gaugeArcWidth <= $$.radius + ? gaugeArcWidth + : $$.radius; +}; + +ChartInternal.prototype.getPadAngle = function() { + if (this.hasType('pie')) { + return this.config.pie_padAngle || 0 + } else if (this.hasType('donut')) { + return this.config.donut_padAngle || 0 + } else { + return 0 + } +}; + +ChartInternal.prototype.updateArc = function() { + var $$ = this; + $$.svgArc = $$.getSvgArc(); + $$.svgArcExpanded = $$.getSvgArcExpanded(); + $$.svgArcExpandedSub = $$.getSvgArcExpanded(0.98); +}; + +ChartInternal.prototype.updateAngle = function(d) { + var $$ = this, + config = $$.config, + found = false, + index = 0, + gMin, + gMax, + gTic, + gValue; + + if (!config) { + return null + } + + $$.pie($$.filterTargetsToShow($$.data.targets)).forEach(function(t) { + if (!found && t.data.id === d.data.id) { + found = true; + d = t; + d.index = index; + } + index++; + }); + if (isNaN(d.startAngle)) { + d.startAngle = 0; + } + if (isNaN(d.endAngle)) { + d.endAngle = d.startAngle; + } + if ($$.isGaugeType(d.data)) { + gMin = config.gauge_min; + gMax = config.gauge_max; + gTic = (Math.PI * (config.gauge_fullCircle ? 2 : 1)) / (gMax - gMin); + gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : gMax - gMin; + d.startAngle = config.gauge_startingAngle; + d.endAngle = d.startAngle + gTic * gValue; + } + return found ? d : null +}; + +ChartInternal.prototype.getSvgArc = function() { + var $$ = this, + hasGaugeType = $$.hasType('gauge'), + singleArcWidth = + $$.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length, + arc = $$.d3 + .arc() + .outerRadius(function(d) { + return hasGaugeType ? $$.radius - singleArcWidth * d.index : $$.radius + }) + .innerRadius(function(d) { + return hasGaugeType + ? $$.radius - singleArcWidth * (d.index + 1) + : $$.innerRadius + }), + newArc = function(d, withoutUpdate) { + var updated; + if (withoutUpdate) { + return arc(d) + } // for interpolate + updated = $$.updateAngle(d); + return updated ? arc(updated) : 'M 0 0' + }; + // TODO: extends all function + newArc.centroid = arc.centroid; + return newArc +}; + +ChartInternal.prototype.getSvgArcExpanded = function(rate) { + rate = rate || 1; + var $$ = this, + hasGaugeType = $$.hasType('gauge'), + singleArcWidth = + $$.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length, + expandWidth = Math.min( + $$.radiusExpanded * rate - $$.radius, + singleArcWidth * 0.8 - (1 - rate) * 100 + ), + arc = $$.d3 + .arc() + .outerRadius(function(d) { + return hasGaugeType + ? $$.radius - singleArcWidth * d.index + expandWidth + : $$.radiusExpanded * rate + }) + .innerRadius(function(d) { + return hasGaugeType + ? $$.radius - singleArcWidth * (d.index + 1) + : $$.innerRadius + }); + return function(d) { + var updated = $$.updateAngle(d); + return updated ? arc(updated) : 'M 0 0' + } +}; + +ChartInternal.prototype.getArc = function(d, withoutUpdate, force) { + return force || this.isArcType(d.data) + ? this.svgArc(d, withoutUpdate) + : 'M 0 0' +}; + +ChartInternal.prototype.transformForArcLabel = function(d) { + var $$ = this, + config = $$.config, + updated = $$.updateAngle(d), + c, + x, + y, + h, + ratio, + translate = '', + hasGauge = $$.hasType('gauge'); + if (updated && !hasGauge) { + c = this.svgArc.centroid(updated); + x = isNaN(c[0]) ? 0 : c[0]; + y = isNaN(c[1]) ? 0 : c[1]; + h = Math.sqrt(x * x + y * y); + if ($$.hasType('donut') && config.donut_label_ratio) { + ratio = isFunction(config.donut_label_ratio) + ? config.donut_label_ratio(d, $$.radius, h) + : config.donut_label_ratio; + } else if ($$.hasType('pie') && config.pie_label_ratio) { + ratio = isFunction(config.pie_label_ratio) + ? config.pie_label_ratio(d, $$.radius, h) + : config.pie_label_ratio; + } else { + ratio = + $$.radius && h + ? ((36 / $$.radius > 0.375 ? 1.175 - 36 / $$.radius : 0.8) * + $$.radius) / + h + : 0; + } + translate = 'translate(' + x * ratio + ',' + y * ratio + ')'; + } else if ( + updated && + hasGauge && + $$.filterTargetsToShow($$.data.targets).length > 1 + ) { + var y1 = Math.sin(updated.endAngle - Math.PI / 2); + x = Math.cos(updated.endAngle - Math.PI / 2) * ($$.radiusExpanded + 25); + y = y1 * ($$.radiusExpanded + 15 - Math.abs(y1 * 10)) + 3; + translate = 'translate(' + x + ',' + y + ')'; + } + return translate +}; + +/** + * @deprecated Use `getRatio('arc', d)` instead. + */ +ChartInternal.prototype.getArcRatio = function(d) { + return this.getRatio('arc', d) +}; + +ChartInternal.prototype.convertToArcData = function(d) { + return this.addName({ + id: d.data.id, + value: d.value, + ratio: this.getRatio('arc', d), + index: d.index + }) +}; + +ChartInternal.prototype.textForArcLabel = function(d) { + var $$ = this, + updated, + value, + ratio, + id, + format; + if (!$$.shouldShowArcLabel()) { + return '' + } + updated = $$.updateAngle(d); + value = updated ? updated.value : null; + ratio = $$.getRatio('arc', updated); + id = d.data.id; + if (!$$.hasType('gauge') && !$$.meetsArcLabelThreshold(ratio)) { + return '' + } + format = $$.getArcLabelFormat(); + return format + ? format(value, ratio, id) + : $$.defaultArcValueFormat(value, ratio) +}; + +ChartInternal.prototype.textForGaugeMinMax = function(value, isMax) { + var $$ = this, + format = $$.getGaugeLabelExtents(); + + return format ? format(value, isMax) : value +}; + +ChartInternal.prototype.expandArc = function(targetIds) { + var $$ = this, + interval; + + // MEMO: avoid to cancel transition + if ($$.transiting) { + interval = window.setInterval(function() { + if (!$$.transiting) { + window.clearInterval(interval); + if ($$.legend.selectAll('.c3-legend-item-focused').size() > 0) { + $$.expandArc(targetIds); + } + } + }, 10); + return + } + + targetIds = $$.mapToTargetIds(targetIds); + + $$.svg + .selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)) + .each(function(d) { + if (!$$.shouldExpand(d.data.id)) { + return + } + $$.d3 + .select(this) + .selectAll('path') + .transition() + .duration($$.expandDuration(d.data.id)) + .attr('d', $$.svgArcExpanded) + .transition() + .duration($$.expandDuration(d.data.id) * 2) + .attr('d', $$.svgArcExpandedSub) + .each(function(d) { + if ($$.isDonutType(d.data)) ; + }); + }); +}; + +ChartInternal.prototype.unexpandArc = function(targetIds) { + var $$ = this; + + if ($$.transiting) { + return + } + + targetIds = $$.mapToTargetIds(targetIds); + + $$.svg + .selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)) + .selectAll('path') + .transition() + .duration(function(d) { + return $$.expandDuration(d.data.id) + }) + .attr('d', $$.svgArc); + $$.svg.selectAll('.' + CLASS.arc); +}; + +ChartInternal.prototype.expandDuration = function(id) { + var $$ = this, + config = $$.config; + + if ($$.isDonutType(id)) { + return config.donut_expand_duration + } else if ($$.isGaugeType(id)) { + return config.gauge_expand_duration + } else if ($$.isPieType(id)) { + return config.pie_expand_duration + } else { + return 50 + } +}; + +ChartInternal.prototype.shouldExpand = function(id) { + var $$ = this, + config = $$.config; + return ( + ($$.isDonutType(id) && config.donut_expand) || + ($$.isGaugeType(id) && config.gauge_expand) || + ($$.isPieType(id) && config.pie_expand) + ) +}; + +ChartInternal.prototype.shouldShowArcLabel = function() { + var $$ = this, + config = $$.config, + shouldShow = true; + if ($$.hasType('donut')) { + shouldShow = config.donut_label_show; + } else if ($$.hasType('pie')) { + shouldShow = config.pie_label_show; + } + // when gauge, always true + return shouldShow +}; + +ChartInternal.prototype.meetsArcLabelThreshold = function(ratio) { + var $$ = this, + config = $$.config, + threshold = $$.hasType('donut') + ? config.donut_label_threshold + : config.pie_label_threshold; + return ratio >= threshold +}; + +ChartInternal.prototype.getArcLabelFormat = function() { + var $$ = this, + config = $$.config, + format = config.pie_label_format; + if ($$.hasType('gauge')) { + format = config.gauge_label_format; + } else if ($$.hasType('donut')) { + format = config.donut_label_format; + } + return format +}; + +ChartInternal.prototype.getGaugeLabelExtents = function() { + var $$ = this, + config = $$.config; + return config.gauge_label_extents +}; + +ChartInternal.prototype.getArcTitle = function() { + var $$ = this; + return $$.hasType('donut') ? $$.config.donut_title : '' +}; + +ChartInternal.prototype.updateTargetsForArc = function(targets) { + var $$ = this, + main = $$.main, + mainPies, + mainPieEnter, + classChartArc = $$.classChartArc.bind($$), + classArcs = $$.classArcs.bind($$), + classFocus = $$.classFocus.bind($$); + mainPies = main + .select('.' + CLASS.chartArcs) + .selectAll('.' + CLASS.chartArc) + .data($$.pie(targets)) + .attr('class', function(d) { + return classChartArc(d) + classFocus(d.data) + }); + mainPieEnter = mainPies + .enter() + .append('g') + .attr('class', classChartArc); + mainPieEnter.append('g').attr('class', classArcs); + mainPieEnter + .append('text') + .attr('dy', $$.hasType('gauge') ? '-.1em' : '.35em') + .style('opacity', 0) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + // MEMO: can not keep same color..., but not bad to update color in redraw + //mainPieUpdate.exit().remove(); +}; + +ChartInternal.prototype.initArc = function() { + var $$ = this; + $$.arcs = $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartArcs) + .attr('transform', $$.getTranslate('arc')); + $$.arcs + .append('text') + .attr('class', CLASS.chartArcsTitle) + .style('text-anchor', 'middle') + .text($$.getArcTitle()); +}; + +ChartInternal.prototype.redrawArc = function( + duration, + durationForExit, + withTransform +) { + var $$ = this, + d3 = $$.d3, + config = $$.config, + main = $$.main, + arcs, + mainArc, + arcLabelLines, + mainArcLabelLine, + hasGaugeType = $$.hasType('gauge'); + arcs = main + .selectAll('.' + CLASS.arcs) + .selectAll('.' + CLASS.arc) + .data($$.arcData.bind($$)); + mainArc = arcs + .enter() + .append('path') + .attr('class', $$.classArc.bind($$)) + .style('fill', function(d) { + return $$.color(d.data) + }) + .style('cursor', function(d) { + return config.interaction_enabled && config.data_selection_isselectable(d) + ? 'pointer' + : null + }) + .each(function(d) { + if ($$.isGaugeType(d.data)) { + d.startAngle = d.endAngle = config.gauge_startingAngle; + } + this._current = d; + }) + .merge(arcs); + if (hasGaugeType) { + arcLabelLines = main + .selectAll('.' + CLASS.arcs) + .selectAll('.' + CLASS.arcLabelLine) + .data($$.arcData.bind($$)); + mainArcLabelLine = arcLabelLines + .enter() + .append('rect') + .attr('class', function(d) { + return ( + CLASS.arcLabelLine + + ' ' + + CLASS.target + + ' ' + + CLASS.target + + '-' + + d.data.id + ) + }) + .merge(arcLabelLines); + + if ($$.filterTargetsToShow($$.data.targets).length === 1) { + mainArcLabelLine.style('display', 'none'); + } else { + mainArcLabelLine + .style('fill', function(d) { + return $$.levelColor + ? $$.levelColor( + d.data.values.reduce(function(total, item) { + return total + item.value + }, 0) + ) + : $$.color(d.data) + }) + .style('display', config.gauge_labelLine_show ? '' : 'none') + .each(function(d) { + var lineLength = 0, + lineThickness = 2, + x = 0, + y = 0, + transform = ''; + if ($$.hiddenTargetIds.indexOf(d.data.id) < 0) { + var updated = $$.updateAngle(d), + innerLineLength = + ($$.gaugeArcWidth / + $$.filterTargetsToShow($$.data.targets).length) * + (updated.index + 1), + lineAngle = updated.endAngle - Math.PI / 2, + arcInnerRadius = $$.radius - innerLineLength, + linePositioningAngle = + lineAngle - (arcInnerRadius === 0 ? 0 : 1 / arcInnerRadius); + lineLength = $$.radiusExpanded - $$.radius + innerLineLength; + x = Math.cos(linePositioningAngle) * arcInnerRadius; + y = Math.sin(linePositioningAngle) * arcInnerRadius; + transform = + 'rotate(' + + (lineAngle * 180) / Math.PI + + ', ' + + x + + ', ' + + y + + ')'; + } + d3.select(this) + .attr('x', x) + .attr('y', y) + .attr('width', lineLength) + .attr('height', lineThickness) + .attr('transform', transform) + .style( + 'stroke-dasharray', + '0, ' + (lineLength + lineThickness) + ', 0' + ); + }); + } + } + mainArc + .attr('transform', function(d) { + return !$$.isGaugeType(d.data) && withTransform ? 'scale(0)' : '' + }) + .on( + 'mouseover', + config.interaction_enabled + ? function(d) { + var updated, arcData; + if ($$.transiting) { + // skip while transiting + return + } + updated = $$.updateAngle(d); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.expandArc(updated.data.id); + $$.api.focus(updated.data.id); + $$.toggleFocusLegend(updated.data.id, true); + $$.config.data_onmouseover(arcData, this); + } + } + : null + ) + .on( + 'mousemove', + config.interaction_enabled + ? function(d) { + var updated = $$.updateAngle(d), + arcData, + selectedData; + if (updated) { +(arcData = $$.convertToArcData(updated)), + (selectedData = [arcData]); + $$.showTooltip(selectedData, this); + } + } + : null + ) + .on( + 'mouseout', + config.interaction_enabled + ? function(d) { + var updated, arcData; + if ($$.transiting) { + // skip while transiting + return + } + updated = $$.updateAngle(d); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.unexpandArc(updated.data.id); + $$.api.revert(); + $$.revertLegend(); + $$.hideTooltip(); + $$.config.data_onmouseout(arcData, this); + } + } + : null + ) + .on( + 'click', + config.interaction_enabled + ? function(d, i) { + var updated = $$.updateAngle(d), + arcData; + if (updated) { + arcData = $$.convertToArcData(updated); + if ($$.toggleShape) { + $$.toggleShape(this, arcData, i); + } + $$.config.data_onclick.call($$.api, arcData, this); + } + } + : null + ) + .each(function() { + $$.transiting = true; + }) + .transition() + .duration(duration) + .attrTween('d', function(d) { + var updated = $$.updateAngle(d), + interpolate; + if (!updated) { + return function() { + return 'M 0 0' + } + } + // if (this._current === d) { + // this._current = { + // startAngle: Math.PI*2, + // endAngle: Math.PI*2, + // }; + // } + if (isNaN(this._current.startAngle)) { + this._current.startAngle = 0; + } + if (isNaN(this._current.endAngle)) { + this._current.endAngle = this._current.startAngle; + } + interpolate = d3.interpolate(this._current, updated); + this._current = interpolate(0); + return function(t) { + // prevents crashing the charts once in transition and chart.destroy() has been called + if ($$.config === null) { + return 'M 0 0' + } + var interpolated = interpolate(t); + interpolated.data = d.data; // data.id will be updated by interporator + return $$.getArc(interpolated, true) + } + }) + .attr('transform', withTransform ? 'scale(1)' : '') + .style('fill', function(d) { + return $$.levelColor + ? $$.levelColor( + d.data.values.reduce(function(total, item) { + return total + item.value + }, 0) + ) + : $$.color(d.data.id) + }) // Where gauge reading color would receive customization. + .call($$.endall, function() { + $$.transiting = false; + }); + arcs + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + main + .selectAll('.' + CLASS.chartArc) + .select('text') + .style('opacity', 0) + .attr('class', function(d) { + return $$.isGaugeType(d.data) ? CLASS.gaugeValue : '' + }) + .text($$.textForArcLabel.bind($$)) + .attr('transform', $$.transformForArcLabel.bind($$)) + .style('font-size', function(d) { + return $$.isGaugeType(d.data) && + $$.filterTargetsToShow($$.data.targets).length === 1 + ? Math.round($$.radius / 5) + 'px' + : '' + }) + .transition() + .duration(duration) + .style('opacity', function(d) { + return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? 1 : 0 + }); + main + .select('.' + CLASS.chartArcsTitle) + .style('opacity', $$.hasType('donut') || hasGaugeType ? 1 : 0); + + if (hasGaugeType) { + let index = 0; + const backgroundArc = $$.arcs + .select('g.' + CLASS.chartArcsBackground) + .selectAll('path.' + CLASS.chartArcsBackground) + .data($$.data.targets); + + backgroundArc + .enter() + .append('path') + .attr( + 'class', + (d, i) => + CLASS.chartArcsBackground + ' ' + CLASS.chartArcsBackground + '-' + i + ) + .merge(backgroundArc) + .attr('d', d1 => { + if ($$.hiddenTargetIds.indexOf(d1.id) >= 0) { + return 'M 0 0' + } + + var d = { + data: [{ value: config.gauge_max }], + startAngle: config.gauge_startingAngle, + endAngle: + -1 * + config.gauge_startingAngle * + (config.gauge_fullCircle ? Math.PI : 1), + index: index++ + }; + return $$.getArc(d, true, true) + }); + + backgroundArc.exit().remove(); + + $$.arcs + .select('.' + CLASS.chartArcsGaugeUnit) + .attr('dy', '.75em') + .text(config.gauge_label_show ? config.gauge_units : ''); + $$.arcs + .select('.' + CLASS.chartArcsGaugeMin) + .attr( + 'dx', + -1 * + ($$.innerRadius + + ($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2)) + + 'px' + ) + .attr('dy', '1.2em') + .text( + config.gauge_label_show + ? $$.textForGaugeMinMax(config.gauge_min, false) + : '' + ); + $$.arcs + .select('.' + CLASS.chartArcsGaugeMax) + .attr( + 'dx', + $$.innerRadius + + ($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2) + + 'px' + ) + .attr('dy', '1.2em') + .text( + config.gauge_label_show + ? $$.textForGaugeMinMax(config.gauge_max, true) + : '' + ); + } +}; +ChartInternal.prototype.initGauge = function() { + var arcs = this.arcs; + if (this.hasType('gauge')) { + arcs.append('g').attr('class', CLASS.chartArcsBackground); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeUnit) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeMin) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeMax) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + } +}; +ChartInternal.prototype.getGaugeLabelHeight = function() { + return this.config.gauge_label_show ? 20 : 0 +}; + +/** + * Store value into cache + * + * @param key + * @param value + */ +ChartInternal.prototype.addToCache = function(key, value) { + this.cache[`$${key}`] = value; +}; + +/** + * Returns a cached value or undefined + * + * @param key + * @return {*} + */ +ChartInternal.prototype.getFromCache = function(key) { + return this.cache[`$${key}`] +}; + +/** + * Reset cached data + */ +ChartInternal.prototype.resetCache = function() { + Object.keys(this.cache) + .filter(key => /^\$/.test(key)) + .forEach(key => { + delete this.cache[key]; + }); +}; + +// Old API that stores Targets + +ChartInternal.prototype.hasCaches = function(ids) { + for (var i = 0; i < ids.length; i++) { + if (!(ids[i] in this.cache)) { + return false + } + } + return true +}; +ChartInternal.prototype.addCache = function(id, target) { + this.cache[id] = this.cloneTarget(target); +}; +ChartInternal.prototype.getCaches = function(ids) { + var targets = [], + i; + for (i = 0; i < ids.length; i++) { + if (ids[i] in this.cache) { + targets.push(this.cloneTarget(this.cache[ids[i]])); + } + } + return targets +}; + +ChartInternal.prototype.categoryName = function(i) { + var config = this.config; + return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i +}; + +ChartInternal.prototype.generateTargetClass = function(targetId) { + return targetId || targetId === 0 ? ('-' + targetId).replace(/\s/g, '-') : '' +}; +ChartInternal.prototype.generateClass = function(prefix, targetId) { + return ' ' + prefix + ' ' + prefix + this.generateTargetClass(targetId) +}; +ChartInternal.prototype.classText = function(d) { + return this.generateClass(CLASS.text, d.index) +}; +ChartInternal.prototype.classTexts = function(d) { + return this.generateClass(CLASS.texts, d.id) +}; +ChartInternal.prototype.classShape = function(d) { + return this.generateClass(CLASS.shape, d.index) +}; +ChartInternal.prototype.classShapes = function(d) { + return this.generateClass(CLASS.shapes, d.id) +}; +ChartInternal.prototype.classLine = function(d) { + return this.classShape(d) + this.generateClass(CLASS.line, d.id) +}; +ChartInternal.prototype.classLines = function(d) { + return this.classShapes(d) + this.generateClass(CLASS.lines, d.id) +}; +ChartInternal.prototype.classCircle = function(d) { + return this.classShape(d) + this.generateClass(CLASS.circle, d.index) +}; +ChartInternal.prototype.classCircles = function(d) { + return this.classShapes(d) + this.generateClass(CLASS.circles, d.id) +}; +ChartInternal.prototype.classBar = function(d) { + return this.classShape(d) + this.generateClass(CLASS.bar, d.index) +}; +ChartInternal.prototype.classBars = function(d) { + return this.classShapes(d) + this.generateClass(CLASS.bars, d.id) +}; +ChartInternal.prototype.classArc = function(d) { + return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id) +}; +ChartInternal.prototype.classArcs = function(d) { + return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id) +}; +ChartInternal.prototype.classArea = function(d) { + return this.classShape(d) + this.generateClass(CLASS.area, d.id) +}; +ChartInternal.prototype.classAreas = function(d) { + return this.classShapes(d) + this.generateClass(CLASS.areas, d.id) +}; +ChartInternal.prototype.classRegion = function(d, i) { + return ( + this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d['class'] : '') + ) +}; +ChartInternal.prototype.classEvent = function(d) { + return this.generateClass(CLASS.eventRect, d.index) +}; +ChartInternal.prototype.classTarget = function(id) { + var $$ = this; + var additionalClassSuffix = $$.config.data_classes[id], + additionalClass = ''; + if (additionalClassSuffix) { + additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; + } + return $$.generateClass(CLASS.target, id) + additionalClass +}; +ChartInternal.prototype.classFocus = function(d) { + return this.classFocused(d) + this.classDefocused(d) +}; +ChartInternal.prototype.classFocused = function(d) { + return ' ' + (this.focusedTargetIds.indexOf(d.id) >= 0 ? CLASS.focused : '') +}; +ChartInternal.prototype.classDefocused = function(d) { + return ( + ' ' + (this.defocusedTargetIds.indexOf(d.id) >= 0 ? CLASS.defocused : '') + ) +}; +ChartInternal.prototype.classChartText = function(d) { + return CLASS.chartText + this.classTarget(d.id) +}; +ChartInternal.prototype.classChartLine = function(d) { + return CLASS.chartLine + this.classTarget(d.id) +}; +ChartInternal.prototype.classChartBar = function(d) { + return CLASS.chartBar + this.classTarget(d.id) +}; +ChartInternal.prototype.classChartArc = function(d) { + return CLASS.chartArc + this.classTarget(d.data.id) +}; +ChartInternal.prototype.getTargetSelectorSuffix = function(targetId) { + const targetClass = this.generateTargetClass(targetId); + if (window.CSS && window.CSS.escape) { + return window.CSS.escape(targetClass) + } + + // fallback on imperfect method for old browsers (does not handles unicode) + return targetClass.replace(/([?!@#$%^&*()=+,.<>'":;\[\]\/|~`{}\\])/g, '\\$1') +}; +ChartInternal.prototype.selectorTarget = function(id, prefix) { + return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id) +}; +ChartInternal.prototype.selectorTargets = function(ids, prefix) { + var $$ = this; + ids = ids || []; + return ids.length + ? ids.map(function(id) { + return $$.selectorTarget(id, prefix) + }) + : null +}; +ChartInternal.prototype.selectorLegend = function(id) { + return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id) +}; +ChartInternal.prototype.selectorLegends = function(ids) { + var $$ = this; + return ids && ids.length + ? ids.map(function(id) { + return $$.selectorLegend(id) + }) + : null +}; + +ChartInternal.prototype.getClipPath = function(id) { + return 'url(' + (isIE(9) ? '' : document.URL.split('#')[0]) + '#' + id + ')' +}; +ChartInternal.prototype.appendClip = function(parent, id) { + return parent + .append('clipPath') + .attr('id', id) + .append('rect') +}; +ChartInternal.prototype.getAxisClipX = function(forHorizontal) { + // axis line width + padding for left + var left = Math.max(30, this.margin.left); + return forHorizontal ? -(1 + left) : -(left - 1) +}; +ChartInternal.prototype.getAxisClipY = function(forHorizontal) { + return forHorizontal ? -20 : -this.margin.top +}; +ChartInternal.prototype.getXAxisClipX = function() { + var $$ = this; + return $$.getAxisClipX(!$$.config.axis_rotated) +}; +ChartInternal.prototype.getXAxisClipY = function() { + var $$ = this; + return $$.getAxisClipY(!$$.config.axis_rotated) +}; +ChartInternal.prototype.getYAxisClipX = function() { + var $$ = this; + return $$.config.axis_y_inner ? -1 : $$.getAxisClipX($$.config.axis_rotated) +}; +ChartInternal.prototype.getYAxisClipY = function() { + var $$ = this; + return $$.getAxisClipY($$.config.axis_rotated) +}; +ChartInternal.prototype.getAxisClipWidth = function(forHorizontal) { + var $$ = this, + left = Math.max(30, $$.margin.left), + right = Math.max(30, $$.margin.right); + // width + axis line width + padding for left/right + return forHorizontal ? $$.width + 2 + left + right : $$.margin.left + 20 +}; +ChartInternal.prototype.getAxisClipHeight = function(forHorizontal) { + // less than 20 is not enough to show the axis label 'outer' without legend + return ( + (forHorizontal ? this.margin.bottom : this.margin.top + this.height) + 20 + ) +}; +ChartInternal.prototype.getXAxisClipWidth = function() { + var $$ = this; + return $$.getAxisClipWidth(!$$.config.axis_rotated) +}; +ChartInternal.prototype.getXAxisClipHeight = function() { + var $$ = this; + return $$.getAxisClipHeight(!$$.config.axis_rotated) +}; +ChartInternal.prototype.getYAxisClipWidth = function() { + var $$ = this; + return ( + $$.getAxisClipWidth($$.config.axis_rotated) + + ($$.config.axis_y_inner ? 20 : 0) + ) +}; +ChartInternal.prototype.getYAxisClipHeight = function() { + var $$ = this; + return $$.getAxisClipHeight($$.config.axis_rotated) +}; + +ChartInternal.prototype.generateColor = function() { + var $$ = this, + config = $$.config, + d3 = $$.d3, + colors = config.data_colors, + pattern = notEmpty(config.color_pattern) + ? config.color_pattern + : d3.schemeCategory10, + callback = config.data_color, + ids = []; + + return function(d) { + var id = d.id || (d.data && d.data.id) || d, + color; + + // if callback function is provided + if (colors[id] instanceof Function) { + color = colors[id](d); + } + // if specified, choose that color + else if (colors[id]) { + color = colors[id]; + } + // if not specified, choose from pattern + else { + if (ids.indexOf(id) < 0) { + ids.push(id); + } + color = pattern[ids.indexOf(id) % pattern.length]; + colors[id] = color; + } + return callback instanceof Function ? callback(color, d) : color + } +}; +ChartInternal.prototype.generateLevelColor = function() { + var $$ = this, + config = $$.config, + colors = config.color_pattern, + threshold = config.color_threshold, + asValue = threshold.unit === 'value', + values = + threshold.values && threshold.values.length ? threshold.values : [], + max = threshold.max || 100; + return notEmpty(threshold) && notEmpty(colors) + ? function(value) { + var i, + v, + color = colors[colors.length - 1]; + for (i = 0; i < values.length; i++) { + v = asValue ? value : (value * 100) / max; + if (v < values[i]) { + color = colors[i]; + break + } + } + return color + } + : null +}; + +ChartInternal.prototype.getDefaultConfig = function() { + var config = { + bindto: '#chart', + svg_classname: undefined, + size_width: undefined, + size_height: undefined, + padding_left: undefined, + padding_right: undefined, + padding_top: undefined, + padding_bottom: undefined, + resize_auto: true, + zoom_enabled: false, + zoom_initialRange: undefined, + zoom_type: 'scroll', + zoom_disableDefaultBehavior: false, + zoom_privileged: false, + zoom_rescale: false, + zoom_onzoom: function() {}, + zoom_onzoomstart: function() {}, + zoom_onzoomend: function() {}, + zoom_x_min: undefined, + zoom_x_max: undefined, + interaction_brighten: true, + interaction_enabled: true, + onmouseover: function() {}, + onmouseout: function() {}, + onresize: function() {}, + onresized: function() {}, + oninit: function() {}, + onrendered: function() {}, + transition_duration: 350, + data_epochs: 'epochs', + data_x: undefined, + data_xs: {}, + data_xFormat: '%Y-%m-%d', + data_xLocaltime: true, + data_xSort: true, + data_idConverter: function(id) { + return id + }, + data_names: {}, + data_classes: {}, + data_groups: [], + data_axes: {}, + data_type: undefined, + data_types: {}, + data_labels: {}, + data_order: 'desc', + data_regions: {}, + data_color: undefined, + data_colors: {}, + data_hide: false, + data_filter: undefined, + data_selection_enabled: false, + data_selection_grouped: false, + data_selection_isselectable: function() { + return true + }, + data_selection_multiple: true, + data_selection_draggable: false, + data_stack_normalize: false, + data_onclick: function() {}, + data_onmouseover: function() {}, + data_onmouseout: function() {}, + data_onselected: function() {}, + data_onunselected: function() {}, + data_url: undefined, + data_headers: undefined, + data_json: undefined, + data_rows: undefined, + data_columns: undefined, + data_mimeType: undefined, + data_keys: undefined, + // configuration for no plot-able data supplied. + data_empty_label_text: '', + // subchart + subchart_show: false, + subchart_size_height: 60, + subchart_axis_x_show: true, + subchart_onbrush: function() {}, + // color + color_pattern: [], + color_threshold: {}, + // legend + legend_show: true, + legend_hide: false, + legend_position: 'bottom', + legend_inset_anchor: 'top-left', + legend_inset_x: 10, + legend_inset_y: 0, + legend_inset_step: undefined, + legend_item_onclick: undefined, + legend_item_onmouseover: undefined, + legend_item_onmouseout: undefined, + legend_equally: false, + legend_padding: 0, + legend_item_tile_width: 10, + legend_item_tile_height: 10, + // axis + axis_rotated: false, + axis_x_show: true, + axis_x_type: 'indexed', + axis_x_localtime: true, + axis_x_categories: [], + axis_x_tick_centered: false, + axis_x_tick_format: undefined, + axis_x_tick_culling: {}, + axis_x_tick_culling_max: 10, + axis_x_tick_count: undefined, + axis_x_tick_fit: true, + axis_x_tick_values: null, + axis_x_tick_rotate: 0, + axis_x_tick_outer: true, + axis_x_tick_multiline: true, + axis_x_tick_multilineMax: 0, + axis_x_tick_width: null, + axis_x_max: undefined, + axis_x_min: undefined, + axis_x_padding: {}, + axis_x_height: undefined, + axis_x_selection: undefined, + axis_x_label: {}, + axis_x_inner: undefined, + axis_y_show: true, + axis_y_type: 'linear', + axis_y_max: undefined, + axis_y_min: undefined, + axis_y_inverted: false, + axis_y_center: undefined, + axis_y_inner: undefined, + axis_y_label: {}, + axis_y_tick_format: undefined, + axis_y_tick_outer: true, + axis_y_tick_values: null, + axis_y_tick_rotate: 0, + axis_y_tick_count: undefined, + axis_y_tick_time_type: undefined, + axis_y_tick_time_interval: undefined, + axis_y_padding: {}, + axis_y_default: undefined, + axis_y2_show: false, + axis_y2_type: 'linear', + axis_y2_max: undefined, + axis_y2_min: undefined, + axis_y2_inverted: false, + axis_y2_center: undefined, + axis_y2_inner: undefined, + axis_y2_label: {}, + axis_y2_tick_format: undefined, + axis_y2_tick_outer: true, + axis_y2_tick_values: null, + axis_y2_tick_count: undefined, + axis_y2_padding: {}, + axis_y2_default: undefined, + // grid + grid_x_show: false, + grid_x_type: 'tick', + grid_x_lines: [], + grid_y_show: false, + // not used + // grid_y_type: 'tick', + grid_y_lines: [], + grid_y_ticks: 10, + grid_focus_show: true, + grid_lines_front: true, + // point - point of each data + point_show: true, + point_r: 2.5, + point_sensitivity: 10, + point_focus_expand_enabled: true, + point_focus_expand_r: undefined, + point_select_r: undefined, + // line + line_connectNull: false, + line_step_type: 'step', + // bar + bar_width: undefined, + bar_width_ratio: 0.6, + bar_width_max: undefined, + bar_zerobased: true, + bar_space: 0, + // area + area_zerobased: true, + area_above: false, + // pie + pie_label_show: true, + pie_label_format: undefined, + pie_label_threshold: 0.05, + pie_label_ratio: undefined, + pie_expand: {}, + pie_expand_duration: 50, + pie_padAngle: 0, + // gauge + gauge_fullCircle: false, + gauge_label_show: true, + gauge_labelLine_show: true, + gauge_label_format: undefined, + gauge_min: 0, + gauge_max: 100, + gauge_startingAngle: (-1 * Math.PI) / 2, + gauge_label_extents: undefined, + gauge_units: undefined, + gauge_width: undefined, + gauge_arcs_minWidth: 5, + gauge_expand: {}, + gauge_expand_duration: 50, + // donut + donut_label_show: true, + donut_label_format: undefined, + donut_label_threshold: 0.05, + donut_label_ratio: undefined, + donut_width: undefined, + donut_title: '', + donut_expand: {}, + donut_expand_duration: 50, + donut_padAngle: 0, + // spline + spline_interpolation_type: 'cardinal', + // stanford + stanford_lines: [], + stanford_regions: [], + stanford_texts: [], + stanford_scaleMin: undefined, + stanford_scaleMax: undefined, + stanford_scaleWidth: undefined, + stanford_scaleFormat: undefined, + stanford_scaleValues: undefined, + stanford_colors: undefined, + stanford_padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + // region - region to change style + regions: [], + // tooltip - show when mouseover on each data + tooltip_show: true, + tooltip_grouped: true, + tooltip_order: undefined, + tooltip_format_title: undefined, + tooltip_format_name: undefined, + tooltip_format_value: undefined, + tooltip_horizontal: undefined, + tooltip_position: undefined, + tooltip_contents: function( + d, + defaultTitleFormat, + defaultValueFormat, + color + ) { + return this.getTooltipContent + ? this.getTooltipContent( + d, + defaultTitleFormat, + defaultValueFormat, + color + ) + : '' + }, + tooltip_init_show: false, + tooltip_init_x: 0, + tooltip_init_position: { top: '0px', left: '50px' }, + tooltip_onshow: function() {}, + tooltip_onhide: function() {}, + // title + title_text: undefined, + title_padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + title_position: 'top-center' + }; + + Object.keys(this.additionalConfig).forEach(function(key) { + config[key] = this.additionalConfig[key]; + }, this); + + return config +}; +ChartInternal.prototype.additionalConfig = {}; + +ChartInternal.prototype.loadConfig = function(config) { + var this_config = this.config, + target, + keys, + read; + function find() { + var key = keys.shift(); + // console.log("key =>", key, ", target =>", target); + if (key && target && typeof target === 'object' && key in target) { + target = target[key]; + return find() + } else if (!key) { + return target + } else { + return undefined + } + } + Object.keys(this_config).forEach(function(key) { + target = config; + keys = key.split('_'); + read = find(); + // console.log("CONFIG : ", key, read); + if (isDefined(read)) { + this_config[key] = read; + } + }); +}; + +ChartInternal.prototype.convertUrlToData = function( + url, + mimeType, + headers, + keys, + done +) { + var $$ = this, + type = mimeType ? mimeType : 'csv', + f, + converter; + + if (type === 'json') { + f = $$.d3.json; + converter = $$.convertJsonToData; + } else if (type === 'tsv') { + f = $$.d3.tsv; + converter = $$.convertXsvToData; + } else { + f = $$.d3.csv; + converter = $$.convertXsvToData; + } + + f(url, headers) + .then(function(data) { + done.call($$, converter.call($$, data, keys)); + }) + .catch(function(error) { + throw error + }); +}; +ChartInternal.prototype.convertXsvToData = function(xsv) { + var keys = xsv.columns, + rows = xsv; + if (rows.length === 0) { + return { + keys, + rows: [keys.reduce((row, key) => Object.assign(row, { [key]: null }), {})] + } + } else { + // [].concat() is to convert result into a plain array otherwise + // test is not happy because rows have properties. + return { keys, rows: [].concat(xsv) } + } +}; +ChartInternal.prototype.convertJsonToData = function(json, keys) { + var $$ = this, + new_rows = [], + targetKeys, + data; + if (keys) { + // when keys specified, json would be an array that includes objects + if (keys.x) { + targetKeys = keys.value.concat(keys.x); + $$.config.data_x = keys.x; + } else { + targetKeys = keys.value; + } + new_rows.push(targetKeys); + json.forEach(function(o) { + var new_row = []; + targetKeys.forEach(function(key) { + // convert undefined to null because undefined data will be removed in convertDataToTargets() + var v = $$.findValueInJson(o, key); + if (isUndefined(v)) { + v = null; + } + new_row.push(v); + }); + new_rows.push(new_row); + }); + data = $$.convertRowsToData(new_rows); + } else { + Object.keys(json).forEach(function(key) { + new_rows.push([key].concat(json[key])); + }); + data = $$.convertColumnsToData(new_rows); + } + return data +}; +/** + * Finds value from the given nested object by the given path. + * If it's not found, then this returns undefined. + * @param {Object} object the object + * @param {string} path the path + */ +ChartInternal.prototype.findValueInJson = function(object, path) { + if (path in object) { + // If object has a key that contains . or [], return the key's value + // instead of searching for an inner object. + // See https://github.com/c3js/c3/issues/1691 for details. + return object[path] + } + + path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties (replace [] with .) + path = path.replace(/^\./, ''); // strip a leading dot + var pathArray = path.split('.'); + for (var i = 0; i < pathArray.length; ++i) { + var k = pathArray[i]; + if (k in object) { + object = object[k]; + } else { + return + } + } + return object +}; + +/** + * Converts the rows to normalized data. + * @param {any[][]} rows The row data + * @return {Object} + */ +ChartInternal.prototype.convertRowsToData = rows => { + const newRows = []; + const keys = rows[0]; + + for (let i = 1; i < rows.length; i++) { + const newRow = {}; + for (let j = 0; j < rows[i].length; j++) { + if (isUndefined(rows[i][j])) { + throw new Error( + 'Source data is missing a component at (' + i + ',' + j + ')!' + ) + } + newRow[keys[j]] = rows[i][j]; + } + newRows.push(newRow); + } + return { keys, rows: newRows } +}; + +/** + * Converts the columns to normalized data. + * @param {any[][]} columns The column data + * @return {Object} + */ +ChartInternal.prototype.convertColumnsToData = columns => { + const newRows = []; + const keys = []; + + for (let i = 0; i < columns.length; i++) { + const key = columns[i][0]; + for (let j = 1; j < columns[i].length; j++) { + if (isUndefined(newRows[j - 1])) { + newRows[j - 1] = {}; + } + if (isUndefined(columns[i][j])) { + throw new Error( + 'Source data is missing a component at (' + i + ',' + j + ')!' + ) + } + newRows[j - 1][key] = columns[i][j]; + } + keys.push(key); + } + + return { keys, rows: newRows } +}; + +/** + * Converts the data format into the target format. + * @param {!Object} data + * @param {!Array} data.keys Ordered list of target IDs. + * @param {!Array} data.rows Rows of data to convert. + * @param {boolean} appendXs True to append to $$.data.xs, False to replace. + * @return {!Array} + */ +ChartInternal.prototype.convertDataToTargets = function(data, appendXs) { + var $$ = this, + config = $$.config, + targets, + ids, + xs, + keys, + epochs; + + // handles format where keys are not orderly provided + if (isArray(data)) { + keys = Object.keys(data[0]); + } else { + keys = data.keys; + data = data.rows; + } + + xs = keys.filter($$.isX, $$); + + if (!$$.isStanfordGraphType()) { + ids = keys.filter($$.isNotX, $$); + } else { + epochs = keys.filter($$.isEpochs, $$); + ids = keys.filter($$.isNotXAndNotEpochs, $$); + + if (xs.length !== 1 || epochs.length !== 1 || ids.length !== 1) { + throw new Error( + "You must define the 'x' key name and the 'epochs' for Stanford Diagrams" + ) + } + } + + // save x for update data by load when custom x and c3.x API + ids.forEach(function(id) { + var xKey = $$.getXKey(id); + + if ($$.isCustomX() || $$.isTimeSeries()) { + // if included in input data + if (xs.indexOf(xKey) >= 0) { + $$.data.xs[id] = (appendXs && $$.data.xs[id] + ? $$.data.xs[id] + : [] + ).concat( + data + .map(function(d) { + return d[xKey] + }) + .filter(isValue) + .map(function(rawX, i) { + return $$.generateTargetX(rawX, id, i) + }) + ); + } + // if not included in input data, find from preloaded data of other id's x + else if (config.data_x) { + $$.data.xs[id] = $$.getOtherTargetXs(); + } + // if not included in input data, find from preloaded data + else if (notEmpty(config.data_xs)) { + $$.data.xs[id] = $$.getXValuesOfXKey(xKey, $$.data.targets); + } + // MEMO: if no x included, use same x of current will be used + } else { + $$.data.xs[id] = data.map(function(d, i) { + return i + }); + } + }); + + // check x is defined + ids.forEach(function(id) { + if (!$$.data.xs[id]) { + throw new Error('x is not defined for id = "' + id + '".') + } + }); + + // convert to target + targets = ids.map(function(id, index) { + var convertedId = config.data_idConverter(id); + return { + id: convertedId, + id_org: id, + values: data + .map(function(d, i) { + var xKey = $$.getXKey(id), + rawX = d[xKey], + value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null, + x, + returnData; + // use x as categories if custom x and categorized + if ($$.isCustomX() && $$.isCategorized() && !isUndefined(rawX)) { + if (index === 0 && i === 0) { + config.axis_x_categories = []; + } + x = config.axis_x_categories.indexOf(rawX); + if (x === -1) { + x = config.axis_x_categories.length; + config.axis_x_categories.push(rawX); + } + } else { + x = $$.generateTargetX(rawX, id, i); + } + // mark as x = undefined if value is undefined and filter to remove after mapped + if (isUndefined(d[id]) || $$.data.xs[id].length <= i) { + x = undefined; + } + + returnData = { x: x, value: value, id: convertedId }; + + if ($$.isStanfordGraphType()) { + returnData.epochs = d[epochs]; + } + + return returnData + }) + .filter(function(v) { + return isDefined(v.x) + }) + } + }); + + // finish targets + targets.forEach(function(t) { + var i; + // sort values by its x + if (config.data_xSort) { + t.values = t.values.sort(function(v1, v2) { + var x1 = v1.x || v1.x === 0 ? v1.x : Infinity, + x2 = v2.x || v2.x === 0 ? v2.x : Infinity; + return x1 - x2 + }); + } + // indexing each value + i = 0; + t.values.forEach(function(v) { + v.index = i++; + }); + // this needs to be sorted because its index and value.index is identical + $$.data.xs[t.id].sort(function(v1, v2) { + return v1 - v2 + }); + }); + + // cache information about values + $$.hasNegativeValue = $$.hasNegativeValueInTargets(targets); + $$.hasPositiveValue = $$.hasPositiveValueInTargets(targets); + + // set target types + if (config.data_type) { + $$.setTargetType( + $$.mapToIds(targets).filter(function(id) { + return !(id in config.data_types) + }), + config.data_type + ); + } + + // cache as original id keyed + targets.forEach(function(d) { + $$.addCache(d.id_org, d); + }); + + return targets +}; + +ChartInternal.prototype.isEpochs = function(key) { + var $$ = this, + config = $$.config; + return config.data_epochs && key === config.data_epochs +}; +ChartInternal.prototype.isX = function(key) { + var $$ = this, + config = $$.config; + return ( + (config.data_x && key === config.data_x) || + (notEmpty(config.data_xs) && hasValue(config.data_xs, key)) + ) +}; +ChartInternal.prototype.isNotX = function(key) { + return !this.isX(key) +}; +ChartInternal.prototype.isNotXAndNotEpochs = function(key) { + return !this.isX(key) && !this.isEpochs(key) +}; + +/** + * Returns whether the normalized stack option is enabled or not. + * + * To be enabled it must also have data.groups defined. + * + * @return {boolean} + */ +ChartInternal.prototype.isStackNormalized = function() { + return this.config.data_stack_normalize && this.config.data_groups.length > 0 +}; + +/** + * Returns whether the axis is normalized or not. + * + * An axis is normalized as long as one of its associated target + * is normalized. + * + * @param axisId Axis ID (y or y2) + * @return {Boolean} + */ +ChartInternal.prototype.isAxisNormalized = function(axisId) { + const $$ = this; + + if (!$$.isStackNormalized()) { + // shortcut + return false + } + + return $$.data.targets + .filter(target => $$.axis.getId(target.id) === axisId) + .some(target => $$.isTargetNormalized(target.id)) +}; + +/** + * Returns whether the values for this target ID is normalized or not. + * + * To be normalized the option needs to be enabled and target needs + * to be defined in `data.groups`. + * + * @param targetId ID of the target + * @return {Boolean} True if the target is normalized, false otherwise. + */ +ChartInternal.prototype.isTargetNormalized = function(targetId) { + const $$ = this; + + return ( + $$.isStackNormalized() && + $$.config.data_groups.some(group => group.includes(targetId)) + ) +}; + +ChartInternal.prototype.getXKey = function(id) { + var $$ = this, + config = $$.config; + return config.data_x + ? config.data_x + : notEmpty(config.data_xs) + ? config.data_xs[id] + : null +}; + +/** + * Get sum of visible data per index for given axis. + * + * Expect axisId to be either 'y' or 'y2'. + * + * @private + * @param axisId Compute sum for data associated to given axis. + * @return {Array} + */ +ChartInternal.prototype.getTotalPerIndex = function(axisId) { + const $$ = this; + + if (!$$.isStackNormalized()) { + return null + } + + const cached = $$.getFromCache('getTotalPerIndex'); + if (cached !== undefined) { + return cached[axisId] + } + + const sum = { y: [], y2: [] }; + + $$.data.targets + // keep only target that are normalized + .filter(target => $$.isTargetNormalized(target.id)) + + // keep only target that are visible + .filter(target => $$.isTargetToShow(target.id)) + + // compute sum per axis + .forEach(target => { + const sumByAxis = sum[$$.axis.getId(target.id)]; + + target.values.forEach((v, i) => { + if (!sumByAxis[i]) { + sumByAxis[i] = 0; + } + sumByAxis[i] += isNumber(v.value) ? v.value : 0; + }); + }); + + $$.addToCache('getTotalPerIndex', sum); + + return sum[axisId] +}; + +/** + * Get sum of visible data. + * + * Should be used for normalised data only since all values + * are expected to be positive. + * + * @private + * @return {Number} + */ +ChartInternal.prototype.getTotalDataSum = function() { + const $$ = this; + + const cached = $$.getFromCache('getTotalDataSum'); + if (cached !== undefined) { + return cached + } + + const totalDataSum = flattenArray( + $$.data.targets + .filter(target => $$.isTargetToShow(target.id)) + .map(target => target.values) + ) + .map(d => d.value) + .reduce((p, c) => p + c, 0); + + $$.addToCache('getTotalDataSum', totalDataSum); + + return totalDataSum +}; + +ChartInternal.prototype.getXValuesOfXKey = function(key, targets) { + var $$ = this, + xValues, + ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : []; + ids.forEach(function(id) { + if ($$.getXKey(id) === key) { + xValues = $$.data.xs[id]; + } + }); + return xValues +}; +ChartInternal.prototype.getXValue = function(id, i) { + var $$ = this; + return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) + ? $$.data.xs[id][i] + : i +}; +ChartInternal.prototype.getOtherTargetXs = function() { + var $$ = this, + idsForX = Object.keys($$.data.xs); + return idsForX.length ? $$.data.xs[idsForX[0]] : null +}; +ChartInternal.prototype.getOtherTargetX = function(index) { + var xs = this.getOtherTargetXs(); + return xs && index < xs.length ? xs[index] : null +}; +ChartInternal.prototype.addXs = function(xs) { + var $$ = this; + Object.keys(xs).forEach(function(id) { + $$.config.data_xs[id] = xs[id]; + }); +}; +ChartInternal.prototype.addName = function(data) { + var $$ = this, + name; + if (data) { + name = $$.config.data_names[data.id]; + data.name = name !== undefined ? name : data.id; + } + return data +}; +ChartInternal.prototype.getValueOnIndex = function(values, index) { + var valueOnIndex = values.filter(function(v) { + return v.index === index + }); + return valueOnIndex.length ? valueOnIndex[0] : null +}; +ChartInternal.prototype.updateTargetX = function(targets, x) { + var $$ = this; + targets.forEach(function(t) { + t.values.forEach(function(v, i) { + v.x = $$.generateTargetX(x[i], t.id, i); + }); + $$.data.xs[t.id] = x; + }); +}; +ChartInternal.prototype.updateTargetXs = function(targets, xs) { + var $$ = this; + targets.forEach(function(t) { + if (xs[t.id]) { + $$.updateTargetX([t], xs[t.id]); + } + }); +}; +ChartInternal.prototype.generateTargetX = function(rawX, id, index) { + var $$ = this, + x; + if ($$.isTimeSeries()) { + x = rawX ? $$.parseDate(rawX) : $$.parseDate($$.getXValue(id, index)); + } else if ($$.isCustomX() && !$$.isCategorized()) { + x = isValue(rawX) ? +rawX : $$.getXValue(id, index); + } else { + x = index; + } + return x +}; +ChartInternal.prototype.cloneTarget = function(target) { + return { + id: target.id, + id_org: target.id_org, + values: target.values.map(function(d) { + return { + x: d.x, + value: d.value, + id: d.id + } + }) + } +}; +ChartInternal.prototype.getMaxDataCount = function() { + var $$ = this; + return $$.d3.max($$.data.targets, function(t) { + return t.values.length + }) +}; +ChartInternal.prototype.mapToIds = function(targets) { + return targets.map(function(d) { + return d.id + }) +}; +ChartInternal.prototype.mapToTargetIds = function(ids) { + var $$ = this; + return ids ? [].concat(ids) : $$.mapToIds($$.data.targets) +}; +ChartInternal.prototype.hasTarget = function(targets, id) { + var ids = this.mapToIds(targets), + i; + for (i = 0; i < ids.length; i++) { + if (ids[i] === id) { + return true + } + } + return false +}; +ChartInternal.prototype.isTargetToShow = function(targetId) { + return this.hiddenTargetIds.indexOf(targetId) < 0 +}; +ChartInternal.prototype.isLegendToShow = function(targetId) { + return this.hiddenLegendIds.indexOf(targetId) < 0 +}; + +/** + * Returns only visible targets. + * + * This is the same as calling {@link filterTargetsToShow} on $$.data.targets. + * + * @return {Array} + */ +ChartInternal.prototype.getTargetsToShow = function() { + const $$ = this; + return $$.filterTargetsToShow($$.data.targets) +}; + +ChartInternal.prototype.filterTargetsToShow = function(targets) { + var $$ = this; + return targets.filter(function(t) { + return $$.isTargetToShow(t.id) + }) +}; + +/** + * @return {Array} Returns all the targets attached to the chart, visible or not + */ +ChartInternal.prototype.getTargets = function() { + const $$ = this; + return $$.data.targets +}; + +ChartInternal.prototype.mapTargetsToUniqueXs = function(targets) { + var $$ = this; + var xs = $$.d3 + .set( + $$.d3.merge( + targets.map(function(t) { + return t.values.map(function(v) { + return +v.x + }) + }) + ) + ) + .values(); + xs = $$.isTimeSeries() + ? xs.map(function(x) { + return new Date(+x) + }) + : xs.map(function(x) { + return +x + }); + return xs.sort(function(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN + }) +}; +ChartInternal.prototype.addHiddenTargetIds = function(targetIds) { + targetIds = targetIds instanceof Array ? targetIds : new Array(targetIds); + for (var i = 0; i < targetIds.length; i++) { + if (this.hiddenTargetIds.indexOf(targetIds[i]) < 0) { + this.hiddenTargetIds = this.hiddenTargetIds.concat(targetIds[i]); + } + } + this.resetCache(); +}; +ChartInternal.prototype.removeHiddenTargetIds = function(targetIds) { + this.hiddenTargetIds = this.hiddenTargetIds.filter(function(id) { + return targetIds.indexOf(id) < 0 + }); + this.resetCache(); +}; +ChartInternal.prototype.addHiddenLegendIds = function(targetIds) { + targetIds = targetIds instanceof Array ? targetIds : new Array(targetIds); + for (var i = 0; i < targetIds.length; i++) { + if (this.hiddenLegendIds.indexOf(targetIds[i]) < 0) { + this.hiddenLegendIds = this.hiddenLegendIds.concat(targetIds[i]); + } + } +}; +ChartInternal.prototype.removeHiddenLegendIds = function(targetIds) { + this.hiddenLegendIds = this.hiddenLegendIds.filter(function(id) { + return targetIds.indexOf(id) < 0 + }); +}; +ChartInternal.prototype.getValuesAsIdKeyed = function(targets) { + var ys = {}; + targets.forEach(function(t) { + ys[t.id] = []; + t.values.forEach(function(v) { + ys[t.id].push(v.value); + }); + }); + return ys +}; +ChartInternal.prototype.checkValueInTargets = function(targets, checker) { + var ids = Object.keys(targets), + i, + j, + values; + for (i = 0; i < ids.length; i++) { + values = targets[ids[i]].values; + for (j = 0; j < values.length; j++) { + if (checker(values[j].value)) { + return true + } + } + } + return false +}; +ChartInternal.prototype.hasNegativeValueInTargets = function(targets) { + return this.checkValueInTargets(targets, function(v) { + return v < 0 + }) +}; +ChartInternal.prototype.hasPositiveValueInTargets = function(targets) { + return this.checkValueInTargets(targets, function(v) { + return v > 0 + }) +}; +ChartInternal.prototype.isOrderDesc = function() { + var config = this.config; + return ( + typeof config.data_order === 'string' && + config.data_order.toLowerCase() === 'desc' + ) +}; +ChartInternal.prototype.isOrderAsc = function() { + var config = this.config; + return ( + typeof config.data_order === 'string' && + config.data_order.toLowerCase() === 'asc' + ) +}; +ChartInternal.prototype.getOrderFunction = function() { + var $$ = this, + config = $$.config, + orderAsc = $$.isOrderAsc(), + orderDesc = $$.isOrderDesc(); + if (orderAsc || orderDesc) { + var reducer = function(p, c) { + return p + Math.abs(c.value) + }; + return function(t1, t2) { + var t1Sum = t1.values.reduce(reducer, 0), + t2Sum = t2.values.reduce(reducer, 0); + return orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum + } + } else if (isFunction(config.data_order)) { + return config.data_order + } else if (isArray(config.data_order)) { + var order = config.data_order; + return function(t1, t2) { + return order.indexOf(t1.id) - order.indexOf(t2.id) + } + } +}; +ChartInternal.prototype.orderTargets = function(targets) { + var fct = this.getOrderFunction(); + if (fct) { + targets.sort(fct); + } + return targets +}; + +/** + * Returns all the values from the given targets at the given index. + * + * @param {Array} targets + * @param {Number} index + * @return {Array} + */ +ChartInternal.prototype.filterByIndex = function(targets, index) { + return this.d3.merge( + targets.map(t => t.values.filter(v => v.index === index)) + ) +}; + +ChartInternal.prototype.filterByX = function(targets, x) { + return this.d3 + .merge( + targets.map(function(t) { + return t.values + }) + ) + .filter(function(v) { + return v.x - x === 0 + }) +}; +ChartInternal.prototype.filterRemoveNull = function(data) { + return data.filter(function(d) { + return isValue(d.value) + }) +}; +ChartInternal.prototype.filterByXDomain = function(targets, xDomain) { + return targets.map(function(t) { + return { + id: t.id, + id_org: t.id_org, + values: t.values.filter(function(v) { + return xDomain[0] <= v.x && v.x <= xDomain[1] + }) + } + }) +}; +ChartInternal.prototype.hasDataLabel = function() { + var config = this.config; + if (typeof config.data_labels === 'boolean' && config.data_labels) { + return true + } else if ( + typeof config.data_labels === 'object' && + notEmpty(config.data_labels) + ) { + return true + } + return false +}; +ChartInternal.prototype.getDataLabelLength = function(min, max, key) { + var $$ = this, + lengths = [0, 0], + paddingCoef = 1.3; + $$.selectChart + .select('svg') + .selectAll('.dummy') + .data([min, max]) + .enter() + .append('text') + .text(function(d) { + return $$.dataLabelFormat(d.id)(d) + }) + .each(function(d, i) { + lengths[i] = getBBox(this)[key] * paddingCoef; + }) + .remove(); + return lengths +}; +/** + * Returns true if the given data point is not arc type, otherwise false. + * @param {Object} d The data point + * @return {boolean} + */ +ChartInternal.prototype.isNoneArc = function(d) { + return this.hasTarget(this.data.targets, d.id) +}; + +/** + * Returns true if the given data point is arc type, otherwise false. + * @param {Object} d The data point + * @return {boolean} + */ +ChartInternal.prototype.isArc = function(d) { + return 'data' in d && this.hasTarget(this.data.targets, d.data.id) +}; + +/** + * Find the closest point from the given pos among the given targets or + * undefined if none satisfies conditions. + * + * @param {Array} targets + * @param {Array} pos An [x,y] coordinate + * @return {Object|undefined} + */ +ChartInternal.prototype.findClosestFromTargets = function(targets, pos) { + const $$ = this; + + // for each target, find the closest point + const candidates = targets + .map(t => + $$.findClosest( + t.values, + pos, + $$.config.tooltip_horizontal + ? $$.horizontalDistance.bind($$) + : $$.dist.bind($$), + $$.config.point_sensitivity + ) + ) + .filter(v => v); + + // returns the closest of candidates + if (candidates.length === 0) { + return undefined + } else if (candidates.length === 1) { + return candidates[0] + } else { + return $$.findClosest(candidates, pos, $$.dist.bind($$)) + } +}; + +/** + * Find the closest point from the x value or undefined if none satisfies conditions. + * + * @param {Array} targets + * @param {Array} x A value on X axis + * @return {Object|undefined} + */ +ChartInternal.prototype.findClosestFromTargetsByX = function(targets, x) { + let closest; + let diff; + + targets.forEach(t => { + t.values.forEach(d => { + let newDiff = Math.abs(x - d.x); + + if (diff === undefined || newDiff < diff) { + closest = d; + diff = newDiff; + } + }); + }); + + return closest +}; + +/** + * Using given compute distance method, returns the closest data point from the + * given position. + * + * Giving optionally a minimum distance to satisfy. + * + * @param {Array} dataPoints List of DataPoints + * @param {Array} pos An [x,y] coordinate + * @param {Function} computeDist Function to compute distance between 2 points + * @param {Number} minDist Minimal distance to satisfy + * @return {Object|undefined} Closest data point + */ +ChartInternal.prototype.findClosest = function( + dataPoints, + pos, + computeDist, + minDist = Infinity +) { + const $$ = this; + + let closest; + + // find closest bar + dataPoints + .filter(v => v && $$.isBarType(v.id)) + .forEach(function(v) { + if (!closest) { + const shape = $$.main + .select( + '.' + + CLASS.bars + + $$.getTargetSelectorSuffix(v.id) + + ' .' + + CLASS.bar + + '-' + + v.index + ) + .node(); + if ($$.isWithinBar(pos, shape)) { + closest = v; + } + } + }); + + // find closest point from non-bar + dataPoints + .filter(v => v && !$$.isBarType(v.id)) + .forEach(v => { + let d = computeDist(v, pos); + if (d < minDist) { + minDist = d; + closest = v; + } + }); + + return closest +}; +ChartInternal.prototype.dist = function(data, pos) { + var $$ = this, + config = $$.config, + xIndex = config.axis_rotated ? 1 : 0, + yIndex = config.axis_rotated ? 0 : 1, + y = $$.circleY(data, data.index), + x = $$.x(data.x); + return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2)) +}; +ChartInternal.prototype.horizontalDistance = function(data, pos) { + var $$ = this, + config = $$.config, + xIndex = config.axis_rotated ? 1 : 0, + x = $$.x(data.x); + + return Math.abs(x - pos[xIndex]) +}; +ChartInternal.prototype.convertValuesToStep = function(values) { + var converted = [].concat(values), + i; + + if (!this.isCategorized()) { + return values + } + + for (i = values.length + 1; 0 < i; i--) { + converted[i] = converted[i - 1]; + } + + converted[0] = { + x: converted[0].x - 1, + value: converted[0].value, + id: converted[0].id + }; + converted[values.length + 1] = { + x: converted[values.length].x + 1, + value: converted[values.length].value, + id: converted[values.length].id + }; + + return converted +}; + +/** + * Get ratio value + * + * @param {String} type Ratio for given type + * @param {Object} d Data value object + * @param {Boolean} asPercent Convert the return as percent or not + * @return {Number} Ratio value + * @private + */ +ChartInternal.prototype.getRatio = function(type, d, asPercent = false) { + const $$ = this; + const api = $$.api; + let ratio = 0; + + if (d && api.data.shown.call(api).length) { + ratio = d.ratio || d.value; + + if (type === 'arc') { + if ($$.hasType('gauge')) { + ratio = + (d.endAngle - d.startAngle) / + (Math.PI * ($$.config.gauge_fullCircle ? 2 : 1)); + } else { + const total = $$.getTotalDataSum(); + + ratio = d.value / total; + } + } else if (type === 'index') { + const total = $$.getTotalPerIndex($$.axis.getId(d.id)); + + d.ratio = + isNumber(d.value) && total && total[d.index] > 0 + ? d.value / total[d.index] + : 0; + + ratio = d.ratio; + } + } + + return asPercent && ratio ? ratio * 100 : ratio +}; + +ChartInternal.prototype.updateDataAttributes = function(name, attrs) { + var $$ = this, + config = $$.config, + current = config['data_' + name]; + if (typeof attrs === 'undefined') { + return current + } + Object.keys(attrs).forEach(function(id) { + current[id] = attrs[id]; + }); + $$.redraw({ + withLegend: true + }); + return current +}; + +ChartInternal.prototype.load = function(targets, args) { + var $$ = this; + if (targets) { + // filter loading targets if needed + if (args.filter) { + targets = targets.filter(args.filter); + } + // set type if args.types || args.type specified + if (args.type || args.types) { + targets.forEach(function(t) { + var type = args.types && args.types[t.id] ? args.types[t.id] : args.type; + $$.setTargetType(t.id, type); + }); + } + // Update/Add data + $$.data.targets.forEach(function(d) { + for (var i = 0; i < targets.length; i++) { + if (d.id === targets[i].id) { + d.values = targets[i].values; + targets.splice(i, 1); + break + } + } + }); + $$.data.targets = $$.data.targets.concat(targets); // add remained + } + + // Set targets + $$.updateTargets($$.data.targets); + + // Redraw with new targets + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + + if (args.done) { + args.done(); + } +}; +ChartInternal.prototype.loadFromArgs = function(args) { + var $$ = this; + + $$.resetCache(); + + if (args.data) { + $$.load($$.convertDataToTargets(args.data), args); + } else if (args.url) { + $$.convertUrlToData( + args.url, + args.mimeType, + args.headers, + args.keys, + function(data) { + $$.load($$.convertDataToTargets(data), args); + } + ); + } else if (args.json) { + $$.load( + $$.convertDataToTargets($$.convertJsonToData(args.json, args.keys)), + args + ); + } else if (args.rows) { + $$.load($$.convertDataToTargets($$.convertRowsToData(args.rows)), args); + } else if (args.columns) { + $$.load( + $$.convertDataToTargets($$.convertColumnsToData(args.columns)), + args + ); + } else { + $$.load(null, args); + } +}; +ChartInternal.prototype.unload = function(targetIds, done) { + var $$ = this; + + $$.resetCache(); + + if (!done) { + done = function() {}; + } + // filter existing target + targetIds = targetIds.filter(function(id) { + return $$.hasTarget($$.data.targets, id) + }); + // If no target, call done and return + if (!targetIds || targetIds.length === 0) { + done(); + return + } + $$.svg + .selectAll( + targetIds.map(function(id) { + return $$.selectorTarget(id) + }) + ) + .transition() + .style('opacity', 0) + .remove() + .call($$.endall, done); + targetIds.forEach(function(id) { + // Reset fadein for future load + $$.withoutFadeIn[id] = false; + // Remove target's elements + if ($$.legend) { + $$.legend + .selectAll('.' + CLASS.legendItem + $$.getTargetSelectorSuffix(id)) + .remove(); + } + // Remove target + $$.data.targets = $$.data.targets.filter(function(t) { + return t.id !== id + }); + }); +}; + +ChartInternal.prototype.getYDomainMin = function(targets) { + var $$ = this, + config = $$.config, + ids = $$.mapToIds(targets), + ys = $$.getValuesAsIdKeyed(targets), + j, + k, + baseId, + idsInGroup, + id, + hasNegativeValue; + if (config.data_groups.length > 0) { + hasNegativeValue = $$.hasNegativeValueInTargets(targets); + for (j = 0; j < config.data_groups.length; j++) { + // Determine baseId + idsInGroup = config.data_groups[j].filter(function(id) { + return ids.indexOf(id) >= 0 + }); + if (idsInGroup.length === 0) { + continue + } + baseId = idsInGroup[0]; + // Consider negative values + if (hasNegativeValue && ys[baseId]) { + ys[baseId].forEach(function(v, i) { + ys[baseId][i] = v < 0 ? v : 0; + }); + } + // Compute min + for (k = 1; k < idsInGroup.length; k++) { + id = idsInGroup[k]; + if (!ys[id]) { + continue + } + ys[id].forEach(function(v, i) { + if ( + $$.axis.getId(id) === $$.axis.getId(baseId) && + ys[baseId] && + !(hasNegativeValue && +v > 0) + ) { + ys[baseId][i] += +v; + } + }); + } + } + } + return $$.d3.min( + Object.keys(ys).map(function(key) { + return $$.d3.min(ys[key]) + }) + ) +}; +ChartInternal.prototype.getYDomainMax = function(targets) { + var $$ = this, + config = $$.config, + ids = $$.mapToIds(targets), + ys = $$.getValuesAsIdKeyed(targets), + j, + k, + baseId, + idsInGroup, + id, + hasPositiveValue; + if (config.data_groups.length > 0) { + hasPositiveValue = $$.hasPositiveValueInTargets(targets); + for (j = 0; j < config.data_groups.length; j++) { + // Determine baseId + idsInGroup = config.data_groups[j].filter(function(id) { + return ids.indexOf(id) >= 0 + }); + if (idsInGroup.length === 0) { + continue + } + baseId = idsInGroup[0]; + // Consider positive values + if (hasPositiveValue && ys[baseId]) { + ys[baseId].forEach(function(v, i) { + ys[baseId][i] = v > 0 ? v : 0; + }); + } + // Compute max + for (k = 1; k < idsInGroup.length; k++) { + id = idsInGroup[k]; + if (!ys[id]) { + continue + } + ys[id].forEach(function(v, i) { + if ( + $$.axis.getId(id) === $$.axis.getId(baseId) && + ys[baseId] && + !(hasPositiveValue && +v < 0) + ) { + ys[baseId][i] += +v; + } + }); + } + } + } + return $$.d3.max( + Object.keys(ys).map(function(key) { + return $$.d3.max(ys[key]) + }) + ) +}; +ChartInternal.prototype.getYDomain = function(targets, axisId, xDomain) { + var $$ = this, + config = $$.config; + + if ($$.isAxisNormalized(axisId)) { + return [0, 100] + } + + var targetsByAxisId = targets.filter(function(t) { + return $$.axis.getId(t.id) === axisId + }), + yTargets = xDomain + ? $$.filterByXDomain(targetsByAxisId, xDomain) + : targetsByAxisId, + yMin = axisId === 'y2' ? config.axis_y2_min : config.axis_y_min, + yMax = axisId === 'y2' ? config.axis_y2_max : config.axis_y_max, + yDomainMin = $$.getYDomainMin(yTargets), + yDomainMax = $$.getYDomainMax(yTargets), + domain, + domainLength, + padding_top, + padding_bottom, + center = axisId === 'y2' ? config.axis_y2_center : config.axis_y_center, + yDomainAbs, + lengths, + diff, + ratio, + isAllPositive, + isAllNegative, + isZeroBased = + ($$.hasType('bar', yTargets) && config.bar_zerobased) || + ($$.hasType('area', yTargets) && config.area_zerobased), + isInverted = + axisId === 'y2' ? config.axis_y2_inverted : config.axis_y_inverted, + showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated, + showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated; + + // MEMO: avoid inverting domain unexpectedly + yDomainMin = isValue(yMin) + ? yMin + : isValue(yMax) + ? yDomainMin < yMax + ? yDomainMin + : yMax - 10 + : yDomainMin; + yDomainMax = isValue(yMax) + ? yMax + : isValue(yMin) + ? yMin < yDomainMax + ? yDomainMax + : yMin + 10 + : yDomainMax; + + if (yTargets.length === 0) { + // use current domain if target of axisId is none + return axisId === 'y2' ? $$.y2.domain() : $$.y.domain() + } + if (isNaN(yDomainMin)) { + // set minimum to zero when not number + yDomainMin = 0; + } + if (isNaN(yDomainMax)) { + // set maximum to have same value as yDomainMin + yDomainMax = yDomainMin; + } + if (yDomainMin === yDomainMax) { + yDomainMin < 0 ? (yDomainMax = 0) : (yDomainMin = 0); + } + isAllPositive = yDomainMin >= 0 && yDomainMax >= 0; + isAllNegative = yDomainMin <= 0 && yDomainMax <= 0; + + // Cancel zerobased if axis_*_min / axis_*_max specified + if ((isValue(yMin) && isAllPositive) || (isValue(yMax) && isAllNegative)) { + isZeroBased = false; + } + + // Bar/Area chart should be 0-based if all positive|negative + if (isZeroBased) { + if (isAllPositive) { + yDomainMin = 0; + } + if (isAllNegative) { + yDomainMax = 0; + } + } + + domainLength = Math.abs(yDomainMax - yDomainMin); + padding_top = padding_bottom = domainLength * 0.1; + + if (typeof center !== 'undefined') { + yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax)); + yDomainMax = center + yDomainAbs; + yDomainMin = center - yDomainAbs; + } + // add padding for data label + if (showHorizontalDataLabel) { + lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'width'); + diff = diffDomain($$.y.range()); + ratio = [lengths[0] / diff, lengths[1] / diff]; + padding_top += domainLength * (ratio[1] / (1 - ratio[0] - ratio[1])); + padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1])); + } else if (showVerticalDataLabel) { + lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'height'); + + const pixelsToAxisPadding = $$.getY( + config[`axis_${axisId}_type`], + // input domain as pixels + [0, config.axis_rotated ? $$.width : $$.height], + // output range as axis padding + [0, domainLength] + ); + + padding_top += pixelsToAxisPadding(lengths[1]); + padding_bottom += pixelsToAxisPadding(lengths[0]); + } + if (axisId === 'y' && notEmpty(config.axis_y_padding)) { + padding_top = $$.axis.getPadding( + config.axis_y_padding, + 'top', + padding_top, + domainLength + ); + padding_bottom = $$.axis.getPadding( + config.axis_y_padding, + 'bottom', + padding_bottom, + domainLength + ); + } + if (axisId === 'y2' && notEmpty(config.axis_y2_padding)) { + padding_top = $$.axis.getPadding( + config.axis_y2_padding, + 'top', + padding_top, + domainLength + ); + padding_bottom = $$.axis.getPadding( + config.axis_y2_padding, + 'bottom', + padding_bottom, + domainLength + ); + } + // Bar/Area chart should be 0-based if all positive|negative + if (isZeroBased) { + if (isAllPositive) { + padding_bottom = yDomainMin; + } + if (isAllNegative) { + padding_top = -yDomainMax; + } + } + domain = [yDomainMin - padding_bottom, yDomainMax + padding_top]; + return isInverted ? domain.reverse() : domain +}; +ChartInternal.prototype.getXDomainMin = function(targets) { + var $$ = this, + config = $$.config; + return isDefined(config.axis_x_min) + ? $$.isTimeSeries() + ? this.parseDate(config.axis_x_min) + : config.axis_x_min + : $$.d3.min(targets, function(t) { + return $$.d3.min(t.values, function(v) { + return v.x + }) + }) +}; +ChartInternal.prototype.getXDomainMax = function(targets) { + var $$ = this, + config = $$.config; + return isDefined(config.axis_x_max) + ? $$.isTimeSeries() + ? this.parseDate(config.axis_x_max) + : config.axis_x_max + : $$.d3.max(targets, function(t) { + return $$.d3.max(t.values, function(v) { + return v.x + }) + }) +}; +ChartInternal.prototype.getXDomainPadding = function(domain) { + var $$ = this, + config = $$.config, + diff = domain[1] - domain[0], + maxDataCount, + padding, + paddingLeft, + paddingRight; + if ($$.isCategorized()) { + padding = 0; + } else if ($$.hasType('bar')) { + maxDataCount = $$.getMaxDataCount(); + padding = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : 0.5; + } else { + padding = diff * 0.01; + } + if ( + typeof config.axis_x_padding === 'object' && + notEmpty(config.axis_x_padding) + ) { + paddingLeft = isValue(config.axis_x_padding.left) + ? config.axis_x_padding.left + : padding; + paddingRight = isValue(config.axis_x_padding.right) + ? config.axis_x_padding.right + : padding; + } else if (typeof config.axis_x_padding === 'number') { + paddingLeft = paddingRight = config.axis_x_padding; + } else { + paddingLeft = paddingRight = padding; + } + return { left: paddingLeft, right: paddingRight } +}; +ChartInternal.prototype.getXDomain = function(targets) { + var $$ = this, + xDomain = [$$.getXDomainMin(targets), $$.getXDomainMax(targets)], + firstX = xDomain[0], + lastX = xDomain[1], + padding = $$.getXDomainPadding(xDomain), + min = 0, + max = 0; + // show center of x domain if min and max are the same + if (firstX - lastX === 0 && !$$.isCategorized()) { + if ($$.isTimeSeries()) { + firstX = new Date(firstX.getTime() * 0.5); + lastX = new Date(lastX.getTime() * 1.5); + } else { + firstX = firstX === 0 ? 1 : firstX * 0.5; + lastX = lastX === 0 ? -1 : lastX * 1.5; + } + } + if (firstX || firstX === 0) { + min = $$.isTimeSeries() + ? new Date(firstX.getTime() - padding.left) + : firstX - padding.left; + } + if (lastX || lastX === 0) { + max = $$.isTimeSeries() + ? new Date(lastX.getTime() + padding.right) + : lastX + padding.right; + } + return [min, max] +}; +ChartInternal.prototype.updateXDomain = function( + targets, + withUpdateXDomain, + withUpdateOrgXDomain, + withTrim, + domain +) { + var $$ = this, + config = $$.config; + + if (withUpdateOrgXDomain) { + $$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets))); + $$.orgXDomain = $$.x.domain(); + if (config.zoom_enabled) { + $$.zoom.update(); + } + $$.subX.domain($$.x.domain()); + if ($$.brush) { + $$.brush.updateScale($$.subX); + } + } + if (withUpdateXDomain) { + $$.x.domain( + domain + ? domain + : !$$.brush || $$.brush.empty() + ? $$.orgXDomain + : $$.brush.selectionAsValue() + ); + } + + // Trim domain when too big by zoom mousemove event + if (withTrim) { + $$.x.domain($$.trimXDomain($$.x.orgDomain())); + } + + return $$.x.domain() +}; +ChartInternal.prototype.trimXDomain = function(domain) { + var zoomDomain = this.getZoomDomain(), + min = zoomDomain[0], + max = zoomDomain[1]; + if (domain[0] <= min) { + domain[1] = +domain[1] + (min - domain[0]); + domain[0] = min; + } + if (max <= domain[1]) { + domain[0] = +domain[0] - (domain[1] - max); + domain[1] = max; + } + return domain +}; + +ChartInternal.prototype.drag = function(mouse) { + var $$ = this, + config = $$.config, + main = $$.main, + d3 = $$.d3; + var sx, sy, mx, my, minX, maxX, minY, maxY; + + if ($$.hasArcType()) { + return + } + if (!config.data_selection_enabled) { + return + } // do nothing if not selectable + if (!config.data_selection_multiple) { + return + } // skip when single selection because drag is used for multiple selection + + sx = $$.dragStart[0]; + sy = $$.dragStart[1]; + mx = mouse[0]; + my = mouse[1]; + minX = Math.min(sx, mx); + maxX = Math.max(sx, mx); + minY = config.data_selection_grouped ? $$.margin.top : Math.min(sy, my); + maxY = config.data_selection_grouped ? $$.height : Math.max(sy, my); + + main + .select('.' + CLASS.dragarea) + .attr('x', minX) + .attr('y', minY) + .attr('width', maxX - minX) + .attr('height', maxY - minY); + // TODO: binary search when multiple xs + main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function(d, i) { + if (!config.data_selection_isselectable(d)) { + return + } + var shape = d3.select(this), + isSelected = shape.classed(CLASS.SELECTED), + isIncluded = shape.classed(CLASS.INCLUDED), + _x, + _y, + _w, + _h, + toggle, + isWithin = false, + box; + if (shape.classed(CLASS.circle)) { + _x = shape.attr('cx') * 1; + _y = shape.attr('cy') * 1; + toggle = $$.togglePoint; + isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY; + } else if (shape.classed(CLASS.bar)) { + box = getPathBox(this); + _x = box.x; + _y = box.y; + _w = box.width; + _h = box.height; + toggle = $$.togglePath; + isWithin = + !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY); + } else { + // line/area selection not supported yet + return + } + if (isWithin ^ isIncluded) { + shape.classed(CLASS.INCLUDED, !isIncluded); + // TODO: included/unincluded callback here + shape.classed(CLASS.SELECTED, !isSelected); + toggle.call($$, !isSelected, shape, d, i); + } + }); +}; + +ChartInternal.prototype.dragstart = function(mouse) { + var $$ = this, + config = $$.config; + if ($$.hasArcType()) { + return + } + if (!config.data_selection_enabled) { + return + } // do nothing if not selectable + $$.dragStart = mouse; + $$.main + .select('.' + CLASS.chart) + .append('rect') + .attr('class', CLASS.dragarea) + .style('opacity', 0.1); + $$.dragging = true; +}; + +ChartInternal.prototype.dragend = function() { + var $$ = this, + config = $$.config; + if ($$.hasArcType()) { + return + } + if (!config.data_selection_enabled) { + return + } // do nothing if not selectable + $$.main + .select('.' + CLASS.dragarea) + .transition() + .duration(100) + .style('opacity', 0) + .remove(); + $$.main.selectAll('.' + CLASS.shape).classed(CLASS.INCLUDED, false); + $$.dragging = false; +}; + +ChartInternal.prototype.getYFormat = function(forArc) { + var $$ = this, + formatForY = + forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.yFormat, + formatForY2 = + forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.y2Format; + return function(v, ratio, id) { + var format = $$.axis.getId(id) === 'y2' ? formatForY2 : formatForY; + return format.call($$, v, ratio) + } +}; +ChartInternal.prototype.yFormat = function(v) { + var $$ = this, + config = $$.config, + format = config.axis_y_tick_format + ? config.axis_y_tick_format + : $$.defaultValueFormat; + return format(v) +}; +ChartInternal.prototype.y2Format = function(v) { + var $$ = this, + config = $$.config, + format = config.axis_y2_tick_format + ? config.axis_y2_tick_format + : $$.defaultValueFormat; + return format(v) +}; +ChartInternal.prototype.defaultValueFormat = function(v) { + return isValue(v) ? +v : '' +}; +ChartInternal.prototype.defaultArcValueFormat = function(v, ratio) { + return (ratio * 100).toFixed(1) + '%' +}; +ChartInternal.prototype.dataLabelFormat = function(targetId) { + var $$ = this, + data_labels = $$.config.data_labels, + format, + defaultFormat = function(v) { + return isValue(v) ? +v : '' + }; + // find format according to axis id + if (typeof data_labels.format === 'function') { + format = data_labels.format; + } else if (typeof data_labels.format === 'object') { + if (data_labels.format[targetId]) { + format = + data_labels.format[targetId] === true + ? defaultFormat + : data_labels.format[targetId]; + } else { + format = function() { + return '' + }; + } + } else { + format = defaultFormat; + } + return format +}; + +ChartInternal.prototype.initGrid = function() { + var $$ = this, + config = $$.config, + d3 = $$.d3; + $$.grid = $$.main + .append('g') + .attr('clip-path', $$.clipPathForGrid) + .attr('class', CLASS.grid); + if (config.grid_x_show) { + $$.grid.append('g').attr('class', CLASS.xgrids); + } + if (config.grid_y_show) { + $$.grid.append('g').attr('class', CLASS.ygrids); + } + if (config.grid_focus_show) { + $$.grid + .append('g') + .attr('class', CLASS.xgridFocus) + .append('line') + .attr('class', CLASS.xgridFocus); + } + $$.xgrid = d3.selectAll([]); + if (!config.grid_lines_front) { + $$.initGridLines(); + } +}; +ChartInternal.prototype.initGridLines = function() { + var $$ = this, + d3 = $$.d3; + $$.gridLines = $$.main + .append('g') + .attr('clip-path', $$.clipPathForGrid) + .attr('class', CLASS.grid + ' ' + CLASS.gridLines); + $$.gridLines.append('g').attr('class', CLASS.xgridLines); + $$.gridLines.append('g').attr('class', CLASS.ygridLines); + $$.xgridLines = d3.selectAll([]); +}; +ChartInternal.prototype.updateXGrid = function(withoutUpdate) { + var $$ = this, + config = $$.config, + d3 = $$.d3, + xgridData = $$.generateGridData(config.grid_x_type, $$.x), + tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; + + $$.xgridAttr = config.axis_rotated + ? { + x1: 0, + x2: $$.width, + y1: function(d) { + return $$.x(d) - tickOffset + }, + y2: function(d) { + return $$.x(d) - tickOffset + } + } + : { + x1: function(d) { + return $$.x(d) + tickOffset + }, + x2: function(d) { + return $$.x(d) + tickOffset + }, + y1: 0, + y2: $$.height + }; + $$.xgridAttr.opacity = function() { + var pos = +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1'); + return pos === (config.axis_rotated ? $$.height : 0) ? 0 : 1 + }; + + var xgrid = $$.main + .select('.' + CLASS.xgrids) + .selectAll('.' + CLASS.xgrid) + .data(xgridData); + var xgridEnter = xgrid + .enter() + .append('line') + .attr('class', CLASS.xgrid) + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', 0); + $$.xgrid = xgridEnter.merge(xgrid); + if (!withoutUpdate) { + $$.xgrid + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', $$.xgridAttr.opacity); + } + xgrid.exit().remove(); +}; + +ChartInternal.prototype.updateYGrid = function() { + var $$ = this, + config = $$.config, + gridValues = $$.yAxis.tickValues() || $$.y.ticks(config.grid_y_ticks); + var ygrid = $$.main + .select('.' + CLASS.ygrids) + .selectAll('.' + CLASS.ygrid) + .data(gridValues); + var ygridEnter = ygrid + .enter() + .append('line') + // TODO: x1, x2, y1, y2, opacity need to be set here maybe + .attr('class', CLASS.ygrid); + $$.ygrid = ygridEnter.merge(ygrid); + $$.ygrid + .attr('x1', config.axis_rotated ? $$.y : 0) + .attr('x2', config.axis_rotated ? $$.y : $$.width) + .attr('y1', config.axis_rotated ? 0 : $$.y) + .attr('y2', config.axis_rotated ? $$.height : $$.y); + ygrid.exit().remove(); + $$.smoothLines($$.ygrid, 'grid'); +}; + +ChartInternal.prototype.gridTextAnchor = function(d) { + return d.position ? d.position : 'end' +}; +ChartInternal.prototype.gridTextDx = function(d) { + return d.position === 'start' ? 4 : d.position === 'middle' ? 0 : -4 +}; +ChartInternal.prototype.xGridTextX = function(d) { + return d.position === 'start' + ? -this.height + : d.position === 'middle' + ? -this.height / 2 + : 0 +}; +ChartInternal.prototype.yGridTextX = function(d) { + return d.position === 'start' + ? 0 + : d.position === 'middle' + ? this.width / 2 + : this.width +}; +ChartInternal.prototype.updateGrid = function(duration) { + var $$ = this, + main = $$.main, + config = $$.config, + xgridLine, + xgridLineEnter, + ygridLine, + ygridLineEnter, + xv = $$.xv.bind($$), + yv = $$.yv.bind($$), + xGridTextX = $$.xGridTextX.bind($$), + yGridTextX = $$.yGridTextX.bind($$); + + // hide if arc type + $$.grid.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + + main.select('line.' + CLASS.xgridFocus).style('visibility', 'hidden'); + if (config.grid_x_show) { + $$.updateXGrid(); + } + xgridLine = main + .select('.' + CLASS.xgridLines) + .selectAll('.' + CLASS.xgridLine) + .data(config.grid_x_lines); + // enter + xgridLineEnter = xgridLine + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.xgridLine + (d['class'] ? ' ' + d['class'] : '') + }); + xgridLineEnter + .append('line') + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv) + .attr('y1', config.axis_rotated ? xv : 0) + .attr('y2', config.axis_rotated ? xv : $$.height) + .style('opacity', 0); + xgridLineEnter + .append('text') + .attr('text-anchor', $$.gridTextAnchor) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .attr('x', config.axis_rotated ? yGridTextX : xGridTextX) + .attr('y', xv) + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style('opacity', 0); + // udpate + $$.xgridLines = xgridLineEnter.merge(xgridLine); + // done in d3.transition() of the end of this function + // exit + xgridLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + + // Y-Grid + if (config.grid_y_show) { + $$.updateYGrid(); + } + ygridLine = main + .select('.' + CLASS.ygridLines) + .selectAll('.' + CLASS.ygridLine) + .data(config.grid_y_lines); + // enter + ygridLineEnter = ygridLine + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.ygridLine + (d['class'] ? ' ' + d['class'] : '') + }); + ygridLineEnter + .append('line') + .attr('x1', config.axis_rotated ? yv : 0) + .attr('x2', config.axis_rotated ? yv : $$.width) + .attr('y1', config.axis_rotated ? 0 : yv) + .attr('y2', config.axis_rotated ? $$.height : yv) + .style('opacity', 0); + ygridLineEnter + .append('text') + .attr('text-anchor', $$.gridTextAnchor) + .attr('transform', config.axis_rotated ? 'rotate(-90)' : '') + .attr('x', config.axis_rotated ? xGridTextX : yGridTextX) + .attr('y', yv) + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style('opacity', 0); + // update + $$.ygridLines = ygridLineEnter.merge(ygridLine); + $$.ygridLines + .select('line') + .transition() + .duration(duration) + .attr('x1', config.axis_rotated ? yv : 0) + .attr('x2', config.axis_rotated ? yv : $$.width) + .attr('y1', config.axis_rotated ? 0 : yv) + .attr('y2', config.axis_rotated ? $$.height : yv) + .style('opacity', 1); + $$.ygridLines + .select('text') + .transition() + .duration(duration) + .attr( + 'x', + config.axis_rotated ? $$.xGridTextX.bind($$) : $$.yGridTextX.bind($$) + ) + .attr('y', yv) + .text(function(d) { + return d.text + }) + .style('opacity', 1); + // exit + ygridLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); +}; +ChartInternal.prototype.redrawGrid = function(withTransition, transition) { + var $$ = this, + config = $$.config, + xv = $$.xv.bind($$), + lines = $$.xgridLines.select('line'), + texts = $$.xgridLines.select('text'); + return [ + (withTransition ? lines.transition(transition) : lines) + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv) + .attr('y1', config.axis_rotated ? xv : 0) + .attr('y2', config.axis_rotated ? xv : $$.height) + .style('opacity', 1), + (withTransition ? texts.transition(transition) : texts) + .attr( + 'x', + config.axis_rotated ? $$.yGridTextX.bind($$) : $$.xGridTextX.bind($$) + ) + .attr('y', xv) + .text(function(d) { + return d.text + }) + .style('opacity', 1) + ] +}; +ChartInternal.prototype.showXGridFocus = function(selectedData) { + var $$ = this, + config = $$.config, + dataToShow = selectedData.filter(function(d) { + return d && isValue(d.value) + }), + focusEl = $$.main.selectAll('line.' + CLASS.xgridFocus), + xx = $$.xx.bind($$); + if (!config.tooltip_show) { + return + } + // Hide when stanford plot exists + if ($$.hasType('stanford') || $$.hasArcType()) { + return + } + focusEl + .style('visibility', 'visible') + .data([dataToShow[0]]) + .attr(config.axis_rotated ? 'y1' : 'x1', xx) + .attr(config.axis_rotated ? 'y2' : 'x2', xx); + $$.smoothLines(focusEl, 'grid'); +}; +ChartInternal.prototype.hideXGridFocus = function() { + this.main.select('line.' + CLASS.xgridFocus).style('visibility', 'hidden'); +}; +ChartInternal.prototype.updateXgridFocus = function() { + var $$ = this, + config = $$.config; + $$.main + .select('line.' + CLASS.xgridFocus) + .attr('x1', config.axis_rotated ? 0 : -10) + .attr('x2', config.axis_rotated ? $$.width : -10) + .attr('y1', config.axis_rotated ? -10 : 0) + .attr('y2', config.axis_rotated ? -10 : $$.height); +}; +ChartInternal.prototype.generateGridData = function(type, scale) { + var $$ = this, + gridData = [], + xDomain, + firstYear, + lastYear, + i, + tickNum = $$.main + .select('.' + CLASS.axisX) + .selectAll('.tick') + .size(); + if (type === 'year') { + xDomain = $$.getXDomain(); + firstYear = xDomain[0].getFullYear(); + lastYear = xDomain[1].getFullYear(); + for (i = firstYear; i <= lastYear; i++) { + gridData.push(new Date(i + '-01-01 00:00:00')); + } + } else { + gridData = scale.ticks(10); + if (gridData.length > tickNum) { + // use only int + gridData = gridData.filter(function(d) { + return ('' + d).indexOf('.') < 0 + }); + } + } + return gridData +}; +ChartInternal.prototype.getGridFilterToRemove = function(params) { + return params + ? function(line) { + var found = false + ;[].concat(params).forEach(function(param) { + if ( + ('value' in param && line.value === param.value) || + ('class' in param && line['class'] === param['class']) + ) { + found = true; + } + }); + return found + } + : function() { + return true + } +}; +ChartInternal.prototype.removeGridLines = function(params, forX) { + var $$ = this, + config = $$.config, + toRemove = $$.getGridFilterToRemove(params), + toShow = function(line) { + return !toRemove(line) + }, + classLines = forX ? CLASS.xgridLines : CLASS.ygridLines, + classLine = forX ? CLASS.xgridLine : CLASS.ygridLine; + $$.main + .select('.' + classLines) + .selectAll('.' + classLine) + .filter(toRemove) + .transition() + .duration(config.transition_duration) + .style('opacity', 0) + .remove(); + if (forX) { + config.grid_x_lines = config.grid_x_lines.filter(toShow); + } else { + config.grid_y_lines = config.grid_y_lines.filter(toShow); + } +}; + +ChartInternal.prototype.initEventRect = function() { + var $$ = this, + config = $$.config; + + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.eventRects) + .style('fill-opacity', 0); + $$.eventRect = $$.main + .select('.' + CLASS.eventRects) + .append('rect') + .attr('class', CLASS.eventRect); + + // event rect handle zoom event as well + if (config.zoom_enabled && $$.zoom) { + $$.eventRect.call($$.zoom).on('dblclick.zoom', null); + if (config.zoom_initialRange) { + // WORKAROUND: Add transition to apply transform immediately when no subchart + $$.eventRect + .transition() + .duration(0) + .call($$.zoom.transform, $$.zoomTransform(config.zoom_initialRange)); + } + } +}; +ChartInternal.prototype.redrawEventRect = function() { + const $$ = this, + d3 = $$.d3, + config = $$.config; + + function mouseout() { + $$.svg.select('.' + CLASS.eventRect).style('cursor', null); + $$.hideXGridFocus(); + $$.hideTooltip(); + $$.unexpandCircles(); + $$.unexpandBars(); + } + + const isHoveringDataPoint = (mouse, closest) => + closest && + ($$.isBarType(closest.id) || + $$.dist(closest, mouse) < config.point_sensitivity); + + const withName = d => (d ? $$.addName(Object.assign({}, d)) : null); + + // rects for mouseover + $$.main + .select('.' + CLASS.eventRects) + .style( + 'cursor', + config.zoom_enabled + ? config.axis_rotated + ? 'ns-resize' + : 'ew-resize' + : null + ); + + $$.eventRect + .attr('x', 0) + .attr('y', 0) + .attr('width', $$.width) + .attr('height', $$.height) + .on( + 'mouseout', + config.interaction_enabled + ? function() { + if (!config) { + return + } // chart is destroyed + if ($$.hasArcType()) { + return + } + if ($$.mouseover) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + mouseout(); + } + : null + ) + .on( + 'mousemove', + config.interaction_enabled + ? function() { + // do nothing when dragging + if ($$.dragging) { + return + } + + const targetsToShow = $$.getTargetsToShow(); + + // do nothing if arc type + if ($$.hasArcType(targetsToShow)) { + return + } + + const mouse = d3.mouse(this); + const closest = withName( + $$.findClosestFromTargets(targetsToShow, mouse) + ); + const isMouseCloseToDataPoint = isHoveringDataPoint(mouse, closest); + + // ensure onmouseout is always called if mousemove switch between 2 targets + if ( + $$.mouseover && + (!closest || + closest.id !== $$.mouseover.id || + closest.index !== $$.mouseover.index) + ) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + if (closest && !$$.mouseover) { + config.data_onmouseover.call($$.api, closest); + $$.mouseover = closest; + } + + // show cursor as pointer if we're hovering a data point close enough + $$.svg + .select('.' + CLASS.eventRect) + .style('cursor', isMouseCloseToDataPoint ? 'pointer' : null); + + // if tooltip not grouped, we want to display only data from closest data point + const showSingleDataPoint = + !config.tooltip_grouped || $$.hasType('stanford', targetsToShow); + + // find data to highlight + let selectedData; + if (showSingleDataPoint) { + if (closest) { + selectedData = [closest]; + } + } else { + let closestByX; + if (closest) { + // reuse closest value + closestByX = closest; + } else { + // try to find the closest value by X values from the mouse position + const mouseX = config.axis_rotated ? mouse[1] : mouse[0]; + closestByX = $$.findClosestFromTargetsByX( + targetsToShow, + $$.x.invert(mouseX) + ); + } + + // highlight all data for this 'x' value + if (closestByX) { + selectedData = $$.filterByX(targetsToShow, closestByX.x); + } + } + + // ensure we have data to show + if (!selectedData || selectedData.length === 0) { + return mouseout() + } + + // inject names for each point + selectedData = selectedData.map(withName); + + // show tooltip + $$.showTooltip(selectedData, this); + + // expand points + if (config.point_focus_expand_enabled) { + $$.unexpandCircles(); + selectedData.forEach(function(d) { + $$.expandCircles(d.index, d.id, false); + }); + } + + // expand bars + $$.unexpandBars(); + selectedData.forEach(function(d) { + $$.expandBars(d.index, d.id, false); + }); + + // Show xgrid focus line + $$.showXGridFocus(selectedData); + } + : null + ) + .on( + 'click', + config.interaction_enabled + ? function() { + const targetsToShow = $$.getTargetsToShow(); + + if ($$.hasArcType(targetsToShow)) { + return + } + + const mouse = d3.mouse(this); + const closest = withName( + $$.findClosestFromTargets(targetsToShow, mouse) + ); + + if (!isHoveringDataPoint(mouse, closest)) { + return + } + + // select if selection enabled + let sameXData; + if (!config.data_selection_grouped || $$.isStanfordType(closest)) { + sameXData = [closest]; + } else { + sameXData = $$.filterByX(targetsToShow, closest.x); + } + + // toggle selected state + sameXData.forEach(function(d) { + $$.main + .selectAll( + '.' + CLASS.shapes + $$.getTargetSelectorSuffix(d.id) + ) + .selectAll('.' + CLASS.shape + '-' + d.index) + .each(function() { + if ( + config.data_selection_grouped || + $$.isWithinShape(this, d) + ) { + $$.toggleShape(this, d, d.index); + } + }); + }); + + // call data_onclick on the closest data point + if (closest) { + const shape = $$.main + .selectAll( + '.' + CLASS.shapes + $$.getTargetSelectorSuffix(closest.id) + ) + .select('.' + CLASS.shape + '-' + closest.index); + config.data_onclick.call($$.api, closest, shape.node()); + } + } + : null + ) + .call( + config.interaction_enabled && config.data_selection_draggable && $$.drag + ? d3 + .drag() + .on('drag', function() { + $$.drag(d3.mouse(this)); + }) + .on('start', function() { + $$.dragstart(d3.mouse(this)); + }) + .on('end', function() { + $$.dragend(); + }) + : function() {} + ); +}; +ChartInternal.prototype.getMousePosition = function(data) { + var $$ = this; + return [$$.x(data.x), $$.getYScale(data.id)(data.value)] +}; +ChartInternal.prototype.dispatchEvent = function(type, mouse) { + var $$ = this, + selector = '.' + CLASS.eventRect, + eventRect = $$.main.select(selector).node(), + box = eventRect.getBoundingClientRect(), + x = box.left + (mouse ? mouse[0] : 0), + y = box.top + (mouse ? mouse[1] : 0), + event = document.createEvent('MouseEvents'); + + event.initMouseEvent( + type, + true, + true, + window, + 0, + x, + y, + x, + y, + false, + false, + false, + false, + 0, + null + ); + eventRect.dispatchEvent(event); +}; + +ChartInternal.prototype.initLegend = function() { + var $$ = this; + $$.legendItemTextBox = {}; + $$.legendHasRendered = false; + $$.legend = $$.svg.append('g').attr('transform', $$.getTranslate('legend')); + if (!$$.config.legend_show) { + $$.legend.style('visibility', 'hidden'); + $$.hiddenLegendIds = $$.mapToIds($$.data.targets); + return + } + // MEMO: call here to update legend box and tranlate for all + // MEMO: translate will be updated by this, so transform not needed in updateLegend() + $$.updateLegendWithDefaults(); +}; +ChartInternal.prototype.updateLegendWithDefaults = function() { + var $$ = this; + $$.updateLegend($$.mapToIds($$.data.targets), { + withTransform: false, + withTransitionForTransform: false, + withTransition: false + }); +}; +ChartInternal.prototype.updateSizeForLegend = function( + legendHeight, + legendWidth +) { + var $$ = this, + config = $$.config, + insetLegendPosition = { + top: $$.isLegendTop + ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 + : $$.currentHeight - + legendHeight - + $$.getCurrentPaddingBottom() - + config.legend_inset_y, + left: $$.isLegendLeft + ? $$.getCurrentPaddingLeft() + config.legend_inset_x + 0.5 + : $$.currentWidth - + legendWidth - + $$.getCurrentPaddingRight() - + config.legend_inset_x + + 0.5 + }; + + $$.margin3 = { + top: $$.isLegendRight + ? 0 + : $$.isLegendInset + ? insetLegendPosition.top + : $$.currentHeight - legendHeight, + right: NaN, + bottom: 0, + left: $$.isLegendRight + ? $$.currentWidth - legendWidth + : $$.isLegendInset + ? insetLegendPosition.left + : 0 + }; +}; +ChartInternal.prototype.transformLegend = function(withTransition) { + var $$ = this + ;(withTransition ? $$.legend.transition() : $$.legend).attr( + 'transform', + $$.getTranslate('legend') + ); +}; +ChartInternal.prototype.updateLegendStep = function(step) { + this.legendStep = step; +}; +ChartInternal.prototype.updateLegendItemWidth = function(w) { + this.legendItemWidth = w; +}; +ChartInternal.prototype.updateLegendItemHeight = function(h) { + this.legendItemHeight = h; +}; +ChartInternal.prototype.getLegendWidth = function() { + var $$ = this; + return $$.config.legend_show + ? $$.isLegendRight || $$.isLegendInset + ? $$.legendItemWidth * ($$.legendStep + 1) + : $$.currentWidth + : 0 +}; +ChartInternal.prototype.getLegendHeight = function() { + var $$ = this, + h = 0; + if ($$.config.legend_show) { + if ($$.isLegendRight) { + h = $$.currentHeight; + } else { + h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1); + } + } + return h +}; +ChartInternal.prototype.opacityForLegend = function(legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 1 +}; +ChartInternal.prototype.opacityForUnfocusedLegend = function(legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 0.3 +}; +ChartInternal.prototype.toggleFocusLegend = function(targetIds, focus) { + var $$ = this; + targetIds = $$.mapToTargetIds(targetIds); + $$.legend + .selectAll('.' + CLASS.legendItem) + .filter(function(id) { + return targetIds.indexOf(id) >= 0 + }) + .classed(CLASS.legendItemFocused, focus) + .transition() + .duration(100) + .style('opacity', function() { + var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend; + return opacity.call($$, $$.d3.select(this)) + }); +}; +ChartInternal.prototype.revertLegend = function() { + var $$ = this, + d3 = $$.d3; + $$.legend + .selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemFocused, false) + .transition() + .duration(100) + .style('opacity', function() { + return $$.opacityForLegend(d3.select(this)) + }); +}; +ChartInternal.prototype.showLegend = function(targetIds) { + var $$ = this, + config = $$.config; + if (!config.legend_show) { + config.legend_show = true; + $$.legend.style('visibility', 'visible'); + if (!$$.legendHasRendered) { + $$.updateLegendWithDefaults(); + } + } + $$.removeHiddenLegendIds(targetIds); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .style('visibility', 'visible') + .transition() + .style('opacity', function() { + return $$.opacityForLegend($$.d3.select(this)) + }); +}; +ChartInternal.prototype.hideLegend = function(targetIds) { + var $$ = this, + config = $$.config; + if (config.legend_show && isEmpty(targetIds)) { + config.legend_show = false; + $$.legend.style('visibility', 'hidden'); + } + $$.addHiddenLegendIds(targetIds); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .style('opacity', 0) + .style('visibility', 'hidden'); +}; +ChartInternal.prototype.clearLegendItemTextBoxCache = function() { + this.legendItemTextBox = {}; +}; +ChartInternal.prototype.updateLegend = function( + targetIds, + options, + transitions +) { + var $$ = this, + config = $$.config; + var xForLegend, + xForLegendText, + xForLegendRect, + yForLegend, + yForLegendText, + yForLegendRect, + x1ForLegendTile, + x2ForLegendTile, + yForLegendTile; + var paddingTop = 4, + paddingRight = 10, + maxWidth = 0, + maxHeight = 0, + posMin = 10, + tileWidth = config.legend_item_tile_width + 5; + var l, + totalLength = 0, + offsets = {}, + widths = {}, + heights = {}, + margins = [0], + steps = {}, + step = 0; + var withTransition, withTransitionForTransform; + var texts, rects, tiles, background; + + // Skip elements when their name is set to null + targetIds = targetIds.filter(function(id) { + return !isDefined(config.data_names[id]) || config.data_names[id] !== null + }); + + options = options || {}; + withTransition = getOption(options, 'withTransition', true); + withTransitionForTransform = getOption( + options, + 'withTransitionForTransform', + true + ); + + function getTextBox(textElement, id) { + if (!$$.legendItemTextBox[id]) { + $$.legendItemTextBox[id] = $$.getTextRect( + textElement.textContent, + CLASS.legendItem, + textElement + ); + } + return $$.legendItemTextBox[id] + } + + function updatePositions(textElement, id, index) { + var reset = index === 0, + isLast = index === targetIds.length - 1, + box = getTextBox(textElement, id), + itemWidth = + box.width + + tileWidth + + (isLast && !($$.isLegendRight || $$.isLegendInset) ? 0 : paddingRight) + + config.legend_padding, + itemHeight = box.height + paddingTop, + itemLength = + $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth, + areaLength = + $$.isLegendRight || $$.isLegendInset + ? $$.getLegendHeight() + : $$.getLegendWidth(), + margin, + maxLength; + + // MEMO: care about condifion of step, totalLength + function updateValues(id, withoutStep) { + if (!withoutStep) { + margin = (areaLength - totalLength - itemLength) / 2; + if (margin < posMin) { + margin = (areaLength - itemLength) / 2; + totalLength = 0; + step++; + } + } + steps[id] = step; + margins[step] = $$.isLegendInset ? 10 : margin; + offsets[id] = totalLength; + totalLength += itemLength; + } + + if (reset) { + totalLength = 0; + step = 0; + maxWidth = 0; + maxHeight = 0; + } + + if (config.legend_show && !$$.isLegendToShow(id)) { + widths[id] = heights[id] = steps[id] = offsets[id] = 0; + return + } + + widths[id] = itemWidth; + heights[id] = itemHeight; + + if (!maxWidth || itemWidth >= maxWidth) { + maxWidth = itemWidth; + } + if (!maxHeight || itemHeight >= maxHeight) { + maxHeight = itemHeight; + } + maxLength = $$.isLegendRight || $$.isLegendInset ? maxHeight : maxWidth; + + if (config.legend_equally) { + Object.keys(widths).forEach(function(id) { + widths[id] = maxWidth; + }); + Object.keys(heights).forEach(function(id) { + heights[id] = maxHeight; + }); + margin = (areaLength - maxLength * targetIds.length) / 2; + if (margin < posMin) { + totalLength = 0; + step = 0; + targetIds.forEach(function(id) { + updateValues(id); + }); + } else { + updateValues(id, true); + } + } else { + updateValues(id); + } + } + + if ($$.isLegendInset) { + step = config.legend_inset_step + ? config.legend_inset_step + : targetIds.length; + $$.updateLegendStep(step); + } + + if ($$.isLegendRight) { + xForLegend = function(id) { + return maxWidth * steps[id] + }; + yForLegend = function(id) { + return margins[steps[id]] + offsets[id] + }; + } else if ($$.isLegendInset) { + xForLegend = function(id) { + return maxWidth * steps[id] + 10 + }; + yForLegend = function(id) { + return margins[steps[id]] + offsets[id] + }; + } else { + xForLegend = function(id) { + return margins[steps[id]] + offsets[id] + }; + yForLegend = function(id) { + return maxHeight * steps[id] + }; + } + xForLegendText = function(id, i) { + return xForLegend(id, i) + 4 + config.legend_item_tile_width + }; + yForLegendText = function(id, i) { + return yForLegend(id, i) + 9 + }; + xForLegendRect = function(id, i) { + return xForLegend(id, i) + }; + yForLegendRect = function(id, i) { + return yForLegend(id, i) - 5 + }; + x1ForLegendTile = function(id, i) { + return xForLegend(id, i) - 2 + }; + x2ForLegendTile = function(id, i) { + return xForLegend(id, i) - 2 + config.legend_item_tile_width + }; + yForLegendTile = function(id, i) { + return yForLegend(id, i) + 4 + }; + + // Define g for legend area + l = $$.legend + .selectAll('.' + CLASS.legendItem) + .data(targetIds) + .enter() + .append('g') + .attr('class', function(id) { + return $$.generateClass(CLASS.legendItem, id) + }) + .style('visibility', function(id) { + return $$.isLegendToShow(id) ? 'visible' : 'hidden' + }) + .style('cursor', function() { + return config.interaction_enabled ? 'pointer' : 'auto' + }) + .on( + 'click', + config.interaction_enabled + ? function(id) { + if (config.legend_item_onclick) { + config.legend_item_onclick.call($$, id); + } else { + if ($$.d3.event.altKey) { + $$.api.hide(); + $$.api.show(id); + } else { + $$.api.toggle(id); + $$.isTargetToShow(id) ? $$.api.focus(id) : $$.api.revert(); + } + } + } + : null + ) + .on( + 'mouseover', + config.interaction_enabled + ? function(id) { + if (config.legend_item_onmouseover) { + config.legend_item_onmouseover.call($$, id); + } else { + $$.d3.select(this).classed(CLASS.legendItemFocused, true); + if (!$$.transiting && $$.isTargetToShow(id)) { + $$.api.focus(id); + } + } + } + : null + ) + .on( + 'mouseout', + config.interaction_enabled + ? function(id) { + if (config.legend_item_onmouseout) { + config.legend_item_onmouseout.call($$, id); + } else { + $$.d3.select(this).classed(CLASS.legendItemFocused, false); + $$.api.revert(); + } + } + : null + ); + + l.append('text') + .text(function(id) { + return isDefined(config.data_names[id]) ? config.data_names[id] : id + }) + .each(function(id, i) { + updatePositions(this, id, i); + }) + .style('pointer-events', 'none') + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendText); + + l.append('rect') + .attr('class', CLASS.legendItemEvent) + .style('fill-opacity', 0) + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendRect : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendRect); + + l.append('line') + .attr('class', CLASS.legendItemTile) + .style('stroke', $$.color) + .style('pointer-events', 'none') + .attr('x1', $$.isLegendRight || $$.isLegendInset ? x1ForLegendTile : -200) + .attr('y1', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) + .attr('x2', $$.isLegendRight || $$.isLegendInset ? x2ForLegendTile : -200) + .attr('y2', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) + .attr('stroke-width', config.legend_item_tile_height); + + // Set background for inset legend + background = $$.legend.select('.' + CLASS.legendBackground + ' rect'); + if ($$.isLegendInset && maxWidth > 0 && background.size() === 0) { + background = $$.legend + .insert('g', '.' + CLASS.legendItem) + .attr('class', CLASS.legendBackground) + .append('rect'); + } + + texts = $$.legend + .selectAll('text') + .data(targetIds) + .text(function(id) { + return isDefined(config.data_names[id]) ? config.data_names[id] : id + }) // MEMO: needed for update + .each(function(id, i) { + updatePositions(this, id, i); + }) + ;(withTransition ? texts.transition() : texts) + .attr('x', xForLegendText) + .attr('y', yForLegendText); + + rects = $$.legend.selectAll('rect.' + CLASS.legendItemEvent).data(targetIds) + ;(withTransition ? rects.transition() : rects) + .attr('width', function(id) { + return widths[id] + }) + .attr('height', function(id) { + return heights[id] + }) + .attr('x', xForLegendRect) + .attr('y', yForLegendRect); + + tiles = $$.legend.selectAll('line.' + CLASS.legendItemTile).data(targetIds) + ;(withTransition ? tiles.transition() : tiles) + .style( + 'stroke', + $$.levelColor + ? function(id) { + return $$.levelColor( + $$.cache[id].values.reduce(function(total, item) { + return total + item.value + }, 0) + ) + } + : $$.color + ) + .attr('x1', x1ForLegendTile) + .attr('y1', yForLegendTile) + .attr('x2', x2ForLegendTile) + .attr('y2', yForLegendTile); + + if (background) { +(withTransition ? background.transition() : background) + .attr('height', $$.getLegendHeight() - 12) + .attr('width', maxWidth * (step + 1) + 10); + } + + // toggle legend state + $$.legend + .selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemHidden, function(id) { + return !$$.isTargetToShow(id) + }); + + // Update all to reflect change of legend + $$.updateLegendItemWidth(maxWidth); + $$.updateLegendItemHeight(maxHeight); + $$.updateLegendStep(step); + // Update size and scale + $$.updateSizes(); + $$.updateScales(); + $$.updateSvgSize(); + // Update g positions + $$.transformAll(withTransitionForTransform, transitions); + $$.legendHasRendered = true; +}; + +ChartInternal.prototype.initRegion = function() { + var $$ = this; + $$.region = $$.main + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.regions); +}; +ChartInternal.prototype.updateRegion = function(duration) { + var $$ = this, + config = $$.config; + + // hide if arc type + $$.region.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + + var mainRegion = $$.main + .select('.' + CLASS.regions) + .selectAll('.' + CLASS.region) + .data(config.regions); + var g = mainRegion.enter().append('g'); + g.append('rect') + .attr('x', $$.regionX.bind($$)) + .attr('y', $$.regionY.bind($$)) + .attr('width', $$.regionWidth.bind($$)) + .attr('height', $$.regionHeight.bind($$)) + .style('fill-opacity', function(d) { + return isValue(d.opacity) ? d.opacity : 0.1 + }); + g.append('text').text($$.labelRegion.bind($$)); + $$.mainRegion = g.merge(mainRegion).attr('class', $$.classRegion.bind($$)); + mainRegion + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); +}; +ChartInternal.prototype.redrawRegion = function(withTransition, transition) { + var $$ = this, + regions = $$.mainRegion, + regionLabels = $$.mainRegion.selectAll('text'); + return [ + (withTransition ? regions.transition(transition) : regions) + .attr('x', $$.regionX.bind($$)) + .attr('y', $$.regionY.bind($$)) + .attr('width', $$.regionWidth.bind($$)) + .attr('height', $$.regionHeight.bind($$)) + .style('fill-opacity', function(d) { + return isValue(d.opacity) ? d.opacity : 0.1 + }), + (withTransition ? regionLabels.transition(transition) : regionLabels) + .attr('x', $$.labelOffsetX.bind($$)) + .attr('y', $$.labelOffsetY.bind($$)) + .attr('transform', $$.labelTransform.bind($$)) + .attr('style', 'text-anchor: left;') + ] +}; +ChartInternal.prototype.regionX = function(d) { + var $$ = this, + config = $$.config, + xPos, + yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + xPos = config.axis_rotated ? ('start' in d ? yScale(d.start) : 0) : 0; + } else { + xPos = config.axis_rotated + ? 0 + : 'start' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) + : 0; + } + return xPos +}; +ChartInternal.prototype.regionY = function(d) { + var $$ = this, + config = $$.config, + yPos, + yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + yPos = config.axis_rotated ? 0 : 'end' in d ? yScale(d.end) : 0; + } else { + yPos = config.axis_rotated + ? 'start' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) + : 0 + : 0; + } + return yPos +}; +ChartInternal.prototype.regionWidth = function(d) { + var $$ = this, + config = $$.config, + start = $$.regionX(d), + end, + yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + end = config.axis_rotated + ? 'end' in d + ? yScale(d.end) + : $$.width + : $$.width; + } else { + end = config.axis_rotated + ? $$.width + : 'end' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) + : $$.width; + } + return end < start ? 0 : end - start +}; +ChartInternal.prototype.regionHeight = function(d) { + var $$ = this, + config = $$.config, + start = this.regionY(d), + end, + yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + end = config.axis_rotated + ? $$.height + : 'start' in d + ? yScale(d.start) + : $$.height; + } else { + end = config.axis_rotated + ? 'end' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) + : $$.height + : $$.height; + } + return end < start ? 0 : end - start +}; +ChartInternal.prototype.isRegionOnX = function(d) { + return !d.axis || d.axis === 'x' +}; +ChartInternal.prototype.labelRegion = function(d) { + return 'label' in d ? d.label : '' +}; +ChartInternal.prototype.labelTransform = function(d) { + return 'vertical' in d && d.vertical ? 'rotate(90)' : '' +}; +ChartInternal.prototype.labelOffsetX = function(d) { + var paddingX = 'paddingX' in d ? d.paddingX : 3; + var paddingY = 'paddingY' in d ? d.paddingY : 3; + return 'vertical' in d && d.vertical + ? this.regionY(d) + paddingY + : this.regionX(d) + paddingX +}; +ChartInternal.prototype.labelOffsetY = function(d) { + var paddingX = 'paddingX' in d ? d.paddingX : 3; + var paddingY = 'paddingY' in d ? d.paddingY : 3; + return 'vertical' in d && d.vertical + ? -(this.regionX(d) + paddingX) + : this.regionY(d) + 10 + paddingY +}; + +function c3LogScale(d3, linearScale, logScale) { + var PROJECTION = [0.01, 10]; + + if (!linearScale) { + linearScale = d3.scaleLinear(); + linearScale.range(PROJECTION); + } + + if (!logScale) { + logScale = d3.scaleLog(); + logScale.domain(PROJECTION); + logScale.nice(); + } + + // copied from https://github.com/compute-io/logspace + function logspace(a, b, len) { + var arr, end, tmp, d; + + if (arguments.length < 3) { + len = 10; + } else { + if (len === 0) { + return [] + } + } + // Calculate the increment: + end = len - 1; + d = (b - a) / end; + + // Build the output array... + arr = new Array(len); + tmp = a; + arr[0] = Math.pow(10, tmp); + for (var i = 1; i < end; i++) { + tmp += d; + arr[i] = Math.pow(10, tmp); + } + arr[end] = Math.pow(10, b); + return arr + } + + function scale(x) { + return logScale(linearScale(x)) + } + + scale.domain = function(x) { + if (!arguments.length) { + return linearScale.domain() + } + linearScale.domain(x); + return scale + }; + + scale.range = function(x) { + if (!arguments.length) { + return logScale.range() + } + logScale.range(x); + return scale + }; + + scale.ticks = function(m) { + return logspace(-2, 1, m || 10).map(function(v) { + return linearScale.invert(v) + }) + }; + + scale.copy = function() { + return c3LogScale(d3, linearScale.copy(), logScale.copy()) + }; + + return scale +} + +ChartInternal.prototype.getScale = function(min, max, forTimeseries) { + return (forTimeseries ? this.d3.scaleTime() : this.d3.scaleLinear()).range([ + min, + max + ]) +}; +ChartInternal.prototype.getX = function(min, max, domain, offset) { + var $$ = this, + scale = $$.getScale(min, max, $$.isTimeSeries()), + _scale = domain ? scale.domain(domain) : scale, + key; + // Define customized scale if categorized axis + if ($$.isCategorized()) { + offset = + offset || + function() { + return 0 + }; + scale = function(d, raw) { + var v = _scale(d) + offset(d); + return raw ? v : Math.ceil(v) + }; + } else { + scale = function(d, raw) { + var v = _scale(d); + return raw ? v : Math.ceil(v) + }; + } + // define functions + for (key in _scale) { + scale[key] = _scale[key]; + } + scale.orgDomain = function() { + return _scale.domain() + }; + // define custom domain() for categorized axis + if ($$.isCategorized()) { + scale.domain = function(domain) { + if (!arguments.length) { + domain = this.orgDomain(); + return [domain[0], domain[1] + 1] + } + _scale.domain(domain); + return scale + }; + } + return scale +}; + +/** + * Creates and configures a D3 scale instance for the given type. + * + * By defaults it returns a Linear scale. + * + * @param {String} type Type of d3-scale to create. Type can be 'linear', 'time', 'timeseries' or 'log'. + * @param {Array} domain The scale domain such as [from, to] + * @param {Array} range The scale's range such as [from, to] + * + * @return A d3-scale instance + */ +ChartInternal.prototype.getY = function(type, domain, range) { + let scale; + if (type === 'timeseries' || type === 'time') { + scale = this.d3.scaleTime(); + } else if (type === 'log') { + scale = c3LogScale(this.d3); + } else if (type === 'linear' || type === undefined) { + scale = this.d3.scaleLinear(); + } else { + throw new Error(`Invalid Y axis type: "${type}"`) + } + + if (domain) { + scale.domain(domain); + } + + if (range) { + scale.range(range); + } + + return scale +}; +ChartInternal.prototype.getYScale = function(id) { + return this.axis.getId(id) === 'y2' ? this.y2 : this.y +}; +ChartInternal.prototype.getSubYScale = function(id) { + return this.axis.getId(id) === 'y2' ? this.subY2 : this.subY +}; +ChartInternal.prototype.updateScales = function() { + var $$ = this, + config = $$.config, + forInit = !$$.x; + // update edges + $$.xMin = config.axis_rotated ? 1 : 0; + $$.xMax = config.axis_rotated ? $$.height : $$.width; + $$.yMin = config.axis_rotated ? 0 : $$.height; + $$.yMax = config.axis_rotated ? $$.width : 1; + $$.subXMin = $$.xMin; + $$.subXMax = $$.xMax; + $$.subYMin = config.axis_rotated ? 0 : $$.height2; + $$.subYMax = config.axis_rotated ? $$.width2 : 1; + // update scales + $$.x = $$.getX( + $$.xMin, + $$.xMax, + forInit ? undefined : $$.x.orgDomain(), + function() { + return $$.xAxis.tickOffset() + } + ); + $$.y = $$.getY( + config.axis_y_type, + forInit ? config.axis_y_default : $$.y.domain(), + [$$.yMin, $$.yMax] + ); + $$.y2 = $$.getY( + config.axis_y2_type, + forInit ? config.axis_y2_default : $$.y2.domain(), + [$$.yMin, $$.yMax] + ); + $$.subX = $$.getX($$.xMin, $$.xMax, $$.orgXDomain, function(d) { + return d % 1 ? 0 : $$.subXAxis.tickOffset() + }); + $$.subY = $$.getY( + config.axis_y_type, + forInit ? config.axis_y_default : $$.subY.domain(), + [$$.subYMin, $$.subYMax] + ); + $$.subY2 = $$.getY( + config.axis_y2_type, + forInit ? config.axis_y2_default : $$.subY2.domain(), + [$$.subYMin, $$.subYMax] + ); + // update axes + $$.xAxisTickFormat = $$.axis.getXAxisTickFormat(); + $$.xAxisTickValues = $$.axis.getXAxisTickValues(); + $$.yAxisTickValues = $$.axis.getYAxisTickValues(); + $$.y2AxisTickValues = $$.axis.getY2AxisTickValues(); + + $$.xAxis = $$.axis.getXAxis( + $$.x, + $$.xOrient, + $$.xAxisTickFormat, + $$.xAxisTickValues, + config.axis_x_tick_outer + ); + $$.subXAxis = $$.axis.getXAxis( + $$.subX, + $$.subXOrient, + $$.xAxisTickFormat, + $$.xAxisTickValues, + config.axis_x_tick_outer + ); + $$.yAxis = $$.axis.getYAxis( + 'y', + $$.y, + $$.yOrient, + $$.yAxisTickValues, + config.axis_y_tick_outer + ); + $$.y2Axis = $$.axis.getYAxis( + 'y2', + $$.y2, + $$.y2Orient, + $$.y2AxisTickValues, + config.axis_y2_tick_outer + ); + + // Set initialized scales to brush and zoom + if (!forInit) { + if ($$.brush) { + $$.brush.updateScale($$.subX); + } + } + // update for arc + if ($$.updateArc) { + $$.updateArc(); + } +}; + +ChartInternal.prototype.selectPoint = function(target, d, i) { + var $$ = this, + config = $$.config, + cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$), + cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$), + r = $$.pointSelectR.bind($$); + config.data_onselected.call($$.api, d, target.node()); + // add selected-circle on low layer g + $$.main + .select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.selectedCircle + '-' + i) + .data([d]) + .enter() + .append('circle') + .attr('class', function() { + return $$.generateClass(CLASS.selectedCircle, i) + }) + .attr('cx', cx) + .attr('cy', cy) + .attr('stroke', function() { + return $$.color(d) + }) + .attr('r', function(d) { + return $$.pointSelectR(d) * 1.4 + }) + .transition() + .duration(100) + .attr('r', r); +}; +ChartInternal.prototype.unselectPoint = function(target, d, i) { + var $$ = this; + $$.config.data_onunselected.call($$.api, d, target.node()); + // remove selected-circle from low layer g + $$.main + .select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.selectedCircle + '-' + i) + .transition() + .duration(100) + .attr('r', 0) + .remove(); +}; +ChartInternal.prototype.togglePoint = function(selected, target, d, i) { + selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i); +}; +ChartInternal.prototype.selectPath = function(target, d) { + var $$ = this; + $$.config.data_onselected.call($$, d, target.node()); + if ($$.config.interaction_brighten) { + target + .transition() + .duration(100) + .style('fill', function() { + return $$.d3.rgb($$.color(d)).brighter(0.75) + }); + } +}; +ChartInternal.prototype.unselectPath = function(target, d) { + var $$ = this; + $$.config.data_onunselected.call($$, d, target.node()); + if ($$.config.interaction_brighten) { + target + .transition() + .duration(100) + .style('fill', function() { + return $$.color(d) + }); + } +}; +ChartInternal.prototype.togglePath = function(selected, target, d, i) { + selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i); +}; +ChartInternal.prototype.getToggle = function(that, d) { + var $$ = this, + toggle; + if (that.nodeName === 'circle') { + if ($$.isStepType(d)) { + // circle is hidden in step chart, so treat as within the click area + toggle = function() {}; // TODO: how to select step chart? + } else { + toggle = $$.togglePoint; + } + } else if (that.nodeName === 'path') { + toggle = $$.togglePath; + } + return toggle +}; +ChartInternal.prototype.toggleShape = function(that, d, i) { + var $$ = this, + d3 = $$.d3, + config = $$.config, + shape = d3.select(that), + isSelected = shape.classed(CLASS.SELECTED), + toggle = $$.getToggle(that, d).bind($$); + + if (config.data_selection_enabled && config.data_selection_isselectable(d)) { + if (!config.data_selection_multiple) { + $$.main + .selectAll( + '.' + + CLASS.shapes + + (config.data_selection_grouped + ? $$.getTargetSelectorSuffix(d.id) + : '') + ) + .selectAll('.' + CLASS.shape) + .each(function(d, i) { + var shape = d3.select(this); + if (shape.classed(CLASS.SELECTED)) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + }); + } + shape.classed(CLASS.SELECTED, !isSelected); + toggle(!isSelected, shape, d, i); + } +}; + +ChartInternal.prototype.initBar = function() { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartBars); +}; +ChartInternal.prototype.updateTargetsForBar = function(targets) { + var $$ = this, + config = $$.config, + mainBars, + mainBarEnter, + classChartBar = $$.classChartBar.bind($$), + classBars = $$.classBars.bind($$), + classFocus = $$.classFocus.bind($$); + mainBars = $$.main + .select('.' + CLASS.chartBars) + .selectAll('.' + CLASS.chartBar) + .data(targets) + .attr('class', function(d) { + return classChartBar(d) + classFocus(d) + }); + mainBarEnter = mainBars + .enter() + .append('g') + .attr('class', classChartBar) + .style('pointer-events', 'none'); + // Bars for each data + mainBarEnter + .append('g') + .attr('class', classBars) + .style('cursor', function(d) { + return config.data_selection_isselectable(d) ? 'pointer' : null + }); +}; +ChartInternal.prototype.updateBar = function(durationForExit) { + var $$ = this, + barData = $$.barData.bind($$), + classBar = $$.classBar.bind($$), + initialOpacity = $$.initialOpacity.bind($$), + color = function(d) { + return $$.color(d.id) + }; + var mainBar = $$.main + .selectAll('.' + CLASS.bars) + .selectAll('.' + CLASS.bar) + .data(barData); + var mainBarEnter = mainBar + .enter() + .append('path') + .attr('class', classBar) + .style('stroke', color) + .style('fill', color); + $$.mainBar = mainBarEnter.merge(mainBar).style('opacity', initialOpacity); + mainBar + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); +}; +ChartInternal.prototype.redrawBar = function( + drawBar, + withTransition, + transition +) { + const $$ = this; + + return [ + (withTransition ? this.mainBar.transition(transition) : this.mainBar) + .attr('d', drawBar) + .style('stroke', this.color) + .style('fill', this.color) + .style('opacity', d => ($$.isTargetToShow(d.id) ? 1 : 0)) + ] +}; +ChartInternal.prototype.getBarW = function(axis, barTargetsNum) { + var $$ = this, + config = $$.config, + w = + typeof config.bar_width === 'number' + ? config.bar_width + : barTargetsNum + ? (axis.tickInterval() * config.bar_width_ratio) / barTargetsNum + : 0; + return config.bar_width_max && w > config.bar_width_max + ? config.bar_width_max + : w +}; +ChartInternal.prototype.getBars = function(i, id) { + var $$ = this; + return (id + ? $$.main.selectAll('.' + CLASS.bars + $$.getTargetSelectorSuffix(id)) + : $$.main + ).selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')) +}; +ChartInternal.prototype.expandBars = function(i, id, reset) { + var $$ = this; + if (reset) { + $$.unexpandBars(); + } + $$.getBars(i, id).classed(CLASS.EXPANDED, true); +}; +ChartInternal.prototype.unexpandBars = function(i) { + var $$ = this; + $$.getBars(i).classed(CLASS.EXPANDED, false); +}; +ChartInternal.prototype.generateDrawBar = function(barIndices, isSub) { + var $$ = this, + config = $$.config, + getPoints = $$.generateGetBarPoints(barIndices, isSub); + return function(d, i) { + // 4 points that make a bar + var points = getPoints(d, i); + + // switch points if axis is rotated, not applicable for sub chart + var indexX = config.axis_rotated ? 1 : 0; + var indexY = config.axis_rotated ? 0 : 1; + + var path = + 'M ' + + points[0][indexX] + + ',' + + points[0][indexY] + + ' ' + + 'L' + + points[1][indexX] + + ',' + + points[1][indexY] + + ' ' + + 'L' + + points[2][indexX] + + ',' + + points[2][indexY] + + ' ' + + 'L' + + points[3][indexX] + + ',' + + points[3][indexY] + + ' ' + + 'z'; + + return path + } +}; +ChartInternal.prototype.generateGetBarPoints = function(barIndices, isSub) { + var $$ = this, + axis = isSub ? $$.subXAxis : $$.xAxis, + barTargetsNum = barIndices.__max__ + 1, + barW = $$.getBarW(axis, barTargetsNum), + barX = $$.getShapeX(barW, barTargetsNum, barIndices, !!isSub), + barY = $$.getShapeY(!!isSub), + barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub), + barSpaceOffset = barW * ($$.config.bar_space / 2), + yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function(d, i) { + var y0 = yScale.call($$, d.id)(0), + offset = barOffset(d, i) || y0, // offset is for stacked bar chart + posX = barX(d), + posY = barY(d); + // fix posY not to overflow opposite quadrant + if ($$.config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + + posY -= y0 - offset; + + // 4 points that make a bar + return [ + [posX + barSpaceOffset, offset], + [posX + barSpaceOffset, posY], + [posX + barW - barSpaceOffset, posY], + [posX + barW - barSpaceOffset, offset] + ] + } +}; + +/** + * Returns whether the data point is within the given bar shape. + * + * @param mouse + * @param barShape + * @return {boolean} + */ +ChartInternal.prototype.isWithinBar = function(mouse, barShape) { + return isWithinBox(mouse, getBBox(barShape), 2) +}; + +ChartInternal.prototype.getShapeIndices = function(typeFilter) { + var $$ = this, + config = $$.config, + indices = {}, + i = 0, + j, + k; + $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach( + function(d) { + for (j = 0; j < config.data_groups.length; j++) { + if (config.data_groups[j].indexOf(d.id) < 0) { + continue + } + for (k = 0; k < config.data_groups[j].length; k++) { + if (config.data_groups[j][k] in indices) { + indices[d.id] = indices[config.data_groups[j][k]]; + break + } + } + } + if (isUndefined(indices[d.id])) { + indices[d.id] = i++; + } + } + ); + indices.__max__ = i - 1; + return indices +}; +ChartInternal.prototype.getShapeX = function( + offset, + targetsNum, + indices, + isSub +) { + var $$ = this, + scale = isSub ? $$.subX : $$.x; + return function(d) { + var index = d.id in indices ? indices[d.id] : 0; + return d.x || d.x === 0 ? scale(d.x) - offset * (targetsNum / 2 - index) : 0 + } +}; +ChartInternal.prototype.getShapeY = function(isSub) { + const $$ = this; + + return function(d) { + const scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id); + return scale( + $$.isTargetNormalized(d.id) ? $$.getRatio('index', d, true) : d.value + ) + } +}; +ChartInternal.prototype.getShapeOffset = function(typeFilter, indices, isSub) { + var $$ = this, + targets = $$.orderTargets( + $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)) + ), + targetIds = targets.map(function(t) { + return t.id + }); + return function(d, i) { + var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id), + y0 = scale(0), + offset = y0; + targets.forEach(function(t) { + const rowValues = $$.isStepType(d) + ? $$.convertValuesToStep(t.values) + : t.values; + const isTargetNormalized = $$.isTargetNormalized(d.id); + const values = rowValues.map(v => + isTargetNormalized ? $$.getRatio('index', v, true) : v.value + ); + + if (t.id === d.id || indices[t.id] !== indices[d.id]) { + return + } + if (targetIds.indexOf(t.id) < targetIds.indexOf(d.id)) { + // check if the x values line up + if (isUndefined(rowValues[i]) || +rowValues[i].x !== +d.x) { + // "+" for timeseries + // if not, try to find the value that does line up + i = -1; + rowValues.forEach(function(v, j) { + const x1 = v.x.constructor === Date ? +v.x : v.x; + const x2 = d.x.constructor === Date ? +d.x : d.x; + + if (x1 === x2) { + i = j; + } + }); + } + if (i in rowValues && rowValues[i].value * d.value >= 0) { + offset += scale(values[i]) - y0; + } + } + }); + return offset + } +}; +ChartInternal.prototype.isWithinShape = function(that, d) { + var $$ = this, + shape = $$.d3.select(that), + isWithin; + if (!$$.isTargetToShow(d.id)) { + isWithin = false; + } else if (that.nodeName === 'circle') { + isWithin = $$.isStepType(d) + ? $$.isWithinStep(that, $$.getYScale(d.id)(d.value)) + : $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); + } else if (that.nodeName === 'path') { + isWithin = shape.classed(CLASS.bar) + ? $$.isWithinBar($$.d3.mouse(that), that) + : true; + } + return isWithin +}; + +ChartInternal.prototype.getInterpolate = function(d) { + var $$ = this, + d3 = $$.d3, + types = { + linear: d3.curveLinear, + 'linear-closed': d3.curveLinearClosed, + basis: d3.curveBasis, + 'basis-open': d3.curveBasisOpen, + 'basis-closed': d3.curveBasisClosed, + bundle: d3.curveBundle, + cardinal: d3.curveCardinal, + 'cardinal-open': d3.curveCardinalOpen, + 'cardinal-closed': d3.curveCardinalClosed, + monotone: d3.curveMonotoneX, + step: d3.curveStep, + 'step-before': d3.curveStepBefore, + 'step-after': d3.curveStepAfter + }, + type; + + if ($$.isSplineType(d)) { + type = types[$$.config.spline_interpolation_type] || types.cardinal; + } else if ($$.isStepType(d)) { + type = types[$$.config.line_step_type]; + } else { + type = types.linear; + } + return type +}; + +ChartInternal.prototype.initLine = function() { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartLines); +}; +ChartInternal.prototype.updateTargetsForLine = function(targets) { + var $$ = this, + config = $$.config, + mainLines, + mainLineEnter, + classChartLine = $$.classChartLine.bind($$), + classLines = $$.classLines.bind($$), + classAreas = $$.classAreas.bind($$), + classCircles = $$.classCircles.bind($$), + classFocus = $$.classFocus.bind($$); + mainLines = $$.main + .select('.' + CLASS.chartLines) + .selectAll('.' + CLASS.chartLine) + .data(targets) + .attr('class', function(d) { + return classChartLine(d) + classFocus(d) + }); + mainLineEnter = mainLines + .enter() + .append('g') + .attr('class', classChartLine) + .style('opacity', 0) + .style('pointer-events', 'none'); + // Lines for each data + mainLineEnter.append('g').attr('class', classLines); + // Areas + mainLineEnter.append('g').attr('class', classAreas); + // Circles for each data point on lines + mainLineEnter.append('g').attr('class', function(d) { + return $$.generateClass(CLASS.selectedCircles, d.id) + }); + mainLineEnter + .append('g') + .attr('class', classCircles) + .style('cursor', function(d) { + return config.data_selection_isselectable(d) ? 'pointer' : null + }); + // Update date for selected circles + targets.forEach(function(t) { + $$.main + .selectAll('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(t.id)) + .selectAll('.' + CLASS.selectedCircle) + .each(function(d) { + d.value = t.values[d.index].value; + }); + }); + // MEMO: can not keep same color... + //mainLineUpdate.exit().remove(); +}; +ChartInternal.prototype.updateLine = function(durationForExit) { + var $$ = this; + var mainLine = $$.main + .selectAll('.' + CLASS.lines) + .selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + var mainLineEnter = mainLine + .enter() + .append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + $$.mainLine = mainLineEnter + .merge(mainLine) + .style('opacity', $$.initialOpacity.bind($$)) + .style('shape-rendering', function(d) { + return $$.isStepType(d) ? 'crispEdges' : '' + }) + .attr('transform', null); + mainLine + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); +}; +ChartInternal.prototype.redrawLine = function( + drawLine, + withTransition, + transition +) { + return [ + (withTransition ? this.mainLine.transition(transition) : this.mainLine) + .attr('d', drawLine) + .style('stroke', this.color) + .style('opacity', 1) + ] +}; +ChartInternal.prototype.generateDrawLine = function(lineIndices, isSub) { + var $$ = this, + config = $$.config, + line = $$.d3.line(), + getPoints = $$.generateGetLinePoints(lineIndices, isSub), + yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, + xValue = function(d) { + return (isSub ? $$.subxx : $$.xx).call($$, d) + }, + yValue = function(d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[0][1] + : yScaleGetter.call($$, d.id)(d.value) + }; + + line = config.axis_rotated + ? line.x(yValue).y(xValue) + : line.x(xValue).y(yValue); + if (!config.line_connectNull) { + line = line.defined(function(d) { + return d.value != null + }); + } + return function(d) { + var values = config.line_connectNull + ? $$.filterRemoveNull(d.values) + : d.values, + x = isSub ? $$.subX : $$.x, + y = yScaleGetter.call($$, d.id), + x0 = 0, + y0 = 0, + path; + if ($$.isLineType(d)) { + if (config.data_regions[d.id]) { + path = $$.lineWithRegions(values, x, y, config.data_regions[d.id]); + } else { + if ($$.isStepType(d)) { + values = $$.convertValuesToStep(values); + } + path = line.curve($$.getInterpolate(d))(values); + } + } else { + if (values[0]) { + x0 = x(values[0].x); + y0 = y(values[0].value); + } + path = config.axis_rotated ? 'M ' + y0 + ' ' + x0 : 'M ' + x0 + ' ' + y0; + } + return path ? path : 'M 0 0' + } +}; +ChartInternal.prototype.generateGetLinePoints = function(lineIndices, isSub) { + // partial duplication of generateGetBarPoints + var $$ = this, + config = $$.config, + lineTargetsNum = lineIndices.__max__ + 1, + x = $$.getShapeX(0, lineTargetsNum, lineIndices, !!isSub), + y = $$.getShapeY(!!isSub), + lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, !!isSub), + yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function(d, i) { + var y0 = yScale.call($$, d.id)(0), + offset = lineOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), + posY = y(d); + // fix posY not to overflow opposite quadrant + if (config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + // 1 point that marks the line position + return [ + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], // needed for compatibility + [posX, posY - (y0 - offset)], // needed for compatibility + [posX, posY - (y0 - offset)] // needed for compatibility + ] + } +}; + +ChartInternal.prototype.lineWithRegions = function(d, x, y, _regions) { + var $$ = this, + config = $$.config, + prev = -1, + i, + j, + s = 'M', + sWithRegion, + xp, + yp, + dx, + dy, + dd, + diff, + diffx2, + xOffset = $$.isCategorized() ? 0.5 : 0, + xValue, + yValue, + regions = []; + + function isWithinRegions(x, regions) { + var i; + for (i = 0; i < regions.length; i++) { + if (regions[i].start < x && x <= regions[i].end) { + return true + } + } + return false + } + + // Check start/end of regions + if (isDefined(_regions)) { + for (i = 0; i < _regions.length; i++) { + regions[i] = {}; + if (isUndefined(_regions[i].start)) { + regions[i].start = d[0].x; + } else { + regions[i].start = $$.isTimeSeries() + ? $$.parseDate(_regions[i].start) + : _regions[i].start; + } + if (isUndefined(_regions[i].end)) { + regions[i].end = d[d.length - 1].x; + } else { + regions[i].end = $$.isTimeSeries() + ? $$.parseDate(_regions[i].end) + : _regions[i].end; + } + } + } + + // Set scales + xValue = config.axis_rotated + ? function(d) { + return y(d.value) + } + : function(d) { + return x(d.x) + }; + yValue = config.axis_rotated + ? function(d) { + return x(d.x) + } + : function(d) { + return y(d.value) + }; + + // Define svg generator function for region + function generateM(points) { + return ( + 'M' + + points[0][0] + + ' ' + + points[0][1] + + ' ' + + points[1][0] + + ' ' + + points[1][1] + ) + } + if ($$.isTimeSeries()) { + sWithRegion = function(d0, d1, j, diff) { + var x0 = d0.x.getTime(), + x_diff = d1.x - d0.x, + xv0 = new Date(x0 + x_diff * j), + xv1 = new Date(x0 + x_diff * (j + diff)), + points; + if (config.axis_rotated) { + points = [ + [y(yp(j)), x(xv0)], + [y(yp(j + diff)), x(xv1)] + ]; + } else { + points = [ + [x(xv0), y(yp(j))], + [x(xv1), y(yp(j + diff))] + ]; + } + return generateM(points) + }; + } else { + sWithRegion = function(d0, d1, j, diff) { + var points; + if (config.axis_rotated) { + points = [ + [y(yp(j), true), x(xp(j))], + [y(yp(j + diff), true), x(xp(j + diff))] + ]; + } else { + points = [ + [x(xp(j), true), y(yp(j))], + [x(xp(j + diff), true), y(yp(j + diff))] + ]; + } + return generateM(points) + }; + } + + // Generate + for (i = 0; i < d.length; i++) { + // Draw as normal + if (isUndefined(regions) || !isWithinRegions(d[i].x, regions)) { + s += ' ' + xValue(d[i]) + ' ' + yValue(d[i]); + } + // Draw with region // TODO: Fix for horizotal charts + else { + xp = $$.getScale( + d[i - 1].x + xOffset, + d[i].x + xOffset, + $$.isTimeSeries() + ); + yp = $$.getScale(d[i - 1].value, d[i].value); + + dx = x(d[i].x) - x(d[i - 1].x); + dy = y(d[i].value) - y(d[i - 1].value); + dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); + diff = 2 / dd; + diffx2 = diff * 2; + + for (j = diff; j <= 1; j += diffx2) { + s += sWithRegion(d[i - 1], d[i], j, diff); + } + } + prev = d[i].x; + } + + return s +}; + +ChartInternal.prototype.updateArea = function(durationForExit) { + var $$ = this, + d3 = $$.d3; + var mainArea = $$.main + .selectAll('.' + CLASS.areas) + .selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + var mainAreaEnter = mainArea + .enter() + .append('path') + .attr('class', $$.classArea.bind($$)) + .style('fill', $$.color) + .style('opacity', function() { + $$.orgAreaOpacity = +d3.select(this).style('opacity'); + return 0 + }); + $$.mainArea = mainAreaEnter + .merge(mainArea) + .style('opacity', $$.orgAreaOpacity); + mainArea + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); +}; +ChartInternal.prototype.redrawArea = function( + drawArea, + withTransition, + transition +) { + return [ + (withTransition ? this.mainArea.transition(transition) : this.mainArea) + .attr('d', drawArea) + .style('fill', this.color) + .style('opacity', this.orgAreaOpacity) + ] +}; +ChartInternal.prototype.generateDrawArea = function(areaIndices, isSub) { + var $$ = this, + config = $$.config, + area = $$.d3.area(), + getPoints = $$.generateGetAreaPoints(areaIndices, isSub), + yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, + xValue = function(d) { + return (isSub ? $$.subxx : $$.xx).call($$, d) + }, + value0 = function(d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[0][1] + : yScaleGetter.call($$, d.id)($$.getAreaBaseValue(d.id)) + }, + value1 = function(d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[1][1] + : yScaleGetter.call($$, d.id)(d.value) + }; + + area = config.axis_rotated + ? area + .x0(value0) + .x1(value1) + .y(xValue) + : area + .x(xValue) + .y0(config.area_above ? 0 : value0) + .y1(value1); + if (!config.line_connectNull) { + area = area.defined(function(d) { + return d.value !== null + }); + } + + return function(d) { + var values = config.line_connectNull + ? $$.filterRemoveNull(d.values) + : d.values, + x0 = 0, + y0 = 0, + path; + if ($$.isAreaType(d)) { + if ($$.isStepType(d)) { + values = $$.convertValuesToStep(values); + } + path = area.curve($$.getInterpolate(d))(values); + } else { + if (values[0]) { + x0 = $$.x(values[0].x); + y0 = $$.getYScale(d.id)(values[0].value); + } + path = config.axis_rotated ? 'M ' + y0 + ' ' + x0 : 'M ' + x0 + ' ' + y0; + } + return path ? path : 'M 0 0' + } +}; +ChartInternal.prototype.getAreaBaseValue = function() { + return 0 +}; +ChartInternal.prototype.generateGetAreaPoints = function(areaIndices, isSub) { + // partial duplication of generateGetBarPoints + var $$ = this, + config = $$.config, + areaTargetsNum = areaIndices.__max__ + 1, + x = $$.getShapeX(0, areaTargetsNum, areaIndices, !!isSub), + y = $$.getShapeY(!!isSub), + areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, !!isSub), + yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function(d, i) { + var y0 = yScale.call($$, d.id)(0), + offset = areaOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), + posY = y(d); + // fix posY not to overflow opposite quadrant + if (config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + // 1 point that marks the area position + return [ + [posX, offset], + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], // needed for compatibility + [posX, offset] // needed for compatibility + ] + } +}; + +ChartInternal.prototype.updateCircle = function(cx, cy) { + var $$ = this; + var mainCircle = $$.main + .selectAll('.' + CLASS.circles) + .selectAll('.' + CLASS.circle) + .data($$.lineOrScatterOrStanfordData.bind($$)); + + var mainCircleEnter = mainCircle + .enter() + .append('circle') + .attr('shape-rendering', $$.isStanfordGraphType() ? 'crispEdges' : '') + .attr('class', $$.classCircle.bind($$)) + .attr('cx', cx) + .attr('cy', cy) + .attr('r', $$.pointR.bind($$)) + .style( + 'color', + $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color + ); + + $$.mainCircle = mainCircleEnter + .merge(mainCircle) + .style( + 'opacity', + $$.isStanfordGraphType() ? 1 : $$.initialOpacityForCircle.bind($$) + ); + + mainCircle.exit().style('opacity', 0); +}; +ChartInternal.prototype.redrawCircle = function( + cx, + cy, + withTransition, + transition +) { + var $$ = this, + selectedCircles = $$.main.selectAll('.' + CLASS.selectedCircle); + return [ + (withTransition ? $$.mainCircle.transition(transition) : $$.mainCircle) + .style('opacity', this.opacityForCircle.bind($$)) + .style( + 'color', + $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color + ) + .attr('cx', cx) + .attr('cy', cy), + (withTransition ? selectedCircles.transition(transition) : selectedCircles) + .attr('cx', cx) + .attr('cy', cy) + ] +}; +ChartInternal.prototype.circleX = function(d) { + return d.x || d.x === 0 ? this.x(d.x) : null +}; +ChartInternal.prototype.updateCircleY = function() { + var $$ = this, + lineIndices, + getPoints; + if ($$.config.data_groups.length > 0) { +(lineIndices = $$.getShapeIndices($$.isLineType)), + (getPoints = $$.generateGetLinePoints(lineIndices)); + $$.circleY = function(d, i) { + return getPoints(d, i)[0][1] + }; + } else { + $$.circleY = function(d) { + return $$.getYScale(d.id)(d.value) + }; + } +}; +ChartInternal.prototype.getCircles = function(i, id) { + var $$ = this; + return (id + ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) + : $$.main + ).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')) +}; +ChartInternal.prototype.expandCircles = function(i, id, reset) { + var $$ = this, + r = $$.pointExpandedR.bind($$); + if (reset) { + $$.unexpandCircles(); + } + $$.getCircles(i, id) + .classed(CLASS.EXPANDED, true) + .attr('r', r); +}; +ChartInternal.prototype.unexpandCircles = function(i) { + var $$ = this, + r = $$.pointR.bind($$); + $$.getCircles(i) + .filter(function() { + return $$.d3.select(this).classed(CLASS.EXPANDED) + }) + .classed(CLASS.EXPANDED, false) + .attr('r', r); +}; +ChartInternal.prototype.pointR = function(d) { + var $$ = this, + config = $$.config; + return $$.isStepType(d) + ? 0 + : isFunction(config.point_r) + ? config.point_r(d) + : config.point_r +}; +ChartInternal.prototype.pointExpandedR = function(d) { + var $$ = this, + config = $$.config; + if (config.point_focus_expand_enabled) { + return isFunction(config.point_focus_expand_r) + ? config.point_focus_expand_r(d) + : config.point_focus_expand_r + ? config.point_focus_expand_r + : $$.pointR(d) * 1.75 + } else { + return $$.pointR(d) + } +}; +ChartInternal.prototype.pointSelectR = function(d) { + var $$ = this, + config = $$.config; + return isFunction(config.point_select_r) + ? config.point_select_r(d) + : config.point_select_r + ? config.point_select_r + : $$.pointR(d) * 4 +}; +ChartInternal.prototype.isWithinCircle = function(that, r) { + var d3 = this.d3, + mouse = d3.mouse(that), + d3_this = d3.select(that), + cx = +d3_this.attr('cx'), + cy = +d3_this.attr('cy'); + return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < r +}; +ChartInternal.prototype.isWithinStep = function(that, y) { + return Math.abs(y - this.d3.mouse(that)[1]) < 30 +}; + +ChartInternal.prototype.getCurrentWidth = function() { + var $$ = this, + config = $$.config; + return config.size_width ? config.size_width : $$.getParentWidth() +}; +ChartInternal.prototype.getCurrentHeight = function() { + var $$ = this, + config = $$.config, + h = config.size_height ? config.size_height : $$.getParentHeight(); + return h > 0 + ? h + : 320 / ($$.hasType('gauge') && !config.gauge_fullCircle ? 2 : 1) +}; +ChartInternal.prototype.getCurrentPaddingTop = function() { + var $$ = this, + config = $$.config, + padding = isValue(config.padding_top) ? config.padding_top : 0; + if ($$.title && $$.title.node()) { + padding += $$.getTitlePadding(); + } + return padding +}; +ChartInternal.prototype.getCurrentPaddingBottom = function() { + var config = this.config; + return isValue(config.padding_bottom) ? config.padding_bottom : 0 +}; +ChartInternal.prototype.getCurrentPaddingLeft = function(withoutRecompute) { + var $$ = this, + config = $$.config; + if (isValue(config.padding_left)) { + return config.padding_left + } else if (config.axis_rotated) { + return !config.axis_x_show || config.axis_x_inner + ? 1 + : Math.max(ceil10($$.getAxisWidthByAxisId('x', withoutRecompute)), 40) + } else if (!config.axis_y_show || config.axis_y_inner) { + // && !config.axis_rotated + return $$.axis.getYAxisLabelPosition().isOuter ? 30 : 1 + } else { + return ceil10($$.getAxisWidthByAxisId('y', withoutRecompute)) + } +}; +ChartInternal.prototype.getCurrentPaddingRight = function() { + var $$ = this, + config = $$.config, + padding = 0, + defaultPadding = 10, + legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0; + + if (isValue(config.padding_right)) { + padding = config.padding_right + 1; // 1 is needed not to hide tick line + } else if (config.axis_rotated) { + padding = defaultPadding + legendWidthOnRight; + } else if (!config.axis_y2_show || config.axis_y2_inner) { + // && !config.axis_rotated + padding = + 2 + + legendWidthOnRight + + ($$.axis.getY2AxisLabelPosition().isOuter ? 20 : 0); + } else { + padding = ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight; + } + + if ($$.colorScale && $$.colorScale.node()) { + padding += $$.getColorScalePadding(); + } + + return padding +}; + +ChartInternal.prototype.getParentRectValue = function(key) { + var parent = this.selectChart.node(), + v; + while (parent && parent.tagName !== 'BODY') { + try { + v = parent.getBoundingClientRect()[key]; + } catch (e) { + if (key === 'width') { + // In IE in certain cases getBoundingClientRect + // will cause an "unspecified error" + v = parent.offsetWidth; + } + } + if (v) { + break + } + parent = parent.parentNode; + } + return v +}; +ChartInternal.prototype.getParentWidth = function() { + return this.getParentRectValue('width') +}; +ChartInternal.prototype.getParentHeight = function() { + var h = this.selectChart.style('height'); + return h.indexOf('px') > 0 ? +h.replace('px', '') : 0 +}; + +ChartInternal.prototype.getSvgLeft = function(withoutRecompute) { + var $$ = this, + config = $$.config, + hasLeftAxisRect = + config.axis_rotated || (!config.axis_rotated && !config.axis_y_inner), + leftAxisClass = config.axis_rotated ? CLASS.axisX : CLASS.axisY, + leftAxis = $$.main.select('.' + leftAxisClass).node(), + svgRect = + leftAxis && hasLeftAxisRect + ? leftAxis.getBoundingClientRect() + : { right: 0 }, + chartRect = $$.selectChart.node().getBoundingClientRect(), + hasArc = $$.hasArcType(), + svgLeft = + svgRect.right - + chartRect.left - + (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute)); + return svgLeft > 0 ? svgLeft : 0 +}; + +ChartInternal.prototype.getAxisWidthByAxisId = function(id, withoutRecompute) { + var $$ = this, + position = $$.axis.getLabelPositionById(id); + return ( + $$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40) + ) +}; +ChartInternal.prototype.getHorizontalAxisHeight = function(axisId) { + var $$ = this, + config = $$.config, + h = 30; + if (axisId === 'x' && !config.axis_x_show) { + return 8 + } + if (axisId === 'x' && config.axis_x_height) { + return config.axis_x_height + } + if (axisId === 'y' && !config.axis_y_show) { + return config.legend_show && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1 + } + if (axisId === 'y2' && !config.axis_y2_show) { + return $$.rotated_padding_top + } + // Calculate x axis height when tick rotated + if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) { + h = + 30 + + $$.axis.getMaxTickWidth(axisId) * + Math.cos((Math.PI * (90 - Math.abs(config.axis_x_tick_rotate))) / 180); + } + // Calculate y axis height when tick rotated + if (axisId === 'y' && config.axis_rotated && config.axis_y_tick_rotate) { + h = + 30 + + $$.axis.getMaxTickWidth(axisId) * + Math.cos((Math.PI * (90 - Math.abs(config.axis_y_tick_rotate))) / 180); + } + return ( + h + + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + + (axisId === 'y2' ? -10 : 0) + ) +}; + +ChartInternal.prototype.initBrush = function(scale) { + var $$ = this, + d3 = $$.d3; + // TODO: dynamically change brushY/brushX according to axis_rotated. + $$.brush = ($$.config.axis_rotated ? d3.brushY() : d3.brushX()) + .on('brush', function() { + var event = d3.event.sourceEvent; + if (event && event.type === 'zoom') { + return + } + $$.redrawForBrush(); + }) + .on('end', function() { + var event = d3.event.sourceEvent; + if (event && event.type === 'zoom') { + return + } + if ($$.brush.empty() && event && event.type !== 'end') { + $$.brush.clear(); + } + }); + $$.brush.updateExtent = function() { + var range = this.scale.range(), + extent; + if ($$.config.axis_rotated) { + extent = [ + [0, range[0]], + [$$.width2, range[1]] + ]; + } else { + extent = [ + [range[0], 0], + [range[1], $$.height2] + ]; + } + this.extent(extent); + return this + }; + $$.brush.updateScale = function(scale) { + this.scale = scale; + return this + }; + $$.brush.update = function(scale) { + this.updateScale(scale || $$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call(this); + }; + $$.brush.clear = function() { + $$.context.select('.' + CLASS.brush).call($$.brush.move, null); + }; + $$.brush.selection = function() { + return d3.brushSelection($$.context.select('.' + CLASS.brush).node()) + }; + $$.brush.selectionAsValue = function(selectionAsValue, withTransition) { + var selection, brush; + if (selectionAsValue) { + if ($$.context) { + selection = [ + this.scale(selectionAsValue[0]), + this.scale(selectionAsValue[1]) + ]; + brush = $$.context.select('.' + CLASS.brush); + if (withTransition) { + brush = brush.transition(); + } + $$.brush.move(brush, selection); + } + return [] + } + selection = $$.brush.selection() || [0, 0]; + return [this.scale.invert(selection[0]), this.scale.invert(selection[1])] + }; + $$.brush.empty = function() { + var selection = $$.brush.selection(); + return !selection || selection[0] === selection[1] + }; + return $$.brush.updateScale(scale) +}; +ChartInternal.prototype.initSubchart = function() { + var $$ = this, + config = $$.config, + context = ($$.context = $$.svg + .append('g') + .attr('transform', $$.getTranslate('context'))); + + // set style + context.style('visibility', 'visible'); + + // Define g for chart area + context + .append('g') + .attr('clip-path', $$.clipPathForSubchart) + .attr('class', CLASS.chart); + + // Define g for bar chart area + context + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartBars); + + // Define g for line chart area + context + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartLines); + + // Add extent rect for Brush + context + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.brush); + + // ATTENTION: This must be called AFTER chart added + // Add Axis + $$.axes.subx = context + .append('g') + .attr('class', CLASS.axisX) + .attr('transform', $$.getTranslate('subx')) + .attr('clip-path', config.axis_rotated ? '' : $$.clipPathForXAxis); +}; +ChartInternal.prototype.initSubchartBrush = function() { + var $$ = this; + // Add extent rect for Brush + $$.initBrush($$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call($$.brush); +}; +ChartInternal.prototype.updateTargetsForSubchart = function(targets) { + var $$ = this, + context = $$.context, + config = $$.config, + contextLineEnter, + contextLine, + contextBarEnter, + contextBar, + classChartBar = $$.classChartBar.bind($$), + classBars = $$.classBars.bind($$), + classChartLine = $$.classChartLine.bind($$), + classLines = $$.classLines.bind($$), + classAreas = $$.classAreas.bind($$); + + //-- Bar --// + contextBar = context + .select('.' + CLASS.chartBars) + .selectAll('.' + CLASS.chartBar) + .data(targets); + contextBarEnter = contextBar + .enter() + .append('g') + .style('opacity', 0); + contextBarEnter.merge(contextBar).attr('class', classChartBar); + // Bars for each data + contextBarEnter.append('g').attr('class', classBars); + + //-- Line --// + contextLine = context + .select('.' + CLASS.chartLines) + .selectAll('.' + CLASS.chartLine) + .data(targets); + contextLineEnter = contextLine + .enter() + .append('g') + .style('opacity', 0); + contextLineEnter.merge(contextLine).attr('class', classChartLine); + // Lines for each data + contextLineEnter.append('g').attr('class', classLines); + // Area + contextLineEnter.append('g').attr('class', classAreas); + + //-- Brush --// + context + .selectAll('.' + CLASS.brush + ' rect') + .attr( + config.axis_rotated ? 'width' : 'height', + config.axis_rotated ? $$.width2 : $$.height2 + ); +}; +ChartInternal.prototype.updateBarForSubchart = function(durationForExit) { + var $$ = this; + var contextBar = $$.context + .selectAll('.' + CLASS.bars) + .selectAll('.' + CLASS.bar) + .data($$.barData.bind($$)); + var contextBarEnter = contextBar + .enter() + .append('path') + .attr('class', $$.classBar.bind($$)) + .style('stroke', 'none') + .style('fill', $$.color); + contextBar + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextBar = contextBarEnter + .merge(contextBar) + .style('opacity', $$.initialOpacity.bind($$)); +}; +ChartInternal.prototype.redrawBarForSubchart = function( + drawBarOnSub, + withTransition, + duration +) { +(withTransition + ? this.contextBar.transition(Math.random().toString()).duration(duration) + : this.contextBar + ) + .attr('d', drawBarOnSub) + .style('opacity', 1); +}; +ChartInternal.prototype.updateLineForSubchart = function(durationForExit) { + var $$ = this; + var contextLine = $$.context + .selectAll('.' + CLASS.lines) + .selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + var contextLineEnter = contextLine + .enter() + .append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + contextLine + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextLine = contextLineEnter + .merge(contextLine) + .style('opacity', $$.initialOpacity.bind($$)); +}; +ChartInternal.prototype.redrawLineForSubchart = function( + drawLineOnSub, + withTransition, + duration +) { +(withTransition + ? this.contextLine.transition(Math.random().toString()).duration(duration) + : this.contextLine + ) + .attr('d', drawLineOnSub) + .style('opacity', 1); +}; +ChartInternal.prototype.updateAreaForSubchart = function(durationForExit) { + var $$ = this, + d3 = $$.d3; + var contextArea = $$.context + .selectAll('.' + CLASS.areas) + .selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + var contextAreaEnter = contextArea + .enter() + .append('path') + .attr('class', $$.classArea.bind($$)) + .style('fill', $$.color) + .style('opacity', function() { + $$.orgAreaOpacity = +d3.select(this).style('opacity'); + return 0 + }); + contextArea + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextArea = contextAreaEnter.merge(contextArea).style('opacity', 0); +}; +ChartInternal.prototype.redrawAreaForSubchart = function( + drawAreaOnSub, + withTransition, + duration +) { +(withTransition + ? this.contextArea.transition(Math.random().toString()).duration(duration) + : this.contextArea + ) + .attr('d', drawAreaOnSub) + .style('fill', this.color) + .style('opacity', this.orgAreaOpacity); +}; +ChartInternal.prototype.redrawSubchart = function( + withSubchart, + transitions, + duration, + durationForExit, + areaIndices, + barIndices, + lineIndices +) { + var $$ = this, + d3 = $$.d3, + drawAreaOnSub, + drawBarOnSub, + drawLineOnSub; + + // reflect main chart to extent on subchart if zoomed + if (d3.event && d3.event.type === 'zoom') { + $$.brush.selectionAsValue($$.x.orgDomain()); + } + // update subchart elements if needed + if (withSubchart) { + // extent rect + if (!$$.brush.empty()) { + $$.brush.selectionAsValue($$.x.orgDomain()); + } + // setup drawer - MEMO: this must be called after axis updated + drawAreaOnSub = $$.generateDrawArea(areaIndices, true); + drawBarOnSub = $$.generateDrawBar(barIndices, true); + drawLineOnSub = $$.generateDrawLine(lineIndices, true); + + $$.updateBarForSubchart(duration); + $$.updateLineForSubchart(duration); + $$.updateAreaForSubchart(duration); + + $$.redrawBarForSubchart(drawBarOnSub, duration, duration); + $$.redrawLineForSubchart(drawLineOnSub, duration, duration); + $$.redrawAreaForSubchart(drawAreaOnSub, duration, duration); + } +}; +ChartInternal.prototype.redrawForBrush = function() { + var $$ = this, + x = $$.x, + d3 = $$.d3, + s; + $$.redraw({ + withTransition: false, + withY: $$.config.zoom_rescale, + withSubchart: false, + withUpdateXDomain: true, + withEventRect: false, + withDimension: false + }); + // update zoom transation binded to event rect + s = d3.event.selection || $$.brush.scale.range(); + $$.main + .select('.' + CLASS.eventRect) + .call( + $$.zoom.transform, + d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0) + ); + $$.config.subchart_onbrush.call($$.api, x.orgDomain()); +}; +ChartInternal.prototype.transformContext = function( + withTransition, + transitions +) { + var $$ = this, + subXAxis; + if (transitions && transitions.axisSubX) { + subXAxis = transitions.axisSubX; + } else { + subXAxis = $$.context.select('.' + CLASS.axisX); + if (withTransition) { + subXAxis = subXAxis.transition(); + } + } + $$.context.attr('transform', $$.getTranslate('context')); + subXAxis.attr('transform', $$.getTranslate('subx')); +}; +ChartInternal.prototype.getDefaultSelection = function() { + var $$ = this, + config = $$.config, + selection = isFunction(config.axis_x_selection) + ? config.axis_x_selection($$.getXDomain($$.data.targets)) + : config.axis_x_selection; + if ($$.isTimeSeries()) { + selection = [$$.parseDate(selection[0]), $$.parseDate(selection[1])]; + } + return selection +}; + +ChartInternal.prototype.removeSubchart = function() { + const $$ = this; + + $$.brush = null; + $$.context.remove(); + $$.context = null; +}; + +ChartInternal.prototype.initText = function() { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartTexts); + $$.mainText = $$.d3.selectAll([]); +}; +ChartInternal.prototype.updateTargetsForText = function(targets) { + var $$ = this, + classChartText = $$.classChartText.bind($$), + classTexts = $$.classTexts.bind($$), + classFocus = $$.classFocus.bind($$); + var mainText = $$.main + .select('.' + CLASS.chartTexts) + .selectAll('.' + CLASS.chartText) + .data(targets); + var mainTextEnter = mainText + .enter() + .append('g') + .attr('class', classChartText) + .style('opacity', 0) + .style('pointer-events', 'none'); + mainTextEnter.append('g').attr('class', classTexts); + mainTextEnter.merge(mainText).attr('class', function(d) { + return classChartText(d) + classFocus(d) + }); +}; +ChartInternal.prototype.updateText = function( + xForText, + yForText, + durationForExit +) { + var $$ = this, + config = $$.config, + barOrLineData = $$.barOrLineData.bind($$), + classText = $$.classText.bind($$); + var mainText = $$.main + .selectAll('.' + CLASS.texts) + .selectAll('.' + CLASS.text) + .data(barOrLineData); + var mainTextEnter = mainText + .enter() + .append('text') + .attr('class', classText) + .attr('text-anchor', function(d) { + return config.axis_rotated ? (d.value < 0 ? 'end' : 'start') : 'middle' + }) + .style('stroke', 'none') + .attr('x', xForText) + .attr('y', yForText) + .style('fill', function(d) { + return $$.color(d) + }) + .style('fill-opacity', 0); + $$.mainText = mainTextEnter.merge(mainText).text(function(d, i, j) { + return $$.dataLabelFormat(d.id)(d.value, d.id, i, j) + }); + mainText + .exit() + .transition() + .duration(durationForExit) + .style('fill-opacity', 0) + .remove(); +}; +ChartInternal.prototype.redrawText = function( + xForText, + yForText, + forFlow, + withTransition, + transition +) { + return [ + (withTransition ? this.mainText.transition(transition) : this.mainText) + .attr('x', xForText) + .attr('y', yForText) + .style('fill', this.color) + .style('fill-opacity', forFlow ? 0 : this.opacityForText.bind(this)) + ] +}; +ChartInternal.prototype.getTextRect = function(text, cls, element) { + var dummy = this.d3 + .select('body') + .append('div') + .classed('c3', true), + svg = dummy + .append('svg') + .style('visibility', 'hidden') + .style('position', 'fixed') + .style('top', 0) + .style('left', 0), + font = this.d3.select(element).style('font'), + rect; + svg + .selectAll('.dummy') + .data([text]) + .enter() + .append('text') + .classed(cls ? cls : '', true) + .style('font', font) + .text(text) + .each(function() { + rect = getBBox(this); + }); + dummy.remove(); + return rect +}; +ChartInternal.prototype.generateXYForText = function( + areaIndices, + barIndices, + lineIndices, + forX +) { + var $$ = this, + getAreaPoints = $$.generateGetAreaPoints(areaIndices, false), + getBarPoints = $$.generateGetBarPoints(barIndices, false), + getLinePoints = $$.generateGetLinePoints(lineIndices, false), + getter = forX ? $$.getXForText : $$.getYForText; + return function(d, i) { + var getPoints = $$.isAreaType(d) + ? getAreaPoints + : $$.isBarType(d) + ? getBarPoints + : getLinePoints; + return getter.call($$, getPoints(d, i), d, this) + } +}; +ChartInternal.prototype.getXForText = function(points, d, textElement) { + var $$ = this, + box = getBBox(textElement), + xPos, + padding; + if ($$.config.axis_rotated) { + padding = $$.isBarType(d) ? 4 : 6; + xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1); + } else { + xPos = $$.hasType('bar') ? (points[2][0] + points[0][0]) / 2 : points[0][0]; + } + // show labels regardless of the domain if value is null + if (d.value === null) { + if (xPos > $$.width) { + xPos = $$.width - box.width; + } else if (xPos < 0) { + xPos = 4; + } + } + return xPos +}; +ChartInternal.prototype.getYForText = function(points, d, textElement) { + var $$ = this, + box = getBBox(textElement), + yPos; + if ($$.config.axis_rotated) { + yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2; + } else { + yPos = points[2][1]; + if (d.value < 0 || (d.value === 0 && !$$.hasPositiveValue)) { + yPos += box.height; + if ($$.isBarType(d) && $$.isSafari()) { + yPos -= 3; + } else if (!$$.isBarType(d) && $$.isChrome()) { + yPos += 3; + } + } else { + yPos += $$.isBarType(d) ? -3 : -6; + } + } + // show labels regardless of the domain if value is null + if (d.value === null && !$$.config.axis_rotated) { + if (yPos < box.height) { + yPos = box.height; + } else if (yPos > this.height) { + yPos = this.height - 4; + } + } + return yPos +}; + +ChartInternal.prototype.initTitle = function() { + var $$ = this; + $$.title = $$.svg + .append('text') + .text($$.config.title_text) + .attr('class', $$.CLASS.title); +}; +ChartInternal.prototype.redrawTitle = function() { + var $$ = this; + $$.title.attr('x', $$.xForTitle.bind($$)).attr('y', $$.yForTitle.bind($$)); +}; +ChartInternal.prototype.xForTitle = function() { + var $$ = this, + config = $$.config, + position = config.title_position || 'left', + x; + if (position.indexOf('right') >= 0) { + x = + $$.currentWidth - + $$.getTextRect( + $$.title.node().textContent, + $$.CLASS.title, + $$.title.node() + ).width - + config.title_padding.right; + } else if (position.indexOf('center') >= 0) { + x = Math.max( + ($$.currentWidth - + $$.getTextRect( + $$.title.node().textContent, + $$.CLASS.title, + $$.title.node() + ).width) / + 2, + 0 + ); + } else { + // left + x = config.title_padding.left; + } + return x +}; +ChartInternal.prototype.yForTitle = function() { + var $$ = this; + return ( + $$.config.title_padding.top + + $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()) + .height + ) +}; +ChartInternal.prototype.getTitlePadding = function() { + var $$ = this; + return $$.yForTitle() + $$.config.title_padding.bottom +}; + +function powerOfTen(d) { + return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1 +} + +ChartInternal.prototype.drawColorScale = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config, + target = $$.data.targets[0], + barWidth, + barHeight, + axis, + points, + legendAxis, + axisScale, + inverseScale, + height; + + barWidth = !isNaN(config.stanford_scaleWidth) + ? config.stanford_scaleWidth + : 20; + barHeight = 5; + + if (barHeight < 0 || barWidth < 0) { + throw Error("Colorscale's barheight and barwidth must be greater than 0.") + } + + height = + $$.height - config.stanford_padding.bottom - config.stanford_padding.top; + + points = d3.range(config.stanford_padding.bottom, height, barHeight); + + inverseScale = d3 + .scaleSequential(target.colors) + .domain([points[points.length - 1], points[0]]); + + if ($$.colorScale) { + $$.colorScale.remove(); + } + + $$.colorScale = $$.svg + .append('g') + .attr('width', 50) + .attr('height', height) + .attr('class', CLASS.colorScale); + + $$.colorScale + .append('g') + .attr('transform', `translate(0, ${config.stanford_padding.top})`) + .selectAll('bars') + .data(points) + .enter() + .append('rect') + .attr('y', (d, i) => i * barHeight) + .attr('x', 0) + .attr('width', barWidth) + .attr('height', barHeight) + .attr('fill', function(d) { + return inverseScale(d) + }); + + // Legend Axis + axisScale = d3 + .scaleLog() + .domain([target.minEpochs, target.maxEpochs]) + .range([ + points[0] + + config.stanford_padding.top + + points[points.length - 1] + + barHeight - + 1, + points[0] + config.stanford_padding.top + ]); + + legendAxis = d3.axisRight(axisScale); + + if (config.stanford_scaleFormat === 'pow10') { + legendAxis.tickValues([1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]); + } else if (isFunction(config.stanford_scaleFormat)) { + legendAxis.tickFormat(config.stanford_scaleFormat); + } else { + legendAxis.tickFormat(d3.format('d')); + } + + if (isFunction(config.stanford_scaleValues)) { + legendAxis.tickValues( + config.stanford_scaleValues(target.minEpochs, target.maxEpochs) + ); + } + + // Draw Axis + axis = $$.colorScale + .append('g') + .attr('class', 'legend axis') + .attr('transform', `translate(${barWidth},0)`) + .call(legendAxis); + + if (config.stanford_scaleFormat === 'pow10') { + axis + .selectAll('.tick text') + .text(null) + .filter(powerOfTen) + .text(10) + .append('tspan') + .attr('dy', '-.7em') // https://bl.ocks.org/mbostock/6738229 + .text(function(d) { + return Math.round(Math.log(d) / Math.LN10) + }); + } + + $$.colorScale.attr( + 'transform', + `translate(${$$.currentWidth - $$.xForColorScale()}, 0)` + ); +}; + +ChartInternal.prototype.xForColorScale = function() { + var $$ = this; + + return $$.config.stanford_padding.right + getBBox($$.colorScale.node()).width +}; + +ChartInternal.prototype.getColorScalePadding = function() { + var $$ = this; + return $$.xForColorScale() + $$.config.stanford_padding.left + 20 +}; + +ChartInternal.prototype.isStanfordGraphType = function() { + var $$ = this; + + return $$.config.data_type === 'stanford' +}; + +ChartInternal.prototype.initStanfordData = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config, + target = $$.data.targets[0], + epochs, + maxEpochs, + minEpochs; + + // Make larger values appear on top + target.values.sort(compareEpochs); + + // Get array of epochs + epochs = target.values.map(a => a.epochs); + + minEpochs = !isNaN(config.stanford_scaleMin) + ? config.stanford_scaleMin + : d3.min(epochs); + maxEpochs = !isNaN(config.stanford_scaleMax) + ? config.stanford_scaleMax + : d3.max(epochs); + + if (minEpochs > maxEpochs) { + throw Error('Number of minEpochs has to be smaller than maxEpochs') + } + + target.colors = isFunction(config.stanford_colors) + ? config.stanford_colors + : d3.interpolateHslLong(d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)); + + target.colorscale = d3 + .scaleSequentialLog(target.colors) + .domain([minEpochs, maxEpochs]); + + target.minEpochs = minEpochs; + target.maxEpochs = maxEpochs; +}; + +ChartInternal.prototype.getStanfordPointColor = function(d) { + var $$ = this, + target = $$.data.targets[0]; + + return target.colorscale(d.epochs) +}; + +// http://jsfiddle.net/Xotic750/KtzLq/ +ChartInternal.prototype.getCentroid = function(points) { + var area = getRegionArea(points); + + var x = 0, + y = 0, + i, + j, + f, + point1, + point2; + + for (i = 0, j = points.length - 1; i < points.length; j = i, i += 1) { + point1 = points[i]; + point2 = points[j]; + f = point1.x * point2.y - point2.x * point1.y; + x += (point1.x + point2.x) * f; + y += (point1.y + point2.y) * f; + } + + f = area * 6; + + return { + x: x / f, + y: y / f + } +}; + +ChartInternal.prototype.getStanfordTooltipTitle = function(d) { + var $$ = this, + labelX = $$.axis.getLabelText('x'), + labelY = $$.axis.getLabelText('y'); + + return ` + ${labelX ? sanitise(labelX) : 'x'}${ + d.x + } + ${labelY ? sanitise(labelY) : 'y'}${ + d.value + } + ` +}; + +ChartInternal.prototype.countEpochsInRegion = function(region) { + var $$ = this, + target = $$.data.targets[0], + total, + count; + + total = target.values.reduce( + (accumulator, currentValue) => accumulator + Number(currentValue.epochs), + 0 + ); + + count = target.values.reduce((accumulator, currentValue) => { + if (pointInRegion(currentValue, region)) { + return accumulator + Number(currentValue.epochs) + } + + return accumulator + }, 0); + + return { + value: count, + percentage: count !== 0 ? ((count / total) * 100).toFixed(1) : 0 + } +}; + +var getRegionArea = function(points) { + // thanks to: https://stackoverflow.com/questions/16282330/find-centerpoint-of-polygon-in-javascript + var area = 0, + i, + j, + point1, + point2; + + for (i = 0, j = points.length - 1; i < points.length; j = i, i += 1) { + point1 = points[i]; + point2 = points[j]; + area += point1.x * point2.y; + area -= point1.y * point2.x; + } + + area /= 2; + + return area +}; + +var pointInRegion = function(point, region) { + // thanks to: http://bl.ocks.org/bycoffe/5575904 + // ray-casting algorithm based on + // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html + let xi, + yi, + yj, + xj, + intersect, + x = point.x, + y = point.value, + inside = false; + + for (let i = 0, j = region.length - 1; i < region.length; j = i++) { + xi = region[i].x; + yi = region[i].y; + + xj = region[j].x; + yj = region[j].y; + + intersect = yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi; + + if (intersect) { + inside = !inside; + } + } + + return inside +}; + +var compareEpochs = function(a, b) { + if (a.epochs < b.epochs) { + return -1 + } + if (a.epochs > b.epochs) { + return 1 + } + + return 0 +}; + +ChartInternal.prototype.initStanfordElements = function() { + var $$ = this; + + // Avoid blocking eventRect + $$.stanfordElements = $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.stanfordElements); + + $$.stanfordElements.append('g').attr('class', CLASS.stanfordLines); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordTexts); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordRegions); +}; + +ChartInternal.prototype.updateStanfordElements = function(duration) { + var $$ = this, + main = $$.main, + config = $$.config, + stanfordLine, + stanfordLineEnter, + stanfordRegion, + stanfordRegionEnter, + stanfordText, + stanfordTextEnter, + xvCustom = $$.xvCustom.bind($$), + yvCustom = $$.yvCustom.bind($$), + countPointsInRegion = $$.countEpochsInRegion.bind($$); + + // Stanford-Lines + stanfordLine = main + .select('.' + CLASS.stanfordLines) + .style('shape-rendering', 'geometricprecision') + .selectAll('.' + CLASS.stanfordLine) + .data(config.stanford_lines); + + // enter + stanfordLineEnter = stanfordLine + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.stanfordLine + (d['class'] ? ' ' + d['class'] : '') + }); + stanfordLineEnter + .append('line') + .attr('x1', d => + config.axis_rotated ? yvCustom(d, 'value_y1') : xvCustom(d, 'value_x1') + ) + .attr('x2', d => + config.axis_rotated ? yvCustom(d, 'value_y2') : xvCustom(d, 'value_x2') + ) + .attr('y1', d => + config.axis_rotated ? xvCustom(d, 'value_x1') : yvCustom(d, 'value_y1') + ) + .attr('y2', d => + config.axis_rotated ? xvCustom(d, 'value_x2') : yvCustom(d, 'value_y2') + ) + .style('opacity', 0); + + // update + $$.stanfordLines = stanfordLineEnter.merge(stanfordLine); + $$.stanfordLines + .select('line') + .transition() + .duration(duration) + .attr('x1', d => + config.axis_rotated ? yvCustom(d, 'value_y1') : xvCustom(d, 'value_x1') + ) + .attr('x2', d => + config.axis_rotated ? yvCustom(d, 'value_y2') : xvCustom(d, 'value_x2') + ) + .attr('y1', d => + config.axis_rotated ? xvCustom(d, 'value_x1') : yvCustom(d, 'value_y1') + ) + .attr('y2', d => + config.axis_rotated ? xvCustom(d, 'value_x2') : yvCustom(d, 'value_y2') + ) + .style('opacity', 1); + + // exit + stanfordLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + + // Stanford-Text + stanfordText = main + .select('.' + CLASS.stanfordTexts) + .selectAll('.' + CLASS.stanfordText) + .data(config.stanford_texts); + + // enter + stanfordTextEnter = stanfordText + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.stanfordText + (d['class'] ? ' ' + d['class'] : '') + }); + stanfordTextEnter + .append('text') + .attr('x', d => (config.axis_rotated ? yvCustom(d, 'y') : xvCustom(d, 'x'))) + .attr('y', d => (config.axis_rotated ? xvCustom(d, 'x') : yvCustom(d, 'y'))) + .style('opacity', 0); + + // update + $$.stanfordTexts = stanfordTextEnter.merge(stanfordText); + $$.stanfordTexts + .select('text') + .transition() + .duration(duration) + .attr('x', d => (config.axis_rotated ? yvCustom(d, 'y') : xvCustom(d, 'x'))) + .attr('y', d => (config.axis_rotated ? xvCustom(d, 'x') : yvCustom(d, 'y'))) + .text(function(d) { + return d.content + }) + .style('opacity', 1); + + // exit + stanfordText + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + + // Stanford-Regions + stanfordRegion = main + .select('.' + CLASS.stanfordRegions) + .selectAll('.' + CLASS.stanfordRegion) + .data(config.stanford_regions); + + // enter + stanfordRegionEnter = stanfordRegion + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.stanfordRegion + (d['class'] ? ' ' + d['class'] : '') + }); + stanfordRegionEnter + .append('polygon') + .attr('points', d => { + return d.points + .map(value => { + return [ + config.axis_rotated ? yvCustom(value, 'y') : xvCustom(value, 'x'), + config.axis_rotated ? xvCustom(value, 'x') : yvCustom(value, 'y') + ].join(',') + }) + .join(' ') + }) + .style('opacity', 0); + stanfordRegionEnter + .append('text') + .attr('x', d => $$.getCentroid(d.points).x) + .attr('y', d => $$.getCentroid(d.points).y) + .style('opacity', 0); + + // update + $$.stanfordRegions = stanfordRegionEnter.merge(stanfordRegion); + $$.stanfordRegions + .select('polygon') + .transition() + .duration(duration) + .attr('points', d => { + return d.points + .map(value => { + return [ + config.axis_rotated ? yvCustom(value, 'y') : xvCustom(value, 'x'), + config.axis_rotated ? xvCustom(value, 'x') : yvCustom(value, 'y') + ].join(',') + }) + .join(' ') + }) + .style('opacity', d => { + return d.opacity ? d.opacity : 0.2 + }); + $$.stanfordRegions + .select('text') + .transition() + .duration(duration) + .attr('x', d => + config.axis_rotated + ? yvCustom($$.getCentroid(d.points), 'y') + : xvCustom($$.getCentroid(d.points), 'x') + ) + .attr('y', d => + config.axis_rotated + ? xvCustom($$.getCentroid(d.points), 'x') + : yvCustom($$.getCentroid(d.points), 'y') + ) + .text(function(d) { + if (d.text) { + var value, percentage, temp; + + if ($$.isStanfordGraphType()) { + temp = countPointsInRegion(d.points); + value = temp.value; + percentage = temp.percentage; + } + + return d.text(value, percentage) + } + + return '' + }) + .attr('text-anchor', 'middle') + .attr('dominant-baseline', 'middle') + .style('opacity', 1); + // exit + stanfordRegion + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); +}; + +ChartInternal.prototype.initTooltip = function() { + var $$ = this, + config = $$.config, + i; + $$.tooltip = $$.selectChart + .style('position', 'relative') + .append('div') + .attr('class', CLASS.tooltipContainer) + .style('position', 'absolute') + .style('pointer-events', 'none') + .style('display', 'none'); + // Show tooltip if needed + if (config.tooltip_init_show) { + if ($$.isTimeSeries() && isString(config.tooltip_init_x)) { + config.tooltip_init_x = $$.parseDate(config.tooltip_init_x); + for (i = 0; i < $$.data.targets[0].values.length; i++) { + if ($$.data.targets[0].values[i].x - config.tooltip_init_x === 0) { + break + } + } + config.tooltip_init_x = i; + } + $$.tooltip.html( + config.tooltip_contents.call( + $$, + $$.data.targets.map(function(d) { + return $$.addName(d.values[config.tooltip_init_x]) + }), + $$.axis.getXAxisTickFormat(), + $$.getYFormat($$.hasArcType()), + $$.color + ) + ); + $$.tooltip + .style('top', config.tooltip_init_position.top) + .style('left', config.tooltip_init_position.left) + .style('display', 'block'); + } +}; +ChartInternal.prototype.getTooltipSortFunction = function() { + var $$ = this, + config = $$.config; + + if (config.data_groups.length === 0 || config.tooltip_order !== undefined) { + // if data are not grouped or if an order is specified + // for the tooltip values we sort them by their values + + var order = config.tooltip_order; + if (order === undefined) { + order = config.data_order; + } + + var valueOf = function(obj) { + return obj ? obj.value : null + }; + + // if data are not grouped, we sort them by their value + if (isString(order) && order.toLowerCase() === 'asc') { + return function(a, b) { + return valueOf(a) - valueOf(b) + } + } else if (isString(order) && order.toLowerCase() === 'desc') { + return function(a, b) { + return valueOf(b) - valueOf(a) + } + } else if (isFunction(order)) { + // if the function is from data_order we need + // to wrap the returned function in order to format + // the sorted value to the expected format + + var sortFunction = order; + + if (config.tooltip_order === undefined) { + sortFunction = function(a, b) { + return order( + a + ? { + id: a.id, + values: [a] + } + : null, + b + ? { + id: b.id, + values: [b] + } + : null + ) + }; + } + + return sortFunction + } else if (isArray(order)) { + return function(a, b) { + return order.indexOf(a.id) - order.indexOf(b.id) + } + } + } else { + // if data are grouped, we follow the order of grouped targets + var ids = $$.orderTargets($$.data.targets).map(function(i) { + return i.id + }); + + // if it was either asc or desc we need to invert the order + // returned by orderTargets + if ($$.isOrderAsc() || $$.isOrderDesc()) { + ids = ids.reverse(); + } + + return function(a, b) { + return ids.indexOf(a.id) - ids.indexOf(b.id) + } + } +}; +ChartInternal.prototype.getTooltipContent = function( + d, + defaultTitleFormat, + defaultValueFormat, + color +) { + var $$ = this, + config = $$.config, + titleFormat = config.tooltip_format_title || defaultTitleFormat, + nameFormat = + config.tooltip_format_name || + function(name) { + return name + }, + text, + i, + title, + value, + name, + bgcolor; + + var valueFormat = config.tooltip_format_value; + if (!valueFormat) { + valueFormat = $$.isTargetNormalized(d.id) + ? (v, ratio) => `${(ratio * 100).toFixed(2)}%` + : defaultValueFormat; + } + + var tooltipSortFunction = this.getTooltipSortFunction(); + if (tooltipSortFunction) { + d.sort(tooltipSortFunction); + } + + for (i = 0; i < d.length; i++) { + if (!(d[i] && (d[i].value || d[i].value === 0))) { + continue + } + + if ($$.isStanfordGraphType()) { + // Custom tooltip for stanford plots + if (!text) { + title = $$.getStanfordTooltipTitle(d[i]); + text = "" + title; + } + + bgcolor = $$.getStanfordPointColor(d[i]); + name = sanitise(config.data_epochs); // Epochs key name + value = d[i].epochs; + } else { + // Regular tooltip + if (!text) { + title = sanitise(titleFormat ? titleFormat(d[i].x, d[i].index) : d[i].x); + text = + "
" + + (title || title === 0 + ? "' + : ''); + } + + value = sanitise( + valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index, d) + ); + if (value !== undefined) { + // Skip elements when their name is set to null + if (d[i].name === null) { + continue + } + + name = sanitise(nameFormat(d[i].name, d[i].ratio, d[i].id, d[i].index)); + bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); + } + } + + if (value !== undefined) { + text += + ""; + text += + "'; + text += "'; + text += ''; + } + } + return text + '
" + title + '
" + + name + + '" + value + '
' +}; +ChartInternal.prototype.tooltipPosition = function( + dataToShow, + tWidth, + tHeight, + element +) { + var $$ = this, + config = $$.config, + d3 = $$.d3; + var svgLeft, tooltipLeft, tooltipRight, tooltipTop, chartRight; + var forArc = $$.hasArcType(), + mouse = d3.mouse(element); + // Determin tooltip position + if (forArc) { + tooltipLeft = + ($$.width - ($$.isLegendRight ? $$.getLegendWidth() : 0)) / 2 + mouse[0]; + tooltipTop = + ($$.hasType('gauge') ? $$.height : $$.height / 2) + mouse[1] + 20; + } else { + svgLeft = $$.getSvgLeft(true); + if (config.axis_rotated) { + tooltipLeft = svgLeft + mouse[0] + 100; + tooltipRight = tooltipLeft + tWidth; + chartRight = $$.currentWidth - $$.getCurrentPaddingRight(); + tooltipTop = $$.x(dataToShow[0].x) + 20; + } else { + tooltipLeft = + svgLeft + $$.getCurrentPaddingLeft(true) + $$.x(dataToShow[0].x) + 20; + tooltipRight = tooltipLeft + tWidth; + chartRight = svgLeft + $$.currentWidth - $$.getCurrentPaddingRight(); + tooltipTop = mouse[1] + 15; + } + + if (tooltipRight > chartRight) { + // 20 is needed for Firefox to keep tooltip width + tooltipLeft -= tooltipRight - chartRight + 20; + } + if (tooltipTop + tHeight > $$.currentHeight) { + tooltipTop -= tHeight + 30; + } + } + if (tooltipTop < 0) { + tooltipTop = 0; + } + return { + top: tooltipTop, + left: tooltipLeft + } +}; +ChartInternal.prototype.showTooltip = function(selectedData, element) { + var $$ = this, + config = $$.config; + var tWidth, tHeight, position; + var forArc = $$.hasArcType(), + dataToShow = selectedData.filter(function(d) { + return d && isValue(d.value) + }), + positionFunction = + config.tooltip_position || ChartInternal.prototype.tooltipPosition; + if (dataToShow.length === 0 || !config.tooltip_show) { + $$.hideTooltip(); + return + } + $$.tooltip + .html( + config.tooltip_contents.call( + $$, + selectedData, + $$.axis.getXAxisTickFormat(), + $$.getYFormat(forArc), + $$.color + ) + ) + .style('display', 'block'); + + // Get tooltip dimensions + tWidth = $$.tooltip.property('offsetWidth'); + tHeight = $$.tooltip.property('offsetHeight'); + + position = positionFunction.call(this, dataToShow, tWidth, tHeight, element); + // Set tooltip + $$.tooltip + .style('top', position.top + 'px') + .style('left', position.left + 'px'); +}; +ChartInternal.prototype.hideTooltip = function() { + this.tooltip.style('display', 'none'); +}; + +ChartInternal.prototype.setTargetType = function(targetIds, type) { + var $$ = this, + config = $$.config; + $$.mapToTargetIds(targetIds).forEach(function(id) { + $$.withoutFadeIn[id] = type === config.data_types[id]; + config.data_types[id] = type; + }); + if (!targetIds) { + config.data_type = type; + } +}; +ChartInternal.prototype.hasType = function(type, targets) { + var $$ = this, + types = $$.config.data_types, + has = false; + targets = targets || $$.data.targets; + if (targets && targets.length) { + targets.forEach(function(target) { + var t = types[target.id]; + if ((t && t.indexOf(type) >= 0) || (!t && type === 'line')) { + has = true; + } + }); + } else if (Object.keys(types).length) { + Object.keys(types).forEach(function(id) { + if (types[id] === type) { + has = true; + } + }); + } else { + has = $$.config.data_type === type; + } + return has +}; +ChartInternal.prototype.hasArcType = function(targets) { + return ( + this.hasType('pie', targets) || + this.hasType('donut', targets) || + this.hasType('gauge', targets) + ) +}; +ChartInternal.prototype.isLineType = function(d) { + var config = this.config, + id = isString(d) ? d : d.id; + return ( + !config.data_types[id] || + ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf( + config.data_types[id] + ) >= 0 + ) +}; +ChartInternal.prototype.isStepType = function(d) { + var id = isString(d) ? d : d.id; + return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0 +}; +ChartInternal.prototype.isSplineType = function(d) { + var id = isString(d) ? d : d.id; + return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0 +}; +ChartInternal.prototype.isAreaType = function(d) { + var id = isString(d) ? d : d.id; + return ( + ['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= + 0 + ) +}; +ChartInternal.prototype.isBarType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'bar' +}; +ChartInternal.prototype.isScatterType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'scatter' +}; +ChartInternal.prototype.isStanfordType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'stanford' +}; +ChartInternal.prototype.isPieType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'pie' +}; +ChartInternal.prototype.isGaugeType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'gauge' +}; +ChartInternal.prototype.isDonutType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'donut' +}; +ChartInternal.prototype.isArcType = function(d) { + return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d) +}; +ChartInternal.prototype.lineData = function(d) { + return this.isLineType(d) ? [d] : [] +}; +ChartInternal.prototype.arcData = function(d) { + return this.isArcType(d.data) ? [d] : [] +}; +/* not used + function scatterData(d) { + return isScatterType(d) ? d.values : []; + } + */ +ChartInternal.prototype.barData = function(d) { + return this.isBarType(d) ? d.values : [] +}; +ChartInternal.prototype.lineOrScatterOrStanfordData = function(d) { + return this.isLineType(d) || this.isScatterType(d) || this.isStanfordType(d) + ? d.values + : [] +}; +ChartInternal.prototype.barOrLineData = function(d) { + return this.isBarType(d) || this.isLineType(d) ? d.values : [] +}; + +ChartInternal.prototype.isSafari = function() { + var ua = window.navigator.userAgent; + return ua.indexOf('Safari') >= 0 && ua.indexOf('Chrome') < 0 +}; +ChartInternal.prototype.isChrome = function() { + var ua = window.navigator.userAgent; + return ua.indexOf('Chrome') >= 0 +}; + +ChartInternal.prototype.initZoom = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config, + startEvent; + + $$.zoom = d3 + .zoom() + .on('start', function() { + if (config.zoom_type !== 'scroll') { + return + } + + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return + } + startEvent = e; + config.zoom_onzoomstart.call($$.api, e); + }) + .on('zoom', function() { + if (config.zoom_type !== 'scroll') { + return + } + + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return + } + + $$.redrawForZoom(); + + config.zoom_onzoom.call($$.api, $$.x.orgDomain()); + }) + .on('end', function() { + if (config.zoom_type !== 'scroll') { + return + } + + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return + } + // if click, do nothing. otherwise, click interaction will be canceled. + if ( + e && + startEvent.clientX === e.clientX && + startEvent.clientY === e.clientY + ) { + return + } + config.zoom_onzoomend.call($$.api, $$.x.orgDomain()); + }); + + $$.zoom.updateDomain = function() { + if (d3.event && d3.event.transform) { + $$.x.domain(d3.event.transform.rescaleX($$.subX).domain()); + } + return this + }; + $$.zoom.updateExtent = function() { + this.scaleExtent([1, Infinity]) + .translateExtent([ + [0, 0], + [$$.width, $$.height] + ]) + .extent([ + [0, 0], + [$$.width, $$.height] + ]); + return this + }; + $$.zoom.update = function() { + return this.updateExtent().updateDomain() + }; + + return $$.zoom.updateExtent() +}; +ChartInternal.prototype.zoomTransform = function(range) { + var $$ = this, + s = [$$.x(range[0]), $$.x(range[1])]; + return $$.d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0) +}; + +ChartInternal.prototype.initDragZoom = function() { + const $$ = this; + const d3 = $$.d3; + const config = $$.config; + const context = ($$.context = $$.svg); + const brushXPos = $$.margin.left + 20.5; + const brushYPos = $$.margin.top + 0.5; + + if (!(config.zoom_type === 'drag' && config.zoom_enabled)) { + return + } + + const getZoomedDomain = selection => + selection && selection.map(x => $$.x.invert(x)); + + const brush = ($$.dragZoomBrush = d3 + .brushX() + .on('start', () => { + $$.api.unzoom(); + + $$.svg.select('.' + CLASS.dragZoom).classed('disabled', false); + + config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent); + }) + .on('brush', () => { + config.zoom_onzoom.call($$.api, getZoomedDomain(d3.event.selection)); + }) + .on('end', () => { + if (d3.event.selection == null) { + return + } + + const zoomedDomain = getZoomedDomain(d3.event.selection); + + if (!config.zoom_disableDefaultBehavior) { + $$.api.zoom(zoomedDomain); + } + + $$.svg.select('.' + CLASS.dragZoom).classed('disabled', true); + + config.zoom_onzoomend.call($$.api, zoomedDomain); + })); + + context + .append('g') + .classed(CLASS.dragZoom, true) + .attr('clip-path', $$.clipPath) + .attr('transform', 'translate(' + brushXPos + ',' + brushYPos + ')') + .call(brush); +}; + +ChartInternal.prototype.getZoomDomain = function() { + var $$ = this, + config = $$.config, + d3 = $$.d3, + min = d3.min([$$.orgXDomain[0], config.zoom_x_min]), + max = d3.max([$$.orgXDomain[1], config.zoom_x_max]); + return [min, max] +}; +ChartInternal.prototype.redrawForZoom = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config, + zoom = $$.zoom, + x = $$.x; + if (!config.zoom_enabled) { + return + } + if ($$.filterTargetsToShow($$.data.targets).length === 0) { + return + } + + zoom.update(); + + if (config.zoom_disableDefaultBehavior) { + return + } + + if ($$.isCategorized() && x.orgDomain()[0] === $$.orgXDomain[0]) { + x.domain([$$.orgXDomain[0] - 1e-10, x.orgDomain()[1]]); + } + + $$.redraw({ + withTransition: false, + withY: config.zoom_rescale, + withSubchart: false, + withEventRect: false, + withDimension: false + }); + + if (d3.event.sourceEvent && d3.event.sourceEvent.type === 'mousemove') { + $$.cancelClick = true; + } +}; + +export default c3; diff --git a/server/static/server/c3/c3.js b/server/static/server/c3/c3.js new file mode 100644 index 0000000..d4b4c1e --- /dev/null +++ b/server/static/server/c3/c3.js @@ -0,0 +1,11320 @@ +/* @license C3.js v0.7.20 | (c) C3 Team and other contributors | http://c3js.org/ */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global.c3 = factory()); +}(this, (function () { 'use strict'; + + function ChartInternal(api) { + var $$ = this; + // Note: This part will be replaced by rollup-plugin-modify + // When bundling esm output. Beware of changing this line. + // TODO: Maybe we should check that the modification by rollup-plugin-modify + // is valid during unit tests. + $$.d3 = window.d3 + ? window.d3 + : typeof require !== 'undefined' + ? require('d3') + : undefined; + $$.api = api; + $$.config = $$.getDefaultConfig(); + $$.data = {}; + $$.cache = {}; + $$.axes = {}; + } + + /** + * The Chart class + * + * The methods of this class is the public APIs of the chart object. + */ + function Chart(config) { + this.internal = new ChartInternal(this); + this.internal.loadConfig(config); + this.internal.beforeInit(config); + this.internal.init(); + this.internal.afterInit(config); + (function bindThis(fn, target, argThis) { + Object.keys(fn).forEach(function (key) { + target[key] = fn[key].bind(argThis); + if (Object.keys(fn[key]).length > 0) { + bindThis(fn[key], target[key], argThis); + } + }); + })(Chart.prototype, this, this); + } + + var asHalfPixel = function (n) { + return Math.ceil(n) + 0.5; + }; + var ceil10 = function (v) { + return Math.ceil(v / 10) * 10; + }; + var diffDomain = function (d) { + return d[1] - d[0]; + }; + var getOption = function (options, key, defaultValue) { + return isDefined(options[key]) ? options[key] : defaultValue; + }; + var getPathBox = function (path) { + var box = getBBox(path), items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)], minX = items[0].x, minY = Math.min(items[0].y, items[1].y); + return { x: minX, y: minY, width: box.width, height: box.height }; + }; + var getBBox = function (element) { + try { + return element.getBBox(); + } + catch (ignore) { + // Firefox will throw an exception if getBBox() is called whereas the + // element is rendered with display:none + // See https://github.com/c3js/c3/issues/2692 + // The previous code was using `getBoundingClientRect` which was returning + // everything at 0 in this case so let's reproduce this behavior here. + return { x: 0, y: 0, width: 0, height: 0 }; + } + }; + var hasValue = function (dict, value) { + var found = false; + Object.keys(dict).forEach(function (key) { + if (dict[key] === value) { + found = true; + } + }); + return found; + }; + var isArray = function (o) { + return Array.isArray(o); + }; + var isDefined = function (v) { + return typeof v !== 'undefined'; + }; + var isEmpty = function (o) { + return (typeof o === 'undefined' || + o === null || + (isString(o) && o.length === 0) || + (typeof o === 'object' && Object.keys(o).length === 0)); + }; + var isFunction = function (o) { + return typeof o === 'function'; + }; + var isNumber = function (o) { + return typeof o === 'number'; + }; + var isString = function (o) { + return typeof o === 'string'; + }; + var isUndefined = function (v) { + return typeof v === 'undefined'; + }; + var isValue = function (v) { + return v || v === 0; + }; + var notEmpty = function (o) { + return !isEmpty(o); + }; + var sanitise = function (str) { + return typeof str === 'string' + ? str.replace(//g, '>') + : str; + }; + var flattenArray = function (arr) { + return Array.isArray(arr) ? [].concat.apply([], arr) : []; + }; + /** + * Returns whether the point is within the given box. + * + * @param {Array} point An [x,y] coordinate + * @param {Object} box An object with {x, y, width, height} keys + * @param {Number} sensitivity An offset to ease check on very small boxes + */ + var isWithinBox = function (point, box, sensitivity) { + if (sensitivity === void 0) { sensitivity = 0; } + var xStart = box.x - sensitivity; + var xEnd = box.x + box.width + sensitivity; + var yStart = box.y + box.height + sensitivity; + var yEnd = box.y - sensitivity; + return (xStart < point[0] && point[0] < xEnd && yEnd < point[1] && point[1] < yStart); + }; + /** + * Returns Internet Explorer version number (or false if no Internet Explorer used). + * + * @param string agent Optional parameter to specify user agent + */ + var getIEVersion = function (agent) { + // https://stackoverflow.com/questions/19999388/check-if-user-is-using-ie + if (typeof agent === 'undefined') { + agent = window.navigator.userAgent; + } + var pos = agent.indexOf('MSIE '); // up to IE10 + if (pos > 0) { + return parseInt(agent.substring(pos + 5, agent.indexOf('.', pos)), 10); + } + pos = agent.indexOf('Trident/'); // IE11 + if (pos > 0) { + pos = agent.indexOf('rv:'); + return parseInt(agent.substring(pos + 3, agent.indexOf('.', pos)), 10); + } + return false; + }; + /** + * Returns whether the used browser is Internet Explorer. + * + * @param version Optional parameter to specify IE version + */ + var isIE = function (version) { + var ver = getIEVersion(); + if (typeof version === 'undefined') { + return !!ver; + } + return version === ver; + }; + + function AxisInternal(component, params) { + var internal = this; + internal.component = component; + internal.params = params || {}; + internal.d3 = component.d3; + internal.scale = internal.d3.scaleLinear(); + internal.range; + internal.orient = 'bottom'; + internal.innerTickSize = 6; + internal.outerTickSize = this.params.withOuterTick ? 6 : 0; + internal.tickPadding = 3; + internal.tickValues = null; + internal.tickFormat; + internal.tickArguments; + internal.tickOffset = 0; + internal.tickCulling = true; + internal.tickCentered; + internal.tickTextCharSize; + internal.tickTextRotate = internal.params.tickTextRotate; + internal.tickLength; + internal.axis = internal.generateAxis(); + } + AxisInternal.prototype.axisX = function (selection, x, tickOffset) { + selection.attr('transform', function (d) { + return 'translate(' + Math.ceil(x(d) + tickOffset) + ', 0)'; + }); + }; + AxisInternal.prototype.axisY = function (selection, y) { + selection.attr('transform', function (d) { + return 'translate(0,' + Math.ceil(y(d)) + ')'; + }); + }; + AxisInternal.prototype.scaleExtent = function (domain) { + var start = domain[0], stop = domain[domain.length - 1]; + return start < stop ? [start, stop] : [stop, start]; + }; + AxisInternal.prototype.generateTicks = function (scale) { + var internal = this; + var i, domain, ticks = []; + if (scale.ticks) { + return scale.ticks.apply(scale, internal.tickArguments); + } + domain = scale.domain(); + for (i = Math.ceil(domain[0]); i < domain[1]; i++) { + ticks.push(i); + } + if (ticks.length > 0 && ticks[0] > 0) { + ticks.unshift(ticks[0] - (ticks[1] - ticks[0])); + } + return ticks; + }; + AxisInternal.prototype.copyScale = function () { + var internal = this; + var newScale = internal.scale.copy(), domain; + if (internal.params.isCategory) { + domain = internal.scale.domain(); + newScale.domain([domain[0], domain[1] - 1]); + } + return newScale; + }; + AxisInternal.prototype.textFormatted = function (v) { + var internal = this, formatted = internal.tickFormat ? internal.tickFormat(v) : v; + return typeof formatted !== 'undefined' ? formatted : ''; + }; + AxisInternal.prototype.updateRange = function () { + var internal = this; + internal.range = internal.scale.rangeExtent + ? internal.scale.rangeExtent() + : internal.scaleExtent(internal.scale.range()); + return internal.range; + }; + AxisInternal.prototype.updateTickTextCharSize = function (tick) { + var internal = this; + if (internal.tickTextCharSize) { + return internal.tickTextCharSize; + } + var size = { + h: 11.5, + w: 5.5 + }; + tick + .select('text') + .text(function (d) { + return internal.textFormatted(d); + }) + .each(function (d) { + var box = getBBox(this), text = internal.textFormatted(d), h = box.height, w = text ? box.width / text.length : undefined; + if (h && w) { + size.h = h; + size.w = w; + } + }) + .text(''); + internal.tickTextCharSize = size; + return size; + }; + AxisInternal.prototype.isVertical = function () { + return this.orient === 'left' || this.orient === 'right'; + }; + AxisInternal.prototype.tspanData = function (d, i, scale) { + var internal = this; + var splitted = internal.params.tickMultiline + ? internal.splitTickText(d, scale) + : [].concat(internal.textFormatted(d)); + if (internal.params.tickMultiline && internal.params.tickMultilineMax > 0) { + splitted = internal.ellipsify(splitted, internal.params.tickMultilineMax); + } + return splitted.map(function (s) { + return { index: i, splitted: s, length: splitted.length }; + }); + }; + AxisInternal.prototype.splitTickText = function (d, scale) { + var internal = this, tickText = internal.textFormatted(d), maxWidth = internal.params.tickWidth, subtext, spaceIndex, textWidth, splitted = []; + if (Object.prototype.toString.call(tickText) === '[object Array]') { + return tickText; + } + if (!maxWidth || maxWidth <= 0) { + maxWidth = internal.isVertical() + ? 95 + : internal.params.isCategory + ? Math.ceil(scale(1) - scale(0)) - 12 + : 110; + } + function split(splitted, text) { + spaceIndex = undefined; + for (var i = 1; i < text.length; i++) { + if (text.charAt(i) === ' ') { + spaceIndex = i; + } + subtext = text.substr(0, i + 1); + textWidth = internal.tickTextCharSize.w * subtext.length; + // if text width gets over tick width, split by space index or crrent index + if (maxWidth < textWidth) { + return split(splitted.concat(text.substr(0, spaceIndex ? spaceIndex : i)), text.slice(spaceIndex ? spaceIndex + 1 : i)); + } + } + return splitted.concat(text); + } + return split(splitted, tickText + ''); + }; + AxisInternal.prototype.ellipsify = function (splitted, max) { + if (splitted.length <= max) { + return splitted; + } + var ellipsified = splitted.slice(0, max); + var remaining = 3; + for (var i = max - 1; i >= 0; i--) { + var available = ellipsified[i].length; + ellipsified[i] = ellipsified[i] + .substr(0, available - remaining) + .padEnd(available, '.'); + remaining -= available; + if (remaining <= 0) { + break; + } + } + return ellipsified; + }; + AxisInternal.prototype.updateTickLength = function () { + var internal = this; + internal.tickLength = + Math.max(internal.innerTickSize, 0) + internal.tickPadding; + }; + AxisInternal.prototype.lineY2 = function (d) { + var internal = this, tickPosition = internal.scale(d) + (internal.tickCentered ? 0 : internal.tickOffset); + return internal.range[0] < tickPosition && tickPosition < internal.range[1] + ? internal.innerTickSize + : 0; + }; + AxisInternal.prototype.textY = function () { + var internal = this, rotate = internal.tickTextRotate; + return rotate + ? 11.5 - 2.5 * (rotate / 15) * (rotate > 0 ? 1 : -1) + : internal.tickLength; + }; + AxisInternal.prototype.textTransform = function () { + var internal = this, rotate = internal.tickTextRotate; + return rotate ? 'rotate(' + rotate + ')' : ''; + }; + AxisInternal.prototype.textTextAnchor = function () { + var internal = this, rotate = internal.tickTextRotate; + return rotate ? (rotate > 0 ? 'start' : 'end') : 'middle'; + }; + AxisInternal.prototype.tspanDx = function () { + var internal = this, rotate = internal.tickTextRotate; + return rotate ? 8 * Math.sin(Math.PI * (rotate / 180)) : 0; + }; + AxisInternal.prototype.tspanDy = function (d, i) { + var internal = this, dy = internal.tickTextCharSize.h; + if (i === 0) { + if (internal.isVertical()) { + dy = -((d.length - 1) * (internal.tickTextCharSize.h / 2) - 3); + } + else { + dy = '.71em'; + } + } + return dy; + }; + AxisInternal.prototype.generateAxis = function () { + var internal = this, d3 = internal.d3, params = internal.params; + function axis(g, transition) { + var self; + g.each(function () { + var g = (axis.g = d3.select(this)); + var scale0 = this.__chart__ || internal.scale, scale1 = (this.__chart__ = internal.copyScale()); + var ticksValues = internal.tickValues + ? internal.tickValues + : internal.generateTicks(scale1), ticks = g.selectAll('.tick').data(ticksValues, scale1), tickEnter = ticks + .enter() + .insert('g', '.domain') + .attr('class', 'tick') + .style('opacity', 1e-6), + // MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks. + tickExit = ticks.exit().remove(), tickUpdate = ticks.merge(tickEnter), tickTransform, tickX, tickY; + if (params.isCategory) { + internal.tickOffset = Math.ceil((scale1(1) - scale1(0)) / 2); + tickX = internal.tickCentered ? 0 : internal.tickOffset; + tickY = internal.tickCentered ? internal.tickOffset : 0; + } + else { + internal.tickOffset = tickX = 0; + } + internal.updateRange(); + internal.updateTickLength(); + internal.updateTickTextCharSize(g.select('.tick')); + var lineUpdate = tickUpdate + .select('line') + .merge(tickEnter.append('line')), textUpdate = tickUpdate.select('text').merge(tickEnter.append('text')); + var tspans = tickUpdate + .selectAll('text') + .selectAll('tspan') + .data(function (d, i) { + return internal.tspanData(d, i, scale1); + }), tspanEnter = tspans.enter().append('tspan'), tspanUpdate = tspanEnter.merge(tspans).text(function (d) { + return d.splitted; + }); + tspans.exit().remove(); + var path = g.selectAll('.domain').data([0]), pathUpdate = path + .enter() + .append('path') + .merge(path) + .attr('class', 'domain'); + // TODO: each attr should be one function and change its behavior by internal.orient, probably + switch (internal.orient) { + case 'bottom': { + tickTransform = internal.axisX; + lineUpdate + .attr('x1', tickX) + .attr('x2', tickX) + .attr('y2', function (d, i) { + return internal.lineY2(d, i); + }); + textUpdate + .attr('x', 0) + .attr('y', function (d, i) { + return internal.textY(d, i); + }) + .attr('transform', function (d, i) { + return internal.textTransform(d, i); + }) + .style('text-anchor', function (d, i) { + return internal.textTextAnchor(d, i); + }); + tspanUpdate + .attr('x', 0) + .attr('dy', function (d, i) { + return internal.tspanDy(d, i); + }) + .attr('dx', function (d, i) { + return internal.tspanDx(d, i); + }); + pathUpdate.attr('d', 'M' + + internal.range[0] + + ',' + + internal.outerTickSize + + 'V0H' + + internal.range[1] + + 'V' + + internal.outerTickSize); + break; + } + case 'top': { + // TODO: rotated tick text + tickTransform = internal.axisX; + lineUpdate + .attr('x1', tickX) + .attr('x2', tickX) + .attr('y2', function (d, i) { + return -1 * internal.lineY2(d, i); + }); + textUpdate + .attr('x', 0) + .attr('y', function (d, i) { + return (-1 * internal.textY(d, i) - + (params.isCategory ? 2 : internal.tickLength - 2)); + }) + .attr('transform', function (d, i) { + return internal.textTransform(d, i); + }) + .style('text-anchor', function (d, i) { + return internal.textTextAnchor(d, i); + }); + tspanUpdate + .attr('x', 0) + .attr('dy', function (d, i) { + return internal.tspanDy(d, i); + }) + .attr('dx', function (d, i) { + return internal.tspanDx(d, i); + }); + pathUpdate.attr('d', 'M' + + internal.range[0] + + ',' + + -internal.outerTickSize + + 'V0H' + + internal.range[1] + + 'V' + + -internal.outerTickSize); + break; + } + case 'left': { + tickTransform = internal.axisY; + lineUpdate + .attr('x2', -internal.innerTickSize) + .attr('y1', tickY) + .attr('y2', tickY); + textUpdate + .attr('x', -internal.tickLength) + .attr('y', internal.tickOffset) + .style('text-anchor', 'end'); + tspanUpdate + .attr('x', -internal.tickLength) + .attr('dy', function (d, i) { + return internal.tspanDy(d, i); + }); + pathUpdate.attr('d', 'M' + + -internal.outerTickSize + + ',' + + internal.range[0] + + 'H0V' + + internal.range[1] + + 'H' + + -internal.outerTickSize); + break; + } + case 'right': { + tickTransform = internal.axisY; + lineUpdate + .attr('x2', internal.innerTickSize) + .attr('y1', tickY) + .attr('y2', tickY); + textUpdate + .attr('x', internal.tickLength) + .attr('y', internal.tickOffset) + .style('text-anchor', 'start'); + tspanUpdate.attr('x', internal.tickLength).attr('dy', function (d, i) { + return internal.tspanDy(d, i); + }); + pathUpdate.attr('d', 'M' + + internal.outerTickSize + + ',' + + internal.range[0] + + 'H0V' + + internal.range[1] + + 'H' + + internal.outerTickSize); + break; + } + } + if (scale1.rangeBand) { + var x = scale1, dx = x.rangeBand() / 2; + scale0 = scale1 = function (d) { + return x(d) + dx; + }; + } + else if (scale0.rangeBand) { + scale0 = scale1; + } + else { + tickExit.call(tickTransform, scale1, internal.tickOffset); + } + tickEnter.call(tickTransform, scale0, internal.tickOffset); + self = (transition ? tickUpdate.transition(transition) : tickUpdate) + .style('opacity', 1) + .call(tickTransform, scale1, internal.tickOffset); + }); + return self; + } + axis.scale = function (x) { + if (!arguments.length) { + return internal.scale; + } + internal.scale = x; + return axis; + }; + axis.orient = function (x) { + if (!arguments.length) { + return internal.orient; + } + internal.orient = + x in { top: 1, right: 1, bottom: 1, left: 1 } ? x + '' : 'bottom'; + return axis; + }; + axis.tickFormat = function (format) { + if (!arguments.length) { + return internal.tickFormat; + } + internal.tickFormat = format; + return axis; + }; + axis.tickCentered = function (isCentered) { + if (!arguments.length) { + return internal.tickCentered; + } + internal.tickCentered = isCentered; + return axis; + }; + axis.tickOffset = function () { + return internal.tickOffset; + }; + axis.tickInterval = function () { + var interval, length; + if (params.isCategory) { + interval = internal.tickOffset * 2; + } + else { + length = + axis.g + .select('path.domain') + .node() + .getTotalLength() - + internal.outerTickSize * 2; + interval = length / axis.g.selectAll('line').size(); + } + return interval === Infinity ? 0 : interval; + }; + axis.ticks = function () { + if (!arguments.length) { + return internal.tickArguments; + } + internal.tickArguments = arguments; + return axis; + }; + axis.tickCulling = function (culling) { + if (!arguments.length) { + return internal.tickCulling; + } + internal.tickCulling = culling; + return axis; + }; + axis.tickValues = function (x) { + if (typeof x === 'function') { + internal.tickValues = function () { + return x(internal.scale.domain()); + }; + } + else { + if (!arguments.length) { + return internal.tickValues; + } + internal.tickValues = x; + } + return axis; + }; + return axis; + }; + + var CLASS = { + target: 'c3-target', + chart: 'c3-chart', + chartLine: 'c3-chart-line', + chartLines: 'c3-chart-lines', + chartBar: 'c3-chart-bar', + chartBars: 'c3-chart-bars', + chartText: 'c3-chart-text', + chartTexts: 'c3-chart-texts', + chartArc: 'c3-chart-arc', + chartArcs: 'c3-chart-arcs', + chartArcsTitle: 'c3-chart-arcs-title', + chartArcsBackground: 'c3-chart-arcs-background', + chartArcsGaugeUnit: 'c3-chart-arcs-gauge-unit', + chartArcsGaugeMax: 'c3-chart-arcs-gauge-max', + chartArcsGaugeMin: 'c3-chart-arcs-gauge-min', + selectedCircle: 'c3-selected-circle', + selectedCircles: 'c3-selected-circles', + eventRect: 'c3-event-rect', + eventRects: 'c3-event-rects', + eventRectsSingle: 'c3-event-rects-single', + eventRectsMultiple: 'c3-event-rects-multiple', + zoomRect: 'c3-zoom-rect', + brush: 'c3-brush', + dragZoom: 'c3-drag-zoom', + focused: 'c3-focused', + defocused: 'c3-defocused', + region: 'c3-region', + regions: 'c3-regions', + title: 'c3-title', + tooltipContainer: 'c3-tooltip-container', + tooltip: 'c3-tooltip', + tooltipName: 'c3-tooltip-name', + shape: 'c3-shape', + shapes: 'c3-shapes', + line: 'c3-line', + lines: 'c3-lines', + bar: 'c3-bar', + bars: 'c3-bars', + circle: 'c3-circle', + circles: 'c3-circles', + arc: 'c3-arc', + arcLabelLine: 'c3-arc-label-line', + arcs: 'c3-arcs', + area: 'c3-area', + areas: 'c3-areas', + empty: 'c3-empty', + text: 'c3-text', + texts: 'c3-texts', + gaugeValue: 'c3-gauge-value', + grid: 'c3-grid', + gridLines: 'c3-grid-lines', + xgrid: 'c3-xgrid', + xgrids: 'c3-xgrids', + xgridLine: 'c3-xgrid-line', + xgridLines: 'c3-xgrid-lines', + xgridFocus: 'c3-xgrid-focus', + ygrid: 'c3-ygrid', + ygrids: 'c3-ygrids', + ygridLine: 'c3-ygrid-line', + ygridLines: 'c3-ygrid-lines', + colorScale: 'c3-colorscale', + stanfordElements: 'c3-stanford-elements', + stanfordLine: 'c3-stanford-line', + stanfordLines: 'c3-stanford-lines', + stanfordRegion: 'c3-stanford-region', + stanfordRegions: 'c3-stanford-regions', + stanfordText: 'c3-stanford-text', + stanfordTexts: 'c3-stanford-texts', + axis: 'c3-axis', + axisX: 'c3-axis-x', + axisXLabel: 'c3-axis-x-label', + axisY: 'c3-axis-y', + axisYLabel: 'c3-axis-y-label', + axisY2: 'c3-axis-y2', + axisY2Label: 'c3-axis-y2-label', + legendBackground: 'c3-legend-background', + legendItem: 'c3-legend-item', + legendItemEvent: 'c3-legend-item-event', + legendItemTile: 'c3-legend-item-tile', + legendItemHidden: 'c3-legend-item-hidden', + legendItemFocused: 'c3-legend-item-focused', + dragarea: 'c3-dragarea', + EXPANDED: '_expanded_', + SELECTED: '_selected_', + INCLUDED: '_included_' + }; + + var AxisClass = /** @class */ (function () { + function AxisClass(owner) { + this.owner = owner; + this.d3 = owner.d3; + this.internal = AxisInternal; + } + return AxisClass; + }()); + var Axis = AxisClass; + Axis.prototype.init = function init() { + var $$ = this.owner, config = $$.config, main = $$.main; + $$.axes.x = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisX) + .attr('clip-path', config.axis_x_inner ? '' : $$.clipPathForXAxis) + .attr('transform', $$.getTranslate('x')) + .style('visibility', config.axis_x_show ? 'visible' : 'hidden'); + $$.axes.x + .append('text') + .attr('class', CLASS.axisXLabel) + .attr('transform', config.axis_rotated ? 'rotate(-90)' : '') + .style('text-anchor', this.textAnchorForXAxisLabel.bind(this)); + $$.axes.y = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisY) + .attr('clip-path', config.axis_y_inner ? '' : $$.clipPathForYAxis) + .attr('transform', $$.getTranslate('y')) + .style('visibility', config.axis_y_show ? 'visible' : 'hidden'); + $$.axes.y + .append('text') + .attr('class', CLASS.axisYLabel) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .style('text-anchor', this.textAnchorForYAxisLabel.bind(this)); + $$.axes.y2 = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisY2) + // clip-path? + .attr('transform', $$.getTranslate('y2')) + .style('visibility', config.axis_y2_show ? 'visible' : 'hidden'); + $$.axes.y2 + .append('text') + .attr('class', CLASS.axisY2Label) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .style('text-anchor', this.textAnchorForY2AxisLabel.bind(this)); + }; + Axis.prototype.getXAxis = function getXAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { + var $$ = this.owner, config = $$.config, axisParams = { + isCategory: $$.isCategorized(), + withOuterTick: withOuterTick, + tickMultiline: config.axis_x_tick_multiline, + tickMultilineMax: config.axis_x_tick_multiline + ? Number(config.axis_x_tick_multilineMax) + : 0, + tickWidth: config.axis_x_tick_width, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_x_tick_rotate, + withoutTransition: withoutTransition + }, axis = new this.internal(this, axisParams).axis.scale(scale).orient(orient); + if ($$.isTimeSeries() && tickValues && typeof tickValues !== 'function') { + tickValues = tickValues.map(function (v) { + return $$.parseDate(v); + }); + } + // Set tick + axis.tickFormat(tickFormat).tickValues(tickValues); + if ($$.isCategorized()) { + axis.tickCentered(config.axis_x_tick_centered); + if (isEmpty(config.axis_x_tick_culling)) { + config.axis_x_tick_culling = false; + } + } + return axis; + }; + Axis.prototype.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) { + var $$ = this.owner, config = $$.config, tickValues; + if (config.axis_x_tick_fit || config.axis_x_tick_count) { + tickValues = this.generateTickValues($$.mapTargetsToUniqueXs(targets), config.axis_x_tick_count, $$.isTimeSeries()); + } + if (axis) { + axis.tickValues(tickValues); + } + else { + $$.xAxis.tickValues(tickValues); + $$.subXAxis.tickValues(tickValues); + } + return tickValues; + }; + Axis.prototype.getYAxis = function getYAxis(axisId, scale, orient, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { + var $$ = this.owner; + var config = $$.config; + var tickFormat = config["axis_" + axisId + "_tick_format"]; + if (!tickFormat && $$.isAxisNormalized(axisId)) { + tickFormat = function (x) { return x + "%"; }; + } + var axis = new this.internal(this, { + withOuterTick: withOuterTick, + withoutTransition: withoutTransition, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate + }).axis + .scale(scale) + .orient(orient); + if (tickFormat) { + axis.tickFormat(tickFormat); + } + if ($$.isTimeSeriesY()) { + axis.ticks(config.axis_y_tick_time_type, config.axis_y_tick_time_interval); + } + else { + axis.tickValues(tickValues); + } + return axis; + }; + Axis.prototype.getId = function getId(id) { + var config = this.owner.config; + return id in config.data_axes ? config.data_axes[id] : 'y'; + }; + Axis.prototype.getXAxisTickFormat = function getXAxisTickFormat() { + // #2251 previously set any negative values to a whole number, + // however both should be truncated according to the users format specification + var $$ = this.owner, config = $$.config; + var format = $$.isTimeSeries() + ? $$.defaultAxisTimeFormat + : $$.isCategorized() + ? $$.categoryName + : function (v) { + return v; + }; + if (config.axis_x_tick_format) { + if (isFunction(config.axis_x_tick_format)) { + format = config.axis_x_tick_format; + } + else if ($$.isTimeSeries()) { + format = function (date) { + return date ? $$.axisTimeFormat(config.axis_x_tick_format)(date) : ''; + }; + } + } + return isFunction(format) + ? function (v) { + return format.call($$, v); + } + : format; + }; + Axis.prototype.getTickValues = function getTickValues(tickValues, axis) { + return tickValues ? tickValues : axis ? axis.tickValues() : undefined; + }; + Axis.prototype.getXAxisTickValues = function getXAxisTickValues() { + return this.getTickValues(this.owner.config.axis_x_tick_values, this.owner.xAxis); + }; + Axis.prototype.getYAxisTickValues = function getYAxisTickValues() { + return this.getTickValues(this.owner.config.axis_y_tick_values, this.owner.yAxis); + }; + Axis.prototype.getY2AxisTickValues = function getY2AxisTickValues() { + return this.getTickValues(this.owner.config.axis_y2_tick_values, this.owner.y2Axis); + }; + Axis.prototype.getLabelOptionByAxisId = function getLabelOptionByAxisId(axisId) { + var $$ = this.owner, config = $$.config, option; + if (axisId === 'y') { + option = config.axis_y_label; + } + else if (axisId === 'y2') { + option = config.axis_y2_label; + } + else if (axisId === 'x') { + option = config.axis_x_label; + } + return option; + }; + Axis.prototype.getLabelText = function getLabelText(axisId) { + var option = this.getLabelOptionByAxisId(axisId); + return isString(option) ? option : option ? option.text : null; + }; + Axis.prototype.setLabelText = function setLabelText(axisId, text) { + var $$ = this.owner, config = $$.config, option = this.getLabelOptionByAxisId(axisId); + if (isString(option)) { + if (axisId === 'y') { + config.axis_y_label = text; + } + else if (axisId === 'y2') { + config.axis_y2_label = text; + } + else if (axisId === 'x') { + config.axis_x_label = text; + } + } + else if (option) { + option.text = text; + } + }; + Axis.prototype.getLabelPosition = function getLabelPosition(axisId, defaultPosition) { + var option = this.getLabelOptionByAxisId(axisId), position = option && typeof option === 'object' && option.position + ? option.position + : defaultPosition; + return { + isInner: position.indexOf('inner') >= 0, + isOuter: position.indexOf('outer') >= 0, + isLeft: position.indexOf('left') >= 0, + isCenter: position.indexOf('center') >= 0, + isRight: position.indexOf('right') >= 0, + isTop: position.indexOf('top') >= 0, + isMiddle: position.indexOf('middle') >= 0, + isBottom: position.indexOf('bottom') >= 0 + }; + }; + Axis.prototype.getXAxisLabelPosition = function getXAxisLabelPosition() { + return this.getLabelPosition('x', this.owner.config.axis_rotated ? 'inner-top' : 'inner-right'); + }; + Axis.prototype.getYAxisLabelPosition = function getYAxisLabelPosition() { + return this.getLabelPosition('y', this.owner.config.axis_rotated ? 'inner-right' : 'inner-top'); + }; + Axis.prototype.getY2AxisLabelPosition = function getY2AxisLabelPosition() { + return this.getLabelPosition('y2', this.owner.config.axis_rotated ? 'inner-right' : 'inner-top'); + }; + Axis.prototype.getLabelPositionById = function getLabelPositionById(id) { + return id === 'y2' + ? this.getY2AxisLabelPosition() + : id === 'y' + ? this.getYAxisLabelPosition() + : this.getXAxisLabelPosition(); + }; + Axis.prototype.textForXAxisLabel = function textForXAxisLabel() { + return this.getLabelText('x'); + }; + Axis.prototype.textForYAxisLabel = function textForYAxisLabel() { + return this.getLabelText('y'); + }; + Axis.prototype.textForY2AxisLabel = function textForY2AxisLabel() { + return this.getLabelText('y2'); + }; + Axis.prototype.xForAxisLabel = function xForAxisLabel(forHorizontal, position) { + var $$ = this.owner; + if (forHorizontal) { + return position.isLeft ? 0 : position.isCenter ? $$.width / 2 : $$.width; + } + else { + return position.isBottom + ? -$$.height + : position.isMiddle + ? -$$.height / 2 + : 0; + } + }; + Axis.prototype.dxForAxisLabel = function dxForAxisLabel(forHorizontal, position) { + if (forHorizontal) { + return position.isLeft ? '0.5em' : position.isRight ? '-0.5em' : '0'; + } + else { + return position.isTop ? '-0.5em' : position.isBottom ? '0.5em' : '0'; + } + }; + Axis.prototype.textAnchorForAxisLabel = function textAnchorForAxisLabel(forHorizontal, position) { + if (forHorizontal) { + return position.isLeft ? 'start' : position.isCenter ? 'middle' : 'end'; + } + else { + return position.isBottom ? 'start' : position.isMiddle ? 'middle' : 'end'; + } + }; + Axis.prototype.xForXAxisLabel = function xForXAxisLabel() { + return this.xForAxisLabel(!this.owner.config.axis_rotated, this.getXAxisLabelPosition()); + }; + Axis.prototype.xForYAxisLabel = function xForYAxisLabel() { + return this.xForAxisLabel(this.owner.config.axis_rotated, this.getYAxisLabelPosition()); + }; + Axis.prototype.xForY2AxisLabel = function xForY2AxisLabel() { + return this.xForAxisLabel(this.owner.config.axis_rotated, this.getY2AxisLabelPosition()); + }; + Axis.prototype.dxForXAxisLabel = function dxForXAxisLabel() { + return this.dxForAxisLabel(!this.owner.config.axis_rotated, this.getXAxisLabelPosition()); + }; + Axis.prototype.dxForYAxisLabel = function dxForYAxisLabel() { + return this.dxForAxisLabel(this.owner.config.axis_rotated, this.getYAxisLabelPosition()); + }; + Axis.prototype.dxForY2AxisLabel = function dxForY2AxisLabel() { + return this.dxForAxisLabel(this.owner.config.axis_rotated, this.getY2AxisLabelPosition()); + }; + Axis.prototype.dyForXAxisLabel = function dyForXAxisLabel() { + var $$ = this.owner, config = $$.config, position = this.getXAxisLabelPosition(); + if (config.axis_rotated) { + return position.isInner + ? '1.2em' + : -25 - ($$.config.axis_x_inner ? 0 : this.getMaxTickWidth('x')); + } + else { + return position.isInner ? '-0.5em' : $$.getHorizontalAxisHeight('x') - 10; + } + }; + Axis.prototype.dyForYAxisLabel = function dyForYAxisLabel() { + var $$ = this.owner, position = this.getYAxisLabelPosition(); + if ($$.config.axis_rotated) { + return position.isInner ? '-0.5em' : '3em'; + } + else { + return position.isInner + ? '1.2em' + : -10 - ($$.config.axis_y_inner ? 0 : this.getMaxTickWidth('y') + 10); + } + }; + Axis.prototype.dyForY2AxisLabel = function dyForY2AxisLabel() { + var $$ = this.owner, position = this.getY2AxisLabelPosition(); + if ($$.config.axis_rotated) { + return position.isInner ? '1.2em' : '-2.2em'; + } + else { + return position.isInner + ? '-0.5em' + : 15 + ($$.config.axis_y2_inner ? 0 : this.getMaxTickWidth('y2') + 15); + } + }; + Axis.prototype.textAnchorForXAxisLabel = function textAnchorForXAxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel(!$$.config.axis_rotated, this.getXAxisLabelPosition()); + }; + Axis.prototype.textAnchorForYAxisLabel = function textAnchorForYAxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel($$.config.axis_rotated, this.getYAxisLabelPosition()); + }; + Axis.prototype.textAnchorForY2AxisLabel = function textAnchorForY2AxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel($$.config.axis_rotated, this.getY2AxisLabelPosition()); + }; + Axis.prototype.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) { + var $$ = this.owner, maxWidth = 0, targetsToShow, scale, axis, dummy, svg; + if (withoutRecompute && $$.currentMaxTickWidths[id]) { + return $$.currentMaxTickWidths[id]; + } + if ($$.svg) { + targetsToShow = $$.filterTargetsToShow($$.data.targets); + if (id === 'y') { + scale = $$.y.copy().domain($$.getYDomain(targetsToShow, 'y')); + axis = this.getYAxis(id, scale, $$.yOrient, $$.yAxisTickValues, false, true, true); + } + else if (id === 'y2') { + scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); + axis = this.getYAxis(id, scale, $$.y2Orient, $$.y2AxisTickValues, false, true, true); + } + else { + scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); + axis = this.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues, false, true, true); + this.updateXAxisTickValues(targetsToShow, axis); + } + dummy = $$.d3 + .select('body') + .append('div') + .classed('c3', true); + (svg = dummy + .append('svg') + .style('visibility', 'hidden') + .style('position', 'fixed') + .style('top', 0) + .style('left', 0)), + svg + .append('g') + .call(axis) + .each(function () { + $$.d3 + .select(this) + .selectAll('text') + .each(function () { + var box = getBBox(this); + if (maxWidth < box.width) { + maxWidth = box.width; + } + }); + dummy.remove(); + }); + } + $$.currentMaxTickWidths[id] = + maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; + return $$.currentMaxTickWidths[id]; + }; + Axis.prototype.updateLabels = function updateLabels(withTransition) { + var $$ = this.owner; + var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel), axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label); + (withTransition ? axisXLabel.transition() : axisXLabel) + .attr('x', this.xForXAxisLabel.bind(this)) + .attr('dx', this.dxForXAxisLabel.bind(this)) + .attr('dy', this.dyForXAxisLabel.bind(this)) + .text(this.textForXAxisLabel.bind(this)); + (withTransition ? axisYLabel.transition() : axisYLabel) + .attr('x', this.xForYAxisLabel.bind(this)) + .attr('dx', this.dxForYAxisLabel.bind(this)) + .attr('dy', this.dyForYAxisLabel.bind(this)) + .text(this.textForYAxisLabel.bind(this)); + (withTransition ? axisY2Label.transition() : axisY2Label) + .attr('x', this.xForY2AxisLabel.bind(this)) + .attr('dx', this.dxForY2AxisLabel.bind(this)) + .attr('dy', this.dyForY2AxisLabel.bind(this)) + .text(this.textForY2AxisLabel.bind(this)); + }; + Axis.prototype.getPadding = function getPadding(padding, key, defaultValue, domainLength) { + var p = typeof padding === 'number' ? padding : padding[key]; + if (!isValue(p)) { + return defaultValue; + } + if (padding.unit === 'ratio') { + return padding[key] * domainLength; + } + // assume padding is pixels if unit is not specified + return this.convertPixelsToAxisPadding(p, domainLength); + }; + Axis.prototype.convertPixelsToAxisPadding = function convertPixelsToAxisPadding(pixels, domainLength) { + var $$ = this.owner, length = $$.config.axis_rotated ? $$.width : $$.height; + return domainLength * (pixels / length); + }; + Axis.prototype.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) { + var tickValues = values, targetCount, start, end, count, interval, i, tickValue; + if (tickCount) { + targetCount = isFunction(tickCount) ? tickCount() : tickCount; + // compute ticks according to tickCount + if (targetCount === 1) { + tickValues = [values[0]]; + } + else if (targetCount === 2) { + tickValues = [values[0], values[values.length - 1]]; + } + else if (targetCount > 2) { + count = targetCount - 2; + start = values[0]; + end = values[values.length - 1]; + interval = (end - start) / (count + 1); + // re-construct unique values + tickValues = [start]; + for (i = 0; i < count; i++) { + tickValue = +start + interval * (i + 1); + tickValues.push(forTimeSeries ? new Date(tickValue) : tickValue); + } + tickValues.push(end); + } + } + if (!forTimeSeries) { + tickValues = tickValues.sort(function (a, b) { + return a - b; + }); + } + return tickValues; + }; + Axis.prototype.generateTransitions = function generateTransitions(duration) { + var $$ = this.owner, axes = $$.axes; + return { + axisX: duration ? axes.x.transition().duration(duration) : axes.x, + axisY: duration ? axes.y.transition().duration(duration) : axes.y, + axisY2: duration ? axes.y2.transition().duration(duration) : axes.y2, + axisSubX: duration ? axes.subx.transition().duration(duration) : axes.subx + }; + }; + Axis.prototype.redraw = function redraw(duration, isHidden) { + var $$ = this.owner, transition = duration ? $$.d3.transition().duration(duration) : null; + $$.axes.x.style('opacity', isHidden ? 0 : 1).call($$.xAxis, transition); + $$.axes.y.style('opacity', isHidden ? 0 : 1).call($$.yAxis, transition); + $$.axes.y2.style('opacity', isHidden ? 0 : 1).call($$.y2Axis, transition); + $$.axes.subx.style('opacity', isHidden ? 0 : 1).call($$.subXAxis, transition); + }; + + var c3 = { + version: '0.7.20', + chart: { + fn: Chart.prototype, + internal: { + fn: ChartInternal.prototype, + axis: { + fn: AxisClass.prototype, + internal: { + fn: AxisInternal.prototype + } + } + } + }, + generate: function (config) { + return new Chart(config); + } + }; + ChartInternal.prototype.beforeInit = function () { + // can do something + }; + ChartInternal.prototype.afterInit = function () { + // can do something + }; + ChartInternal.prototype.init = function () { + var $$ = this, config = $$.config; + $$.initParams(); + if (config.data_url) { + $$.convertUrlToData(config.data_url, config.data_mimeType, config.data_headers, config.data_keys, $$.initWithData); + } + else if (config.data_json) { + $$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); + } + else if (config.data_rows) { + $$.initWithData($$.convertRowsToData(config.data_rows)); + } + else if (config.data_columns) { + $$.initWithData($$.convertColumnsToData(config.data_columns)); + } + else { + throw Error('url or json or rows or columns is required.'); + } + }; + ChartInternal.prototype.initParams = function () { + var $$ = this, d3 = $$.d3, config = $$.config; + // MEMO: clipId needs to be unique because it conflicts when multiple charts exist + $$.clipId = 'c3-' + new Date().valueOf() + '-clip'; + $$.clipIdForXAxis = $$.clipId + '-xaxis'; + $$.clipIdForYAxis = $$.clipId + '-yaxis'; + $$.clipIdForGrid = $$.clipId + '-grid'; + $$.clipIdForSubchart = $$.clipId + '-subchart'; + $$.clipPath = $$.getClipPath($$.clipId); + $$.clipPathForXAxis = $$.getClipPath($$.clipIdForXAxis); + $$.clipPathForYAxis = $$.getClipPath($$.clipIdForYAxis); + $$.clipPathForGrid = $$.getClipPath($$.clipIdForGrid); + $$.clipPathForSubchart = $$.getClipPath($$.clipIdForSubchart); + $$.dragStart = null; + $$.dragging = false; + $$.flowing = false; + $$.cancelClick = false; + $$.mouseover = undefined; + $$.transiting = false; + $$.color = $$.generateColor(); + $$.levelColor = $$.generateLevelColor(); + $$.dataTimeParse = (config.data_xLocaltime ? d3.timeParse : d3.utcParse)($$.config.data_xFormat); + $$.axisTimeFormat = config.axis_x_localtime ? d3.timeFormat : d3.utcFormat; + $$.defaultAxisTimeFormat = function (date) { + if (date.getMilliseconds()) { + return d3.timeFormat('.%L')(date); + } + if (date.getSeconds()) { + return d3.timeFormat(':%S')(date); + } + if (date.getMinutes()) { + return d3.timeFormat('%I:%M')(date); + } + if (date.getHours()) { + return d3.timeFormat('%I %p')(date); + } + if (date.getDay() && date.getDate() !== 1) { + return d3.timeFormat('%-m/%-d')(date); + } + if (date.getDate() !== 1) { + return d3.timeFormat('%-m/%-d')(date); + } + if (date.getMonth()) { + return d3.timeFormat('%-m/%-d')(date); + } + return d3.timeFormat('%Y/%-m/%-d')(date); + }; + $$.hiddenTargetIds = []; + $$.hiddenLegendIds = []; + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; + $$.xOrient = config.axis_rotated + ? config.axis_x_inner + ? 'right' + : 'left' + : config.axis_x_inner + ? 'top' + : 'bottom'; + $$.yOrient = config.axis_rotated + ? config.axis_y_inner + ? 'top' + : 'bottom' + : config.axis_y_inner + ? 'right' + : 'left'; + $$.y2Orient = config.axis_rotated + ? config.axis_y2_inner + ? 'bottom' + : 'top' + : config.axis_y2_inner + ? 'left' + : 'right'; + $$.subXOrient = config.axis_rotated ? 'left' : 'bottom'; + $$.isLegendRight = config.legend_position === 'right'; + $$.isLegendInset = config.legend_position === 'inset'; + $$.isLegendTop = + config.legend_inset_anchor === 'top-left' || + config.legend_inset_anchor === 'top-right'; + $$.isLegendLeft = + config.legend_inset_anchor === 'top-left' || + config.legend_inset_anchor === 'bottom-left'; + $$.legendStep = 0; + $$.legendItemWidth = 0; + $$.legendItemHeight = 0; + $$.currentMaxTickWidths = { + x: 0, + y: 0, + y2: 0 + }; + $$.rotated_padding_left = 30; + $$.rotated_padding_right = config.axis_rotated && !config.axis_x_show ? 0 : 30; + $$.rotated_padding_top = 5; + $$.withoutFadeIn = {}; + $$.intervalForObserveInserted = undefined; + $$.axes.subx = d3.selectAll([]); // needs when excluding subchart.js + }; + ChartInternal.prototype.initChartElements = function () { + if (this.initBar) { + this.initBar(); + } + if (this.initLine) { + this.initLine(); + } + if (this.initArc) { + this.initArc(); + } + if (this.initGauge) { + this.initGauge(); + } + if (this.initText) { + this.initText(); + } + }; + ChartInternal.prototype.initWithData = function (data) { + var $$ = this, d3 = $$.d3, config = $$.config; + var defs, main, binding = true; + $$.axis = new AxisClass($$); + if (!config.bindto) { + $$.selectChart = d3.selectAll([]); + } + else if (typeof config.bindto.node === 'function') { + $$.selectChart = config.bindto; + } + else { + $$.selectChart = d3.select(config.bindto); + } + if ($$.selectChart.empty()) { + $$.selectChart = d3 + .select(document.createElement('div')) + .style('opacity', 0); + $$.observeInserted($$.selectChart); + binding = false; + } + $$.selectChart.html('').classed('c3', true); + // Init data as targets + $$.data.xs = {}; + $$.data.targets = $$.convertDataToTargets(data); + if (config.data_filter) { + $$.data.targets = $$.data.targets.filter(config.data_filter); + } + // Set targets to hide if needed + if (config.data_hide) { + $$.addHiddenTargetIds(config.data_hide === true + ? $$.mapToIds($$.data.targets) + : config.data_hide); + } + if (config.legend_hide) { + $$.addHiddenLegendIds(config.legend_hide === true + ? $$.mapToIds($$.data.targets) + : config.legend_hide); + } + if ($$.isStanfordGraphType()) { + $$.initStanfordData(); + } + // Init sizes and scales + $$.updateSizes(); + $$.updateScales(); + // Set domains for each scale + $$.x.domain(d3.extent($$.getXDomain($$.data.targets))); + $$.y.domain($$.getYDomain($$.data.targets, 'y')); + $$.y2.domain($$.getYDomain($$.data.targets, 'y2')); + $$.subX.domain($$.x.domain()); + $$.subY.domain($$.y.domain()); + $$.subY2.domain($$.y2.domain()); + // Save original x domain for zoom update + $$.orgXDomain = $$.x.domain(); + /*-- Basic Elements --*/ + // Define svgs + $$.svg = $$.selectChart + .append('svg') + .style('overflow', 'hidden') + .on('mouseenter', function () { + return config.onmouseover.call($$); + }) + .on('mouseleave', function () { + return config.onmouseout.call($$); + }); + if ($$.config.svg_classname) { + $$.svg.attr('class', $$.config.svg_classname); + } + // Define defs + defs = $$.svg.append('defs'); + $$.clipChart = $$.appendClip(defs, $$.clipId); + $$.clipXAxis = $$.appendClip(defs, $$.clipIdForXAxis); + $$.clipYAxis = $$.appendClip(defs, $$.clipIdForYAxis); + $$.clipGrid = $$.appendClip(defs, $$.clipIdForGrid); + $$.clipSubchart = $$.appendClip(defs, $$.clipIdForSubchart); + $$.updateSvgSize(); + // Define regions + main = $$.main = $$.svg.append('g').attr('transform', $$.getTranslate('main')); + if ($$.initPie) { + $$.initPie(); + } + if ($$.initDragZoom) { + $$.initDragZoom(); + } + if (config.subchart_show && $$.initSubchart) { + $$.initSubchart(); + } + if ($$.initTooltip) { + $$.initTooltip(); + } + if ($$.initLegend) { + $$.initLegend(); + } + if ($$.initTitle) { + $$.initTitle(); + } + if ($$.initZoom) { + $$.initZoom(); + } + if ($$.isStanfordGraphType()) { + $$.drawColorScale(); + } + // Update selection based on size and scale + // TODO: currently this must be called after initLegend because of update of sizes, but it should be done in initSubchart. + if (config.subchart_show && $$.initSubchartBrush) { + $$.initSubchartBrush(); + } + /*-- Main Region --*/ + // text when empty + main + .append('text') + .attr('class', CLASS.text + ' ' + CLASS.empty) + .attr('text-anchor', 'middle') // horizontal centering of text at x position in all browsers. + .attr('dominant-baseline', 'middle'); // vertical centering of text at y position in all browsers, except IE. + // Regions + $$.initRegion(); + // Grids + $$.initGrid(); + // Define g for chart area + main + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.chart); + // Grid lines + if (config.grid_lines_front) { + $$.initGridLines(); + } + $$.initStanfordElements(); + // Cover whole with rects for events + $$.initEventRect(); + // Define g for chart + $$.initChartElements(); + // Add Axis + $$.axis.init(); + // Set targets + $$.updateTargets($$.data.targets); + // Set default extent if defined + if (config.axis_x_selection) { + $$.brush.selectionAsValue($$.getDefaultSelection()); + } + // Draw with targets + if (binding) { + $$.updateDimension(); + $$.config.oninit.call($$); + $$.redraw({ + withTransition: false, + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransitionForAxis: false + }); + } + // Bind to resize event + $$.bindResize(); + // Bind to window focus event + $$.bindWindowFocus(); + // export element of the chart + $$.api.element = $$.selectChart.node(); + }; + ChartInternal.prototype.smoothLines = function (el, type) { + var $$ = this; + if (type === 'grid') { + el.each(function () { + var g = $$.d3.select(this), x1 = g.attr('x1'), x2 = g.attr('x2'), y1 = g.attr('y1'), y2 = g.attr('y2'); + g.attr({ + x1: Math.ceil(x1), + x2: Math.ceil(x2), + y1: Math.ceil(y1), + y2: Math.ceil(y2) + }); + }); + } + }; + ChartInternal.prototype.updateSizes = function () { + var $$ = this, config = $$.config; + var legendHeight = $$.legend ? $$.getLegendHeight() : 0, legendWidth = $$.legend ? $$.getLegendWidth() : 0, legendHeightForBottom = $$.isLegendRight || $$.isLegendInset ? 0 : legendHeight, hasArc = $$.hasArcType(), xAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), subchartXAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x', true), subchartHeight = config.subchart_show && !hasArc + ? config.subchart_size_height + subchartXAxisHeight + : 0; + $$.currentWidth = $$.getCurrentWidth(); + $$.currentHeight = $$.getCurrentHeight(); + // for main + $$.margin = config.axis_rotated + ? { + top: $$.getHorizontalAxisHeight('y2') + $$.getCurrentPaddingTop(), + right: hasArc ? 0 : $$.getCurrentPaddingRight(), + bottom: $$.getHorizontalAxisHeight('y') + + legendHeightForBottom + + $$.getCurrentPaddingBottom(), + left: subchartHeight + (hasArc ? 0 : $$.getCurrentPaddingLeft()) + } + : { + top: 4 + $$.getCurrentPaddingTop(), + right: hasArc ? 0 : $$.getCurrentPaddingRight(), + bottom: xAxisHeight + + subchartHeight + + legendHeightForBottom + + $$.getCurrentPaddingBottom(), + left: hasArc ? 0 : $$.getCurrentPaddingLeft() + }; + // for subchart + $$.margin2 = config.axis_rotated + ? { + top: $$.margin.top, + right: NaN, + bottom: 20 + legendHeightForBottom, + left: $$.rotated_padding_left + } + : { + top: $$.currentHeight - subchartHeight - legendHeightForBottom, + right: NaN, + bottom: subchartXAxisHeight + legendHeightForBottom, + left: $$.margin.left + }; + // for legend + $$.margin3 = { + top: 0, + right: NaN, + bottom: 0, + left: 0 + }; + if ($$.updateSizeForLegend) { + $$.updateSizeForLegend(legendHeight, legendWidth); + } + $$.width = $$.currentWidth - $$.margin.left - $$.margin.right; + $$.height = $$.currentHeight - $$.margin.top - $$.margin.bottom; + if ($$.width < 0) { + $$.width = 0; + } + if ($$.height < 0) { + $$.height = 0; + } + $$.width2 = config.axis_rotated + ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right + : $$.width; + $$.height2 = config.axis_rotated + ? $$.height + : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; + if ($$.width2 < 0) { + $$.width2 = 0; + } + if ($$.height2 < 0) { + $$.height2 = 0; + } + // for arc + $$.arcWidth = $$.width - ($$.isLegendRight ? legendWidth + 10 : 0); + $$.arcHeight = $$.height - ($$.isLegendRight ? 0 : 10); + if ($$.hasType('gauge') && !config.gauge_fullCircle) { + $$.arcHeight += $$.height - $$.getGaugeLabelHeight(); + } + if ($$.updateRadius) { + $$.updateRadius(); + } + if ($$.isLegendRight && hasArc) { + $$.margin3.left = $$.arcWidth / 2 + $$.radiusExpanded * 1.1; + } + }; + ChartInternal.prototype.updateTargets = function (targets) { + var $$ = this, config = $$.config; + /*-- Main --*/ + //-- Text --// + $$.updateTargetsForText(targets); + //-- Bar --// + $$.updateTargetsForBar(targets); + //-- Line --// + $$.updateTargetsForLine(targets); + //-- Arc --// + if ($$.hasArcType() && $$.updateTargetsForArc) { + $$.updateTargetsForArc(targets); + } + /*-- Sub --*/ + if (config.subchart_show && $$.updateTargetsForSubchart) { + $$.updateTargetsForSubchart(targets); + } + // Fade-in each chart + $$.showTargets(); + }; + ChartInternal.prototype.showTargets = function () { + var $$ = this; + $$.svg + .selectAll('.' + CLASS.target) + .filter(function (d) { + return $$.isTargetToShow(d.id); + }) + .transition() + .duration($$.config.transition_duration) + .style('opacity', 1); + }; + ChartInternal.prototype.redraw = function (options, transitions) { + var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config; + var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType); + var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend, withEventRect, withDimension, withUpdateXAxis; + var hideAxis = $$.hasArcType(); + var drawArea, drawBar, drawLine, xForText, yForText; + var duration, durationForExit, durationForAxis; + var transitionsToWait, waitForDraw, flow, transition; + var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling, xDomainForZoom; + var xv = $$.xv.bind($$), cx, cy; + options = options || {}; + withY = getOption(options, 'withY', true); + withSubchart = getOption(options, 'withSubchart', true); + withTransition = getOption(options, 'withTransition', true); + withTransform = getOption(options, 'withTransform', false); + withUpdateXDomain = getOption(options, 'withUpdateXDomain', false); + withUpdateOrgXDomain = getOption(options, 'withUpdateOrgXDomain', false); + withTrimXDomain = getOption(options, 'withTrimXDomain', true); + withUpdateXAxis = getOption(options, 'withUpdateXAxis', withUpdateXDomain); + withLegend = getOption(options, 'withLegend', false); + withEventRect = getOption(options, 'withEventRect', true); + withDimension = getOption(options, 'withDimension', true); + withTransitionForExit = getOption(options, 'withTransitionForExit', withTransition); + withTransitionForAxis = getOption(options, 'withTransitionForAxis', withTransition); + duration = withTransition ? config.transition_duration : 0; + durationForExit = withTransitionForExit ? duration : 0; + durationForAxis = withTransitionForAxis ? duration : 0; + transitions = transitions || $$.axis.generateTransitions(durationForAxis); + // update legend and transform each g + if (withLegend && config.legend_show) { + $$.updateLegend($$.mapToIds($$.data.targets), options, transitions); + } + else if (withDimension) { + // need to update dimension (e.g. axis.y.tick.values) because y tick values should change + // no need to update axis in it because they will be updated in redraw() + $$.updateDimension(true); + } + // MEMO: needed for grids calculation + if ($$.isCategorized() && targetsToShow.length === 0) { + $$.x.domain([0, $$.axes.x.selectAll('.tick').size()]); + } + if (targetsToShow.length) { + $$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain); + if (!config.axis_x_tick_values) { + tickValues = $$.axis.updateXAxisTickValues(targetsToShow); + } + } + else { + $$.xAxis.tickValues([]); + $$.subXAxis.tickValues([]); + } + if (config.zoom_rescale && !options.flow) { + xDomainForZoom = $$.x.orgDomain(); + } + $$.y.domain($$.getYDomain(targetsToShow, 'y', xDomainForZoom)); + $$.y2.domain($$.getYDomain(targetsToShow, 'y2', xDomainForZoom)); + if (!config.axis_y_tick_values && config.axis_y_tick_count) { + $$.yAxis.tickValues($$.axis.generateTickValues($$.y.domain(), config.axis_y_tick_count)); + } + if (!config.axis_y2_tick_values && config.axis_y2_tick_count) { + $$.y2Axis.tickValues($$.axis.generateTickValues($$.y2.domain(), config.axis_y2_tick_count)); + } + // axes + $$.axis.redraw(durationForAxis, hideAxis); + // Update axis label + $$.axis.updateLabels(withTransition); + // show/hide if manual culling needed + if ((withUpdateXDomain || withUpdateXAxis) && targetsToShow.length) { + if (config.axis_x_tick_culling && tickValues) { + for (i = 1; i < tickValues.length; i++) { + if (tickValues.length / i < config.axis_x_tick_culling_max) { + intervalForCulling = i; + break; + } + } + $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').each(function (e) { + var index = tickValues.indexOf(e); + if (index >= 0) { + d3.select(this).style('display', index % intervalForCulling ? 'none' : 'block'); + } + }); + } + else { + $$.svg + .selectAll('.' + CLASS.axisX + ' .tick text') + .style('display', 'block'); + } + } + // setup drawer - MEMO: these must be called after axis updated + drawArea = $$.generateDrawArea + ? $$.generateDrawArea(areaIndices, false) + : undefined; + drawBar = $$.generateDrawBar ? $$.generateDrawBar(barIndices) : undefined; + drawLine = $$.generateDrawLine + ? $$.generateDrawLine(lineIndices, false) + : undefined; + xForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, true); + yForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, false); + // update circleY based on updated parameters + $$.updateCircleY(); + // generate circle x/y functions depending on updated params + cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$); + cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); + // Update sub domain + if (withY) { + $$.subY.domain($$.getYDomain(targetsToShow, 'y')); + $$.subY2.domain($$.getYDomain(targetsToShow, 'y2')); + } + // xgrid focus + $$.updateXgridFocus(); + // Data empty label positioning and text. + main + .select('text.' + CLASS.text + '.' + CLASS.empty) + .attr('x', $$.width / 2) + .attr('y', $$.height / 2) + .text(config.data_empty_label_text) + .transition() + .style('opacity', targetsToShow.length ? 0 : 1); + // event rect + if (withEventRect) { + $$.redrawEventRect(); + } + // grid + $$.updateGrid(duration); + $$.updateStanfordElements(duration); + // rect for regions + $$.updateRegion(duration); + // bars + $$.updateBar(durationForExit); + // lines, areas and circles + $$.updateLine(durationForExit); + $$.updateArea(durationForExit); + $$.updateCircle(cx, cy); + // text + if ($$.hasDataLabel()) { + $$.updateText(xForText, yForText, durationForExit); + } + // title + if ($$.redrawTitle) { + $$.redrawTitle(); + } + // arc + if ($$.redrawArc) { + $$.redrawArc(duration, durationForExit, withTransform); + } + // subchart + if (config.subchart_show && $$.redrawSubchart) { + $$.redrawSubchart(withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices); + } + if ($$.isStanfordGraphType()) { + $$.drawColorScale(); + } + // circles for select + main + .selectAll('.' + CLASS.selectedCircles) + .filter($$.isBarType.bind($$)) + .selectAll('circle') + .remove(); + if (options.flow) { + flow = $$.generateFlow({ + targets: targetsToShow, + flow: options.flow, + duration: options.flow.duration, + drawBar: drawBar, + drawLine: drawLine, + drawArea: drawArea, + cx: cx, + cy: cy, + xv: xv, + xForText: xForText, + yForText: yForText + }); + } + if (duration && $$.isTabVisible()) { + // Only use transition if tab visible. See #938. + // transition should be derived from one transition + transition = d3.transition().duration(duration); + transitionsToWait = []; + [ + $$.redrawBar(drawBar, true, transition), + $$.redrawLine(drawLine, true, transition), + $$.redrawArea(drawArea, true, transition), + $$.redrawCircle(cx, cy, true, transition), + $$.redrawText(xForText, yForText, options.flow, true, transition), + $$.redrawRegion(true, transition), + $$.redrawGrid(true, transition) + ].forEach(function (transitions) { + transitions.forEach(function (transition) { + transitionsToWait.push(transition); + }); + }); + // Wait for end of transitions to call flow and onrendered callback + waitForDraw = $$.generateWait(); + transitionsToWait.forEach(function (t) { + waitForDraw.add(t); + }); + waitForDraw(function () { + if (flow) { + flow(); + } + if (config.onrendered) { + config.onrendered.call($$); + } + }); + } + else { + $$.redrawBar(drawBar); + $$.redrawLine(drawLine); + $$.redrawArea(drawArea); + $$.redrawCircle(cx, cy); + $$.redrawText(xForText, yForText, options.flow); + $$.redrawRegion(); + $$.redrawGrid(); + if (flow) { + flow(); + } + if (config.onrendered) { + config.onrendered.call($$); + } + } + // update fadein condition + $$.mapToIds($$.data.targets).forEach(function (id) { + $$.withoutFadeIn[id] = true; + }); + }; + ChartInternal.prototype.updateAndRedraw = function (options) { + var $$ = this, config = $$.config, transitions; + options = options || {}; + // same with redraw + options.withTransition = getOption(options, 'withTransition', true); + options.withTransform = getOption(options, 'withTransform', false); + options.withLegend = getOption(options, 'withLegend', false); + // NOT same with redraw + options.withUpdateXDomain = getOption(options, 'withUpdateXDomain', true); + options.withUpdateOrgXDomain = getOption(options, 'withUpdateOrgXDomain', true); + options.withTransitionForExit = false; + options.withTransitionForTransform = getOption(options, 'withTransitionForTransform', options.withTransition); + // MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called) + $$.updateSizes(); + // MEMO: called in updateLegend in redraw if withLegend + if (!(options.withLegend && config.legend_show)) { + transitions = $$.axis.generateTransitions(options.withTransitionForAxis ? config.transition_duration : 0); + // Update scales + $$.updateScales(); + $$.updateSvgSize(); + // Update g positions + $$.transformAll(options.withTransitionForTransform, transitions); + } + // Draw with new sizes & scales + $$.redraw(options, transitions); + }; + ChartInternal.prototype.redrawWithoutRescale = function () { + this.redraw({ + withY: false, + withSubchart: false, + withEventRect: false, + withTransitionForAxis: false + }); + }; + ChartInternal.prototype.isTimeSeries = function () { + return this.config.axis_x_type === 'timeseries'; + }; + ChartInternal.prototype.isCategorized = function () { + return this.config.axis_x_type.indexOf('categor') >= 0; + }; + ChartInternal.prototype.isCustomX = function () { + var $$ = this, config = $$.config; + return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)); + }; + ChartInternal.prototype.isTimeSeriesY = function () { + return this.config.axis_y_type === 'timeseries'; + }; + ChartInternal.prototype.getTranslate = function (target) { + var $$ = this, config = $$.config, x, y; + if (target === 'main') { + x = asHalfPixel($$.margin.left); + y = asHalfPixel($$.margin.top); + } + else if (target === 'context') { + x = asHalfPixel($$.margin2.left); + y = asHalfPixel($$.margin2.top); + } + else if (target === 'legend') { + x = $$.margin3.left; + y = $$.margin3.top; + } + else if (target === 'x') { + x = 0; + y = config.axis_rotated ? 0 : $$.height; + } + else if (target === 'y') { + x = 0; + y = config.axis_rotated ? $$.height : 0; + } + else if (target === 'y2') { + x = config.axis_rotated ? 0 : $$.width; + y = config.axis_rotated ? 1 : 0; + } + else if (target === 'subx') { + x = 0; + y = config.axis_rotated ? 0 : $$.height2; + } + else if (target === 'arc') { + x = $$.arcWidth / 2; + y = $$.arcHeight / 2 - ($$.hasType('gauge') ? 6 : 0); // to prevent wrong display of min and max label + } + return 'translate(' + x + ',' + y + ')'; + }; + ChartInternal.prototype.initialOpacity = function (d) { + return d.value !== null && this.withoutFadeIn[d.id] ? 1 : 0; + }; + ChartInternal.prototype.initialOpacityForCircle = function (d) { + return d.value !== null && this.withoutFadeIn[d.id] + ? this.opacityForCircle(d) + : 0; + }; + ChartInternal.prototype.opacityForCircle = function (d) { + var isPointShouldBeShown = isFunction(this.config.point_show) + ? this.config.point_show(d) + : this.config.point_show; + var opacity = isPointShouldBeShown || this.isStanfordType(d) ? 1 : 0; + return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0; + }; + ChartInternal.prototype.opacityForText = function () { + return this.hasDataLabel() ? 1 : 0; + }; + ChartInternal.prototype.xx = function (d) { + return d ? this.x(d.x) : null; + }; + ChartInternal.prototype.xvCustom = function (d, xyValue) { + var $$ = this, value = xyValue ? d[xyValue] : d.value; + if ($$.isTimeSeries()) { + value = $$.parseDate(d.value); + } + else if ($$.isCategorized() && typeof d.value === 'string') { + value = $$.config.axis_x_categories.indexOf(d.value); + } + return Math.ceil($$.x(value)); + }; + ChartInternal.prototype.yvCustom = function (d, xyValue) { + var $$ = this, yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y, value = xyValue ? d[xyValue] : d.value; + return Math.ceil(yScale(value)); + }; + ChartInternal.prototype.xv = function (d) { + var $$ = this, value = d.value; + if ($$.isTimeSeries()) { + value = $$.parseDate(d.value); + } + else if ($$.isCategorized() && typeof d.value === 'string') { + value = $$.config.axis_x_categories.indexOf(d.value); + } + return Math.ceil($$.x(value)); + }; + ChartInternal.prototype.yv = function (d) { + var $$ = this, yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y; + return Math.ceil(yScale(d.value)); + }; + ChartInternal.prototype.subxx = function (d) { + return d ? this.subX(d.x) : null; + }; + ChartInternal.prototype.transformMain = function (withTransition, transitions) { + var $$ = this, xAxis, yAxis, y2Axis; + if (transitions && transitions.axisX) { + xAxis = transitions.axisX; + } + else { + xAxis = $$.main.select('.' + CLASS.axisX); + if (withTransition) { + xAxis = xAxis.transition(); + } + } + if (transitions && transitions.axisY) { + yAxis = transitions.axisY; + } + else { + yAxis = $$.main.select('.' + CLASS.axisY); + if (withTransition) { + yAxis = yAxis.transition(); + } + } + if (transitions && transitions.axisY2) { + y2Axis = transitions.axisY2; + } + else { + y2Axis = $$.main.select('.' + CLASS.axisY2); + if (withTransition) { + y2Axis = y2Axis.transition(); + } + } + (withTransition ? $$.main.transition() : $$.main).attr('transform', $$.getTranslate('main')); + xAxis.attr('transform', $$.getTranslate('x')); + yAxis.attr('transform', $$.getTranslate('y')); + y2Axis.attr('transform', $$.getTranslate('y2')); + $$.main + .select('.' + CLASS.chartArcs) + .attr('transform', $$.getTranslate('arc')); + }; + ChartInternal.prototype.transformAll = function (withTransition, transitions) { + var $$ = this; + $$.transformMain(withTransition, transitions); + if ($$.config.subchart_show) { + $$.transformContext(withTransition, transitions); + } + if ($$.legend) { + $$.transformLegend(withTransition); + } + }; + ChartInternal.prototype.updateSvgSize = function () { + var $$ = this, brush = $$.svg.select("." + CLASS.brush + " .overlay"); + $$.svg.attr('width', $$.currentWidth).attr('height', $$.currentHeight); + $$.svg + .selectAll(['#' + $$.clipId, '#' + $$.clipIdForGrid]) + .select('rect') + .attr('width', $$.width) + .attr('height', $$.height); + $$.svg + .select('#' + $$.clipIdForXAxis) + .select('rect') + .attr('x', $$.getXAxisClipX.bind($$)) + .attr('y', $$.getXAxisClipY.bind($$)) + .attr('width', $$.getXAxisClipWidth.bind($$)) + .attr('height', $$.getXAxisClipHeight.bind($$)); + $$.svg + .select('#' + $$.clipIdForYAxis) + .select('rect') + .attr('x', $$.getYAxisClipX.bind($$)) + .attr('y', $$.getYAxisClipY.bind($$)) + .attr('width', $$.getYAxisClipWidth.bind($$)) + .attr('height', $$.getYAxisClipHeight.bind($$)); + $$.svg + .select('#' + $$.clipIdForSubchart) + .select('rect') + .attr('width', $$.width) + .attr('height', (brush.size() && brush.attr('height')) || 0); + // MEMO: parent div's height will be bigger than svg when + $$.selectChart.style('max-height', $$.currentHeight + 'px'); + }; + ChartInternal.prototype.updateDimension = function (withoutAxis) { + var $$ = this; + if (!withoutAxis) { + if ($$.config.axis_rotated) { + $$.axes.x.call($$.xAxis); + $$.axes.subx.call($$.subXAxis); + } + else { + $$.axes.y.call($$.yAxis); + $$.axes.y2.call($$.y2Axis); + } + } + $$.updateSizes(); + $$.updateScales(); + $$.updateSvgSize(); + $$.transformAll(false); + }; + ChartInternal.prototype.observeInserted = function (selection) { + var $$ = this, observer; + if (typeof MutationObserver === 'undefined') { + window.console.error('MutationObserver not defined.'); + return; + } + observer = new MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + if (mutation.type === 'childList' && mutation.previousSibling) { + observer.disconnect(); + // need to wait for completion of load because size calculation requires the actual sizes determined after that completion + $$.intervalForObserveInserted = window.setInterval(function () { + // parentNode will NOT be null when completed + if (selection.node().parentNode) { + window.clearInterval($$.intervalForObserveInserted); + $$.updateDimension(); + if ($$.brush) { + $$.brush.update(); + } + $$.config.oninit.call($$); + $$.redraw({ + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransition: false, + withTransitionForTransform: false, + withLegend: true + }); + selection.transition().style('opacity', 1); + } + }, 10); + } + }); + }); + observer.observe(selection.node(), { + attributes: true, + childList: true, + characterData: true + }); + }; + /** + * Binds handlers to the window resize event. + */ + ChartInternal.prototype.bindResize = function () { + var $$ = this, config = $$.config; + $$.resizeFunction = $$.generateResize(); // need to call .remove + $$.resizeFunction.add(function () { + config.onresize.call($$); + }); + if (config.resize_auto) { + $$.resizeFunction.add(function () { + if ($$.resizeTimeout !== undefined) { + window.clearTimeout($$.resizeTimeout); + } + $$.resizeTimeout = window.setTimeout(function () { + delete $$.resizeTimeout; + $$.updateAndRedraw({ + withUpdateXDomain: false, + withUpdateOrgXDomain: false, + withTransition: false, + withTransitionForTransform: false, + withLegend: true + }); + if ($$.brush) { + $$.brush.update(); + } + }, 100); + }); + } + $$.resizeFunction.add(function () { + config.onresized.call($$); + }); + $$.resizeIfElementDisplayed = function () { + // if element not displayed skip it + if ($$.api == null || !$$.api.element.offsetParent) { + return; + } + $$.resizeFunction(); + }; + window.addEventListener('resize', $$.resizeIfElementDisplayed, false); + }; + /** + * Binds handlers to the window focus event. + */ + ChartInternal.prototype.bindWindowFocus = function () { + var _this = this; + if (this.windowFocusHandler) { + // The handler is already set + return; + } + this.windowFocusHandler = function () { + _this.redraw(); + }; + window.addEventListener('focus', this.windowFocusHandler); + }; + /** + * Unbinds from the window focus event. + */ + ChartInternal.prototype.unbindWindowFocus = function () { + window.removeEventListener('focus', this.windowFocusHandler); + delete this.windowFocusHandler; + }; + ChartInternal.prototype.generateResize = function () { + var resizeFunctions = []; + function callResizeFunctions() { + resizeFunctions.forEach(function (f) { + f(); + }); + } + callResizeFunctions.add = function (f) { + resizeFunctions.push(f); + }; + callResizeFunctions.remove = function (f) { + for (var i = 0; i < resizeFunctions.length; i++) { + if (resizeFunctions[i] === f) { + resizeFunctions.splice(i, 1); + break; + } + } + }; + return callResizeFunctions; + }; + ChartInternal.prototype.endall = function (transition, callback) { + var n = 0; + transition + .each(function () { + ++n; + }) + .on('end', function () { + if (!--n) { + callback.apply(this, arguments); + } + }); + }; + ChartInternal.prototype.generateWait = function () { + var $$ = this; + var transitionsToWait = [], f = function (callback) { + var timer = setInterval(function () { + if (!$$.isTabVisible()) { + return; + } + var done = 0; + transitionsToWait.forEach(function (t) { + if (t.empty()) { + done += 1; + return; + } + try { + t.transition(); + } + catch (e) { + done += 1; + } + }); + if (done === transitionsToWait.length) { + clearInterval(timer); + if (callback) { + callback(); + } + } + }, 50); + }; + f.add = function (transition) { + transitionsToWait.push(transition); + }; + return f; + }; + ChartInternal.prototype.parseDate = function (date) { + var $$ = this, parsedDate; + if (date instanceof Date) { + parsedDate = date; + } + else if (typeof date === 'string') { + parsedDate = $$.dataTimeParse(date); + } + else if (typeof date === 'object') { + parsedDate = new Date(+date); + } + else if (typeof date === 'number' && !isNaN(date)) { + parsedDate = new Date(+date); + } + if (!parsedDate || isNaN(+parsedDate)) { + window.console.error("Failed to parse x '" + date + "' to Date object"); + } + return parsedDate; + }; + ChartInternal.prototype.isTabVisible = function () { + return !document.hidden; + }; + ChartInternal.prototype.getPathBox = getPathBox; + ChartInternal.prototype.CLASS = CLASS; + + /* jshint ignore:start */ + (function () { + if (!('SVGPathSeg' in window)) { + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg + window.SVGPathSeg = function (type, typeAsLetter, owningPathSegList) { + this.pathSegType = type; + this.pathSegTypeAsLetter = typeAsLetter; + this._owningPathSegList = owningPathSegList; + }; + window.SVGPathSeg.prototype.classname = 'SVGPathSeg'; + window.SVGPathSeg.PATHSEG_UNKNOWN = 0; + window.SVGPathSeg.PATHSEG_CLOSEPATH = 1; + window.SVGPathSeg.PATHSEG_MOVETO_ABS = 2; + window.SVGPathSeg.PATHSEG_MOVETO_REL = 3; + window.SVGPathSeg.PATHSEG_LINETO_ABS = 4; + window.SVGPathSeg.PATHSEG_LINETO_REL = 5; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; + window.SVGPathSeg.PATHSEG_ARC_ABS = 10; + window.SVGPathSeg.PATHSEG_ARC_REL = 11; + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; + // Notify owning PathSegList on any changes so they can be synchronized back to the path element. + window.SVGPathSeg.prototype._segmentChanged = function () { + if (this._owningPathSegList) + this._owningPathSegList.segmentChanged(this); + }; + window.SVGPathSegClosePath = function (owningPathSegList) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList); + }; + window.SVGPathSegClosePath.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegClosePath.prototype.toString = function () { + return '[object SVGPathSegClosePath]'; + }; + window.SVGPathSegClosePath.prototype._asPathString = function () { + return this.pathSegTypeAsLetter; + }; + window.SVGPathSegClosePath.prototype.clone = function () { + return new window.SVGPathSegClosePath(undefined); + }; + window.SVGPathSegMovetoAbs = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegMovetoAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegMovetoAbs.prototype.toString = function () { + return '[object SVGPathSegMovetoAbs]'; + }; + window.SVGPathSegMovetoAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegMovetoAbs.prototype.clone = function () { + return new window.SVGPathSegMovetoAbs(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegMovetoRel = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegMovetoRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegMovetoRel.prototype.toString = function () { + return '[object SVGPathSegMovetoRel]'; + }; + window.SVGPathSegMovetoRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegMovetoRel.prototype.clone = function () { + return new window.SVGPathSegMovetoRel(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegMovetoRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegMovetoRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoAbs = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegLinetoAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoAbs.prototype.toString = function () { + return '[object SVGPathSegLinetoAbs]'; + }; + window.SVGPathSegLinetoAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegLinetoAbs.prototype.clone = function () { + return new window.SVGPathSegLinetoAbs(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoRel = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegLinetoRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoRel.prototype.toString = function () { + return '[object SVGPathSegLinetoRel]'; + }; + window.SVGPathSegLinetoRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegLinetoRel.prototype.clone = function () { + return new window.SVGPathSegLinetoRel(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegLinetoRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegLinetoRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoCubicAbs = function (owningPathSegList, x, y, x1, y1, x2, y2) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoCubicAbs.prototype.toString = function () { + return '[object SVGPathSegCurvetoCubicAbs]'; + }; + window.SVGPathSegCurvetoCubicAbs.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoCubicAbs.prototype.clone = function () { + return new window.SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x1', { + get: function () { + return this._x1; + }, + set: function (x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y1', { + get: function () { + return this._y1; + }, + set: function (y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x2', { + get: function () { + return this._x2; + }, + set: function (x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y2', { + get: function () { + return this._y2; + }, + set: function (y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoCubicRel = function (owningPathSegList, x, y, x1, y1, x2, y2) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoCubicRel.prototype.toString = function () { + return '[object SVGPathSegCurvetoCubicRel]'; + }; + window.SVGPathSegCurvetoCubicRel.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoCubicRel.prototype.clone = function () { + return new window.SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x1', { + get: function () { + return this._x1; + }, + set: function (x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y1', { + get: function () { + return this._y1; + }, + set: function (y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x2', { + get: function () { + return this._x2; + }, + set: function (x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y2', { + get: function () { + return this._y2; + }, + set: function (y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoQuadraticAbs = function (owningPathSegList, x, y, x1, y1) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoQuadraticAbs.prototype.toString = function () { + return '[object SVGPathSegCurvetoQuadraticAbs]'; + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype.clone = function () { + return new window.SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'x1', { + get: function () { + return this._x1; + }, + set: function (x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'y1', { + get: function () { + return this._y1; + }, + set: function (y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoQuadraticRel = function (owningPathSegList, x, y, x1, y1) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + }; + window.SVGPathSegCurvetoQuadraticRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoQuadraticRel.prototype.toString = function () { + return '[object SVGPathSegCurvetoQuadraticRel]'; + }; + window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoQuadraticRel.prototype.clone = function () { + return new window.SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'x1', { + get: function () { + return this._x1; + }, + set: function (x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'y1', { + get: function () { + return this._y1; + }, + set: function (y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegArcAbs = function (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + }; + window.SVGPathSegArcAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegArcAbs.prototype.toString = function () { + return '[object SVGPathSegArcAbs]'; + }; + window.SVGPathSegArcAbs.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._r1 + + ' ' + + this._r2 + + ' ' + + this._angle + + ' ' + + (this._largeArcFlag ? '1' : '0') + + ' ' + + (this._sweepFlag ? '1' : '0') + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegArcAbs.prototype.clone = function () { + return new window.SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + }; + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'r1', { + get: function () { + return this._r1; + }, + set: function (r1) { + this._r1 = r1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'r2', { + get: function () { + return this._r2; + }, + set: function (r2) { + this._r2 = r2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'angle', { + get: function () { + return this._angle; + }, + set: function (angle) { + this._angle = angle; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'largeArcFlag', { + get: function () { + return this._largeArcFlag; + }, + set: function (largeArcFlag) { + this._largeArcFlag = largeArcFlag; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'sweepFlag', { + get: function () { + return this._sweepFlag; + }, + set: function (sweepFlag) { + this._sweepFlag = sweepFlag; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegArcRel = function (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + }; + window.SVGPathSegArcRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegArcRel.prototype.toString = function () { + return '[object SVGPathSegArcRel]'; + }; + window.SVGPathSegArcRel.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._r1 + + ' ' + + this._r2 + + ' ' + + this._angle + + ' ' + + (this._largeArcFlag ? '1' : '0') + + ' ' + + (this._sweepFlag ? '1' : '0') + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegArcRel.prototype.clone = function () { + return new window.SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + }; + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'r1', { + get: function () { + return this._r1; + }, + set: function (r1) { + this._r1 = r1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'r2', { + get: function () { + return this._r2; + }, + set: function (r2) { + this._r2 = r2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'angle', { + get: function () { + return this._angle; + }, + set: function (angle) { + this._angle = angle; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'largeArcFlag', { + get: function () { + return this._largeArcFlag; + }, + set: function (largeArcFlag) { + this._largeArcFlag = largeArcFlag; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'sweepFlag', { + get: function () { + return this._sweepFlag; + }, + set: function (sweepFlag) { + this._sweepFlag = sweepFlag; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoHorizontalAbs = function (owningPathSegList, x) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList); + this._x = x; + }; + window.SVGPathSegLinetoHorizontalAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoHorizontalAbs.prototype.toString = function () { + return '[object SVGPathSegLinetoHorizontalAbs]'; + }; + window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x; + }; + window.SVGPathSegLinetoHorizontalAbs.prototype.clone = function () { + return new window.SVGPathSegLinetoHorizontalAbs(undefined, this._x); + }; + Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoHorizontalRel = function (owningPathSegList, x) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList); + this._x = x; + }; + window.SVGPathSegLinetoHorizontalRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoHorizontalRel.prototype.toString = function () { + return '[object SVGPathSegLinetoHorizontalRel]'; + }; + window.SVGPathSegLinetoHorizontalRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x; + }; + window.SVGPathSegLinetoHorizontalRel.prototype.clone = function () { + return new window.SVGPathSegLinetoHorizontalRel(undefined, this._x); + }; + Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoVerticalAbs = function (owningPathSegList, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList); + this._y = y; + }; + window.SVGPathSegLinetoVerticalAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoVerticalAbs.prototype.toString = function () { + return '[object SVGPathSegLinetoVerticalAbs]'; + }; + window.SVGPathSegLinetoVerticalAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._y; + }; + window.SVGPathSegLinetoVerticalAbs.prototype.clone = function () { + return new window.SVGPathSegLinetoVerticalAbs(undefined, this._y); + }; + Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoVerticalRel = function (owningPathSegList, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList); + this._y = y; + }; + window.SVGPathSegLinetoVerticalRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoVerticalRel.prototype.toString = function () { + return '[object SVGPathSegLinetoVerticalRel]'; + }; + window.SVGPathSegLinetoVerticalRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._y; + }; + window.SVGPathSegLinetoVerticalRel.prototype.clone = function () { + return new window.SVGPathSegLinetoVerticalRel(undefined, this._y); + }; + Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoCubicSmoothAbs = function (owningPathSegList, x, y, x2, y2) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString = function () { + return '[object SVGPathSegCurvetoCubicSmoothAbs]'; + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone = function () { + return new window.SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, 'x2', { + get: function () { + return this._x2; + }, + set: function (x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, 'y2', { + get: function () { + return this._y2; + }, + set: function (y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoCubicSmoothRel = function (owningPathSegList, x, y, x2, y2) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString = function () { + return '[object SVGPathSegCurvetoCubicSmoothRel]'; + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone = function () { + return new window.SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, 'x2', { + get: function () { + return this._x2; + }, + set: function (x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, 'y2', { + get: function () { + return this._y2; + }, + set: function (y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoQuadraticSmoothAbs = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString = function () { + return '[object SVGPathSegCurvetoQuadraticSmoothAbs]'; + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone = function () { + return new window.SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoQuadraticSmoothRel = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString = function () { + return '[object SVGPathSegCurvetoQuadraticSmoothRel]'; + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone = function () { + return new window.SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + // Add createSVGPathSeg* functions to window.SVGPathElement. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-Interfacewindow.SVGPathElement. + window.SVGPathElement.prototype.createSVGPathSegClosePath = function () { + return new window.SVGPathSegClosePath(undefined); + }; + window.SVGPathElement.prototype.createSVGPathSegMovetoAbs = function (x, y) { + return new window.SVGPathSegMovetoAbs(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegMovetoRel = function (x, y) { + return new window.SVGPathSegMovetoRel(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoAbs = function (x, y) { + return new window.SVGPathSegLinetoAbs(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoRel = function (x, y) { + return new window.SVGPathSegLinetoRel(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function (x, y, x1, y1, x2, y2) { + return new window.SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function (x, y, x1, y1, x2, y2) { + return new window.SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function (x, y, x1, y1) { + return new window.SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function (x, y, x1, y1) { + return new window.SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); + }; + window.SVGPathElement.prototype.createSVGPathSegArcAbs = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + return new window.SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + }; + window.SVGPathElement.prototype.createSVGPathSegArcRel = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + return new window.SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function (x) { + return new window.SVGPathSegLinetoHorizontalAbs(undefined, x); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function (x) { + return new window.SVGPathSegLinetoHorizontalRel(undefined, x); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function (y) { + return new window.SVGPathSegLinetoVerticalAbs(undefined, y); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function (y) { + return new window.SVGPathSegLinetoVerticalRel(undefined, y); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function (x, y, x2, y2) { + return new window.SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function (x, y, x2, y2) { + return new window.SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function (x, y) { + return new window.SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function (x, y) { + return new window.SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); + }; + if (!('getPathSegAtLength' in window.SVGPathElement.prototype)) { + // Add getPathSegAtLength to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength + // This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm. + window.SVGPathElement.prototype.getPathSegAtLength = function (distance) { + if (distance === undefined || !isFinite(distance)) + throw 'Invalid arguments.'; + var measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + measurementElement.setAttribute('d', this.getAttribute('d')); + var lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; + // If the path is empty, return 0. + if (lastPathSegment <= 0) + return 0; + do { + measurementElement.pathSegList.removeItem(lastPathSegment); + if (distance > measurementElement.getTotalLength()) + break; + lastPathSegment--; + } while (lastPathSegment > 0); + return lastPathSegment; + }; + } + } + if (!('SVGPathSegList' in window)) { + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList + window.SVGPathSegList = function (pathElement) { + this._pathElement = pathElement; + this._list = this._parsePath(this._pathElement.getAttribute('d')); + // Use a MutationObserver to catch changes to the path's "d" attribute. + this._mutationObserverConfig = { + attributes: true, + attributeFilter: ['d'] + }; + this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this)); + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + }; + window.SVGPathSegList.prototype.classname = 'SVGPathSegList'; + Object.defineProperty(window.SVGPathSegList.prototype, 'numberOfItems', { + get: function () { + this._checkPathSynchronizedToList(); + return this._list.length; + }, + enumerable: true + }); + // Add the pathSegList accessors to window.SVGPathElement. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData + Object.defineProperty(window.SVGPathElement.prototype, 'pathSegList', { + get: function () { + if (!this._pathSegList) + this._pathSegList = new window.SVGPathSegList(this); + return this._pathSegList; + }, + enumerable: true + }); + // FIXME: The following are not implemented and simply return window.SVGPathElement.pathSegList. + Object.defineProperty(window.SVGPathElement.prototype, 'normalizedPathSegList', { + get: function () { + return this.pathSegList; + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathElement.prototype, 'animatedPathSegList', { + get: function () { + return this.pathSegList; + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathElement.prototype, 'animatedNormalizedPathSegList', { + get: function () { + return this.pathSegList; + }, + enumerable: true + }); + // Process any pending mutations to the path element and update the list as needed. + // This should be the first call of all public functions and is needed because + // MutationObservers are not synchronous so we can have pending asynchronous mutations. + window.SVGPathSegList.prototype._checkPathSynchronizedToList = function () { + this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords()); + }; + window.SVGPathSegList.prototype._updateListFromPathMutations = function (mutationRecords) { + if (!this._pathElement) + return; + var hasPathMutations = false; + mutationRecords.forEach(function (record) { + if (record.attributeName == 'd') + hasPathMutations = true; + }); + if (hasPathMutations) + this._list = this._parsePath(this._pathElement.getAttribute('d')); + }; + // Serialize the list and update the path's 'd' attribute. + window.SVGPathSegList.prototype._writeListToPath = function () { + this._pathElementMutationObserver.disconnect(); + this._pathElement.setAttribute('d', window.SVGPathSegList._pathSegArrayAsString(this._list)); + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + }; + // When a path segment changes the list needs to be synchronized back to the path element. + window.SVGPathSegList.prototype.segmentChanged = function (pathSeg) { + this._writeListToPath(); + }; + window.SVGPathSegList.prototype.clear = function () { + this._checkPathSynchronizedToList(); + this._list.forEach(function (pathSeg) { + pathSeg._owningPathSegList = null; + }); + this._list = []; + this._writeListToPath(); + }; + window.SVGPathSegList.prototype.initialize = function (newItem) { + this._checkPathSynchronizedToList(); + this._list = [newItem]; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem; + }; + window.SVGPathSegList.prototype._checkValidIndex = function (index) { + if (isNaN(index) || index < 0 || index >= this.numberOfItems) + throw 'INDEX_SIZE_ERR'; + }; + window.SVGPathSegList.prototype.getItem = function (index) { + this._checkPathSynchronizedToList(); + this._checkValidIndex(index); + return this._list[index]; + }; + window.SVGPathSegList.prototype.insertItemBefore = function (newItem, index) { + this._checkPathSynchronizedToList(); + // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + if (index > this.numberOfItems) + index = this.numberOfItems; + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.splice(index, 0, newItem); + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem; + }; + window.SVGPathSegList.prototype.replaceItem = function (newItem, index) { + this._checkPathSynchronizedToList(); + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._checkValidIndex(index); + this._list[index] = newItem; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem; + }; + window.SVGPathSegList.prototype.removeItem = function (index) { + this._checkPathSynchronizedToList(); + this._checkValidIndex(index); + var item = this._list[index]; + this._list.splice(index, 1); + this._writeListToPath(); + return item; + }; + window.SVGPathSegList.prototype.appendItem = function (newItem) { + this._checkPathSynchronizedToList(); + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.push(newItem); + newItem._owningPathSegList = this; + // TODO: Optimize this to just append to the existing attribute. + this._writeListToPath(); + return newItem; + }; + window.SVGPathSegList._pathSegArrayAsString = function (pathSegArray) { + var string = ''; + var first = true; + pathSegArray.forEach(function (pathSeg) { + if (first) { + first = false; + string += pathSeg._asPathString(); + } + else { + string += ' ' + pathSeg._asPathString(); + } + }); + return string; + }; + // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. + window.SVGPathSegList.prototype._parsePath = function (string) { + if (!string || string.length == 0) + return []; + var owningPathSegList = this; + var Builder = function () { + this.pathSegList = []; + }; + Builder.prototype.appendSegment = function (pathSeg) { + this.pathSegList.push(pathSeg); + }; + var Source = function (string) { + this._string = string; + this._currentIndex = 0; + this._endIndex = this._string.length; + this._previousCommand = window.SVGPathSeg.PATHSEG_UNKNOWN; + this._skipOptionalSpaces(); + }; + Source.prototype._isCurrentSpace = function () { + var character = this._string[this._currentIndex]; + return (character <= ' ' && + (character == ' ' || + character == '\n' || + character == '\t' || + character == '\r' || + character == '\f')); + }; + Source.prototype._skipOptionalSpaces = function () { + while (this._currentIndex < this._endIndex && this._isCurrentSpace()) + this._currentIndex++; + return this._currentIndex < this._endIndex; + }; + Source.prototype._skipOptionalSpacesOrDelimiter = function () { + if (this._currentIndex < this._endIndex && + !this._isCurrentSpace() && + this._string.charAt(this._currentIndex) != ',') + return false; + if (this._skipOptionalSpaces()) { + if (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == ',') { + this._currentIndex++; + this._skipOptionalSpaces(); + } + } + return this._currentIndex < this._endIndex; + }; + Source.prototype.hasMoreData = function () { + return this._currentIndex < this._endIndex; + }; + Source.prototype.peekSegmentType = function () { + var lookahead = this._string[this._currentIndex]; + return this._pathSegTypeFromChar(lookahead); + }; + Source.prototype._pathSegTypeFromChar = function (lookahead) { + switch (lookahead) { + case 'Z': + case 'z': + return window.SVGPathSeg.PATHSEG_CLOSEPATH; + case 'M': + return window.SVGPathSeg.PATHSEG_MOVETO_ABS; + case 'm': + return window.SVGPathSeg.PATHSEG_MOVETO_REL; + case 'L': + return window.SVGPathSeg.PATHSEG_LINETO_ABS; + case 'l': + return window.SVGPathSeg.PATHSEG_LINETO_REL; + case 'C': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS; + case 'c': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL; + case 'Q': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS; + case 'q': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL; + case 'A': + return window.SVGPathSeg.PATHSEG_ARC_ABS; + case 'a': + return window.SVGPathSeg.PATHSEG_ARC_REL; + case 'H': + return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS; + case 'h': + return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL; + case 'V': + return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS; + case 'v': + return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL; + case 'S': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; + case 's': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL; + case 'T': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; + case 't': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; + default: + return window.SVGPathSeg.PATHSEG_UNKNOWN; + } + }; + Source.prototype._nextCommandHelper = function (lookahead, previousCommand) { + // Check for remaining coordinates in the current command. + if ((lookahead == '+' || + lookahead == '-' || + lookahead == '.' || + (lookahead >= '0' && lookahead <= '9')) && + previousCommand != window.SVGPathSeg.PATHSEG_CLOSEPATH) { + if (previousCommand == window.SVGPathSeg.PATHSEG_MOVETO_ABS) + return window.SVGPathSeg.PATHSEG_LINETO_ABS; + if (previousCommand == window.SVGPathSeg.PATHSEG_MOVETO_REL) + return window.SVGPathSeg.PATHSEG_LINETO_REL; + return previousCommand; + } + return window.SVGPathSeg.PATHSEG_UNKNOWN; + }; + Source.prototype.initialCommandIsMoveTo = function () { + // If the path is empty it is still valid, so return true. + if (!this.hasMoreData()) + return true; + var command = this.peekSegmentType(); + // Path must start with moveTo. + return (command == window.SVGPathSeg.PATHSEG_MOVETO_ABS || + command == window.SVGPathSeg.PATHSEG_MOVETO_REL); + }; + // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF + Source.prototype._parseNumber = function () { + var exponent = 0; + var integer = 0; + var frac = 1; + var decimal = 0; + var sign = 1; + var expsign = 1; + var startIndex = this._currentIndex; + this._skipOptionalSpaces(); + // Read the sign. + if (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '+') + this._currentIndex++; + else if (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '-') { + this._currentIndex++; + sign = -1; + } + if (this._currentIndex == this._endIndex || + ((this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9') && + this._string.charAt(this._currentIndex) != '.')) + // The first character of a number must be one of [0-9+-.]. + return undefined; + // Read the integer part, build right-to-left. + var startIntPartIndex = this._currentIndex; + while (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9') + this._currentIndex++; // Advance to first non-digit. + if (this._currentIndex != startIntPartIndex) { + var scanIntPartIndex = this._currentIndex - 1; + var multiplier = 1; + while (scanIntPartIndex >= startIntPartIndex) { + integer += + multiplier * (this._string.charAt(scanIntPartIndex--) - '0'); + multiplier *= 10; + } + } + // Read the decimals. + if (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '.') { + this._currentIndex++; + // There must be a least one digit following the . + if (this._currentIndex >= this._endIndex || + this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9') + return undefined; + while (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9') { + frac *= 10; + decimal += (this._string.charAt(this._currentIndex) - '0') / frac; + this._currentIndex += 1; + } + } + // Read the exponent part. + if (this._currentIndex != startIndex && + this._currentIndex + 1 < this._endIndex && + (this._string.charAt(this._currentIndex) == 'e' || + this._string.charAt(this._currentIndex) == 'E') && + this._string.charAt(this._currentIndex + 1) != 'x' && + this._string.charAt(this._currentIndex + 1) != 'm') { + this._currentIndex++; + // Read the sign of the exponent. + if (this._string.charAt(this._currentIndex) == '+') { + this._currentIndex++; + } + else if (this._string.charAt(this._currentIndex) == '-') { + this._currentIndex++; + expsign = -1; + } + // There must be an exponent. + if (this._currentIndex >= this._endIndex || + this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9') + return undefined; + while (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9') { + exponent *= 10; + exponent += this._string.charAt(this._currentIndex) - '0'; + this._currentIndex++; + } + } + var number = integer + decimal; + number *= sign; + if (exponent) + number *= Math.pow(10, expsign * exponent); + if (startIndex == this._currentIndex) + return undefined; + this._skipOptionalSpacesOrDelimiter(); + return number; + }; + Source.prototype._parseArcFlag = function () { + if (this._currentIndex >= this._endIndex) + return undefined; + var flag = false; + var flagChar = this._string.charAt(this._currentIndex++); + if (flagChar == '0') + flag = false; + else if (flagChar == '1') + flag = true; + else + return undefined; + this._skipOptionalSpacesOrDelimiter(); + return flag; + }; + Source.prototype.parseSegment = function () { + var lookahead = this._string[this._currentIndex]; + var command = this._pathSegTypeFromChar(lookahead); + if (command == window.SVGPathSeg.PATHSEG_UNKNOWN) { + // Possibly an implicit command. Not allowed if this is the first command. + if (this._previousCommand == window.SVGPathSeg.PATHSEG_UNKNOWN) + return null; + command = this._nextCommandHelper(lookahead, this._previousCommand); + if (command == window.SVGPathSeg.PATHSEG_UNKNOWN) + return null; + } + else { + this._currentIndex++; + } + this._previousCommand = command; + switch (command) { + case window.SVGPathSeg.PATHSEG_MOVETO_REL: + return new window.SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_MOVETO_ABS: + return new window.SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_REL: + return new window.SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_ABS: + return new window.SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: + return new window.SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: + return new window.SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: + return new window.SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: + return new window.SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber()); + case window.SVGPathSeg.PATHSEG_CLOSEPATH: + this._skipOptionalSpaces(); + return new window.SVGPathSegClosePath(owningPathSegList); + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + var points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, points.x, points.y, points.x2, points.y2); + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + var points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, points.x, points.y, points.x2, points.y2); + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoQuadraticRel(owningPathSegList, points.x, points.y, points.x1, points.y1); + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoQuadraticAbs(owningPathSegList, points.x, points.y, points.x1, points.y1); + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + return new window.SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + return new window.SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_ARC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegArcRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); + case window.SVGPathSeg.PATHSEG_ARC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegArcAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); + default: + throw 'Unknown path seg type.'; + } + }; + var builder = new Builder(); + var source = new Source(string); + if (!source.initialCommandIsMoveTo()) + return []; + while (source.hasMoreData()) { + var pathSeg = source.parseSegment(); + if (!pathSeg) + return []; + builder.appendSegment(pathSeg); + } + return builder.pathSegList; + }; + } + })(); + // String.padEnd polyfill for IE11 + // + // https://github.com/uxitten/polyfill/blob/master/string.polyfill.js + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd + if (!String.prototype.padEnd) { + String.prototype.padEnd = function padEnd(targetLength, padString) { + targetLength = targetLength >> 0; //floor if number or convert non-number to 0; + padString = String(typeof padString !== 'undefined' ? padString : ' '); + if (this.length > targetLength) { + return String(this); + } + else { + targetLength = targetLength - this.length; + if (targetLength > padString.length) { + padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed + } + return String(this) + padString.slice(0, targetLength); + } + }; + } + // Object.assign polyfill for IE11 + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill + if (typeof Object.assign !== 'function') { + // Must be writable: true, enumerable: false, configurable: true + Object.defineProperty(Object, 'assign', { + value: function assign(target, varArgs) { + if (target === null || target === undefined) { + throw new TypeError('Cannot convert undefined or null to object'); + } + var to = Object(target); + for (var index = 1; index < arguments.length; index++) { + var nextSource = arguments[index]; + if (nextSource !== null && nextSource !== undefined) { + for (var nextKey in nextSource) { + // Avoid bugs when hasOwnProperty is shadowed + if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { + to[nextKey] = nextSource[nextKey]; + } + } + } + } + return to; + }, + writable: true, + configurable: true + }); + } + /* jshint ignore:end */ + + Chart.prototype.axis = function () { }; + Chart.prototype.axis.labels = function (labels) { + var $$ = this.internal; + if (arguments.length) { + Object.keys(labels).forEach(function (axisId) { + $$.axis.setLabelText(axisId, labels[axisId]); + }); + $$.axis.updateLabels(); + } + // TODO: return some values? + }; + Chart.prototype.axis.max = function (max) { + var $$ = this.internal, config = $$.config; + if (arguments.length) { + if (typeof max === 'object') { + if (isValue(max.x)) { + config.axis_x_max = max.x; + } + if (isValue(max.y)) { + config.axis_y_max = max.y; + } + if (isValue(max.y2)) { + config.axis_y2_max = max.y2; + } + } + else { + config.axis_y_max = config.axis_y2_max = max; + } + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + else { + return { + x: config.axis_x_max, + y: config.axis_y_max, + y2: config.axis_y2_max + }; + } + }; + Chart.prototype.axis.min = function (min) { + var $$ = this.internal, config = $$.config; + if (arguments.length) { + if (typeof min === 'object') { + if (isValue(min.x)) { + config.axis_x_min = min.x; + } + if (isValue(min.y)) { + config.axis_y_min = min.y; + } + if (isValue(min.y2)) { + config.axis_y2_min = min.y2; + } + } + else { + config.axis_y_min = config.axis_y2_min = min; + } + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + else { + return { + x: config.axis_x_min, + y: config.axis_y_min, + y2: config.axis_y2_min + }; + } + }; + Chart.prototype.axis.range = function (range) { + if (arguments.length) { + if (isDefined(range.max)) { + this.axis.max(range.max); + } + if (isDefined(range.min)) { + this.axis.min(range.min); + } + } + else { + return { + max: this.axis.max(), + min: this.axis.min() + }; + } + }; + Chart.prototype.axis.types = function (types) { + var $$ = this.internal; + if (types === undefined) { + return { + y: $$.config.axis_y_type, + y2: $$.config.axis_y2_type + }; + } + else { + if (isDefined(types.y)) { + $$.config.axis_y_type = types.y; + } + if (isDefined(types.y2)) { + $$.config.axis_y2_type = types.y2; + } + $$.updateScales(); + $$.redraw(); + } + }; + + Chart.prototype.category = function (i, category) { + var $$ = this.internal, config = $$.config; + if (arguments.length > 1) { + config.axis_x_categories[i] = category; + $$.redraw(); + } + return config.axis_x_categories[i]; + }; + Chart.prototype.categories = function (categories) { + var $$ = this.internal, config = $$.config; + if (!arguments.length) { + return config.axis_x_categories; + } + config.axis_x_categories = categories; + $$.redraw(); + return config.axis_x_categories; + }; + + Chart.prototype.resize = function (size) { + var $$ = this.internal, config = $$.config; + config.size_width = size ? size.width : null; + config.size_height = size ? size.height : null; + this.flush(); + }; + Chart.prototype.flush = function () { + var $$ = this.internal; + $$.updateAndRedraw({ + withLegend: true, + withTransition: false, + withTransitionForTransform: false + }); + }; + Chart.prototype.destroy = function () { + var $$ = this.internal; + window.clearInterval($$.intervalForObserveInserted); + if ($$.resizeTimeout !== undefined) { + window.clearTimeout($$.resizeTimeout); + } + window.removeEventListener('resize', $$.resizeIfElementDisplayed); + // Removes the inner resize functions + $$.resizeFunction.remove(); + // Unbinds from the window focus event + $$.unbindWindowFocus(); + $$.selectChart.classed('c3', false).html(''); + // MEMO: this is needed because the reference of some elements will not be released, then memory leak will happen. + Object.keys($$).forEach(function (key) { + $$[key] = null; + }); + return null; + }; + + // TODO: fix + Chart.prototype.color = function (id) { + var $$ = this.internal; + return $$.color(id); // more patterns + }; + + Chart.prototype.data = function (targetIds) { + var targets = this.internal.data.targets; + return typeof targetIds === 'undefined' + ? targets + : targets.filter(function (t) { + return [].concat(targetIds).indexOf(t.id) >= 0; + }); + }; + Chart.prototype.data.shown = function (targetIds) { + return this.internal.filterTargetsToShow(this.data(targetIds)); + }; + /** + * Get values of the data loaded in the chart. + * + * @param {String|Array} targetId This API returns the value of specified target. + * @param flat + * @return {Array} Data values + */ + Chart.prototype.data.values = function (targetId, flat) { + if (flat === void 0) { flat = true; } + var values = null; + if (targetId) { + var targets = this.data(targetId); + if (targets && isArray(targets)) { + values = targets.reduce(function (ret, v) { + var dataValue = v.values.map(function (d) { return d.value; }); + if (flat) { + ret = ret.concat(dataValue); + } + else { + ret.push(dataValue); + } + return ret; + }, []); + } + } + return values; + }; + Chart.prototype.data.names = function (names) { + this.internal.clearLegendItemTextBoxCache(); + return this.internal.updateDataAttributes('names', names); + }; + Chart.prototype.data.colors = function (colors) { + return this.internal.updateDataAttributes('colors', colors); + }; + Chart.prototype.data.axes = function (axes) { + return this.internal.updateDataAttributes('axes', axes); + }; + Chart.prototype.data.stackNormalized = function (normalized) { + if (normalized === undefined) { + return this.internal.isStackNormalized(); + } + this.internal.config.data_stack_normalize = !!normalized; + this.internal.redraw(); + }; + + Chart.prototype.donut = function () { }; + Chart.prototype.donut.padAngle = function (padAngle) { + if (padAngle === undefined) { + return this.internal.config.donut_padAngle; + } + this.internal.config.donut_padAngle = padAngle; + this.flush(); + }; + + Chart.prototype.flow = function (args) { + var $$ = this.internal, targets, data, notfoundIds = [], orgDataCount = $$.getMaxDataCount(), dataCount, domain, baseTarget, baseValue, length = 0, tail = 0, diff, to; + if (args.json) { + data = $$.convertJsonToData(args.json, args.keys); + } + else if (args.rows) { + data = $$.convertRowsToData(args.rows); + } + else if (args.columns) { + data = $$.convertColumnsToData(args.columns); + } + else { + return; + } + targets = $$.convertDataToTargets(data, true); + // Update/Add data + $$.data.targets.forEach(function (t) { + var found = false, i, j; + for (i = 0; i < targets.length; i++) { + if (t.id === targets[i].id) { + found = true; + if (t.values[t.values.length - 1]) { + tail = t.values[t.values.length - 1].index + 1; + } + length = targets[i].values.length; + for (j = 0; j < length; j++) { + targets[i].values[j].index = tail + j; + if (!$$.isTimeSeries()) { + targets[i].values[j].x = tail + j; + } + } + t.values = t.values.concat(targets[i].values); + targets.splice(i, 1); + break; + } + } + if (!found) { + notfoundIds.push(t.id); + } + }); + // Append null for not found targets + $$.data.targets.forEach(function (t) { + var i, j; + for (i = 0; i < notfoundIds.length; i++) { + if (t.id === notfoundIds[i]) { + tail = t.values[t.values.length - 1].index + 1; + for (j = 0; j < length; j++) { + t.values.push({ + id: t.id, + index: tail + j, + x: $$.isTimeSeries() ? $$.getOtherTargetX(tail + j) : tail + j, + value: null + }); + } + } + } + }); + // Generate null values for new target + if ($$.data.targets.length) { + targets.forEach(function (t) { + var i, missing = []; + for (i = $$.data.targets[0].values[0].index; i < tail; i++) { + missing.push({ + id: t.id, + index: i, + x: $$.isTimeSeries() ? $$.getOtherTargetX(i) : i, + value: null + }); + } + t.values.forEach(function (v) { + v.index += tail; + if (!$$.isTimeSeries()) { + v.x += tail; + } + }); + t.values = missing.concat(t.values); + }); + } + $$.data.targets = $$.data.targets.concat(targets); // add remained + // check data count because behavior needs to change when it's only one + dataCount = $$.getMaxDataCount(); + baseTarget = $$.data.targets[0]; + baseValue = baseTarget.values[0]; + // Update length to flow if needed + if (isDefined(args.to)) { + length = 0; + to = $$.isTimeSeries() ? $$.parseDate(args.to) : args.to; + baseTarget.values.forEach(function (v) { + if (v.x < to) { + length++; + } + }); + } + else if (isDefined(args.length)) { + length = args.length; + } + // If only one data, update the domain to flow from left edge of the chart + if (!orgDataCount) { + if ($$.isTimeSeries()) { + if (baseTarget.values.length > 1) { + diff = baseTarget.values[baseTarget.values.length - 1].x - baseValue.x; + } + else { + diff = baseValue.x - $$.getXDomain($$.data.targets)[0]; + } + } + else { + diff = 1; + } + domain = [baseValue.x - diff, baseValue.x]; + $$.updateXDomain(null, true, true, false, domain); + } + else if (orgDataCount === 1) { + if ($$.isTimeSeries()) { + diff = + (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2; + domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)]; + $$.updateXDomain(null, true, true, false, domain); + } + } + // Set targets + $$.updateTargets($$.data.targets); + // Redraw with new targets + $$.redraw({ + flow: { + index: baseValue.index, + length: length, + duration: isValue(args.duration) + ? args.duration + : $$.config.transition_duration, + done: args.done, + orgDataCount: orgDataCount + }, + withLegend: true, + withTransition: orgDataCount > 1, + withTrimXDomain: false, + withUpdateXAxis: true + }); + }; + ChartInternal.prototype.generateFlow = function (args) { + var $$ = this, config = $$.config, d3 = $$.d3; + return function () { + var targets = args.targets, flow = args.flow, drawBar = args.drawBar, drawLine = args.drawLine, drawArea = args.drawArea, cx = args.cx, cy = args.cy, xv = args.xv, xForText = args.xForText, yForText = args.yForText, duration = args.duration; + var translateX, scaleX = 1, transform, flowIndex = flow.index, flowLength = flow.length, flowStart = $$.getValueOnIndex($$.data.targets[0].values, flowIndex), flowEnd = $$.getValueOnIndex($$.data.targets[0].values, flowIndex + flowLength), orgDomain = $$.x.domain(), domain, durationForFlow = flow.duration || duration, done = flow.done || function () { }, wait = $$.generateWait(); + var xgrid, xgridLines, mainRegion, mainText, mainBar, mainLine, mainArea, mainCircle; + // set flag + $$.flowing = true; + // remove head data after rendered + $$.data.targets.forEach(function (d) { + d.values.splice(0, flowLength); + }); + // update x domain to generate axis elements for flow + domain = $$.updateXDomain(targets, true, true); + // update elements related to x scale + if ($$.updateXGrid) { + $$.updateXGrid(true); + } + xgrid = $$.xgrid || d3.selectAll([]); // xgrid needs to be obtained after updateXGrid + xgridLines = $$.xgridLines || d3.selectAll([]); + mainRegion = $$.mainRegion || d3.selectAll([]); + mainText = $$.mainText || d3.selectAll([]); + mainBar = $$.mainBar || d3.selectAll([]); + mainLine = $$.mainLine || d3.selectAll([]); + mainArea = $$.mainArea || d3.selectAll([]); + mainCircle = $$.mainCircle || d3.selectAll([]); + // generate transform to flow + if (!flow.orgDataCount) { + // if empty + if ($$.data.targets[0].values.length !== 1) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } + else { + if ($$.isTimeSeries()) { + flowStart = $$.getValueOnIndex($$.data.targets[0].values, 0); + flowEnd = $$.getValueOnIndex($$.data.targets[0].values, $$.data.targets[0].values.length - 1); + translateX = $$.x(flowStart.x) - $$.x(flowEnd.x); + } + else { + translateX = diffDomain(domain) / 2; + } + } + } + else if (flow.orgDataCount === 1 || + (flowStart && flowStart.x) === (flowEnd && flowEnd.x)) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } + else { + if ($$.isTimeSeries()) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } + else { + translateX = $$.x(flowStart.x) - $$.x(flowEnd.x); + } + } + scaleX = diffDomain(orgDomain) / diffDomain(domain); + transform = 'translate(' + translateX + ',0) scale(' + scaleX + ',1)'; + $$.hideXGridFocus(); + var flowTransition = d3 + .transition() + .ease(d3.easeLinear) + .duration(durationForFlow); + wait.add($$.xAxis($$.axes.x, flowTransition)); + wait.add(mainBar.transition(flowTransition).attr('transform', transform)); + wait.add(mainLine.transition(flowTransition).attr('transform', transform)); + wait.add(mainArea.transition(flowTransition).attr('transform', transform)); + wait.add(mainCircle.transition(flowTransition).attr('transform', transform)); + wait.add(mainText.transition(flowTransition).attr('transform', transform)); + wait.add(mainRegion + .filter($$.isRegionOnX) + .transition(flowTransition) + .attr('transform', transform)); + wait.add(xgrid.transition(flowTransition).attr('transform', transform)); + wait.add(xgridLines.transition(flowTransition).attr('transform', transform)); + wait(function () { + var i, shapes = [], texts = []; + // remove flowed elements + if (flowLength) { + for (i = 0; i < flowLength; i++) { + shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); + texts.push('.' + CLASS.text + '-' + (flowIndex + i)); + } + $$.svg + .selectAll('.' + CLASS.shapes) + .selectAll(shapes) + .remove(); + $$.svg + .selectAll('.' + CLASS.texts) + .selectAll(texts) + .remove(); + $$.svg.select('.' + CLASS.xgrid).remove(); + } + // draw again for removing flowed elements and reverting attr + xgrid + .attr('transform', null) + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', $$.xgridAttr.opacity); + xgridLines.attr('transform', null); + xgridLines + .select('line') + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv); + xgridLines + .select('text') + .attr('x', config.axis_rotated ? $$.width : 0) + .attr('y', xv); + mainBar.attr('transform', null).attr('d', drawBar); + mainLine.attr('transform', null).attr('d', drawLine); + mainArea.attr('transform', null).attr('d', drawArea); + mainCircle + .attr('transform', null) + .attr('cx', cx) + .attr('cy', cy); + mainText + .attr('transform', null) + .attr('x', xForText) + .attr('y', yForText) + .style('fill-opacity', $$.opacityForText.bind($$)); + mainRegion.attr('transform', null); + mainRegion + .filter($$.isRegionOnX) + .attr('x', $$.regionX.bind($$)) + .attr('width', $$.regionWidth.bind($$)); + // callback for end of flow + done(); + $$.flowing = false; + }); + }; + }; + + Chart.prototype.focus = function (targetIds) { + var $$ = this.internal, candidates; + targetIds = $$.mapToTargetIds(targetIds); + (candidates = $$.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)))), + this.revert(); + this.defocus(); + candidates.classed(CLASS.focused, true).classed(CLASS.defocused, false); + if ($$.hasArcType()) { + $$.expandArc(targetIds); + } + $$.toggleFocusLegend(targetIds, true); + $$.focusedTargetIds = targetIds; + $$.defocusedTargetIds = $$.defocusedTargetIds.filter(function (id) { + return targetIds.indexOf(id) < 0; + }); + }; + Chart.prototype.defocus = function (targetIds) { + var $$ = this.internal, candidates; + targetIds = $$.mapToTargetIds(targetIds); + (candidates = $$.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)))), + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, true); + if ($$.hasArcType()) { + $$.unexpandArc(targetIds); + } + $$.toggleFocusLegend(targetIds, false); + $$.focusedTargetIds = $$.focusedTargetIds.filter(function (id) { + return targetIds.indexOf(id) < 0; + }); + $$.defocusedTargetIds = targetIds; + }; + Chart.prototype.revert = function (targetIds) { + var $$ = this.internal, candidates; + targetIds = $$.mapToTargetIds(targetIds); + candidates = $$.svg.selectAll($$.selectorTargets(targetIds)); // should be for all targets + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, false); + if ($$.hasArcType()) { + $$.unexpandArc(targetIds); + } + if ($$.config.legend_show) { + $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$))); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .filter(function () { + return $$.d3.select(this).classed(CLASS.legendItemFocused); + }) + .classed(CLASS.legendItemFocused, false); + } + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; + }; + + Chart.prototype.xgrids = function (grids) { + var $$ = this.internal, config = $$.config; + if (!grids) { + return config.grid_x_lines; + } + config.grid_x_lines = grids; + $$.redrawWithoutRescale(); + return config.grid_x_lines; + }; + Chart.prototype.xgrids.add = function (grids) { + var $$ = this.internal; + return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : [])); + }; + Chart.prototype.xgrids.remove = function (params) { + // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, true); + }; + Chart.prototype.ygrids = function (grids) { + var $$ = this.internal, config = $$.config; + if (!grids) { + return config.grid_y_lines; + } + config.grid_y_lines = grids; + $$.redrawWithoutRescale(); + return config.grid_y_lines; + }; + Chart.prototype.ygrids.add = function (grids) { + var $$ = this.internal; + return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : [])); + }; + Chart.prototype.ygrids.remove = function (params) { + // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, false); + }; + + Chart.prototype.groups = function (groups) { + var $$ = this.internal, config = $$.config; + if (isUndefined(groups)) { + return config.data_groups; + } + config.data_groups = groups; + $$.redraw(); + return config.data_groups; + }; + + Chart.prototype.legend = function () { }; + Chart.prototype.legend.show = function (targetIds) { + var $$ = this.internal; + $$.showLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({ withLegend: true }); + }; + Chart.prototype.legend.hide = function (targetIds) { + var $$ = this.internal; + $$.hideLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({ withLegend: false }); + }; + + Chart.prototype.load = function (args) { + var $$ = this.internal, config = $$.config; + // update xs if specified + if (args.xs) { + $$.addXs(args.xs); + } + // update names if exists + if ('names' in args) { + Chart.prototype.data.names.bind(this)(args.names); + } + // update classes if exists + if ('classes' in args) { + Object.keys(args.classes).forEach(function (id) { + config.data_classes[id] = args.classes[id]; + }); + } + // update categories if exists + if ('categories' in args && $$.isCategorized()) { + config.axis_x_categories = args.categories; + } + // update axes if exists + if ('axes' in args) { + Object.keys(args.axes).forEach(function (id) { + config.data_axes[id] = args.axes[id]; + }); + } + // update colors if exists + if ('colors' in args) { + Object.keys(args.colors).forEach(function (id) { + config.data_colors[id] = args.colors[id]; + }); + } + // use cache if exists + if ('cacheIds' in args && $$.hasCaches(args.cacheIds)) { + $$.load($$.getCaches(args.cacheIds), args.done); + return; + } + // unload if needed + if (args.unload) { + // TODO: do not unload if target will load (included in url/rows/columns) + $$.unload($$.mapToTargetIds(args.unload === true ? null : args.unload), function () { + $$.loadFromArgs(args); + }); + } + else { + $$.loadFromArgs(args); + } + }; + Chart.prototype.unload = function (args) { + var $$ = this.internal; + args = args || {}; + if (args instanceof Array) { + args = { ids: args }; + } + else if (typeof args === 'string') { + args = { ids: [args] }; + } + $$.unload($$.mapToTargetIds(args.ids), function () { + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + if (args.done) { + args.done(); + } + }); + }; + + Chart.prototype.pie = function () { }; + Chart.prototype.pie.padAngle = function (padAngle) { + if (padAngle === undefined) { + return this.internal.config.pie_padAngle; + } + this.internal.config.pie_padAngle = padAngle; + this.flush(); + }; + + Chart.prototype.regions = function (regions) { + var $$ = this.internal, config = $$.config; + if (!regions) { + return config.regions; + } + config.regions = regions; + $$.redrawWithoutRescale(); + return config.regions; + }; + Chart.prototype.regions.add = function (regions) { + var $$ = this.internal, config = $$.config; + if (!regions) { + return config.regions; + } + config.regions = config.regions.concat(regions); + $$.redrawWithoutRescale(); + return config.regions; + }; + Chart.prototype.regions.remove = function (options) { + var $$ = this.internal, config = $$.config, duration, classes, regions; + options = options || {}; + duration = getOption(options, 'duration', config.transition_duration); + classes = getOption(options, 'classes', [CLASS.region]); + regions = $$.main.select('.' + CLASS.regions).selectAll(classes.map(function (c) { + return '.' + c; + })); + (duration ? regions.transition().duration(duration) : regions) + .style('opacity', 0) + .remove(); + config.regions = config.regions.filter(function (region) { + var found = false; + if (!region['class']) { + return true; + } + region['class'].split(' ').forEach(function (c) { + if (classes.indexOf(c) >= 0) { + found = true; + } + }); + return !found; + }); + return config.regions; + }; + + Chart.prototype.selected = function (targetId) { + var $$ = this.internal, d3 = $$.d3; + return $$.main + .selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)) + .selectAll('.' + CLASS.shape) + .filter(function () { + return d3.select(this).classed(CLASS.SELECTED); + }) + .nodes() + .map(function (d) { + var data = d.__data__; + return data.data ? data.data : data; + }); + }; + Chart.prototype.select = function (ids, indices, resetOther) { + var $$ = this.internal, d3 = $$.d3, config = $$.config; + if (!config.data_selection_enabled) { + return; + } + $$.main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function (d, i) { + var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this, d).bind($$), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS.SELECTED); + // line/area selection not supported yet + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { + return; + } + if (isTargetId && isTargetIndex) { + if (config.data_selection_isselectable(d) && !isSelected) { + toggle(true, shape.classed(CLASS.SELECTED, true), d, i); + } + } + else if (isDefined(resetOther) && resetOther) { + if (isSelected) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + } + }); + }; + Chart.prototype.unselect = function (ids, indices) { + var $$ = this.internal, d3 = $$.d3, config = $$.config; + if (!config.data_selection_enabled) { + return; + } + $$.main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function (d, i) { + var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this, d).bind($$), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS.SELECTED); + // line/area selection not supported yet + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { + return; + } + if (isTargetId && isTargetIndex) { + if (config.data_selection_isselectable(d)) { + if (isSelected) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + } + } + }); + }; + + Chart.prototype.show = function (targetIds, options) { + var $$ = this.internal, targets; + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + $$.removeHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + targets + .transition() + .style('display', isIE() ? 'block' : 'initial', 'important') + .style('opacity', 1, 'important') + .call($$.endall, function () { + targets.style('opacity', null).style('opacity', 1); + }); + if (options.withLegend) { + $$.showLegend(targetIds); + } + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + }; + Chart.prototype.hide = function (targetIds, options) { + var $$ = this.internal, targets; + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + $$.addHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + targets + .transition() + .style('opacity', 0, 'important') + .call($$.endall, function () { + targets.style('opacity', null).style('opacity', 0); + targets.style('display', 'none'); + }); + if (options.withLegend) { + $$.hideLegend(targetIds); + } + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + }; + Chart.prototype.toggle = function (targetIds, options) { + var that = this, $$ = this.internal; + $$.mapToTargetIds(targetIds).forEach(function (targetId) { + $$.isTargetToShow(targetId) + ? that.hide(targetId, options) + : that.show(targetId, options); + }); + }; + + Chart.prototype.subchart = function () { }; + Chart.prototype.subchart.isShown = function () { + var $$ = this.internal; + return $$.config.subchart_show; + }; + Chart.prototype.subchart.show = function () { + var $$ = this.internal; + if ($$.config.subchart_show) { + return; + } + $$.config.subchart_show = true; + // insert DOM + $$.initSubchart(); + // update dimensions with sub chart now visible + $$.updateDimension(); + // insert brush (depends on sizes previously updated) + $$.initSubchartBrush(); + // attach data + $$.updateTargetsForSubchart($$.getTargets()); + // reset fade-in state + $$.mapToIds($$.data.targets).forEach(function (id) { + $$.withoutFadeIn[id] = false; + }); + // redraw chart ! + $$.updateAndRedraw(); + // update visible targets ! + $$.showTargets(); + }; + Chart.prototype.subchart.hide = function () { + var $$ = this.internal; + if (!$$.config.subchart_show) { + return; + } + $$.config.subchart_show = false; + // remove DOM + $$.removeSubchart(); + // re-render chart + $$.redraw(); + }; + + Chart.prototype.tooltip = function () { }; + Chart.prototype.tooltip.show = function (args) { + var $$ = this.internal, targets, data, mouse = {}; + // determine mouse position on the chart + if (args.mouse) { + mouse = args.mouse; + } + else { + // determine focus data + if (args.data) { + data = args.data; + } + else if (typeof args.x !== 'undefined') { + if (args.id) { + targets = $$.data.targets.filter(function (t) { + return t.id === args.id; + }); + } + else { + targets = $$.data.targets; + } + data = $$.filterByX(targets, args.x).slice(0, 1)[0]; + } + mouse = data ? $$.getMousePosition(data) : null; + } + // emulate mouse events to show + $$.dispatchEvent('mousemove', mouse); + $$.config.tooltip_onshow.call($$, data); + }; + Chart.prototype.tooltip.hide = function () { + // TODO: get target data by checking the state of focus + this.internal.dispatchEvent('mouseout', 0); + this.internal.config.tooltip_onhide.call(this); + }; + + Chart.prototype.transform = function (type, targetIds) { + var $$ = this.internal, options = ['pie', 'donut'].indexOf(type) >= 0 ? { withTransform: true } : null; + $$.transformTo(targetIds, type, options); + }; + ChartInternal.prototype.transformTo = function (targetIds, type, optionsForRedraw) { + var $$ = this, withTransitionForAxis = !$$.hasArcType(), options = optionsForRedraw || { + withTransitionForAxis: withTransitionForAxis + }; + options.withTransitionForTransform = false; + $$.transiting = false; + $$.setTargetType(targetIds, type); + $$.updateTargets($$.data.targets); // this is needed when transforming to arc + $$.updateAndRedraw(options); + }; + + Chart.prototype.x = function (x) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetX($$.data.targets, x); + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + return $$.data.xs; + }; + Chart.prototype.xs = function (xs) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetXs($$.data.targets, xs); + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + return $$.data.xs; + }; + + Chart.prototype.zoom = function (domain) { + var $$ = this.internal; + if (domain) { + if ($$.isTimeSeries()) { + domain = domain.map(function (x) { + return $$.parseDate(x); + }); + } + if ($$.config.subchart_show) { + $$.brush.selectionAsValue(domain, true); + } + else { + $$.updateXDomain(null, true, false, false, domain); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } + $$.config.zoom_onzoom.call(this, $$.x.orgDomain()); + return domain; + } + else { + return $$.x.domain(); + } + }; + Chart.prototype.zoom.enable = function (enabled) { + var $$ = this.internal; + $$.config.zoom_enabled = enabled; + $$.updateAndRedraw(); + }; + Chart.prototype.unzoom = function () { + var $$ = this.internal; + if ($$.config.subchart_show) { + $$.brush.clear(); + } + else { + $$.updateXDomain(null, true, false, false, $$.subX.domain()); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } + }; + Chart.prototype.zoom.max = function (max) { + var $$ = this.internal, config = $$.config, d3 = $$.d3; + if (max === 0 || max) { + config.zoom_x_max = d3.max([$$.orgXDomain[1], max]); + } + else { + return config.zoom_x_max; + } + }; + Chart.prototype.zoom.min = function (min) { + var $$ = this.internal, config = $$.config, d3 = $$.d3; + if (min === 0 || min) { + config.zoom_x_min = d3.min([$$.orgXDomain[0], min]); + } + else { + return config.zoom_x_min; + } + }; + Chart.prototype.zoom.range = function (range) { + if (arguments.length) { + if (isDefined(range.max)) { + this.domain.max(range.max); + } + if (isDefined(range.min)) { + this.domain.min(range.min); + } + } + else { + return { + max: this.domain.max(), + min: this.domain.min() + }; + } + }; + + ChartInternal.prototype.initPie = function () { + var $$ = this, d3 = $$.d3; + $$.pie = d3 + .pie() + .padAngle(this.getPadAngle.bind(this)) + .value(function (d) { + return d.values.reduce(function (a, b) { + return a + b.value; + }, 0); + }); + var orderFct = $$.getOrderFunction(); + // we need to reverse the returned order if asc or desc to have the slice in expected order. + if (orderFct && ($$.isOrderAsc() || $$.isOrderDesc())) { + var defaultSort_1 = orderFct; + orderFct = function (t1, t2) { return defaultSort_1(t1, t2) * -1; }; + } + $$.pie.sort(orderFct || null); + }; + ChartInternal.prototype.updateRadius = function () { + var $$ = this, config = $$.config, w = config.gauge_width || config.donut_width, gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length * + $$.config.gauge_arcs_minWidth; + $$.radiusExpanded = + (Math.min($$.arcWidth, $$.arcHeight) / 2) * ($$.hasType('gauge') ? 0.85 : 1); + $$.radius = $$.radiusExpanded * 0.95; + $$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6; + $$.innerRadius = + $$.hasType('donut') || $$.hasType('gauge') + ? $$.radius * $$.innerRadiusRatio + : 0; + $$.gaugeArcWidth = w + ? w + : gaugeArcWidth <= $$.radius - $$.innerRadius + ? $$.radius - $$.innerRadius + : gaugeArcWidth <= $$.radius + ? gaugeArcWidth + : $$.radius; + }; + ChartInternal.prototype.getPadAngle = function () { + if (this.hasType('pie')) { + return this.config.pie_padAngle || 0; + } + else if (this.hasType('donut')) { + return this.config.donut_padAngle || 0; + } + else { + return 0; + } + }; + ChartInternal.prototype.updateArc = function () { + var $$ = this; + $$.svgArc = $$.getSvgArc(); + $$.svgArcExpanded = $$.getSvgArcExpanded(); + $$.svgArcExpandedSub = $$.getSvgArcExpanded(0.98); + }; + ChartInternal.prototype.updateAngle = function (d) { + var $$ = this, config = $$.config, found = false, index = 0, gMin, gMax, gTic, gValue; + if (!config) { + return null; + } + $$.pie($$.filterTargetsToShow($$.data.targets)).forEach(function (t) { + if (!found && t.data.id === d.data.id) { + found = true; + d = t; + d.index = index; + } + index++; + }); + if (isNaN(d.startAngle)) { + d.startAngle = 0; + } + if (isNaN(d.endAngle)) { + d.endAngle = d.startAngle; + } + if ($$.isGaugeType(d.data)) { + gMin = config.gauge_min; + gMax = config.gauge_max; + gTic = (Math.PI * (config.gauge_fullCircle ? 2 : 1)) / (gMax - gMin); + gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : gMax - gMin; + d.startAngle = config.gauge_startingAngle; + d.endAngle = d.startAngle + gTic * gValue; + } + return found ? d : null; + }; + ChartInternal.prototype.getSvgArc = function () { + var $$ = this, hasGaugeType = $$.hasType('gauge'), singleArcWidth = $$.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length, arc = $$.d3 + .arc() + .outerRadius(function (d) { + return hasGaugeType ? $$.radius - singleArcWidth * d.index : $$.radius; + }) + .innerRadius(function (d) { + return hasGaugeType + ? $$.radius - singleArcWidth * (d.index + 1) + : $$.innerRadius; + }), newArc = function (d, withoutUpdate) { + var updated; + if (withoutUpdate) { + return arc(d); + } // for interpolate + updated = $$.updateAngle(d); + return updated ? arc(updated) : 'M 0 0'; + }; + newArc.centroid = arc.centroid; + return newArc; + }; + ChartInternal.prototype.getSvgArcExpanded = function (rate) { + rate = rate || 1; + var $$ = this, hasGaugeType = $$.hasType('gauge'), singleArcWidth = $$.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length, expandWidth = Math.min($$.radiusExpanded * rate - $$.radius, singleArcWidth * 0.8 - (1 - rate) * 100), arc = $$.d3 + .arc() + .outerRadius(function (d) { + return hasGaugeType + ? $$.radius - singleArcWidth * d.index + expandWidth + : $$.radiusExpanded * rate; + }) + .innerRadius(function (d) { + return hasGaugeType + ? $$.radius - singleArcWidth * (d.index + 1) + : $$.innerRadius; + }); + return function (d) { + var updated = $$.updateAngle(d); + return updated ? arc(updated) : 'M 0 0'; + }; + }; + ChartInternal.prototype.getArc = function (d, withoutUpdate, force) { + return force || this.isArcType(d.data) + ? this.svgArc(d, withoutUpdate) + : 'M 0 0'; + }; + ChartInternal.prototype.transformForArcLabel = function (d) { + var $$ = this, config = $$.config, updated = $$.updateAngle(d), c, x, y, h, ratio, translate = '', hasGauge = $$.hasType('gauge'); + if (updated && !hasGauge) { + c = this.svgArc.centroid(updated); + x = isNaN(c[0]) ? 0 : c[0]; + y = isNaN(c[1]) ? 0 : c[1]; + h = Math.sqrt(x * x + y * y); + if ($$.hasType('donut') && config.donut_label_ratio) { + ratio = isFunction(config.donut_label_ratio) + ? config.donut_label_ratio(d, $$.radius, h) + : config.donut_label_ratio; + } + else if ($$.hasType('pie') && config.pie_label_ratio) { + ratio = isFunction(config.pie_label_ratio) + ? config.pie_label_ratio(d, $$.radius, h) + : config.pie_label_ratio; + } + else { + ratio = + $$.radius && h + ? ((36 / $$.radius > 0.375 ? 1.175 - 36 / $$.radius : 0.8) * + $$.radius) / + h + : 0; + } + translate = 'translate(' + x * ratio + ',' + y * ratio + ')'; + } + else if (updated && + hasGauge && + $$.filterTargetsToShow($$.data.targets).length > 1) { + var y1 = Math.sin(updated.endAngle - Math.PI / 2); + x = Math.cos(updated.endAngle - Math.PI / 2) * ($$.radiusExpanded + 25); + y = y1 * ($$.radiusExpanded + 15 - Math.abs(y1 * 10)) + 3; + translate = 'translate(' + x + ',' + y + ')'; + } + return translate; + }; + /** + * @deprecated Use `getRatio('arc', d)` instead. + */ + ChartInternal.prototype.getArcRatio = function (d) { + return this.getRatio('arc', d); + }; + ChartInternal.prototype.convertToArcData = function (d) { + return this.addName({ + id: d.data.id, + value: d.value, + ratio: this.getRatio('arc', d), + index: d.index + }); + }; + ChartInternal.prototype.textForArcLabel = function (d) { + var $$ = this, updated, value, ratio, id, format; + if (!$$.shouldShowArcLabel()) { + return ''; + } + updated = $$.updateAngle(d); + value = updated ? updated.value : null; + ratio = $$.getRatio('arc', updated); + id = d.data.id; + if (!$$.hasType('gauge') && !$$.meetsArcLabelThreshold(ratio)) { + return ''; + } + format = $$.getArcLabelFormat(); + return format + ? format(value, ratio, id) + : $$.defaultArcValueFormat(value, ratio); + }; + ChartInternal.prototype.textForGaugeMinMax = function (value, isMax) { + var $$ = this, format = $$.getGaugeLabelExtents(); + return format ? format(value, isMax) : value; + }; + ChartInternal.prototype.expandArc = function (targetIds) { + var $$ = this, interval; + // MEMO: avoid to cancel transition + if ($$.transiting) { + interval = window.setInterval(function () { + if (!$$.transiting) { + window.clearInterval(interval); + if ($$.legend.selectAll('.c3-legend-item-focused').size() > 0) { + $$.expandArc(targetIds); + } + } + }, 10); + return; + } + targetIds = $$.mapToTargetIds(targetIds); + $$.svg + .selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)) + .each(function (d) { + if (!$$.shouldExpand(d.data.id)) { + return; + } + $$.d3 + .select(this) + .selectAll('path') + .transition() + .duration($$.expandDuration(d.data.id)) + .attr('d', $$.svgArcExpanded) + .transition() + .duration($$.expandDuration(d.data.id) * 2) + .attr('d', $$.svgArcExpandedSub) + .each(function (d) { + if ($$.isDonutType(d.data)) ; + }); + }); + }; + ChartInternal.prototype.unexpandArc = function (targetIds) { + var $$ = this; + if ($$.transiting) { + return; + } + targetIds = $$.mapToTargetIds(targetIds); + $$.svg + .selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)) + .selectAll('path') + .transition() + .duration(function (d) { + return $$.expandDuration(d.data.id); + }) + .attr('d', $$.svgArc); + $$.svg.selectAll('.' + CLASS.arc); + }; + ChartInternal.prototype.expandDuration = function (id) { + var $$ = this, config = $$.config; + if ($$.isDonutType(id)) { + return config.donut_expand_duration; + } + else if ($$.isGaugeType(id)) { + return config.gauge_expand_duration; + } + else if ($$.isPieType(id)) { + return config.pie_expand_duration; + } + else { + return 50; + } + }; + ChartInternal.prototype.shouldExpand = function (id) { + var $$ = this, config = $$.config; + return (($$.isDonutType(id) && config.donut_expand) || + ($$.isGaugeType(id) && config.gauge_expand) || + ($$.isPieType(id) && config.pie_expand)); + }; + ChartInternal.prototype.shouldShowArcLabel = function () { + var $$ = this, config = $$.config, shouldShow = true; + if ($$.hasType('donut')) { + shouldShow = config.donut_label_show; + } + else if ($$.hasType('pie')) { + shouldShow = config.pie_label_show; + } + // when gauge, always true + return shouldShow; + }; + ChartInternal.prototype.meetsArcLabelThreshold = function (ratio) { + var $$ = this, config = $$.config, threshold = $$.hasType('donut') + ? config.donut_label_threshold + : config.pie_label_threshold; + return ratio >= threshold; + }; + ChartInternal.prototype.getArcLabelFormat = function () { + var $$ = this, config = $$.config, format = config.pie_label_format; + if ($$.hasType('gauge')) { + format = config.gauge_label_format; + } + else if ($$.hasType('donut')) { + format = config.donut_label_format; + } + return format; + }; + ChartInternal.prototype.getGaugeLabelExtents = function () { + var $$ = this, config = $$.config; + return config.gauge_label_extents; + }; + ChartInternal.prototype.getArcTitle = function () { + var $$ = this; + return $$.hasType('donut') ? $$.config.donut_title : ''; + }; + ChartInternal.prototype.updateTargetsForArc = function (targets) { + var $$ = this, main = $$.main, mainPies, mainPieEnter, classChartArc = $$.classChartArc.bind($$), classArcs = $$.classArcs.bind($$), classFocus = $$.classFocus.bind($$); + mainPies = main + .select('.' + CLASS.chartArcs) + .selectAll('.' + CLASS.chartArc) + .data($$.pie(targets)) + .attr('class', function (d) { + return classChartArc(d) + classFocus(d.data); + }); + mainPieEnter = mainPies + .enter() + .append('g') + .attr('class', classChartArc); + mainPieEnter.append('g').attr('class', classArcs); + mainPieEnter + .append('text') + .attr('dy', $$.hasType('gauge') ? '-.1em' : '.35em') + .style('opacity', 0) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + // MEMO: can not keep same color..., but not bad to update color in redraw + //mainPieUpdate.exit().remove(); + }; + ChartInternal.prototype.initArc = function () { + var $$ = this; + $$.arcs = $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartArcs) + .attr('transform', $$.getTranslate('arc')); + $$.arcs + .append('text') + .attr('class', CLASS.chartArcsTitle) + .style('text-anchor', 'middle') + .text($$.getArcTitle()); + }; + ChartInternal.prototype.redrawArc = function (duration, durationForExit, withTransform) { + var $$ = this, d3 = $$.d3, config = $$.config, main = $$.main, arcs, mainArc, arcLabelLines, mainArcLabelLine, hasGaugeType = $$.hasType('gauge'); + arcs = main + .selectAll('.' + CLASS.arcs) + .selectAll('.' + CLASS.arc) + .data($$.arcData.bind($$)); + mainArc = arcs + .enter() + .append('path') + .attr('class', $$.classArc.bind($$)) + .style('fill', function (d) { + return $$.color(d.data); + }) + .style('cursor', function (d) { + return config.interaction_enabled && config.data_selection_isselectable(d) + ? 'pointer' + : null; + }) + .each(function (d) { + if ($$.isGaugeType(d.data)) { + d.startAngle = d.endAngle = config.gauge_startingAngle; + } + this._current = d; + }) + .merge(arcs); + if (hasGaugeType) { + arcLabelLines = main + .selectAll('.' + CLASS.arcs) + .selectAll('.' + CLASS.arcLabelLine) + .data($$.arcData.bind($$)); + mainArcLabelLine = arcLabelLines + .enter() + .append('rect') + .attr('class', function (d) { + return (CLASS.arcLabelLine + + ' ' + + CLASS.target + + ' ' + + CLASS.target + + '-' + + d.data.id); + }) + .merge(arcLabelLines); + if ($$.filterTargetsToShow($$.data.targets).length === 1) { + mainArcLabelLine.style('display', 'none'); + } + else { + mainArcLabelLine + .style('fill', function (d) { + return $$.levelColor + ? $$.levelColor(d.data.values.reduce(function (total, item) { + return total + item.value; + }, 0)) + : $$.color(d.data); + }) + .style('display', config.gauge_labelLine_show ? '' : 'none') + .each(function (d) { + var lineLength = 0, lineThickness = 2, x = 0, y = 0, transform = ''; + if ($$.hiddenTargetIds.indexOf(d.data.id) < 0) { + var updated = $$.updateAngle(d), innerLineLength = ($$.gaugeArcWidth / + $$.filterTargetsToShow($$.data.targets).length) * + (updated.index + 1), lineAngle = updated.endAngle - Math.PI / 2, arcInnerRadius = $$.radius - innerLineLength, linePositioningAngle = lineAngle - (arcInnerRadius === 0 ? 0 : 1 / arcInnerRadius); + lineLength = $$.radiusExpanded - $$.radius + innerLineLength; + x = Math.cos(linePositioningAngle) * arcInnerRadius; + y = Math.sin(linePositioningAngle) * arcInnerRadius; + transform = + 'rotate(' + + (lineAngle * 180) / Math.PI + + ', ' + + x + + ', ' + + y + + ')'; + } + d3.select(this) + .attr('x', x) + .attr('y', y) + .attr('width', lineLength) + .attr('height', lineThickness) + .attr('transform', transform) + .style('stroke-dasharray', '0, ' + (lineLength + lineThickness) + ', 0'); + }); + } + } + mainArc + .attr('transform', function (d) { + return !$$.isGaugeType(d.data) && withTransform ? 'scale(0)' : ''; + }) + .on('mouseover', config.interaction_enabled + ? function (d) { + var updated, arcData; + if ($$.transiting) { + // skip while transiting + return; + } + updated = $$.updateAngle(d); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.expandArc(updated.data.id); + $$.api.focus(updated.data.id); + $$.toggleFocusLegend(updated.data.id, true); + $$.config.data_onmouseover(arcData, this); + } + } + : null) + .on('mousemove', config.interaction_enabled + ? function (d) { + var updated = $$.updateAngle(d), arcData, selectedData; + if (updated) { + (arcData = $$.convertToArcData(updated)), + (selectedData = [arcData]); + $$.showTooltip(selectedData, this); + } + } + : null) + .on('mouseout', config.interaction_enabled + ? function (d) { + var updated, arcData; + if ($$.transiting) { + // skip while transiting + return; + } + updated = $$.updateAngle(d); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.unexpandArc(updated.data.id); + $$.api.revert(); + $$.revertLegend(); + $$.hideTooltip(); + $$.config.data_onmouseout(arcData, this); + } + } + : null) + .on('click', config.interaction_enabled + ? function (d, i) { + var updated = $$.updateAngle(d), arcData; + if (updated) { + arcData = $$.convertToArcData(updated); + if ($$.toggleShape) { + $$.toggleShape(this, arcData, i); + } + $$.config.data_onclick.call($$.api, arcData, this); + } + } + : null) + .each(function () { + $$.transiting = true; + }) + .transition() + .duration(duration) + .attrTween('d', function (d) { + var updated = $$.updateAngle(d), interpolate; + if (!updated) { + return function () { + return 'M 0 0'; + }; + } + // if (this._current === d) { + // this._current = { + // startAngle: Math.PI*2, + // endAngle: Math.PI*2, + // }; + // } + if (isNaN(this._current.startAngle)) { + this._current.startAngle = 0; + } + if (isNaN(this._current.endAngle)) { + this._current.endAngle = this._current.startAngle; + } + interpolate = d3.interpolate(this._current, updated); + this._current = interpolate(0); + return function (t) { + // prevents crashing the charts once in transition and chart.destroy() has been called + if ($$.config === null) { + return 'M 0 0'; + } + var interpolated = interpolate(t); + interpolated.data = d.data; // data.id will be updated by interporator + return $$.getArc(interpolated, true); + }; + }) + .attr('transform', withTransform ? 'scale(1)' : '') + .style('fill', function (d) { + return $$.levelColor + ? $$.levelColor(d.data.values.reduce(function (total, item) { + return total + item.value; + }, 0)) + : $$.color(d.data.id); + }) // Where gauge reading color would receive customization. + .call($$.endall, function () { + $$.transiting = false; + }); + arcs + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + main + .selectAll('.' + CLASS.chartArc) + .select('text') + .style('opacity', 0) + .attr('class', function (d) { + return $$.isGaugeType(d.data) ? CLASS.gaugeValue : ''; + }) + .text($$.textForArcLabel.bind($$)) + .attr('transform', $$.transformForArcLabel.bind($$)) + .style('font-size', function (d) { + return $$.isGaugeType(d.data) && + $$.filterTargetsToShow($$.data.targets).length === 1 + ? Math.round($$.radius / 5) + 'px' + : ''; + }) + .transition() + .duration(duration) + .style('opacity', function (d) { + return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? 1 : 0; + }); + main + .select('.' + CLASS.chartArcsTitle) + .style('opacity', $$.hasType('donut') || hasGaugeType ? 1 : 0); + if (hasGaugeType) { + var index_1 = 0; + var backgroundArc = $$.arcs + .select('g.' + CLASS.chartArcsBackground) + .selectAll('path.' + CLASS.chartArcsBackground) + .data($$.data.targets); + backgroundArc + .enter() + .append('path') + .attr('class', function (d, i) { + return CLASS.chartArcsBackground + ' ' + CLASS.chartArcsBackground + '-' + i; + }) + .merge(backgroundArc) + .attr('d', function (d1) { + if ($$.hiddenTargetIds.indexOf(d1.id) >= 0) { + return 'M 0 0'; + } + var d = { + data: [{ value: config.gauge_max }], + startAngle: config.gauge_startingAngle, + endAngle: -1 * + config.gauge_startingAngle * + (config.gauge_fullCircle ? Math.PI : 1), + index: index_1++ + }; + return $$.getArc(d, true, true); + }); + backgroundArc.exit().remove(); + $$.arcs + .select('.' + CLASS.chartArcsGaugeUnit) + .attr('dy', '.75em') + .text(config.gauge_label_show ? config.gauge_units : ''); + $$.arcs + .select('.' + CLASS.chartArcsGaugeMin) + .attr('dx', -1 * + ($$.innerRadius + + ($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2)) + + 'px') + .attr('dy', '1.2em') + .text(config.gauge_label_show + ? $$.textForGaugeMinMax(config.gauge_min, false) + : ''); + $$.arcs + .select('.' + CLASS.chartArcsGaugeMax) + .attr('dx', $$.innerRadius + + ($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2) + + 'px') + .attr('dy', '1.2em') + .text(config.gauge_label_show + ? $$.textForGaugeMinMax(config.gauge_max, true) + : ''); + } + }; + ChartInternal.prototype.initGauge = function () { + var arcs = this.arcs; + if (this.hasType('gauge')) { + arcs.append('g').attr('class', CLASS.chartArcsBackground); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeUnit) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeMin) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeMax) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + } + }; + ChartInternal.prototype.getGaugeLabelHeight = function () { + return this.config.gauge_label_show ? 20 : 0; + }; + + /** + * Store value into cache + * + * @param key + * @param value + */ + ChartInternal.prototype.addToCache = function (key, value) { + this.cache["$" + key] = value; + }; + /** + * Returns a cached value or undefined + * + * @param key + * @return {*} + */ + ChartInternal.prototype.getFromCache = function (key) { + return this.cache["$" + key]; + }; + /** + * Reset cached data + */ + ChartInternal.prototype.resetCache = function () { + var _this = this; + Object.keys(this.cache) + .filter(function (key) { return /^\$/.test(key); }) + .forEach(function (key) { + delete _this.cache[key]; + }); + }; + // Old API that stores Targets + ChartInternal.prototype.hasCaches = function (ids) { + for (var i = 0; i < ids.length; i++) { + if (!(ids[i] in this.cache)) { + return false; + } + } + return true; + }; + ChartInternal.prototype.addCache = function (id, target) { + this.cache[id] = this.cloneTarget(target); + }; + ChartInternal.prototype.getCaches = function (ids) { + var targets = [], i; + for (i = 0; i < ids.length; i++) { + if (ids[i] in this.cache) { + targets.push(this.cloneTarget(this.cache[ids[i]])); + } + } + return targets; + }; + + ChartInternal.prototype.categoryName = function (i) { + var config = this.config; + return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i; + }; + + ChartInternal.prototype.generateTargetClass = function (targetId) { + return targetId || targetId === 0 ? ('-' + targetId).replace(/\s/g, '-') : ''; + }; + ChartInternal.prototype.generateClass = function (prefix, targetId) { + return ' ' + prefix + ' ' + prefix + this.generateTargetClass(targetId); + }; + ChartInternal.prototype.classText = function (d) { + return this.generateClass(CLASS.text, d.index); + }; + ChartInternal.prototype.classTexts = function (d) { + return this.generateClass(CLASS.texts, d.id); + }; + ChartInternal.prototype.classShape = function (d) { + return this.generateClass(CLASS.shape, d.index); + }; + ChartInternal.prototype.classShapes = function (d) { + return this.generateClass(CLASS.shapes, d.id); + }; + ChartInternal.prototype.classLine = function (d) { + return this.classShape(d) + this.generateClass(CLASS.line, d.id); + }; + ChartInternal.prototype.classLines = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.lines, d.id); + }; + ChartInternal.prototype.classCircle = function (d) { + return this.classShape(d) + this.generateClass(CLASS.circle, d.index); + }; + ChartInternal.prototype.classCircles = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.circles, d.id); + }; + ChartInternal.prototype.classBar = function (d) { + return this.classShape(d) + this.generateClass(CLASS.bar, d.index); + }; + ChartInternal.prototype.classBars = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.bars, d.id); + }; + ChartInternal.prototype.classArc = function (d) { + return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id); + }; + ChartInternal.prototype.classArcs = function (d) { + return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id); + }; + ChartInternal.prototype.classArea = function (d) { + return this.classShape(d) + this.generateClass(CLASS.area, d.id); + }; + ChartInternal.prototype.classAreas = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.areas, d.id); + }; + ChartInternal.prototype.classRegion = function (d, i) { + return (this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d['class'] : '')); + }; + ChartInternal.prototype.classEvent = function (d) { + return this.generateClass(CLASS.eventRect, d.index); + }; + ChartInternal.prototype.classTarget = function (id) { + var $$ = this; + var additionalClassSuffix = $$.config.data_classes[id], additionalClass = ''; + if (additionalClassSuffix) { + additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; + } + return $$.generateClass(CLASS.target, id) + additionalClass; + }; + ChartInternal.prototype.classFocus = function (d) { + return this.classFocused(d) + this.classDefocused(d); + }; + ChartInternal.prototype.classFocused = function (d) { + return ' ' + (this.focusedTargetIds.indexOf(d.id) >= 0 ? CLASS.focused : ''); + }; + ChartInternal.prototype.classDefocused = function (d) { + return (' ' + (this.defocusedTargetIds.indexOf(d.id) >= 0 ? CLASS.defocused : '')); + }; + ChartInternal.prototype.classChartText = function (d) { + return CLASS.chartText + this.classTarget(d.id); + }; + ChartInternal.prototype.classChartLine = function (d) { + return CLASS.chartLine + this.classTarget(d.id); + }; + ChartInternal.prototype.classChartBar = function (d) { + return CLASS.chartBar + this.classTarget(d.id); + }; + ChartInternal.prototype.classChartArc = function (d) { + return CLASS.chartArc + this.classTarget(d.data.id); + }; + ChartInternal.prototype.getTargetSelectorSuffix = function (targetId) { + var targetClass = this.generateTargetClass(targetId); + if (window.CSS && window.CSS.escape) { + return window.CSS.escape(targetClass); + } + // fallback on imperfect method for old browsers (does not handles unicode) + return targetClass.replace(/([?!@#$%^&*()=+,.<>'":;\[\]\/|~`{}\\])/g, '\\$1'); + }; + ChartInternal.prototype.selectorTarget = function (id, prefix) { + return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id); + }; + ChartInternal.prototype.selectorTargets = function (ids, prefix) { + var $$ = this; + ids = ids || []; + return ids.length + ? ids.map(function (id) { + return $$.selectorTarget(id, prefix); + }) + : null; + }; + ChartInternal.prototype.selectorLegend = function (id) { + return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id); + }; + ChartInternal.prototype.selectorLegends = function (ids) { + var $$ = this; + return ids && ids.length + ? ids.map(function (id) { + return $$.selectorLegend(id); + }) + : null; + }; + + ChartInternal.prototype.getClipPath = function (id) { + return 'url(' + (isIE(9) ? '' : document.URL.split('#')[0]) + '#' + id + ')'; + }; + ChartInternal.prototype.appendClip = function (parent, id) { + return parent + .append('clipPath') + .attr('id', id) + .append('rect'); + }; + ChartInternal.prototype.getAxisClipX = function (forHorizontal) { + // axis line width + padding for left + var left = Math.max(30, this.margin.left); + return forHorizontal ? -(1 + left) : -(left - 1); + }; + ChartInternal.prototype.getAxisClipY = function (forHorizontal) { + return forHorizontal ? -20 : -this.margin.top; + }; + ChartInternal.prototype.getXAxisClipX = function () { + var $$ = this; + return $$.getAxisClipX(!$$.config.axis_rotated); + }; + ChartInternal.prototype.getXAxisClipY = function () { + var $$ = this; + return $$.getAxisClipY(!$$.config.axis_rotated); + }; + ChartInternal.prototype.getYAxisClipX = function () { + var $$ = this; + return $$.config.axis_y_inner ? -1 : $$.getAxisClipX($$.config.axis_rotated); + }; + ChartInternal.prototype.getYAxisClipY = function () { + var $$ = this; + return $$.getAxisClipY($$.config.axis_rotated); + }; + ChartInternal.prototype.getAxisClipWidth = function (forHorizontal) { + var $$ = this, left = Math.max(30, $$.margin.left), right = Math.max(30, $$.margin.right); + // width + axis line width + padding for left/right + return forHorizontal ? $$.width + 2 + left + right : $$.margin.left + 20; + }; + ChartInternal.prototype.getAxisClipHeight = function (forHorizontal) { + // less than 20 is not enough to show the axis label 'outer' without legend + return ((forHorizontal ? this.margin.bottom : this.margin.top + this.height) + 20); + }; + ChartInternal.prototype.getXAxisClipWidth = function () { + var $$ = this; + return $$.getAxisClipWidth(!$$.config.axis_rotated); + }; + ChartInternal.prototype.getXAxisClipHeight = function () { + var $$ = this; + return $$.getAxisClipHeight(!$$.config.axis_rotated); + }; + ChartInternal.prototype.getYAxisClipWidth = function () { + var $$ = this; + return ($$.getAxisClipWidth($$.config.axis_rotated) + + ($$.config.axis_y_inner ? 20 : 0)); + }; + ChartInternal.prototype.getYAxisClipHeight = function () { + var $$ = this; + return $$.getAxisClipHeight($$.config.axis_rotated); + }; + + ChartInternal.prototype.generateColor = function () { + var $$ = this, config = $$.config, d3 = $$.d3, colors = config.data_colors, pattern = notEmpty(config.color_pattern) + ? config.color_pattern + : d3.schemeCategory10, callback = config.data_color, ids = []; + return function (d) { + var id = d.id || (d.data && d.data.id) || d, color; + // if callback function is provided + if (colors[id] instanceof Function) { + color = colors[id](d); + } + // if specified, choose that color + else if (colors[id]) { + color = colors[id]; + } + // if not specified, choose from pattern + else { + if (ids.indexOf(id) < 0) { + ids.push(id); + } + color = pattern[ids.indexOf(id) % pattern.length]; + colors[id] = color; + } + return callback instanceof Function ? callback(color, d) : color; + }; + }; + ChartInternal.prototype.generateLevelColor = function () { + var $$ = this, config = $$.config, colors = config.color_pattern, threshold = config.color_threshold, asValue = threshold.unit === 'value', values = threshold.values && threshold.values.length ? threshold.values : [], max = threshold.max || 100; + return notEmpty(threshold) && notEmpty(colors) + ? function (value) { + var i, v, color = colors[colors.length - 1]; + for (i = 0; i < values.length; i++) { + v = asValue ? value : (value * 100) / max; + if (v < values[i]) { + color = colors[i]; + break; + } + } + return color; + } + : null; + }; + + ChartInternal.prototype.getDefaultConfig = function () { + var config = { + bindto: '#chart', + svg_classname: undefined, + size_width: undefined, + size_height: undefined, + padding_left: undefined, + padding_right: undefined, + padding_top: undefined, + padding_bottom: undefined, + resize_auto: true, + zoom_enabled: false, + zoom_initialRange: undefined, + zoom_type: 'scroll', + zoom_disableDefaultBehavior: false, + zoom_privileged: false, + zoom_rescale: false, + zoom_onzoom: function () { }, + zoom_onzoomstart: function () { }, + zoom_onzoomend: function () { }, + zoom_x_min: undefined, + zoom_x_max: undefined, + interaction_brighten: true, + interaction_enabled: true, + onmouseover: function () { }, + onmouseout: function () { }, + onresize: function () { }, + onresized: function () { }, + oninit: function () { }, + onrendered: function () { }, + transition_duration: 350, + data_epochs: 'epochs', + data_x: undefined, + data_xs: {}, + data_xFormat: '%Y-%m-%d', + data_xLocaltime: true, + data_xSort: true, + data_idConverter: function (id) { + return id; + }, + data_names: {}, + data_classes: {}, + data_groups: [], + data_axes: {}, + data_type: undefined, + data_types: {}, + data_labels: {}, + data_order: 'desc', + data_regions: {}, + data_color: undefined, + data_colors: {}, + data_hide: false, + data_filter: undefined, + data_selection_enabled: false, + data_selection_grouped: false, + data_selection_isselectable: function () { + return true; + }, + data_selection_multiple: true, + data_selection_draggable: false, + data_stack_normalize: false, + data_onclick: function () { }, + data_onmouseover: function () { }, + data_onmouseout: function () { }, + data_onselected: function () { }, + data_onunselected: function () { }, + data_url: undefined, + data_headers: undefined, + data_json: undefined, + data_rows: undefined, + data_columns: undefined, + data_mimeType: undefined, + data_keys: undefined, + // configuration for no plot-able data supplied. + data_empty_label_text: '', + // subchart + subchart_show: false, + subchart_size_height: 60, + subchart_axis_x_show: true, + subchart_onbrush: function () { }, + // color + color_pattern: [], + color_threshold: {}, + // legend + legend_show: true, + legend_hide: false, + legend_position: 'bottom', + legend_inset_anchor: 'top-left', + legend_inset_x: 10, + legend_inset_y: 0, + legend_inset_step: undefined, + legend_item_onclick: undefined, + legend_item_onmouseover: undefined, + legend_item_onmouseout: undefined, + legend_equally: false, + legend_padding: 0, + legend_item_tile_width: 10, + legend_item_tile_height: 10, + // axis + axis_rotated: false, + axis_x_show: true, + axis_x_type: 'indexed', + axis_x_localtime: true, + axis_x_categories: [], + axis_x_tick_centered: false, + axis_x_tick_format: undefined, + axis_x_tick_culling: {}, + axis_x_tick_culling_max: 10, + axis_x_tick_count: undefined, + axis_x_tick_fit: true, + axis_x_tick_values: null, + axis_x_tick_rotate: 0, + axis_x_tick_outer: true, + axis_x_tick_multiline: true, + axis_x_tick_multilineMax: 0, + axis_x_tick_width: null, + axis_x_max: undefined, + axis_x_min: undefined, + axis_x_padding: {}, + axis_x_height: undefined, + axis_x_selection: undefined, + axis_x_label: {}, + axis_x_inner: undefined, + axis_y_show: true, + axis_y_type: 'linear', + axis_y_max: undefined, + axis_y_min: undefined, + axis_y_inverted: false, + axis_y_center: undefined, + axis_y_inner: undefined, + axis_y_label: {}, + axis_y_tick_format: undefined, + axis_y_tick_outer: true, + axis_y_tick_values: null, + axis_y_tick_rotate: 0, + axis_y_tick_count: undefined, + axis_y_tick_time_type: undefined, + axis_y_tick_time_interval: undefined, + axis_y_padding: {}, + axis_y_default: undefined, + axis_y2_show: false, + axis_y2_type: 'linear', + axis_y2_max: undefined, + axis_y2_min: undefined, + axis_y2_inverted: false, + axis_y2_center: undefined, + axis_y2_inner: undefined, + axis_y2_label: {}, + axis_y2_tick_format: undefined, + axis_y2_tick_outer: true, + axis_y2_tick_values: null, + axis_y2_tick_count: undefined, + axis_y2_padding: {}, + axis_y2_default: undefined, + // grid + grid_x_show: false, + grid_x_type: 'tick', + grid_x_lines: [], + grid_y_show: false, + // not used + // grid_y_type: 'tick', + grid_y_lines: [], + grid_y_ticks: 10, + grid_focus_show: true, + grid_lines_front: true, + // point - point of each data + point_show: true, + point_r: 2.5, + point_sensitivity: 10, + point_focus_expand_enabled: true, + point_focus_expand_r: undefined, + point_select_r: undefined, + // line + line_connectNull: false, + line_step_type: 'step', + // bar + bar_width: undefined, + bar_width_ratio: 0.6, + bar_width_max: undefined, + bar_zerobased: true, + bar_space: 0, + // area + area_zerobased: true, + area_above: false, + // pie + pie_label_show: true, + pie_label_format: undefined, + pie_label_threshold: 0.05, + pie_label_ratio: undefined, + pie_expand: {}, + pie_expand_duration: 50, + pie_padAngle: 0, + // gauge + gauge_fullCircle: false, + gauge_label_show: true, + gauge_labelLine_show: true, + gauge_label_format: undefined, + gauge_min: 0, + gauge_max: 100, + gauge_startingAngle: (-1 * Math.PI) / 2, + gauge_label_extents: undefined, + gauge_units: undefined, + gauge_width: undefined, + gauge_arcs_minWidth: 5, + gauge_expand: {}, + gauge_expand_duration: 50, + // donut + donut_label_show: true, + donut_label_format: undefined, + donut_label_threshold: 0.05, + donut_label_ratio: undefined, + donut_width: undefined, + donut_title: '', + donut_expand: {}, + donut_expand_duration: 50, + donut_padAngle: 0, + // spline + spline_interpolation_type: 'cardinal', + // stanford + stanford_lines: [], + stanford_regions: [], + stanford_texts: [], + stanford_scaleMin: undefined, + stanford_scaleMax: undefined, + stanford_scaleWidth: undefined, + stanford_scaleFormat: undefined, + stanford_scaleValues: undefined, + stanford_colors: undefined, + stanford_padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + // region - region to change style + regions: [], + // tooltip - show when mouseover on each data + tooltip_show: true, + tooltip_grouped: true, + tooltip_order: undefined, + tooltip_format_title: undefined, + tooltip_format_name: undefined, + tooltip_format_value: undefined, + tooltip_horizontal: undefined, + tooltip_position: undefined, + tooltip_contents: function (d, defaultTitleFormat, defaultValueFormat, color) { + return this.getTooltipContent + ? this.getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) + : ''; + }, + tooltip_init_show: false, + tooltip_init_x: 0, + tooltip_init_position: { top: '0px', left: '50px' }, + tooltip_onshow: function () { }, + tooltip_onhide: function () { }, + // title + title_text: undefined, + title_padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + title_position: 'top-center' + }; + Object.keys(this.additionalConfig).forEach(function (key) { + config[key] = this.additionalConfig[key]; + }, this); + return config; + }; + ChartInternal.prototype.additionalConfig = {}; + ChartInternal.prototype.loadConfig = function (config) { + var this_config = this.config, target, keys, read; + function find() { + var key = keys.shift(); + // console.log("key =>", key, ", target =>", target); + if (key && target && typeof target === 'object' && key in target) { + target = target[key]; + return find(); + } + else if (!key) { + return target; + } + else { + return undefined; + } + } + Object.keys(this_config).forEach(function (key) { + target = config; + keys = key.split('_'); + read = find(); + // console.log("CONFIG : ", key, read); + if (isDefined(read)) { + this_config[key] = read; + } + }); + }; + + ChartInternal.prototype.convertUrlToData = function (url, mimeType, headers, keys, done) { + var $$ = this, type = mimeType ? mimeType : 'csv', f, converter; + if (type === 'json') { + f = $$.d3.json; + converter = $$.convertJsonToData; + } + else if (type === 'tsv') { + f = $$.d3.tsv; + converter = $$.convertXsvToData; + } + else { + f = $$.d3.csv; + converter = $$.convertXsvToData; + } + f(url, headers) + .then(function (data) { + done.call($$, converter.call($$, data, keys)); + }) + .catch(function (error) { + throw error; + }); + }; + ChartInternal.prototype.convertXsvToData = function (xsv) { + var keys = xsv.columns, rows = xsv; + if (rows.length === 0) { + return { + keys: keys, + rows: [keys.reduce(function (row, key) { + var _a; + return Object.assign(row, (_a = {}, _a[key] = null, _a)); + }, {})] + }; + } + else { + // [].concat() is to convert result into a plain array otherwise + // test is not happy because rows have properties. + return { keys: keys, rows: [].concat(xsv) }; + } + }; + ChartInternal.prototype.convertJsonToData = function (json, keys) { + var $$ = this, new_rows = [], targetKeys, data; + if (keys) { + // when keys specified, json would be an array that includes objects + if (keys.x) { + targetKeys = keys.value.concat(keys.x); + $$.config.data_x = keys.x; + } + else { + targetKeys = keys.value; + } + new_rows.push(targetKeys); + json.forEach(function (o) { + var new_row = []; + targetKeys.forEach(function (key) { + // convert undefined to null because undefined data will be removed in convertDataToTargets() + var v = $$.findValueInJson(o, key); + if (isUndefined(v)) { + v = null; + } + new_row.push(v); + }); + new_rows.push(new_row); + }); + data = $$.convertRowsToData(new_rows); + } + else { + Object.keys(json).forEach(function (key) { + new_rows.push([key].concat(json[key])); + }); + data = $$.convertColumnsToData(new_rows); + } + return data; + }; + /** + * Finds value from the given nested object by the given path. + * If it's not found, then this returns undefined. + * @param {Object} object the object + * @param {string} path the path + */ + ChartInternal.prototype.findValueInJson = function (object, path) { + if (path in object) { + // If object has a key that contains . or [], return the key's value + // instead of searching for an inner object. + // See https://github.com/c3js/c3/issues/1691 for details. + return object[path]; + } + path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties (replace [] with .) + path = path.replace(/^\./, ''); // strip a leading dot + var pathArray = path.split('.'); + for (var i = 0; i < pathArray.length; ++i) { + var k = pathArray[i]; + if (k in object) { + object = object[k]; + } + else { + return; + } + } + return object; + }; + /** + * Converts the rows to normalized data. + * @param {any[][]} rows The row data + * @return {Object} + */ + ChartInternal.prototype.convertRowsToData = function (rows) { + var newRows = []; + var keys = rows[0]; + for (var i = 1; i < rows.length; i++) { + var newRow = {}; + for (var j = 0; j < rows[i].length; j++) { + if (isUndefined(rows[i][j])) { + throw new Error('Source data is missing a component at (' + i + ',' + j + ')!'); + } + newRow[keys[j]] = rows[i][j]; + } + newRows.push(newRow); + } + return { keys: keys, rows: newRows }; + }; + /** + * Converts the columns to normalized data. + * @param {any[][]} columns The column data + * @return {Object} + */ + ChartInternal.prototype.convertColumnsToData = function (columns) { + var newRows = []; + var keys = []; + for (var i = 0; i < columns.length; i++) { + var key = columns[i][0]; + for (var j = 1; j < columns[i].length; j++) { + if (isUndefined(newRows[j - 1])) { + newRows[j - 1] = {}; + } + if (isUndefined(columns[i][j])) { + throw new Error('Source data is missing a component at (' + i + ',' + j + ')!'); + } + newRows[j - 1][key] = columns[i][j]; + } + keys.push(key); + } + return { keys: keys, rows: newRows }; + }; + /** + * Converts the data format into the target format. + * @param {!Object} data + * @param {!Array} data.keys Ordered list of target IDs. + * @param {!Array} data.rows Rows of data to convert. + * @param {boolean} appendXs True to append to $$.data.xs, False to replace. + * @return {!Array} + */ + ChartInternal.prototype.convertDataToTargets = function (data, appendXs) { + var $$ = this, config = $$.config, targets, ids, xs, keys, epochs; + // handles format where keys are not orderly provided + if (isArray(data)) { + keys = Object.keys(data[0]); + } + else { + keys = data.keys; + data = data.rows; + } + xs = keys.filter($$.isX, $$); + if (!$$.isStanfordGraphType()) { + ids = keys.filter($$.isNotX, $$); + } + else { + epochs = keys.filter($$.isEpochs, $$); + ids = keys.filter($$.isNotXAndNotEpochs, $$); + if (xs.length !== 1 || epochs.length !== 1 || ids.length !== 1) { + throw new Error("You must define the 'x' key name and the 'epochs' for Stanford Diagrams"); + } + } + // save x for update data by load when custom x and c3.x API + ids.forEach(function (id) { + var xKey = $$.getXKey(id); + if ($$.isCustomX() || $$.isTimeSeries()) { + // if included in input data + if (xs.indexOf(xKey) >= 0) { + $$.data.xs[id] = (appendXs && $$.data.xs[id] + ? $$.data.xs[id] + : []).concat(data + .map(function (d) { + return d[xKey]; + }) + .filter(isValue) + .map(function (rawX, i) { + return $$.generateTargetX(rawX, id, i); + })); + } + // if not included in input data, find from preloaded data of other id's x + else if (config.data_x) { + $$.data.xs[id] = $$.getOtherTargetXs(); + } + // if not included in input data, find from preloaded data + else if (notEmpty(config.data_xs)) { + $$.data.xs[id] = $$.getXValuesOfXKey(xKey, $$.data.targets); + } + // MEMO: if no x included, use same x of current will be used + } + else { + $$.data.xs[id] = data.map(function (d, i) { + return i; + }); + } + }); + // check x is defined + ids.forEach(function (id) { + if (!$$.data.xs[id]) { + throw new Error('x is not defined for id = "' + id + '".'); + } + }); + // convert to target + targets = ids.map(function (id, index) { + var convertedId = config.data_idConverter(id); + return { + id: convertedId, + id_org: id, + values: data + .map(function (d, i) { + var xKey = $$.getXKey(id), rawX = d[xKey], value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null, x, returnData; + // use x as categories if custom x and categorized + if ($$.isCustomX() && $$.isCategorized() && !isUndefined(rawX)) { + if (index === 0 && i === 0) { + config.axis_x_categories = []; + } + x = config.axis_x_categories.indexOf(rawX); + if (x === -1) { + x = config.axis_x_categories.length; + config.axis_x_categories.push(rawX); + } + } + else { + x = $$.generateTargetX(rawX, id, i); + } + // mark as x = undefined if value is undefined and filter to remove after mapped + if (isUndefined(d[id]) || $$.data.xs[id].length <= i) { + x = undefined; + } + returnData = { x: x, value: value, id: convertedId }; + if ($$.isStanfordGraphType()) { + returnData.epochs = d[epochs]; + } + return returnData; + }) + .filter(function (v) { + return isDefined(v.x); + }) + }; + }); + // finish targets + targets.forEach(function (t) { + var i; + // sort values by its x + if (config.data_xSort) { + t.values = t.values.sort(function (v1, v2) { + var x1 = v1.x || v1.x === 0 ? v1.x : Infinity, x2 = v2.x || v2.x === 0 ? v2.x : Infinity; + return x1 - x2; + }); + } + // indexing each value + i = 0; + t.values.forEach(function (v) { + v.index = i++; + }); + // this needs to be sorted because its index and value.index is identical + $$.data.xs[t.id].sort(function (v1, v2) { + return v1 - v2; + }); + }); + // cache information about values + $$.hasNegativeValue = $$.hasNegativeValueInTargets(targets); + $$.hasPositiveValue = $$.hasPositiveValueInTargets(targets); + // set target types + if (config.data_type) { + $$.setTargetType($$.mapToIds(targets).filter(function (id) { + return !(id in config.data_types); + }), config.data_type); + } + // cache as original id keyed + targets.forEach(function (d) { + $$.addCache(d.id_org, d); + }); + return targets; + }; + + ChartInternal.prototype.isEpochs = function (key) { + var $$ = this, config = $$.config; + return config.data_epochs && key === config.data_epochs; + }; + ChartInternal.prototype.isX = function (key) { + var $$ = this, config = $$.config; + return ((config.data_x && key === config.data_x) || + (notEmpty(config.data_xs) && hasValue(config.data_xs, key))); + }; + ChartInternal.prototype.isNotX = function (key) { + return !this.isX(key); + }; + ChartInternal.prototype.isNotXAndNotEpochs = function (key) { + return !this.isX(key) && !this.isEpochs(key); + }; + /** + * Returns whether the normalized stack option is enabled or not. + * + * To be enabled it must also have data.groups defined. + * + * @return {boolean} + */ + ChartInternal.prototype.isStackNormalized = function () { + return this.config.data_stack_normalize && this.config.data_groups.length > 0; + }; + /** + * Returns whether the axis is normalized or not. + * + * An axis is normalized as long as one of its associated target + * is normalized. + * + * @param axisId Axis ID (y or y2) + * @return {Boolean} + */ + ChartInternal.prototype.isAxisNormalized = function (axisId) { + var $$ = this; + if (!$$.isStackNormalized()) { + // shortcut + return false; + } + return $$.data.targets + .filter(function (target) { return $$.axis.getId(target.id) === axisId; }) + .some(function (target) { return $$.isTargetNormalized(target.id); }); + }; + /** + * Returns whether the values for this target ID is normalized or not. + * + * To be normalized the option needs to be enabled and target needs + * to be defined in `data.groups`. + * + * @param targetId ID of the target + * @return {Boolean} True if the target is normalized, false otherwise. + */ + ChartInternal.prototype.isTargetNormalized = function (targetId) { + var $$ = this; + return ($$.isStackNormalized() && + $$.config.data_groups.some(function (group) { return group.includes(targetId); })); + }; + ChartInternal.prototype.getXKey = function (id) { + var $$ = this, config = $$.config; + return config.data_x + ? config.data_x + : notEmpty(config.data_xs) + ? config.data_xs[id] + : null; + }; + /** + * Get sum of visible data per index for given axis. + * + * Expect axisId to be either 'y' or 'y2'. + * + * @private + * @param axisId Compute sum for data associated to given axis. + * @return {Array} + */ + ChartInternal.prototype.getTotalPerIndex = function (axisId) { + var $$ = this; + if (!$$.isStackNormalized()) { + return null; + } + var cached = $$.getFromCache('getTotalPerIndex'); + if (cached !== undefined) { + return cached[axisId]; + } + var sum = { y: [], y2: [] }; + $$.data.targets + // keep only target that are normalized + .filter(function (target) { return $$.isTargetNormalized(target.id); }) + // keep only target that are visible + .filter(function (target) { return $$.isTargetToShow(target.id); }) + // compute sum per axis + .forEach(function (target) { + var sumByAxis = sum[$$.axis.getId(target.id)]; + target.values.forEach(function (v, i) { + if (!sumByAxis[i]) { + sumByAxis[i] = 0; + } + sumByAxis[i] += isNumber(v.value) ? v.value : 0; + }); + }); + $$.addToCache('getTotalPerIndex', sum); + return sum[axisId]; + }; + /** + * Get sum of visible data. + * + * Should be used for normalised data only since all values + * are expected to be positive. + * + * @private + * @return {Number} + */ + ChartInternal.prototype.getTotalDataSum = function () { + var $$ = this; + var cached = $$.getFromCache('getTotalDataSum'); + if (cached !== undefined) { + return cached; + } + var totalDataSum = flattenArray($$.data.targets + .filter(function (target) { return $$.isTargetToShow(target.id); }) + .map(function (target) { return target.values; })) + .map(function (d) { return d.value; }) + .reduce(function (p, c) { return p + c; }, 0); + $$.addToCache('getTotalDataSum', totalDataSum); + return totalDataSum; + }; + ChartInternal.prototype.getXValuesOfXKey = function (key, targets) { + var $$ = this, xValues, ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : []; + ids.forEach(function (id) { + if ($$.getXKey(id) === key) { + xValues = $$.data.xs[id]; + } + }); + return xValues; + }; + ChartInternal.prototype.getXValue = function (id, i) { + var $$ = this; + return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) + ? $$.data.xs[id][i] + : i; + }; + ChartInternal.prototype.getOtherTargetXs = function () { + var $$ = this, idsForX = Object.keys($$.data.xs); + return idsForX.length ? $$.data.xs[idsForX[0]] : null; + }; + ChartInternal.prototype.getOtherTargetX = function (index) { + var xs = this.getOtherTargetXs(); + return xs && index < xs.length ? xs[index] : null; + }; + ChartInternal.prototype.addXs = function (xs) { + var $$ = this; + Object.keys(xs).forEach(function (id) { + $$.config.data_xs[id] = xs[id]; + }); + }; + ChartInternal.prototype.addName = function (data) { + var $$ = this, name; + if (data) { + name = $$.config.data_names[data.id]; + data.name = name !== undefined ? name : data.id; + } + return data; + }; + ChartInternal.prototype.getValueOnIndex = function (values, index) { + var valueOnIndex = values.filter(function (v) { + return v.index === index; + }); + return valueOnIndex.length ? valueOnIndex[0] : null; + }; + ChartInternal.prototype.updateTargetX = function (targets, x) { + var $$ = this; + targets.forEach(function (t) { + t.values.forEach(function (v, i) { + v.x = $$.generateTargetX(x[i], t.id, i); + }); + $$.data.xs[t.id] = x; + }); + }; + ChartInternal.prototype.updateTargetXs = function (targets, xs) { + var $$ = this; + targets.forEach(function (t) { + if (xs[t.id]) { + $$.updateTargetX([t], xs[t.id]); + } + }); + }; + ChartInternal.prototype.generateTargetX = function (rawX, id, index) { + var $$ = this, x; + if ($$.isTimeSeries()) { + x = rawX ? $$.parseDate(rawX) : $$.parseDate($$.getXValue(id, index)); + } + else if ($$.isCustomX() && !$$.isCategorized()) { + x = isValue(rawX) ? +rawX : $$.getXValue(id, index); + } + else { + x = index; + } + return x; + }; + ChartInternal.prototype.cloneTarget = function (target) { + return { + id: target.id, + id_org: target.id_org, + values: target.values.map(function (d) { + return { + x: d.x, + value: d.value, + id: d.id + }; + }) + }; + }; + ChartInternal.prototype.getMaxDataCount = function () { + var $$ = this; + return $$.d3.max($$.data.targets, function (t) { + return t.values.length; + }); + }; + ChartInternal.prototype.mapToIds = function (targets) { + return targets.map(function (d) { + return d.id; + }); + }; + ChartInternal.prototype.mapToTargetIds = function (ids) { + var $$ = this; + return ids ? [].concat(ids) : $$.mapToIds($$.data.targets); + }; + ChartInternal.prototype.hasTarget = function (targets, id) { + var ids = this.mapToIds(targets), i; + for (i = 0; i < ids.length; i++) { + if (ids[i] === id) { + return true; + } + } + return false; + }; + ChartInternal.prototype.isTargetToShow = function (targetId) { + return this.hiddenTargetIds.indexOf(targetId) < 0; + }; + ChartInternal.prototype.isLegendToShow = function (targetId) { + return this.hiddenLegendIds.indexOf(targetId) < 0; + }; + /** + * Returns only visible targets. + * + * This is the same as calling {@link filterTargetsToShow} on $$.data.targets. + * + * @return {Array} + */ + ChartInternal.prototype.getTargetsToShow = function () { + var $$ = this; + return $$.filterTargetsToShow($$.data.targets); + }; + ChartInternal.prototype.filterTargetsToShow = function (targets) { + var $$ = this; + return targets.filter(function (t) { + return $$.isTargetToShow(t.id); + }); + }; + /** + * @return {Array} Returns all the targets attached to the chart, visible or not + */ + ChartInternal.prototype.getTargets = function () { + var $$ = this; + return $$.data.targets; + }; + ChartInternal.prototype.mapTargetsToUniqueXs = function (targets) { + var $$ = this; + var xs = $$.d3 + .set($$.d3.merge(targets.map(function (t) { + return t.values.map(function (v) { + return +v.x; + }); + }))) + .values(); + xs = $$.isTimeSeries() + ? xs.map(function (x) { + return new Date(+x); + }) + : xs.map(function (x) { + return +x; + }); + return xs.sort(function (a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; + }); + }; + ChartInternal.prototype.addHiddenTargetIds = function (targetIds) { + targetIds = targetIds instanceof Array ? targetIds : new Array(targetIds); + for (var i = 0; i < targetIds.length; i++) { + if (this.hiddenTargetIds.indexOf(targetIds[i]) < 0) { + this.hiddenTargetIds = this.hiddenTargetIds.concat(targetIds[i]); + } + } + this.resetCache(); + }; + ChartInternal.prototype.removeHiddenTargetIds = function (targetIds) { + this.hiddenTargetIds = this.hiddenTargetIds.filter(function (id) { + return targetIds.indexOf(id) < 0; + }); + this.resetCache(); + }; + ChartInternal.prototype.addHiddenLegendIds = function (targetIds) { + targetIds = targetIds instanceof Array ? targetIds : new Array(targetIds); + for (var i = 0; i < targetIds.length; i++) { + if (this.hiddenLegendIds.indexOf(targetIds[i]) < 0) { + this.hiddenLegendIds = this.hiddenLegendIds.concat(targetIds[i]); + } + } + }; + ChartInternal.prototype.removeHiddenLegendIds = function (targetIds) { + this.hiddenLegendIds = this.hiddenLegendIds.filter(function (id) { + return targetIds.indexOf(id) < 0; + }); + }; + ChartInternal.prototype.getValuesAsIdKeyed = function (targets) { + var ys = {}; + targets.forEach(function (t) { + ys[t.id] = []; + t.values.forEach(function (v) { + ys[t.id].push(v.value); + }); + }); + return ys; + }; + ChartInternal.prototype.checkValueInTargets = function (targets, checker) { + var ids = Object.keys(targets), i, j, values; + for (i = 0; i < ids.length; i++) { + values = targets[ids[i]].values; + for (j = 0; j < values.length; j++) { + if (checker(values[j].value)) { + return true; + } + } + } + return false; + }; + ChartInternal.prototype.hasNegativeValueInTargets = function (targets) { + return this.checkValueInTargets(targets, function (v) { + return v < 0; + }); + }; + ChartInternal.prototype.hasPositiveValueInTargets = function (targets) { + return this.checkValueInTargets(targets, function (v) { + return v > 0; + }); + }; + ChartInternal.prototype.isOrderDesc = function () { + var config = this.config; + return (typeof config.data_order === 'string' && + config.data_order.toLowerCase() === 'desc'); + }; + ChartInternal.prototype.isOrderAsc = function () { + var config = this.config; + return (typeof config.data_order === 'string' && + config.data_order.toLowerCase() === 'asc'); + }; + ChartInternal.prototype.getOrderFunction = function () { + var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc(); + if (orderAsc || orderDesc) { + var reducer = function (p, c) { + return p + Math.abs(c.value); + }; + return function (t1, t2) { + var t1Sum = t1.values.reduce(reducer, 0), t2Sum = t2.values.reduce(reducer, 0); + return orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum; + }; + } + else if (isFunction(config.data_order)) { + return config.data_order; + } + else if (isArray(config.data_order)) { + var order = config.data_order; + return function (t1, t2) { + return order.indexOf(t1.id) - order.indexOf(t2.id); + }; + } + }; + ChartInternal.prototype.orderTargets = function (targets) { + var fct = this.getOrderFunction(); + if (fct) { + targets.sort(fct); + } + return targets; + }; + /** + * Returns all the values from the given targets at the given index. + * + * @param {Array} targets + * @param {Number} index + * @return {Array} + */ + ChartInternal.prototype.filterByIndex = function (targets, index) { + return this.d3.merge(targets.map(function (t) { return t.values.filter(function (v) { return v.index === index; }); })); + }; + ChartInternal.prototype.filterByX = function (targets, x) { + return this.d3 + .merge(targets.map(function (t) { + return t.values; + })) + .filter(function (v) { + return v.x - x === 0; + }); + }; + ChartInternal.prototype.filterRemoveNull = function (data) { + return data.filter(function (d) { + return isValue(d.value); + }); + }; + ChartInternal.prototype.filterByXDomain = function (targets, xDomain) { + return targets.map(function (t) { + return { + id: t.id, + id_org: t.id_org, + values: t.values.filter(function (v) { + return xDomain[0] <= v.x && v.x <= xDomain[1]; + }) + }; + }); + }; + ChartInternal.prototype.hasDataLabel = function () { + var config = this.config; + if (typeof config.data_labels === 'boolean' && config.data_labels) { + return true; + } + else if (typeof config.data_labels === 'object' && + notEmpty(config.data_labels)) { + return true; + } + return false; + }; + ChartInternal.prototype.getDataLabelLength = function (min, max, key) { + var $$ = this, lengths = [0, 0], paddingCoef = 1.3; + $$.selectChart + .select('svg') + .selectAll('.dummy') + .data([min, max]) + .enter() + .append('text') + .text(function (d) { + return $$.dataLabelFormat(d.id)(d); + }) + .each(function (d, i) { + lengths[i] = getBBox(this)[key] * paddingCoef; + }) + .remove(); + return lengths; + }; + /** + * Returns true if the given data point is not arc type, otherwise false. + * @param {Object} d The data point + * @return {boolean} + */ + ChartInternal.prototype.isNoneArc = function (d) { + return this.hasTarget(this.data.targets, d.id); + }; + /** + * Returns true if the given data point is arc type, otherwise false. + * @param {Object} d The data point + * @return {boolean} + */ + ChartInternal.prototype.isArc = function (d) { + return 'data' in d && this.hasTarget(this.data.targets, d.data.id); + }; + /** + * Find the closest point from the given pos among the given targets or + * undefined if none satisfies conditions. + * + * @param {Array} targets + * @param {Array} pos An [x,y] coordinate + * @return {Object|undefined} + */ + ChartInternal.prototype.findClosestFromTargets = function (targets, pos) { + var $$ = this; + // for each target, find the closest point + var candidates = targets + .map(function (t) { + return $$.findClosest(t.values, pos, $$.config.tooltip_horizontal + ? $$.horizontalDistance.bind($$) + : $$.dist.bind($$), $$.config.point_sensitivity); + }) + .filter(function (v) { return v; }); + // returns the closest of candidates + if (candidates.length === 0) { + return undefined; + } + else if (candidates.length === 1) { + return candidates[0]; + } + else { + return $$.findClosest(candidates, pos, $$.dist.bind($$)); + } + }; + /** + * Find the closest point from the x value or undefined if none satisfies conditions. + * + * @param {Array} targets + * @param {Array} x A value on X axis + * @return {Object|undefined} + */ + ChartInternal.prototype.findClosestFromTargetsByX = function (targets, x) { + var closest; + var diff; + targets.forEach(function (t) { + t.values.forEach(function (d) { + var newDiff = Math.abs(x - d.x); + if (diff === undefined || newDiff < diff) { + closest = d; + diff = newDiff; + } + }); + }); + return closest; + }; + /** + * Using given compute distance method, returns the closest data point from the + * given position. + * + * Giving optionally a minimum distance to satisfy. + * + * @param {Array} dataPoints List of DataPoints + * @param {Array} pos An [x,y] coordinate + * @param {Function} computeDist Function to compute distance between 2 points + * @param {Number} minDist Minimal distance to satisfy + * @return {Object|undefined} Closest data point + */ + ChartInternal.prototype.findClosest = function (dataPoints, pos, computeDist, minDist) { + if (minDist === void 0) { minDist = Infinity; } + var $$ = this; + var closest; + // find closest bar + dataPoints + .filter(function (v) { return v && $$.isBarType(v.id); }) + .forEach(function (v) { + if (!closest) { + var shape = $$.main + .select('.' + + CLASS.bars + + $$.getTargetSelectorSuffix(v.id) + + ' .' + + CLASS.bar + + '-' + + v.index) + .node(); + if ($$.isWithinBar(pos, shape)) { + closest = v; + } + } + }); + // find closest point from non-bar + dataPoints + .filter(function (v) { return v && !$$.isBarType(v.id); }) + .forEach(function (v) { + var d = computeDist(v, pos); + if (d < minDist) { + minDist = d; + closest = v; + } + }); + return closest; + }; + ChartInternal.prototype.dist = function (data, pos) { + var $$ = this, config = $$.config, xIndex = config.axis_rotated ? 1 : 0, yIndex = config.axis_rotated ? 0 : 1, y = $$.circleY(data, data.index), x = $$.x(data.x); + return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2)); + }; + ChartInternal.prototype.horizontalDistance = function (data, pos) { + var $$ = this, config = $$.config, xIndex = config.axis_rotated ? 1 : 0, x = $$.x(data.x); + return Math.abs(x - pos[xIndex]); + }; + ChartInternal.prototype.convertValuesToStep = function (values) { + var converted = [].concat(values), i; + if (!this.isCategorized()) { + return values; + } + for (i = values.length + 1; 0 < i; i--) { + converted[i] = converted[i - 1]; + } + converted[0] = { + x: converted[0].x - 1, + value: converted[0].value, + id: converted[0].id + }; + converted[values.length + 1] = { + x: converted[values.length].x + 1, + value: converted[values.length].value, + id: converted[values.length].id + }; + return converted; + }; + /** + * Get ratio value + * + * @param {String} type Ratio for given type + * @param {Object} d Data value object + * @param {Boolean} asPercent Convert the return as percent or not + * @return {Number} Ratio value + * @private + */ + ChartInternal.prototype.getRatio = function (type, d, asPercent) { + if (asPercent === void 0) { asPercent = false; } + var $$ = this; + var api = $$.api; + var ratio = 0; + if (d && api.data.shown.call(api).length) { + ratio = d.ratio || d.value; + if (type === 'arc') { + if ($$.hasType('gauge')) { + ratio = + (d.endAngle - d.startAngle) / + (Math.PI * ($$.config.gauge_fullCircle ? 2 : 1)); + } + else { + var total = $$.getTotalDataSum(); + ratio = d.value / total; + } + } + else if (type === 'index') { + var total = $$.getTotalPerIndex($$.axis.getId(d.id)); + d.ratio = + isNumber(d.value) && total && total[d.index] > 0 + ? d.value / total[d.index] + : 0; + ratio = d.ratio; + } + } + return asPercent && ratio ? ratio * 100 : ratio; + }; + ChartInternal.prototype.updateDataAttributes = function (name, attrs) { + var $$ = this, config = $$.config, current = config['data_' + name]; + if (typeof attrs === 'undefined') { + return current; + } + Object.keys(attrs).forEach(function (id) { + current[id] = attrs[id]; + }); + $$.redraw({ + withLegend: true + }); + return current; + }; + + ChartInternal.prototype.load = function (targets, args) { + var $$ = this; + if (targets) { + // filter loading targets if needed + if (args.filter) { + targets = targets.filter(args.filter); + } + // set type if args.types || args.type specified + if (args.type || args.types) { + targets.forEach(function (t) { + var type = args.types && args.types[t.id] ? args.types[t.id] : args.type; + $$.setTargetType(t.id, type); + }); + } + // Update/Add data + $$.data.targets.forEach(function (d) { + for (var i = 0; i < targets.length; i++) { + if (d.id === targets[i].id) { + d.values = targets[i].values; + targets.splice(i, 1); + break; + } + } + }); + $$.data.targets = $$.data.targets.concat(targets); // add remained + } + // Set targets + $$.updateTargets($$.data.targets); + // Redraw with new targets + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + if (args.done) { + args.done(); + } + }; + ChartInternal.prototype.loadFromArgs = function (args) { + var $$ = this; + $$.resetCache(); + if (args.data) { + $$.load($$.convertDataToTargets(args.data), args); + } + else if (args.url) { + $$.convertUrlToData(args.url, args.mimeType, args.headers, args.keys, function (data) { + $$.load($$.convertDataToTargets(data), args); + }); + } + else if (args.json) { + $$.load($$.convertDataToTargets($$.convertJsonToData(args.json, args.keys)), args); + } + else if (args.rows) { + $$.load($$.convertDataToTargets($$.convertRowsToData(args.rows)), args); + } + else if (args.columns) { + $$.load($$.convertDataToTargets($$.convertColumnsToData(args.columns)), args); + } + else { + $$.load(null, args); + } + }; + ChartInternal.prototype.unload = function (targetIds, done) { + var $$ = this; + $$.resetCache(); + if (!done) { + done = function () { }; + } + // filter existing target + targetIds = targetIds.filter(function (id) { + return $$.hasTarget($$.data.targets, id); + }); + // If no target, call done and return + if (!targetIds || targetIds.length === 0) { + done(); + return; + } + $$.svg + .selectAll(targetIds.map(function (id) { + return $$.selectorTarget(id); + })) + .transition() + .style('opacity', 0) + .remove() + .call($$.endall, done); + targetIds.forEach(function (id) { + // Reset fadein for future load + $$.withoutFadeIn[id] = false; + // Remove target's elements + if ($$.legend) { + $$.legend + .selectAll('.' + CLASS.legendItem + $$.getTargetSelectorSuffix(id)) + .remove(); + } + // Remove target + $$.data.targets = $$.data.targets.filter(function (t) { + return t.id !== id; + }); + }); + }; + + ChartInternal.prototype.getYDomainMin = function (targets) { + var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasNegativeValue; + if (config.data_groups.length > 0) { + hasNegativeValue = $$.hasNegativeValueInTargets(targets); + for (j = 0; j < config.data_groups.length; j++) { + // Determine baseId + idsInGroup = config.data_groups[j].filter(function (id) { + return ids.indexOf(id) >= 0; + }); + if (idsInGroup.length === 0) { + continue; + } + baseId = idsInGroup[0]; + // Consider negative values + if (hasNegativeValue && ys[baseId]) { + ys[baseId].forEach(function (v, i) { + ys[baseId][i] = v < 0 ? v : 0; + }); + } + // Compute min + for (k = 1; k < idsInGroup.length; k++) { + id = idsInGroup[k]; + if (!ys[id]) { + continue; + } + ys[id].forEach(function (v, i) { + if ($$.axis.getId(id) === $$.axis.getId(baseId) && + ys[baseId] && + !(hasNegativeValue && +v > 0)) { + ys[baseId][i] += +v; + } + }); + } + } + } + return $$.d3.min(Object.keys(ys).map(function (key) { + return $$.d3.min(ys[key]); + })); + }; + ChartInternal.prototype.getYDomainMax = function (targets) { + var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasPositiveValue; + if (config.data_groups.length > 0) { + hasPositiveValue = $$.hasPositiveValueInTargets(targets); + for (j = 0; j < config.data_groups.length; j++) { + // Determine baseId + idsInGroup = config.data_groups[j].filter(function (id) { + return ids.indexOf(id) >= 0; + }); + if (idsInGroup.length === 0) { + continue; + } + baseId = idsInGroup[0]; + // Consider positive values + if (hasPositiveValue && ys[baseId]) { + ys[baseId].forEach(function (v, i) { + ys[baseId][i] = v > 0 ? v : 0; + }); + } + // Compute max + for (k = 1; k < idsInGroup.length; k++) { + id = idsInGroup[k]; + if (!ys[id]) { + continue; + } + ys[id].forEach(function (v, i) { + if ($$.axis.getId(id) === $$.axis.getId(baseId) && + ys[baseId] && + !(hasPositiveValue && +v < 0)) { + ys[baseId][i] += +v; + } + }); + } + } + } + return $$.d3.max(Object.keys(ys).map(function (key) { + return $$.d3.max(ys[key]); + })); + }; + ChartInternal.prototype.getYDomain = function (targets, axisId, xDomain) { + var $$ = this, config = $$.config; + if ($$.isAxisNormalized(axisId)) { + return [0, 100]; + } + var targetsByAxisId = targets.filter(function (t) { + return $$.axis.getId(t.id) === axisId; + }), yTargets = xDomain + ? $$.filterByXDomain(targetsByAxisId, xDomain) + : targetsByAxisId, yMin = axisId === 'y2' ? config.axis_y2_min : config.axis_y_min, yMax = axisId === 'y2' ? config.axis_y2_max : config.axis_y_max, yDomainMin = $$.getYDomainMin(yTargets), yDomainMax = $$.getYDomainMax(yTargets), domain, domainLength, padding_top, padding_bottom, center = axisId === 'y2' ? config.axis_y2_center : config.axis_y_center, yDomainAbs, lengths, diff, ratio, isAllPositive, isAllNegative, isZeroBased = ($$.hasType('bar', yTargets) && config.bar_zerobased) || + ($$.hasType('area', yTargets) && config.area_zerobased), isInverted = axisId === 'y2' ? config.axis_y2_inverted : config.axis_y_inverted, showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated, showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated; + // MEMO: avoid inverting domain unexpectedly + yDomainMin = isValue(yMin) + ? yMin + : isValue(yMax) + ? yDomainMin < yMax + ? yDomainMin + : yMax - 10 + : yDomainMin; + yDomainMax = isValue(yMax) + ? yMax + : isValue(yMin) + ? yMin < yDomainMax + ? yDomainMax + : yMin + 10 + : yDomainMax; + if (yTargets.length === 0) { + // use current domain if target of axisId is none + return axisId === 'y2' ? $$.y2.domain() : $$.y.domain(); + } + if (isNaN(yDomainMin)) { + // set minimum to zero when not number + yDomainMin = 0; + } + if (isNaN(yDomainMax)) { + // set maximum to have same value as yDomainMin + yDomainMax = yDomainMin; + } + if (yDomainMin === yDomainMax) { + yDomainMin < 0 ? (yDomainMax = 0) : (yDomainMin = 0); + } + isAllPositive = yDomainMin >= 0 && yDomainMax >= 0; + isAllNegative = yDomainMin <= 0 && yDomainMax <= 0; + // Cancel zerobased if axis_*_min / axis_*_max specified + if ((isValue(yMin) && isAllPositive) || (isValue(yMax) && isAllNegative)) { + isZeroBased = false; + } + // Bar/Area chart should be 0-based if all positive|negative + if (isZeroBased) { + if (isAllPositive) { + yDomainMin = 0; + } + if (isAllNegative) { + yDomainMax = 0; + } + } + domainLength = Math.abs(yDomainMax - yDomainMin); + padding_top = padding_bottom = domainLength * 0.1; + if (typeof center !== 'undefined') { + yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax)); + yDomainMax = center + yDomainAbs; + yDomainMin = center - yDomainAbs; + } + // add padding for data label + if (showHorizontalDataLabel) { + lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'width'); + diff = diffDomain($$.y.range()); + ratio = [lengths[0] / diff, lengths[1] / diff]; + padding_top += domainLength * (ratio[1] / (1 - ratio[0] - ratio[1])); + padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1])); + } + else if (showVerticalDataLabel) { + lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'height'); + var pixelsToAxisPadding = $$.getY(config["axis_" + axisId + "_type"], + // input domain as pixels + [0, config.axis_rotated ? $$.width : $$.height], + // output range as axis padding + [0, domainLength]); + padding_top += pixelsToAxisPadding(lengths[1]); + padding_bottom += pixelsToAxisPadding(lengths[0]); + } + if (axisId === 'y' && notEmpty(config.axis_y_padding)) { + padding_top = $$.axis.getPadding(config.axis_y_padding, 'top', padding_top, domainLength); + padding_bottom = $$.axis.getPadding(config.axis_y_padding, 'bottom', padding_bottom, domainLength); + } + if (axisId === 'y2' && notEmpty(config.axis_y2_padding)) { + padding_top = $$.axis.getPadding(config.axis_y2_padding, 'top', padding_top, domainLength); + padding_bottom = $$.axis.getPadding(config.axis_y2_padding, 'bottom', padding_bottom, domainLength); + } + // Bar/Area chart should be 0-based if all positive|negative + if (isZeroBased) { + if (isAllPositive) { + padding_bottom = yDomainMin; + } + if (isAllNegative) { + padding_top = -yDomainMax; + } + } + domain = [yDomainMin - padding_bottom, yDomainMax + padding_top]; + return isInverted ? domain.reverse() : domain; + }; + ChartInternal.prototype.getXDomainMin = function (targets) { + var $$ = this, config = $$.config; + return isDefined(config.axis_x_min) + ? $$.isTimeSeries() + ? this.parseDate(config.axis_x_min) + : config.axis_x_min + : $$.d3.min(targets, function (t) { + return $$.d3.min(t.values, function (v) { + return v.x; + }); + }); + }; + ChartInternal.prototype.getXDomainMax = function (targets) { + var $$ = this, config = $$.config; + return isDefined(config.axis_x_max) + ? $$.isTimeSeries() + ? this.parseDate(config.axis_x_max) + : config.axis_x_max + : $$.d3.max(targets, function (t) { + return $$.d3.max(t.values, function (v) { + return v.x; + }); + }); + }; + ChartInternal.prototype.getXDomainPadding = function (domain) { + var $$ = this, config = $$.config, diff = domain[1] - domain[0], maxDataCount, padding, paddingLeft, paddingRight; + if ($$.isCategorized()) { + padding = 0; + } + else if ($$.hasType('bar')) { + maxDataCount = $$.getMaxDataCount(); + padding = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : 0.5; + } + else { + padding = diff * 0.01; + } + if (typeof config.axis_x_padding === 'object' && + notEmpty(config.axis_x_padding)) { + paddingLeft = isValue(config.axis_x_padding.left) + ? config.axis_x_padding.left + : padding; + paddingRight = isValue(config.axis_x_padding.right) + ? config.axis_x_padding.right + : padding; + } + else if (typeof config.axis_x_padding === 'number') { + paddingLeft = paddingRight = config.axis_x_padding; + } + else { + paddingLeft = paddingRight = padding; + } + return { left: paddingLeft, right: paddingRight }; + }; + ChartInternal.prototype.getXDomain = function (targets) { + var $$ = this, xDomain = [$$.getXDomainMin(targets), $$.getXDomainMax(targets)], firstX = xDomain[0], lastX = xDomain[1], padding = $$.getXDomainPadding(xDomain), min = 0, max = 0; + // show center of x domain if min and max are the same + if (firstX - lastX === 0 && !$$.isCategorized()) { + if ($$.isTimeSeries()) { + firstX = new Date(firstX.getTime() * 0.5); + lastX = new Date(lastX.getTime() * 1.5); + } + else { + firstX = firstX === 0 ? 1 : firstX * 0.5; + lastX = lastX === 0 ? -1 : lastX * 1.5; + } + } + if (firstX || firstX === 0) { + min = $$.isTimeSeries() + ? new Date(firstX.getTime() - padding.left) + : firstX - padding.left; + } + if (lastX || lastX === 0) { + max = $$.isTimeSeries() + ? new Date(lastX.getTime() + padding.right) + : lastX + padding.right; + } + return [min, max]; + }; + ChartInternal.prototype.updateXDomain = function (targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) { + var $$ = this, config = $$.config; + if (withUpdateOrgXDomain) { + $$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets))); + $$.orgXDomain = $$.x.domain(); + if (config.zoom_enabled) { + $$.zoom.update(); + } + $$.subX.domain($$.x.domain()); + if ($$.brush) { + $$.brush.updateScale($$.subX); + } + } + if (withUpdateXDomain) { + $$.x.domain(domain + ? domain + : !$$.brush || $$.brush.empty() + ? $$.orgXDomain + : $$.brush.selectionAsValue()); + } + // Trim domain when too big by zoom mousemove event + if (withTrim) { + $$.x.domain($$.trimXDomain($$.x.orgDomain())); + } + return $$.x.domain(); + }; + ChartInternal.prototype.trimXDomain = function (domain) { + var zoomDomain = this.getZoomDomain(), min = zoomDomain[0], max = zoomDomain[1]; + if (domain[0] <= min) { + domain[1] = +domain[1] + (min - domain[0]); + domain[0] = min; + } + if (max <= domain[1]) { + domain[0] = +domain[0] - (domain[1] - max); + domain[1] = max; + } + return domain; + }; + + ChartInternal.prototype.drag = function (mouse) { + var $$ = this, config = $$.config, main = $$.main, d3 = $$.d3; + var sx, sy, mx, my, minX, maxX, minY, maxY; + if ($$.hasArcType()) { + return; + } + if (!config.data_selection_enabled) { + return; + } // do nothing if not selectable + if (!config.data_selection_multiple) { + return; + } // skip when single selection because drag is used for multiple selection + sx = $$.dragStart[0]; + sy = $$.dragStart[1]; + mx = mouse[0]; + my = mouse[1]; + minX = Math.min(sx, mx); + maxX = Math.max(sx, mx); + minY = config.data_selection_grouped ? $$.margin.top : Math.min(sy, my); + maxY = config.data_selection_grouped ? $$.height : Math.max(sy, my); + main + .select('.' + CLASS.dragarea) + .attr('x', minX) + .attr('y', minY) + .attr('width', maxX - minX) + .attr('height', maxY - minY); + // TODO: binary search when multiple xs + main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function (d, i) { + if (!config.data_selection_isselectable(d)) { + return; + } + var shape = d3.select(this), isSelected = shape.classed(CLASS.SELECTED), isIncluded = shape.classed(CLASS.INCLUDED), _x, _y, _w, _h, toggle, isWithin = false, box; + if (shape.classed(CLASS.circle)) { + _x = shape.attr('cx') * 1; + _y = shape.attr('cy') * 1; + toggle = $$.togglePoint; + isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY; + } + else if (shape.classed(CLASS.bar)) { + box = getPathBox(this); + _x = box.x; + _y = box.y; + _w = box.width; + _h = box.height; + toggle = $$.togglePath; + isWithin = + !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY); + } + else { + // line/area selection not supported yet + return; + } + if (isWithin ^ isIncluded) { + shape.classed(CLASS.INCLUDED, !isIncluded); + // TODO: included/unincluded callback here + shape.classed(CLASS.SELECTED, !isSelected); + toggle.call($$, !isSelected, shape, d, i); + } + }); + }; + ChartInternal.prototype.dragstart = function (mouse) { + var $$ = this, config = $$.config; + if ($$.hasArcType()) { + return; + } + if (!config.data_selection_enabled) { + return; + } // do nothing if not selectable + $$.dragStart = mouse; + $$.main + .select('.' + CLASS.chart) + .append('rect') + .attr('class', CLASS.dragarea) + .style('opacity', 0.1); + $$.dragging = true; + }; + ChartInternal.prototype.dragend = function () { + var $$ = this, config = $$.config; + if ($$.hasArcType()) { + return; + } + if (!config.data_selection_enabled) { + return; + } // do nothing if not selectable + $$.main + .select('.' + CLASS.dragarea) + .transition() + .duration(100) + .style('opacity', 0) + .remove(); + $$.main.selectAll('.' + CLASS.shape).classed(CLASS.INCLUDED, false); + $$.dragging = false; + }; + + ChartInternal.prototype.getYFormat = function (forArc) { + var $$ = this, formatForY = forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.yFormat, formatForY2 = forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.y2Format; + return function (v, ratio, id) { + var format = $$.axis.getId(id) === 'y2' ? formatForY2 : formatForY; + return format.call($$, v, ratio); + }; + }; + ChartInternal.prototype.yFormat = function (v) { + var $$ = this, config = $$.config, format = config.axis_y_tick_format + ? config.axis_y_tick_format + : $$.defaultValueFormat; + return format(v); + }; + ChartInternal.prototype.y2Format = function (v) { + var $$ = this, config = $$.config, format = config.axis_y2_tick_format + ? config.axis_y2_tick_format + : $$.defaultValueFormat; + return format(v); + }; + ChartInternal.prototype.defaultValueFormat = function (v) { + return isValue(v) ? +v : ''; + }; + ChartInternal.prototype.defaultArcValueFormat = function (v, ratio) { + return (ratio * 100).toFixed(1) + '%'; + }; + ChartInternal.prototype.dataLabelFormat = function (targetId) { + var $$ = this, data_labels = $$.config.data_labels, format, defaultFormat = function (v) { + return isValue(v) ? +v : ''; + }; + // find format according to axis id + if (typeof data_labels.format === 'function') { + format = data_labels.format; + } + else if (typeof data_labels.format === 'object') { + if (data_labels.format[targetId]) { + format = + data_labels.format[targetId] === true + ? defaultFormat + : data_labels.format[targetId]; + } + else { + format = function () { + return ''; + }; + } + } + else { + format = defaultFormat; + } + return format; + }; + + ChartInternal.prototype.initGrid = function () { + var $$ = this, config = $$.config, d3 = $$.d3; + $$.grid = $$.main + .append('g') + .attr('clip-path', $$.clipPathForGrid) + .attr('class', CLASS.grid); + if (config.grid_x_show) { + $$.grid.append('g').attr('class', CLASS.xgrids); + } + if (config.grid_y_show) { + $$.grid.append('g').attr('class', CLASS.ygrids); + } + if (config.grid_focus_show) { + $$.grid + .append('g') + .attr('class', CLASS.xgridFocus) + .append('line') + .attr('class', CLASS.xgridFocus); + } + $$.xgrid = d3.selectAll([]); + if (!config.grid_lines_front) { + $$.initGridLines(); + } + }; + ChartInternal.prototype.initGridLines = function () { + var $$ = this, d3 = $$.d3; + $$.gridLines = $$.main + .append('g') + .attr('clip-path', $$.clipPathForGrid) + .attr('class', CLASS.grid + ' ' + CLASS.gridLines); + $$.gridLines.append('g').attr('class', CLASS.xgridLines); + $$.gridLines.append('g').attr('class', CLASS.ygridLines); + $$.xgridLines = d3.selectAll([]); + }; + ChartInternal.prototype.updateXGrid = function (withoutUpdate) { + var $$ = this, config = $$.config, d3 = $$.d3, xgridData = $$.generateGridData(config.grid_x_type, $$.x), tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; + $$.xgridAttr = config.axis_rotated + ? { + x1: 0, + x2: $$.width, + y1: function (d) { + return $$.x(d) - tickOffset; + }, + y2: function (d) { + return $$.x(d) - tickOffset; + } + } + : { + x1: function (d) { + return $$.x(d) + tickOffset; + }, + x2: function (d) { + return $$.x(d) + tickOffset; + }, + y1: 0, + y2: $$.height + }; + $$.xgridAttr.opacity = function () { + var pos = +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1'); + return pos === (config.axis_rotated ? $$.height : 0) ? 0 : 1; + }; + var xgrid = $$.main + .select('.' + CLASS.xgrids) + .selectAll('.' + CLASS.xgrid) + .data(xgridData); + var xgridEnter = xgrid + .enter() + .append('line') + .attr('class', CLASS.xgrid) + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', 0); + $$.xgrid = xgridEnter.merge(xgrid); + if (!withoutUpdate) { + $$.xgrid + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', $$.xgridAttr.opacity); + } + xgrid.exit().remove(); + }; + ChartInternal.prototype.updateYGrid = function () { + var $$ = this, config = $$.config, gridValues = $$.yAxis.tickValues() || $$.y.ticks(config.grid_y_ticks); + var ygrid = $$.main + .select('.' + CLASS.ygrids) + .selectAll('.' + CLASS.ygrid) + .data(gridValues); + var ygridEnter = ygrid + .enter() + .append('line') + // TODO: x1, x2, y1, y2, opacity need to be set here maybe + .attr('class', CLASS.ygrid); + $$.ygrid = ygridEnter.merge(ygrid); + $$.ygrid + .attr('x1', config.axis_rotated ? $$.y : 0) + .attr('x2', config.axis_rotated ? $$.y : $$.width) + .attr('y1', config.axis_rotated ? 0 : $$.y) + .attr('y2', config.axis_rotated ? $$.height : $$.y); + ygrid.exit().remove(); + $$.smoothLines($$.ygrid, 'grid'); + }; + ChartInternal.prototype.gridTextAnchor = function (d) { + return d.position ? d.position : 'end'; + }; + ChartInternal.prototype.gridTextDx = function (d) { + return d.position === 'start' ? 4 : d.position === 'middle' ? 0 : -4; + }; + ChartInternal.prototype.xGridTextX = function (d) { + return d.position === 'start' + ? -this.height + : d.position === 'middle' + ? -this.height / 2 + : 0; + }; + ChartInternal.prototype.yGridTextX = function (d) { + return d.position === 'start' + ? 0 + : d.position === 'middle' + ? this.width / 2 + : this.width; + }; + ChartInternal.prototype.updateGrid = function (duration) { + var $$ = this, main = $$.main, config = $$.config, xgridLine, xgridLineEnter, ygridLine, ygridLineEnter, xv = $$.xv.bind($$), yv = $$.yv.bind($$), xGridTextX = $$.xGridTextX.bind($$), yGridTextX = $$.yGridTextX.bind($$); + // hide if arc type + $$.grid.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + main.select('line.' + CLASS.xgridFocus).style('visibility', 'hidden'); + if (config.grid_x_show) { + $$.updateXGrid(); + } + xgridLine = main + .select('.' + CLASS.xgridLines) + .selectAll('.' + CLASS.xgridLine) + .data(config.grid_x_lines); + // enter + xgridLineEnter = xgridLine + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.xgridLine + (d['class'] ? ' ' + d['class'] : ''); + }); + xgridLineEnter + .append('line') + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv) + .attr('y1', config.axis_rotated ? xv : 0) + .attr('y2', config.axis_rotated ? xv : $$.height) + .style('opacity', 0); + xgridLineEnter + .append('text') + .attr('text-anchor', $$.gridTextAnchor) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .attr('x', config.axis_rotated ? yGridTextX : xGridTextX) + .attr('y', xv) + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style('opacity', 0); + // udpate + $$.xgridLines = xgridLineEnter.merge(xgridLine); + // done in d3.transition() of the end of this function + // exit + xgridLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + // Y-Grid + if (config.grid_y_show) { + $$.updateYGrid(); + } + ygridLine = main + .select('.' + CLASS.ygridLines) + .selectAll('.' + CLASS.ygridLine) + .data(config.grid_y_lines); + // enter + ygridLineEnter = ygridLine + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.ygridLine + (d['class'] ? ' ' + d['class'] : ''); + }); + ygridLineEnter + .append('line') + .attr('x1', config.axis_rotated ? yv : 0) + .attr('x2', config.axis_rotated ? yv : $$.width) + .attr('y1', config.axis_rotated ? 0 : yv) + .attr('y2', config.axis_rotated ? $$.height : yv) + .style('opacity', 0); + ygridLineEnter + .append('text') + .attr('text-anchor', $$.gridTextAnchor) + .attr('transform', config.axis_rotated ? 'rotate(-90)' : '') + .attr('x', config.axis_rotated ? xGridTextX : yGridTextX) + .attr('y', yv) + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style('opacity', 0); + // update + $$.ygridLines = ygridLineEnter.merge(ygridLine); + $$.ygridLines + .select('line') + .transition() + .duration(duration) + .attr('x1', config.axis_rotated ? yv : 0) + .attr('x2', config.axis_rotated ? yv : $$.width) + .attr('y1', config.axis_rotated ? 0 : yv) + .attr('y2', config.axis_rotated ? $$.height : yv) + .style('opacity', 1); + $$.ygridLines + .select('text') + .transition() + .duration(duration) + .attr('x', config.axis_rotated ? $$.xGridTextX.bind($$) : $$.yGridTextX.bind($$)) + .attr('y', yv) + .text(function (d) { + return d.text; + }) + .style('opacity', 1); + // exit + ygridLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + }; + ChartInternal.prototype.redrawGrid = function (withTransition, transition) { + var $$ = this, config = $$.config, xv = $$.xv.bind($$), lines = $$.xgridLines.select('line'), texts = $$.xgridLines.select('text'); + return [ + (withTransition ? lines.transition(transition) : lines) + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv) + .attr('y1', config.axis_rotated ? xv : 0) + .attr('y2', config.axis_rotated ? xv : $$.height) + .style('opacity', 1), + (withTransition ? texts.transition(transition) : texts) + .attr('x', config.axis_rotated ? $$.yGridTextX.bind($$) : $$.xGridTextX.bind($$)) + .attr('y', xv) + .text(function (d) { + return d.text; + }) + .style('opacity', 1) + ]; + }; + ChartInternal.prototype.showXGridFocus = function (selectedData) { + var $$ = this, config = $$.config, dataToShow = selectedData.filter(function (d) { + return d && isValue(d.value); + }), focusEl = $$.main.selectAll('line.' + CLASS.xgridFocus), xx = $$.xx.bind($$); + if (!config.tooltip_show) { + return; + } + // Hide when stanford plot exists + if ($$.hasType('stanford') || $$.hasArcType()) { + return; + } + focusEl + .style('visibility', 'visible') + .data([dataToShow[0]]) + .attr(config.axis_rotated ? 'y1' : 'x1', xx) + .attr(config.axis_rotated ? 'y2' : 'x2', xx); + $$.smoothLines(focusEl, 'grid'); + }; + ChartInternal.prototype.hideXGridFocus = function () { + this.main.select('line.' + CLASS.xgridFocus).style('visibility', 'hidden'); + }; + ChartInternal.prototype.updateXgridFocus = function () { + var $$ = this, config = $$.config; + $$.main + .select('line.' + CLASS.xgridFocus) + .attr('x1', config.axis_rotated ? 0 : -10) + .attr('x2', config.axis_rotated ? $$.width : -10) + .attr('y1', config.axis_rotated ? -10 : 0) + .attr('y2', config.axis_rotated ? -10 : $$.height); + }; + ChartInternal.prototype.generateGridData = function (type, scale) { + var $$ = this, gridData = [], xDomain, firstYear, lastYear, i, tickNum = $$.main + .select('.' + CLASS.axisX) + .selectAll('.tick') + .size(); + if (type === 'year') { + xDomain = $$.getXDomain(); + firstYear = xDomain[0].getFullYear(); + lastYear = xDomain[1].getFullYear(); + for (i = firstYear; i <= lastYear; i++) { + gridData.push(new Date(i + '-01-01 00:00:00')); + } + } + else { + gridData = scale.ticks(10); + if (gridData.length > tickNum) { + // use only int + gridData = gridData.filter(function (d) { + return ('' + d).indexOf('.') < 0; + }); + } + } + return gridData; + }; + ChartInternal.prototype.getGridFilterToRemove = function (params) { + return params + ? function (line) { + var found = false; + [].concat(params).forEach(function (param) { + if (('value' in param && line.value === param.value) || + ('class' in param && line['class'] === param['class'])) { + found = true; + } + }); + return found; + } + : function () { + return true; + }; + }; + ChartInternal.prototype.removeGridLines = function (params, forX) { + var $$ = this, config = $$.config, toRemove = $$.getGridFilterToRemove(params), toShow = function (line) { + return !toRemove(line); + }, classLines = forX ? CLASS.xgridLines : CLASS.ygridLines, classLine = forX ? CLASS.xgridLine : CLASS.ygridLine; + $$.main + .select('.' + classLines) + .selectAll('.' + classLine) + .filter(toRemove) + .transition() + .duration(config.transition_duration) + .style('opacity', 0) + .remove(); + if (forX) { + config.grid_x_lines = config.grid_x_lines.filter(toShow); + } + else { + config.grid_y_lines = config.grid_y_lines.filter(toShow); + } + }; + + ChartInternal.prototype.initEventRect = function () { + var $$ = this, config = $$.config; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.eventRects) + .style('fill-opacity', 0); + $$.eventRect = $$.main + .select('.' + CLASS.eventRects) + .append('rect') + .attr('class', CLASS.eventRect); + // event rect handle zoom event as well + if (config.zoom_enabled && $$.zoom) { + $$.eventRect.call($$.zoom).on('dblclick.zoom', null); + if (config.zoom_initialRange) { + // WORKAROUND: Add transition to apply transform immediately when no subchart + $$.eventRect + .transition() + .duration(0) + .call($$.zoom.transform, $$.zoomTransform(config.zoom_initialRange)); + } + } + }; + ChartInternal.prototype.redrawEventRect = function () { + var $$ = this, d3 = $$.d3, config = $$.config; + function mouseout() { + $$.svg.select('.' + CLASS.eventRect).style('cursor', null); + $$.hideXGridFocus(); + $$.hideTooltip(); + $$.unexpandCircles(); + $$.unexpandBars(); + } + var isHoveringDataPoint = function (mouse, closest) { + return closest && + ($$.isBarType(closest.id) || + $$.dist(closest, mouse) < config.point_sensitivity); + }; + var withName = function (d) { return (d ? $$.addName(Object.assign({}, d)) : null); }; + // rects for mouseover + $$.main + .select('.' + CLASS.eventRects) + .style('cursor', config.zoom_enabled + ? config.axis_rotated + ? 'ns-resize' + : 'ew-resize' + : null); + $$.eventRect + .attr('x', 0) + .attr('y', 0) + .attr('width', $$.width) + .attr('height', $$.height) + .on('mouseout', config.interaction_enabled + ? function () { + if (!config) { + return; + } // chart is destroyed + if ($$.hasArcType()) { + return; + } + if ($$.mouseover) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + mouseout(); + } + : null) + .on('mousemove', config.interaction_enabled + ? function () { + // do nothing when dragging + if ($$.dragging) { + return; + } + var targetsToShow = $$.getTargetsToShow(); + // do nothing if arc type + if ($$.hasArcType(targetsToShow)) { + return; + } + var mouse = d3.mouse(this); + var closest = withName($$.findClosestFromTargets(targetsToShow, mouse)); + var isMouseCloseToDataPoint = isHoveringDataPoint(mouse, closest); + // ensure onmouseout is always called if mousemove switch between 2 targets + if ($$.mouseover && + (!closest || + closest.id !== $$.mouseover.id || + closest.index !== $$.mouseover.index)) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + if (closest && !$$.mouseover) { + config.data_onmouseover.call($$.api, closest); + $$.mouseover = closest; + } + // show cursor as pointer if we're hovering a data point close enough + $$.svg + .select('.' + CLASS.eventRect) + .style('cursor', isMouseCloseToDataPoint ? 'pointer' : null); + // if tooltip not grouped, we want to display only data from closest data point + var showSingleDataPoint = !config.tooltip_grouped || $$.hasType('stanford', targetsToShow); + // find data to highlight + var selectedData; + if (showSingleDataPoint) { + if (closest) { + selectedData = [closest]; + } + } + else { + var closestByX = void 0; + if (closest) { + // reuse closest value + closestByX = closest; + } + else { + // try to find the closest value by X values from the mouse position + var mouseX = config.axis_rotated ? mouse[1] : mouse[0]; + closestByX = $$.findClosestFromTargetsByX(targetsToShow, $$.x.invert(mouseX)); + } + // highlight all data for this 'x' value + if (closestByX) { + selectedData = $$.filterByX(targetsToShow, closestByX.x); + } + } + // ensure we have data to show + if (!selectedData || selectedData.length === 0) { + return mouseout(); + } + // inject names for each point + selectedData = selectedData.map(withName); + // show tooltip + $$.showTooltip(selectedData, this); + // expand points + if (config.point_focus_expand_enabled) { + $$.unexpandCircles(); + selectedData.forEach(function (d) { + $$.expandCircles(d.index, d.id, false); + }); + } + // expand bars + $$.unexpandBars(); + selectedData.forEach(function (d) { + $$.expandBars(d.index, d.id, false); + }); + // Show xgrid focus line + $$.showXGridFocus(selectedData); + } + : null) + .on('click', config.interaction_enabled + ? function () { + var targetsToShow = $$.getTargetsToShow(); + if ($$.hasArcType(targetsToShow)) { + return; + } + var mouse = d3.mouse(this); + var closest = withName($$.findClosestFromTargets(targetsToShow, mouse)); + if (!isHoveringDataPoint(mouse, closest)) { + return; + } + // select if selection enabled + var sameXData; + if (!config.data_selection_grouped || $$.isStanfordType(closest)) { + sameXData = [closest]; + } + else { + sameXData = $$.filterByX(targetsToShow, closest.x); + } + // toggle selected state + sameXData.forEach(function (d) { + $$.main + .selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.shape + '-' + d.index) + .each(function () { + if (config.data_selection_grouped || + $$.isWithinShape(this, d)) { + $$.toggleShape(this, d, d.index); + } + }); + }); + // call data_onclick on the closest data point + if (closest) { + var shape = $$.main + .selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(closest.id)) + .select('.' + CLASS.shape + '-' + closest.index); + config.data_onclick.call($$.api, closest, shape.node()); + } + } + : null) + .call(config.interaction_enabled && config.data_selection_draggable && $$.drag + ? d3 + .drag() + .on('drag', function () { + $$.drag(d3.mouse(this)); + }) + .on('start', function () { + $$.dragstart(d3.mouse(this)); + }) + .on('end', function () { + $$.dragend(); + }) + : function () { }); + }; + ChartInternal.prototype.getMousePosition = function (data) { + var $$ = this; + return [$$.x(data.x), $$.getYScale(data.id)(data.value)]; + }; + ChartInternal.prototype.dispatchEvent = function (type, mouse) { + var $$ = this, selector = '.' + CLASS.eventRect, eventRect = $$.main.select(selector).node(), box = eventRect.getBoundingClientRect(), x = box.left + (mouse ? mouse[0] : 0), y = box.top + (mouse ? mouse[1] : 0), event = document.createEvent('MouseEvents'); + event.initMouseEvent(type, true, true, window, 0, x, y, x, y, false, false, false, false, 0, null); + eventRect.dispatchEvent(event); + }; + + ChartInternal.prototype.initLegend = function () { + var $$ = this; + $$.legendItemTextBox = {}; + $$.legendHasRendered = false; + $$.legend = $$.svg.append('g').attr('transform', $$.getTranslate('legend')); + if (!$$.config.legend_show) { + $$.legend.style('visibility', 'hidden'); + $$.hiddenLegendIds = $$.mapToIds($$.data.targets); + return; + } + // MEMO: call here to update legend box and tranlate for all + // MEMO: translate will be updated by this, so transform not needed in updateLegend() + $$.updateLegendWithDefaults(); + }; + ChartInternal.prototype.updateLegendWithDefaults = function () { + var $$ = this; + $$.updateLegend($$.mapToIds($$.data.targets), { + withTransform: false, + withTransitionForTransform: false, + withTransition: false + }); + }; + ChartInternal.prototype.updateSizeForLegend = function (legendHeight, legendWidth) { + var $$ = this, config = $$.config, insetLegendPosition = { + top: $$.isLegendTop + ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 + : $$.currentHeight - + legendHeight - + $$.getCurrentPaddingBottom() - + config.legend_inset_y, + left: $$.isLegendLeft + ? $$.getCurrentPaddingLeft() + config.legend_inset_x + 0.5 + : $$.currentWidth - + legendWidth - + $$.getCurrentPaddingRight() - + config.legend_inset_x + + 0.5 + }; + $$.margin3 = { + top: $$.isLegendRight + ? 0 + : $$.isLegendInset + ? insetLegendPosition.top + : $$.currentHeight - legendHeight, + right: NaN, + bottom: 0, + left: $$.isLegendRight + ? $$.currentWidth - legendWidth + : $$.isLegendInset + ? insetLegendPosition.left + : 0 + }; + }; + ChartInternal.prototype.transformLegend = function (withTransition) { + var $$ = this; + (withTransition ? $$.legend.transition() : $$.legend).attr('transform', $$.getTranslate('legend')); + }; + ChartInternal.prototype.updateLegendStep = function (step) { + this.legendStep = step; + }; + ChartInternal.prototype.updateLegendItemWidth = function (w) { + this.legendItemWidth = w; + }; + ChartInternal.prototype.updateLegendItemHeight = function (h) { + this.legendItemHeight = h; + }; + ChartInternal.prototype.getLegendWidth = function () { + var $$ = this; + return $$.config.legend_show + ? $$.isLegendRight || $$.isLegendInset + ? $$.legendItemWidth * ($$.legendStep + 1) + : $$.currentWidth + : 0; + }; + ChartInternal.prototype.getLegendHeight = function () { + var $$ = this, h = 0; + if ($$.config.legend_show) { + if ($$.isLegendRight) { + h = $$.currentHeight; + } + else { + h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1); + } + } + return h; + }; + ChartInternal.prototype.opacityForLegend = function (legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 1; + }; + ChartInternal.prototype.opacityForUnfocusedLegend = function (legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 0.3; + }; + ChartInternal.prototype.toggleFocusLegend = function (targetIds, focus) { + var $$ = this; + targetIds = $$.mapToTargetIds(targetIds); + $$.legend + .selectAll('.' + CLASS.legendItem) + .filter(function (id) { + return targetIds.indexOf(id) >= 0; + }) + .classed(CLASS.legendItemFocused, focus) + .transition() + .duration(100) + .style('opacity', function () { + var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend; + return opacity.call($$, $$.d3.select(this)); + }); + }; + ChartInternal.prototype.revertLegend = function () { + var $$ = this, d3 = $$.d3; + $$.legend + .selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemFocused, false) + .transition() + .duration(100) + .style('opacity', function () { + return $$.opacityForLegend(d3.select(this)); + }); + }; + ChartInternal.prototype.showLegend = function (targetIds) { + var $$ = this, config = $$.config; + if (!config.legend_show) { + config.legend_show = true; + $$.legend.style('visibility', 'visible'); + if (!$$.legendHasRendered) { + $$.updateLegendWithDefaults(); + } + } + $$.removeHiddenLegendIds(targetIds); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .style('visibility', 'visible') + .transition() + .style('opacity', function () { + return $$.opacityForLegend($$.d3.select(this)); + }); + }; + ChartInternal.prototype.hideLegend = function (targetIds) { + var $$ = this, config = $$.config; + if (config.legend_show && isEmpty(targetIds)) { + config.legend_show = false; + $$.legend.style('visibility', 'hidden'); + } + $$.addHiddenLegendIds(targetIds); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .style('opacity', 0) + .style('visibility', 'hidden'); + }; + ChartInternal.prototype.clearLegendItemTextBoxCache = function () { + this.legendItemTextBox = {}; + }; + ChartInternal.prototype.updateLegend = function (targetIds, options, transitions) { + var $$ = this, config = $$.config; + var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect, x1ForLegendTile, x2ForLegendTile, yForLegendTile; + var paddingTop = 4, paddingRight = 10, maxWidth = 0, maxHeight = 0, posMin = 10, tileWidth = config.legend_item_tile_width + 5; + var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; + var withTransition, withTransitionForTransform; + var texts, rects, tiles, background; + // Skip elements when their name is set to null + targetIds = targetIds.filter(function (id) { + return !isDefined(config.data_names[id]) || config.data_names[id] !== null; + }); + options = options || {}; + withTransition = getOption(options, 'withTransition', true); + withTransitionForTransform = getOption(options, 'withTransitionForTransform', true); + function getTextBox(textElement, id) { + if (!$$.legendItemTextBox[id]) { + $$.legendItemTextBox[id] = $$.getTextRect(textElement.textContent, CLASS.legendItem, textElement); + } + return $$.legendItemTextBox[id]; + } + function updatePositions(textElement, id, index) { + var reset = index === 0, isLast = index === targetIds.length - 1, box = getTextBox(textElement, id), itemWidth = box.width + + tileWidth + + (isLast && !($$.isLegendRight || $$.isLegendInset) ? 0 : paddingRight) + + config.legend_padding, itemHeight = box.height + paddingTop, itemLength = $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth, areaLength = $$.isLegendRight || $$.isLegendInset + ? $$.getLegendHeight() + : $$.getLegendWidth(), margin, maxLength; + // MEMO: care about condifion of step, totalLength + function updateValues(id, withoutStep) { + if (!withoutStep) { + margin = (areaLength - totalLength - itemLength) / 2; + if (margin < posMin) { + margin = (areaLength - itemLength) / 2; + totalLength = 0; + step++; + } + } + steps[id] = step; + margins[step] = $$.isLegendInset ? 10 : margin; + offsets[id] = totalLength; + totalLength += itemLength; + } + if (reset) { + totalLength = 0; + step = 0; + maxWidth = 0; + maxHeight = 0; + } + if (config.legend_show && !$$.isLegendToShow(id)) { + widths[id] = heights[id] = steps[id] = offsets[id] = 0; + return; + } + widths[id] = itemWidth; + heights[id] = itemHeight; + if (!maxWidth || itemWidth >= maxWidth) { + maxWidth = itemWidth; + } + if (!maxHeight || itemHeight >= maxHeight) { + maxHeight = itemHeight; + } + maxLength = $$.isLegendRight || $$.isLegendInset ? maxHeight : maxWidth; + if (config.legend_equally) { + Object.keys(widths).forEach(function (id) { + widths[id] = maxWidth; + }); + Object.keys(heights).forEach(function (id) { + heights[id] = maxHeight; + }); + margin = (areaLength - maxLength * targetIds.length) / 2; + if (margin < posMin) { + totalLength = 0; + step = 0; + targetIds.forEach(function (id) { + updateValues(id); + }); + } + else { + updateValues(id, true); + } + } + else { + updateValues(id); + } + } + if ($$.isLegendInset) { + step = config.legend_inset_step + ? config.legend_inset_step + : targetIds.length; + $$.updateLegendStep(step); + } + if ($$.isLegendRight) { + xForLegend = function (id) { + return maxWidth * steps[id]; + }; + yForLegend = function (id) { + return margins[steps[id]] + offsets[id]; + }; + } + else if ($$.isLegendInset) { + xForLegend = function (id) { + return maxWidth * steps[id] + 10; + }; + yForLegend = function (id) { + return margins[steps[id]] + offsets[id]; + }; + } + else { + xForLegend = function (id) { + return margins[steps[id]] + offsets[id]; + }; + yForLegend = function (id) { + return maxHeight * steps[id]; + }; + } + xForLegendText = function (id, i) { + return xForLegend(id, i) + 4 + config.legend_item_tile_width; + }; + yForLegendText = function (id, i) { + return yForLegend(id, i) + 9; + }; + xForLegendRect = function (id, i) { + return xForLegend(id, i); + }; + yForLegendRect = function (id, i) { + return yForLegend(id, i) - 5; + }; + x1ForLegendTile = function (id, i) { + return xForLegend(id, i) - 2; + }; + x2ForLegendTile = function (id, i) { + return xForLegend(id, i) - 2 + config.legend_item_tile_width; + }; + yForLegendTile = function (id, i) { + return yForLegend(id, i) + 4; + }; + // Define g for legend area + l = $$.legend + .selectAll('.' + CLASS.legendItem) + .data(targetIds) + .enter() + .append('g') + .attr('class', function (id) { + return $$.generateClass(CLASS.legendItem, id); + }) + .style('visibility', function (id) { + return $$.isLegendToShow(id) ? 'visible' : 'hidden'; + }) + .style('cursor', function () { + return config.interaction_enabled ? 'pointer' : 'auto'; + }) + .on('click', config.interaction_enabled + ? function (id) { + if (config.legend_item_onclick) { + config.legend_item_onclick.call($$, id); + } + else { + if ($$.d3.event.altKey) { + $$.api.hide(); + $$.api.show(id); + } + else { + $$.api.toggle(id); + $$.isTargetToShow(id) ? $$.api.focus(id) : $$.api.revert(); + } + } + } + : null) + .on('mouseover', config.interaction_enabled + ? function (id) { + if (config.legend_item_onmouseover) { + config.legend_item_onmouseover.call($$, id); + } + else { + $$.d3.select(this).classed(CLASS.legendItemFocused, true); + if (!$$.transiting && $$.isTargetToShow(id)) { + $$.api.focus(id); + } + } + } + : null) + .on('mouseout', config.interaction_enabled + ? function (id) { + if (config.legend_item_onmouseout) { + config.legend_item_onmouseout.call($$, id); + } + else { + $$.d3.select(this).classed(CLASS.legendItemFocused, false); + $$.api.revert(); + } + } + : null); + l.append('text') + .text(function (id) { + return isDefined(config.data_names[id]) ? config.data_names[id] : id; + }) + .each(function (id, i) { + updatePositions(this, id, i); + }) + .style('pointer-events', 'none') + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendText); + l.append('rect') + .attr('class', CLASS.legendItemEvent) + .style('fill-opacity', 0) + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendRect : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendRect); + l.append('line') + .attr('class', CLASS.legendItemTile) + .style('stroke', $$.color) + .style('pointer-events', 'none') + .attr('x1', $$.isLegendRight || $$.isLegendInset ? x1ForLegendTile : -200) + .attr('y1', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) + .attr('x2', $$.isLegendRight || $$.isLegendInset ? x2ForLegendTile : -200) + .attr('y2', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) + .attr('stroke-width', config.legend_item_tile_height); + // Set background for inset legend + background = $$.legend.select('.' + CLASS.legendBackground + ' rect'); + if ($$.isLegendInset && maxWidth > 0 && background.size() === 0) { + background = $$.legend + .insert('g', '.' + CLASS.legendItem) + .attr('class', CLASS.legendBackground) + .append('rect'); + } + texts = $$.legend + .selectAll('text') + .data(targetIds) + .text(function (id) { + return isDefined(config.data_names[id]) ? config.data_names[id] : id; + }) // MEMO: needed for update + .each(function (id, i) { + updatePositions(this, id, i); + }); + (withTransition ? texts.transition() : texts) + .attr('x', xForLegendText) + .attr('y', yForLegendText); + rects = $$.legend.selectAll('rect.' + CLASS.legendItemEvent).data(targetIds); + (withTransition ? rects.transition() : rects) + .attr('width', function (id) { + return widths[id]; + }) + .attr('height', function (id) { + return heights[id]; + }) + .attr('x', xForLegendRect) + .attr('y', yForLegendRect); + tiles = $$.legend.selectAll('line.' + CLASS.legendItemTile).data(targetIds); + (withTransition ? tiles.transition() : tiles) + .style('stroke', $$.levelColor + ? function (id) { + return $$.levelColor($$.cache[id].values.reduce(function (total, item) { + return total + item.value; + }, 0)); + } + : $$.color) + .attr('x1', x1ForLegendTile) + .attr('y1', yForLegendTile) + .attr('x2', x2ForLegendTile) + .attr('y2', yForLegendTile); + if (background) { + (withTransition ? background.transition() : background) + .attr('height', $$.getLegendHeight() - 12) + .attr('width', maxWidth * (step + 1) + 10); + } + // toggle legend state + $$.legend + .selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemHidden, function (id) { + return !$$.isTargetToShow(id); + }); + // Update all to reflect change of legend + $$.updateLegendItemWidth(maxWidth); + $$.updateLegendItemHeight(maxHeight); + $$.updateLegendStep(step); + // Update size and scale + $$.updateSizes(); + $$.updateScales(); + $$.updateSvgSize(); + // Update g positions + $$.transformAll(withTransitionForTransform, transitions); + $$.legendHasRendered = true; + }; + + ChartInternal.prototype.initRegion = function () { + var $$ = this; + $$.region = $$.main + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.regions); + }; + ChartInternal.prototype.updateRegion = function (duration) { + var $$ = this, config = $$.config; + // hide if arc type + $$.region.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + var mainRegion = $$.main + .select('.' + CLASS.regions) + .selectAll('.' + CLASS.region) + .data(config.regions); + var g = mainRegion.enter().append('g'); + g.append('rect') + .attr('x', $$.regionX.bind($$)) + .attr('y', $$.regionY.bind($$)) + .attr('width', $$.regionWidth.bind($$)) + .attr('height', $$.regionHeight.bind($$)) + .style('fill-opacity', function (d) { + return isValue(d.opacity) ? d.opacity : 0.1; + }); + g.append('text').text($$.labelRegion.bind($$)); + $$.mainRegion = g.merge(mainRegion).attr('class', $$.classRegion.bind($$)); + mainRegion + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + }; + ChartInternal.prototype.redrawRegion = function (withTransition, transition) { + var $$ = this, regions = $$.mainRegion, regionLabels = $$.mainRegion.selectAll('text'); + return [ + (withTransition ? regions.transition(transition) : regions) + .attr('x', $$.regionX.bind($$)) + .attr('y', $$.regionY.bind($$)) + .attr('width', $$.regionWidth.bind($$)) + .attr('height', $$.regionHeight.bind($$)) + .style('fill-opacity', function (d) { + return isValue(d.opacity) ? d.opacity : 0.1; + }), + (withTransition ? regionLabels.transition(transition) : regionLabels) + .attr('x', $$.labelOffsetX.bind($$)) + .attr('y', $$.labelOffsetY.bind($$)) + .attr('transform', $$.labelTransform.bind($$)) + .attr('style', 'text-anchor: left;') + ]; + }; + ChartInternal.prototype.regionX = function (d) { + var $$ = this, config = $$.config, xPos, yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + xPos = config.axis_rotated ? ('start' in d ? yScale(d.start) : 0) : 0; + } + else { + xPos = config.axis_rotated + ? 0 + : 'start' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) + : 0; + } + return xPos; + }; + ChartInternal.prototype.regionY = function (d) { + var $$ = this, config = $$.config, yPos, yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + yPos = config.axis_rotated ? 0 : 'end' in d ? yScale(d.end) : 0; + } + else { + yPos = config.axis_rotated + ? 'start' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) + : 0 + : 0; + } + return yPos; + }; + ChartInternal.prototype.regionWidth = function (d) { + var $$ = this, config = $$.config, start = $$.regionX(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + end = config.axis_rotated + ? 'end' in d + ? yScale(d.end) + : $$.width + : $$.width; + } + else { + end = config.axis_rotated + ? $$.width + : 'end' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) + : $$.width; + } + return end < start ? 0 : end - start; + }; + ChartInternal.prototype.regionHeight = function (d) { + var $$ = this, config = $$.config, start = this.regionY(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + end = config.axis_rotated + ? $$.height + : 'start' in d + ? yScale(d.start) + : $$.height; + } + else { + end = config.axis_rotated + ? 'end' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) + : $$.height + : $$.height; + } + return end < start ? 0 : end - start; + }; + ChartInternal.prototype.isRegionOnX = function (d) { + return !d.axis || d.axis === 'x'; + }; + ChartInternal.prototype.labelRegion = function (d) { + return 'label' in d ? d.label : ''; + }; + ChartInternal.prototype.labelTransform = function (d) { + return 'vertical' in d && d.vertical ? 'rotate(90)' : ''; + }; + ChartInternal.prototype.labelOffsetX = function (d) { + var paddingX = 'paddingX' in d ? d.paddingX : 3; + var paddingY = 'paddingY' in d ? d.paddingY : 3; + return 'vertical' in d && d.vertical + ? this.regionY(d) + paddingY + : this.regionX(d) + paddingX; + }; + ChartInternal.prototype.labelOffsetY = function (d) { + var paddingX = 'paddingX' in d ? d.paddingX : 3; + var paddingY = 'paddingY' in d ? d.paddingY : 3; + return 'vertical' in d && d.vertical + ? -(this.regionX(d) + paddingX) + : this.regionY(d) + 10 + paddingY; + }; + + function c3LogScale(d3, linearScale, logScale) { + var PROJECTION = [0.01, 10]; + if (!linearScale) { + linearScale = d3.scaleLinear(); + linearScale.range(PROJECTION); + } + if (!logScale) { + logScale = d3.scaleLog(); + logScale.domain(PROJECTION); + logScale.nice(); + } + // copied from https://github.com/compute-io/logspace + function logspace(a, b, len) { + var arr, end, tmp, d; + if (arguments.length < 3) { + len = 10; + } + else { + if (len === 0) { + return []; + } + } + // Calculate the increment: + end = len - 1; + d = (b - a) / end; + // Build the output array... + arr = new Array(len); + tmp = a; + arr[0] = Math.pow(10, tmp); + for (var i = 1; i < end; i++) { + tmp += d; + arr[i] = Math.pow(10, tmp); + } + arr[end] = Math.pow(10, b); + return arr; + } + function scale(x) { + return logScale(linearScale(x)); + } + scale.domain = function (x) { + if (!arguments.length) { + return linearScale.domain(); + } + linearScale.domain(x); + return scale; + }; + scale.range = function (x) { + if (!arguments.length) { + return logScale.range(); + } + logScale.range(x); + return scale; + }; + scale.ticks = function (m) { + return logspace(-2, 1, m || 10).map(function (v) { + return linearScale.invert(v); + }); + }; + scale.copy = function () { + return c3LogScale(d3, linearScale.copy(), logScale.copy()); + }; + return scale; + } + ChartInternal.prototype.getScale = function (min, max, forTimeseries) { + return (forTimeseries ? this.d3.scaleTime() : this.d3.scaleLinear()).range([ + min, + max + ]); + }; + ChartInternal.prototype.getX = function (min, max, domain, offset) { + var $$ = this, scale = $$.getScale(min, max, $$.isTimeSeries()), _scale = domain ? scale.domain(domain) : scale, key; + // Define customized scale if categorized axis + if ($$.isCategorized()) { + offset = + offset || + function () { + return 0; + }; + scale = function (d, raw) { + var v = _scale(d) + offset(d); + return raw ? v : Math.ceil(v); + }; + } + else { + scale = function (d, raw) { + var v = _scale(d); + return raw ? v : Math.ceil(v); + }; + } + // define functions + for (key in _scale) { + scale[key] = _scale[key]; + } + scale.orgDomain = function () { + return _scale.domain(); + }; + // define custom domain() for categorized axis + if ($$.isCategorized()) { + scale.domain = function (domain) { + if (!arguments.length) { + domain = this.orgDomain(); + return [domain[0], domain[1] + 1]; + } + _scale.domain(domain); + return scale; + }; + } + return scale; + }; + /** + * Creates and configures a D3 scale instance for the given type. + * + * By defaults it returns a Linear scale. + * + * @param {String} type Type of d3-scale to create. Type can be 'linear', 'time', 'timeseries' or 'log'. + * @param {Array} domain The scale domain such as [from, to] + * @param {Array} range The scale's range such as [from, to] + * + * @return A d3-scale instance + */ + ChartInternal.prototype.getY = function (type, domain, range) { + var scale; + if (type === 'timeseries' || type === 'time') { + scale = this.d3.scaleTime(); + } + else if (type === 'log') { + scale = c3LogScale(this.d3); + } + else if (type === 'linear' || type === undefined) { + scale = this.d3.scaleLinear(); + } + else { + throw new Error("Invalid Y axis type: \"" + type + "\""); + } + if (domain) { + scale.domain(domain); + } + if (range) { + scale.range(range); + } + return scale; + }; + ChartInternal.prototype.getYScale = function (id) { + return this.axis.getId(id) === 'y2' ? this.y2 : this.y; + }; + ChartInternal.prototype.getSubYScale = function (id) { + return this.axis.getId(id) === 'y2' ? this.subY2 : this.subY; + }; + ChartInternal.prototype.updateScales = function () { + var $$ = this, config = $$.config, forInit = !$$.x; + // update edges + $$.xMin = config.axis_rotated ? 1 : 0; + $$.xMax = config.axis_rotated ? $$.height : $$.width; + $$.yMin = config.axis_rotated ? 0 : $$.height; + $$.yMax = config.axis_rotated ? $$.width : 1; + $$.subXMin = $$.xMin; + $$.subXMax = $$.xMax; + $$.subYMin = config.axis_rotated ? 0 : $$.height2; + $$.subYMax = config.axis_rotated ? $$.width2 : 1; + // update scales + $$.x = $$.getX($$.xMin, $$.xMax, forInit ? undefined : $$.x.orgDomain(), function () { + return $$.xAxis.tickOffset(); + }); + $$.y = $$.getY(config.axis_y_type, forInit ? config.axis_y_default : $$.y.domain(), [$$.yMin, $$.yMax]); + $$.y2 = $$.getY(config.axis_y2_type, forInit ? config.axis_y2_default : $$.y2.domain(), [$$.yMin, $$.yMax]); + $$.subX = $$.getX($$.xMin, $$.xMax, $$.orgXDomain, function (d) { + return d % 1 ? 0 : $$.subXAxis.tickOffset(); + }); + $$.subY = $$.getY(config.axis_y_type, forInit ? config.axis_y_default : $$.subY.domain(), [$$.subYMin, $$.subYMax]); + $$.subY2 = $$.getY(config.axis_y2_type, forInit ? config.axis_y2_default : $$.subY2.domain(), [$$.subYMin, $$.subYMax]); + // update axes + $$.xAxisTickFormat = $$.axis.getXAxisTickFormat(); + $$.xAxisTickValues = $$.axis.getXAxisTickValues(); + $$.yAxisTickValues = $$.axis.getYAxisTickValues(); + $$.y2AxisTickValues = $$.axis.getY2AxisTickValues(); + $$.xAxis = $$.axis.getXAxis($$.x, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues, config.axis_x_tick_outer); + $$.subXAxis = $$.axis.getXAxis($$.subX, $$.subXOrient, $$.xAxisTickFormat, $$.xAxisTickValues, config.axis_x_tick_outer); + $$.yAxis = $$.axis.getYAxis('y', $$.y, $$.yOrient, $$.yAxisTickValues, config.axis_y_tick_outer); + $$.y2Axis = $$.axis.getYAxis('y2', $$.y2, $$.y2Orient, $$.y2AxisTickValues, config.axis_y2_tick_outer); + // Set initialized scales to brush and zoom + if (!forInit) { + if ($$.brush) { + $$.brush.updateScale($$.subX); + } + } + // update for arc + if ($$.updateArc) { + $$.updateArc(); + } + }; + + ChartInternal.prototype.selectPoint = function (target, d, i) { + var $$ = this, config = $$.config, cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$), cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$), r = $$.pointSelectR.bind($$); + config.data_onselected.call($$.api, d, target.node()); + // add selected-circle on low layer g + $$.main + .select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.selectedCircle + '-' + i) + .data([d]) + .enter() + .append('circle') + .attr('class', function () { + return $$.generateClass(CLASS.selectedCircle, i); + }) + .attr('cx', cx) + .attr('cy', cy) + .attr('stroke', function () { + return $$.color(d); + }) + .attr('r', function (d) { + return $$.pointSelectR(d) * 1.4; + }) + .transition() + .duration(100) + .attr('r', r); + }; + ChartInternal.prototype.unselectPoint = function (target, d, i) { + var $$ = this; + $$.config.data_onunselected.call($$.api, d, target.node()); + // remove selected-circle from low layer g + $$.main + .select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.selectedCircle + '-' + i) + .transition() + .duration(100) + .attr('r', 0) + .remove(); + }; + ChartInternal.prototype.togglePoint = function (selected, target, d, i) { + selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i); + }; + ChartInternal.prototype.selectPath = function (target, d) { + var $$ = this; + $$.config.data_onselected.call($$, d, target.node()); + if ($$.config.interaction_brighten) { + target + .transition() + .duration(100) + .style('fill', function () { + return $$.d3.rgb($$.color(d)).brighter(0.75); + }); + } + }; + ChartInternal.prototype.unselectPath = function (target, d) { + var $$ = this; + $$.config.data_onunselected.call($$, d, target.node()); + if ($$.config.interaction_brighten) { + target + .transition() + .duration(100) + .style('fill', function () { + return $$.color(d); + }); + } + }; + ChartInternal.prototype.togglePath = function (selected, target, d, i) { + selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i); + }; + ChartInternal.prototype.getToggle = function (that, d) { + var $$ = this, toggle; + if (that.nodeName === 'circle') { + if ($$.isStepType(d)) { + // circle is hidden in step chart, so treat as within the click area + toggle = function () { }; // TODO: how to select step chart? + } + else { + toggle = $$.togglePoint; + } + } + else if (that.nodeName === 'path') { + toggle = $$.togglePath; + } + return toggle; + }; + ChartInternal.prototype.toggleShape = function (that, d, i) { + var $$ = this, d3 = $$.d3, config = $$.config, shape = d3.select(that), isSelected = shape.classed(CLASS.SELECTED), toggle = $$.getToggle(that, d).bind($$); + if (config.data_selection_enabled && config.data_selection_isselectable(d)) { + if (!config.data_selection_multiple) { + $$.main + .selectAll('.' + + CLASS.shapes + + (config.data_selection_grouped + ? $$.getTargetSelectorSuffix(d.id) + : '')) + .selectAll('.' + CLASS.shape) + .each(function (d, i) { + var shape = d3.select(this); + if (shape.classed(CLASS.SELECTED)) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + }); + } + shape.classed(CLASS.SELECTED, !isSelected); + toggle(!isSelected, shape, d, i); + } + }; + + ChartInternal.prototype.initBar = function () { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartBars); + }; + ChartInternal.prototype.updateTargetsForBar = function (targets) { + var $$ = this, config = $$.config, mainBars, mainBarEnter, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$), classFocus = $$.classFocus.bind($$); + mainBars = $$.main + .select('.' + CLASS.chartBars) + .selectAll('.' + CLASS.chartBar) + .data(targets) + .attr('class', function (d) { + return classChartBar(d) + classFocus(d); + }); + mainBarEnter = mainBars + .enter() + .append('g') + .attr('class', classChartBar) + .style('pointer-events', 'none'); + // Bars for each data + mainBarEnter + .append('g') + .attr('class', classBars) + .style('cursor', function (d) { + return config.data_selection_isselectable(d) ? 'pointer' : null; + }); + }; + ChartInternal.prototype.updateBar = function (durationForExit) { + var $$ = this, barData = $$.barData.bind($$), classBar = $$.classBar.bind($$), initialOpacity = $$.initialOpacity.bind($$), color = function (d) { + return $$.color(d.id); + }; + var mainBar = $$.main + .selectAll('.' + CLASS.bars) + .selectAll('.' + CLASS.bar) + .data(barData); + var mainBarEnter = mainBar + .enter() + .append('path') + .attr('class', classBar) + .style('stroke', color) + .style('fill', color); + $$.mainBar = mainBarEnter.merge(mainBar).style('opacity', initialOpacity); + mainBar + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); + }; + ChartInternal.prototype.redrawBar = function (drawBar, withTransition, transition) { + var $$ = this; + return [ + (withTransition ? this.mainBar.transition(transition) : this.mainBar) + .attr('d', drawBar) + .style('stroke', this.color) + .style('fill', this.color) + .style('opacity', function (d) { return ($$.isTargetToShow(d.id) ? 1 : 0); }) + ]; + }; + ChartInternal.prototype.getBarW = function (axis, barTargetsNum) { + var $$ = this, config = $$.config, w = typeof config.bar_width === 'number' + ? config.bar_width + : barTargetsNum + ? (axis.tickInterval() * config.bar_width_ratio) / barTargetsNum + : 0; + return config.bar_width_max && w > config.bar_width_max + ? config.bar_width_max + : w; + }; + ChartInternal.prototype.getBars = function (i, id) { + var $$ = this; + return (id + ? $$.main.selectAll('.' + CLASS.bars + $$.getTargetSelectorSuffix(id)) + : $$.main).selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')); + }; + ChartInternal.prototype.expandBars = function (i, id, reset) { + var $$ = this; + if (reset) { + $$.unexpandBars(); + } + $$.getBars(i, id).classed(CLASS.EXPANDED, true); + }; + ChartInternal.prototype.unexpandBars = function (i) { + var $$ = this; + $$.getBars(i).classed(CLASS.EXPANDED, false); + }; + ChartInternal.prototype.generateDrawBar = function (barIndices, isSub) { + var $$ = this, config = $$.config, getPoints = $$.generateGetBarPoints(barIndices, isSub); + return function (d, i) { + // 4 points that make a bar + var points = getPoints(d, i); + // switch points if axis is rotated, not applicable for sub chart + var indexX = config.axis_rotated ? 1 : 0; + var indexY = config.axis_rotated ? 0 : 1; + var path = 'M ' + + points[0][indexX] + + ',' + + points[0][indexY] + + ' ' + + 'L' + + points[1][indexX] + + ',' + + points[1][indexY] + + ' ' + + 'L' + + points[2][indexX] + + ',' + + points[2][indexY] + + ' ' + + 'L' + + points[3][indexX] + + ',' + + points[3][indexY] + + ' ' + + 'z'; + return path; + }; + }; + ChartInternal.prototype.generateGetBarPoints = function (barIndices, isSub) { + var $$ = this, axis = isSub ? $$.subXAxis : $$.xAxis, barTargetsNum = barIndices.__max__ + 1, barW = $$.getBarW(axis, barTargetsNum), barX = $$.getShapeX(barW, barTargetsNum, barIndices, !!isSub), barY = $$.getShapeY(!!isSub), barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub), barSpaceOffset = barW * ($$.config.bar_space / 2), yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function (d, i) { + var y0 = yScale.call($$, d.id)(0), offset = barOffset(d, i) || y0, // offset is for stacked bar chart + posX = barX(d), posY = barY(d); + // fix posY not to overflow opposite quadrant + if ($$.config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + posY -= y0 - offset; + // 4 points that make a bar + return [ + [posX + barSpaceOffset, offset], + [posX + barSpaceOffset, posY], + [posX + barW - barSpaceOffset, posY], + [posX + barW - barSpaceOffset, offset] + ]; + }; + }; + /** + * Returns whether the data point is within the given bar shape. + * + * @param mouse + * @param barShape + * @return {boolean} + */ + ChartInternal.prototype.isWithinBar = function (mouse, barShape) { + return isWithinBox(mouse, getBBox(barShape), 2); + }; + + ChartInternal.prototype.getShapeIndices = function (typeFilter) { + var $$ = this, config = $$.config, indices = {}, i = 0, j, k; + $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) { + for (j = 0; j < config.data_groups.length; j++) { + if (config.data_groups[j].indexOf(d.id) < 0) { + continue; + } + for (k = 0; k < config.data_groups[j].length; k++) { + if (config.data_groups[j][k] in indices) { + indices[d.id] = indices[config.data_groups[j][k]]; + break; + } + } + } + if (isUndefined(indices[d.id])) { + indices[d.id] = i++; + } + }); + indices.__max__ = i - 1; + return indices; + }; + ChartInternal.prototype.getShapeX = function (offset, targetsNum, indices, isSub) { + var $$ = this, scale = isSub ? $$.subX : $$.x; + return function (d) { + var index = d.id in indices ? indices[d.id] : 0; + return d.x || d.x === 0 ? scale(d.x) - offset * (targetsNum / 2 - index) : 0; + }; + }; + ChartInternal.prototype.getShapeY = function (isSub) { + var $$ = this; + return function (d) { + var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id); + return scale($$.isTargetNormalized(d.id) ? $$.getRatio('index', d, true) : d.value); + }; + }; + ChartInternal.prototype.getShapeOffset = function (typeFilter, indices, isSub) { + var $$ = this, targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))), targetIds = targets.map(function (t) { + return t.id; + }); + return function (d, i) { + var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id), y0 = scale(0), offset = y0; + targets.forEach(function (t) { + var rowValues = $$.isStepType(d) + ? $$.convertValuesToStep(t.values) + : t.values; + var isTargetNormalized = $$.isTargetNormalized(d.id); + var values = rowValues.map(function (v) { + return isTargetNormalized ? $$.getRatio('index', v, true) : v.value; + }); + if (t.id === d.id || indices[t.id] !== indices[d.id]) { + return; + } + if (targetIds.indexOf(t.id) < targetIds.indexOf(d.id)) { + // check if the x values line up + if (isUndefined(rowValues[i]) || +rowValues[i].x !== +d.x) { + // "+" for timeseries + // if not, try to find the value that does line up + i = -1; + rowValues.forEach(function (v, j) { + var x1 = v.x.constructor === Date ? +v.x : v.x; + var x2 = d.x.constructor === Date ? +d.x : d.x; + if (x1 === x2) { + i = j; + } + }); + } + if (i in rowValues && rowValues[i].value * d.value >= 0) { + offset += scale(values[i]) - y0; + } + } + }); + return offset; + }; + }; + ChartInternal.prototype.isWithinShape = function (that, d) { + var $$ = this, shape = $$.d3.select(that), isWithin; + if (!$$.isTargetToShow(d.id)) { + isWithin = false; + } + else if (that.nodeName === 'circle') { + isWithin = $$.isStepType(d) + ? $$.isWithinStep(that, $$.getYScale(d.id)(d.value)) + : $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); + } + else if (that.nodeName === 'path') { + isWithin = shape.classed(CLASS.bar) + ? $$.isWithinBar($$.d3.mouse(that), that) + : true; + } + return isWithin; + }; + ChartInternal.prototype.getInterpolate = function (d) { + var $$ = this, d3 = $$.d3, types = { + linear: d3.curveLinear, + 'linear-closed': d3.curveLinearClosed, + basis: d3.curveBasis, + 'basis-open': d3.curveBasisOpen, + 'basis-closed': d3.curveBasisClosed, + bundle: d3.curveBundle, + cardinal: d3.curveCardinal, + 'cardinal-open': d3.curveCardinalOpen, + 'cardinal-closed': d3.curveCardinalClosed, + monotone: d3.curveMonotoneX, + step: d3.curveStep, + 'step-before': d3.curveStepBefore, + 'step-after': d3.curveStepAfter + }, type; + if ($$.isSplineType(d)) { + type = types[$$.config.spline_interpolation_type] || types.cardinal; + } + else if ($$.isStepType(d)) { + type = types[$$.config.line_step_type]; + } + else { + type = types.linear; + } + return type; + }; + + ChartInternal.prototype.initLine = function () { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartLines); + }; + ChartInternal.prototype.updateTargetsForLine = function (targets) { + var $$ = this, config = $$.config, mainLines, mainLineEnter, classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$), classCircles = $$.classCircles.bind($$), classFocus = $$.classFocus.bind($$); + mainLines = $$.main + .select('.' + CLASS.chartLines) + .selectAll('.' + CLASS.chartLine) + .data(targets) + .attr('class', function (d) { + return classChartLine(d) + classFocus(d); + }); + mainLineEnter = mainLines + .enter() + .append('g') + .attr('class', classChartLine) + .style('opacity', 0) + .style('pointer-events', 'none'); + // Lines for each data + mainLineEnter.append('g').attr('class', classLines); + // Areas + mainLineEnter.append('g').attr('class', classAreas); + // Circles for each data point on lines + mainLineEnter.append('g').attr('class', function (d) { + return $$.generateClass(CLASS.selectedCircles, d.id); + }); + mainLineEnter + .append('g') + .attr('class', classCircles) + .style('cursor', function (d) { + return config.data_selection_isselectable(d) ? 'pointer' : null; + }); + // Update date for selected circles + targets.forEach(function (t) { + $$.main + .selectAll('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(t.id)) + .selectAll('.' + CLASS.selectedCircle) + .each(function (d) { + d.value = t.values[d.index].value; + }); + }); + // MEMO: can not keep same color... + //mainLineUpdate.exit().remove(); + }; + ChartInternal.prototype.updateLine = function (durationForExit) { + var $$ = this; + var mainLine = $$.main + .selectAll('.' + CLASS.lines) + .selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + var mainLineEnter = mainLine + .enter() + .append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + $$.mainLine = mainLineEnter + .merge(mainLine) + .style('opacity', $$.initialOpacity.bind($$)) + .style('shape-rendering', function (d) { + return $$.isStepType(d) ? 'crispEdges' : ''; + }) + .attr('transform', null); + mainLine + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); + }; + ChartInternal.prototype.redrawLine = function (drawLine, withTransition, transition) { + return [ + (withTransition ? this.mainLine.transition(transition) : this.mainLine) + .attr('d', drawLine) + .style('stroke', this.color) + .style('opacity', 1) + ]; + }; + ChartInternal.prototype.generateDrawLine = function (lineIndices, isSub) { + var $$ = this, config = $$.config, line = $$.d3.line(), getPoints = $$.generateGetLinePoints(lineIndices, isSub), yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { + return (isSub ? $$.subxx : $$.xx).call($$, d); + }, yValue = function (d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[0][1] + : yScaleGetter.call($$, d.id)(d.value); + }; + line = config.axis_rotated + ? line.x(yValue).y(xValue) + : line.x(xValue).y(yValue); + if (!config.line_connectNull) { + line = line.defined(function (d) { + return d.value != null; + }); + } + return function (d) { + var values = config.line_connectNull + ? $$.filterRemoveNull(d.values) + : d.values, x = isSub ? $$.subX : $$.x, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path; + if ($$.isLineType(d)) { + if (config.data_regions[d.id]) { + path = $$.lineWithRegions(values, x, y, config.data_regions[d.id]); + } + else { + if ($$.isStepType(d)) { + values = $$.convertValuesToStep(values); + } + path = line.curve($$.getInterpolate(d))(values); + } + } + else { + if (values[0]) { + x0 = x(values[0].x); + y0 = y(values[0].value); + } + path = config.axis_rotated ? 'M ' + y0 + ' ' + x0 : 'M ' + x0 + ' ' + y0; + } + return path ? path : 'M 0 0'; + }; + }; + ChartInternal.prototype.generateGetLinePoints = function (lineIndices, isSub) { + // partial duplication of generateGetBarPoints + var $$ = this, config = $$.config, lineTargetsNum = lineIndices.__max__ + 1, x = $$.getShapeX(0, lineTargetsNum, lineIndices, !!isSub), y = $$.getShapeY(!!isSub), lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, !!isSub), yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function (d, i) { + var y0 = yScale.call($$, d.id)(0), offset = lineOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), posY = y(d); + // fix posY not to overflow opposite quadrant + if (config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + // 1 point that marks the line position + return [ + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)] // needed for compatibility + ]; + }; + }; + ChartInternal.prototype.lineWithRegions = function (d, x, y, _regions) { + var $$ = this, config = $$.config, prev = -1, i, j, s = 'M', sWithRegion, xp, yp, dx, dy, dd, diff, diffx2, xOffset = $$.isCategorized() ? 0.5 : 0, xValue, yValue, regions = []; + function isWithinRegions(x, regions) { + var i; + for (i = 0; i < regions.length; i++) { + if (regions[i].start < x && x <= regions[i].end) { + return true; + } + } + return false; + } + // Check start/end of regions + if (isDefined(_regions)) { + for (i = 0; i < _regions.length; i++) { + regions[i] = {}; + if (isUndefined(_regions[i].start)) { + regions[i].start = d[0].x; + } + else { + regions[i].start = $$.isTimeSeries() + ? $$.parseDate(_regions[i].start) + : _regions[i].start; + } + if (isUndefined(_regions[i].end)) { + regions[i].end = d[d.length - 1].x; + } + else { + regions[i].end = $$.isTimeSeries() + ? $$.parseDate(_regions[i].end) + : _regions[i].end; + } + } + } + // Set scales + xValue = config.axis_rotated + ? function (d) { + return y(d.value); + } + : function (d) { + return x(d.x); + }; + yValue = config.axis_rotated + ? function (d) { + return x(d.x); + } + : function (d) { + return y(d.value); + }; + // Define svg generator function for region + function generateM(points) { + return ('M' + + points[0][0] + + ' ' + + points[0][1] + + ' ' + + points[1][0] + + ' ' + + points[1][1]); + } + if ($$.isTimeSeries()) { + sWithRegion = function (d0, d1, j, diff) { + var x0 = d0.x.getTime(), x_diff = d1.x - d0.x, xv0 = new Date(x0 + x_diff * j), xv1 = new Date(x0 + x_diff * (j + diff)), points; + if (config.axis_rotated) { + points = [ + [y(yp(j)), x(xv0)], + [y(yp(j + diff)), x(xv1)] + ]; + } + else { + points = [ + [x(xv0), y(yp(j))], + [x(xv1), y(yp(j + diff))] + ]; + } + return generateM(points); + }; + } + else { + sWithRegion = function (d0, d1, j, diff) { + var points; + if (config.axis_rotated) { + points = [ + [y(yp(j), true), x(xp(j))], + [y(yp(j + diff), true), x(xp(j + diff))] + ]; + } + else { + points = [ + [x(xp(j), true), y(yp(j))], + [x(xp(j + diff), true), y(yp(j + diff))] + ]; + } + return generateM(points); + }; + } + // Generate + for (i = 0; i < d.length; i++) { + // Draw as normal + if (isUndefined(regions) || !isWithinRegions(d[i].x, regions)) { + s += ' ' + xValue(d[i]) + ' ' + yValue(d[i]); + } + // Draw with region // TODO: Fix for horizotal charts + else { + xp = $$.getScale(d[i - 1].x + xOffset, d[i].x + xOffset, $$.isTimeSeries()); + yp = $$.getScale(d[i - 1].value, d[i].value); + dx = x(d[i].x) - x(d[i - 1].x); + dy = y(d[i].value) - y(d[i - 1].value); + dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); + diff = 2 / dd; + diffx2 = diff * 2; + for (j = diff; j <= 1; j += diffx2) { + s += sWithRegion(d[i - 1], d[i], j, diff); + } + } + prev = d[i].x; + } + return s; + }; + ChartInternal.prototype.updateArea = function (durationForExit) { + var $$ = this, d3 = $$.d3; + var mainArea = $$.main + .selectAll('.' + CLASS.areas) + .selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + var mainAreaEnter = mainArea + .enter() + .append('path') + .attr('class', $$.classArea.bind($$)) + .style('fill', $$.color) + .style('opacity', function () { + $$.orgAreaOpacity = +d3.select(this).style('opacity'); + return 0; + }); + $$.mainArea = mainAreaEnter + .merge(mainArea) + .style('opacity', $$.orgAreaOpacity); + mainArea + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); + }; + ChartInternal.prototype.redrawArea = function (drawArea, withTransition, transition) { + return [ + (withTransition ? this.mainArea.transition(transition) : this.mainArea) + .attr('d', drawArea) + .style('fill', this.color) + .style('opacity', this.orgAreaOpacity) + ]; + }; + ChartInternal.prototype.generateDrawArea = function (areaIndices, isSub) { + var $$ = this, config = $$.config, area = $$.d3.area(), getPoints = $$.generateGetAreaPoints(areaIndices, isSub), yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { + return (isSub ? $$.subxx : $$.xx).call($$, d); + }, value0 = function (d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[0][1] + : yScaleGetter.call($$, d.id)($$.getAreaBaseValue(d.id)); + }, value1 = function (d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[1][1] + : yScaleGetter.call($$, d.id)(d.value); + }; + area = config.axis_rotated + ? area + .x0(value0) + .x1(value1) + .y(xValue) + : area + .x(xValue) + .y0(config.area_above ? 0 : value0) + .y1(value1); + if (!config.line_connectNull) { + area = area.defined(function (d) { + return d.value !== null; + }); + } + return function (d) { + var values = config.line_connectNull + ? $$.filterRemoveNull(d.values) + : d.values, x0 = 0, y0 = 0, path; + if ($$.isAreaType(d)) { + if ($$.isStepType(d)) { + values = $$.convertValuesToStep(values); + } + path = area.curve($$.getInterpolate(d))(values); + } + else { + if (values[0]) { + x0 = $$.x(values[0].x); + y0 = $$.getYScale(d.id)(values[0].value); + } + path = config.axis_rotated ? 'M ' + y0 + ' ' + x0 : 'M ' + x0 + ' ' + y0; + } + return path ? path : 'M 0 0'; + }; + }; + ChartInternal.prototype.getAreaBaseValue = function () { + return 0; + }; + ChartInternal.prototype.generateGetAreaPoints = function (areaIndices, isSub) { + // partial duplication of generateGetBarPoints + var $$ = this, config = $$.config, areaTargetsNum = areaIndices.__max__ + 1, x = $$.getShapeX(0, areaTargetsNum, areaIndices, !!isSub), y = $$.getShapeY(!!isSub), areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, !!isSub), yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function (d, i) { + var y0 = yScale.call($$, d.id)(0), offset = areaOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), posY = y(d); + // fix posY not to overflow opposite quadrant + if (config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + // 1 point that marks the area position + return [ + [posX, offset], + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], + [posX, offset] // needed for compatibility + ]; + }; + }; + ChartInternal.prototype.updateCircle = function (cx, cy) { + var $$ = this; + var mainCircle = $$.main + .selectAll('.' + CLASS.circles) + .selectAll('.' + CLASS.circle) + .data($$.lineOrScatterOrStanfordData.bind($$)); + var mainCircleEnter = mainCircle + .enter() + .append('circle') + .attr('shape-rendering', $$.isStanfordGraphType() ? 'crispEdges' : '') + .attr('class', $$.classCircle.bind($$)) + .attr('cx', cx) + .attr('cy', cy) + .attr('r', $$.pointR.bind($$)) + .style('color', $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color); + $$.mainCircle = mainCircleEnter + .merge(mainCircle) + .style('opacity', $$.isStanfordGraphType() ? 1 : $$.initialOpacityForCircle.bind($$)); + mainCircle.exit().style('opacity', 0); + }; + ChartInternal.prototype.redrawCircle = function (cx, cy, withTransition, transition) { + var $$ = this, selectedCircles = $$.main.selectAll('.' + CLASS.selectedCircle); + return [ + (withTransition ? $$.mainCircle.transition(transition) : $$.mainCircle) + .style('opacity', this.opacityForCircle.bind($$)) + .style('color', $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color) + .attr('cx', cx) + .attr('cy', cy), + (withTransition ? selectedCircles.transition(transition) : selectedCircles) + .attr('cx', cx) + .attr('cy', cy) + ]; + }; + ChartInternal.prototype.circleX = function (d) { + return d.x || d.x === 0 ? this.x(d.x) : null; + }; + ChartInternal.prototype.updateCircleY = function () { + var $$ = this, lineIndices, getPoints; + if ($$.config.data_groups.length > 0) { + (lineIndices = $$.getShapeIndices($$.isLineType)), + (getPoints = $$.generateGetLinePoints(lineIndices)); + $$.circleY = function (d, i) { + return getPoints(d, i)[0][1]; + }; + } + else { + $$.circleY = function (d) { + return $$.getYScale(d.id)(d.value); + }; + } + }; + ChartInternal.prototype.getCircles = function (i, id) { + var $$ = this; + return (id + ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) + : $$.main).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')); + }; + ChartInternal.prototype.expandCircles = function (i, id, reset) { + var $$ = this, r = $$.pointExpandedR.bind($$); + if (reset) { + $$.unexpandCircles(); + } + $$.getCircles(i, id) + .classed(CLASS.EXPANDED, true) + .attr('r', r); + }; + ChartInternal.prototype.unexpandCircles = function (i) { + var $$ = this, r = $$.pointR.bind($$); + $$.getCircles(i) + .filter(function () { + return $$.d3.select(this).classed(CLASS.EXPANDED); + }) + .classed(CLASS.EXPANDED, false) + .attr('r', r); + }; + ChartInternal.prototype.pointR = function (d) { + var $$ = this, config = $$.config; + return $$.isStepType(d) + ? 0 + : isFunction(config.point_r) + ? config.point_r(d) + : config.point_r; + }; + ChartInternal.prototype.pointExpandedR = function (d) { + var $$ = this, config = $$.config; + if (config.point_focus_expand_enabled) { + return isFunction(config.point_focus_expand_r) + ? config.point_focus_expand_r(d) + : config.point_focus_expand_r + ? config.point_focus_expand_r + : $$.pointR(d) * 1.75; + } + else { + return $$.pointR(d); + } + }; + ChartInternal.prototype.pointSelectR = function (d) { + var $$ = this, config = $$.config; + return isFunction(config.point_select_r) + ? config.point_select_r(d) + : config.point_select_r + ? config.point_select_r + : $$.pointR(d) * 4; + }; + ChartInternal.prototype.isWithinCircle = function (that, r) { + var d3 = this.d3, mouse = d3.mouse(that), d3_this = d3.select(that), cx = +d3_this.attr('cx'), cy = +d3_this.attr('cy'); + return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < r; + }; + ChartInternal.prototype.isWithinStep = function (that, y) { + return Math.abs(y - this.d3.mouse(that)[1]) < 30; + }; + + ChartInternal.prototype.getCurrentWidth = function () { + var $$ = this, config = $$.config; + return config.size_width ? config.size_width : $$.getParentWidth(); + }; + ChartInternal.prototype.getCurrentHeight = function () { + var $$ = this, config = $$.config, h = config.size_height ? config.size_height : $$.getParentHeight(); + return h > 0 + ? h + : 320 / ($$.hasType('gauge') && !config.gauge_fullCircle ? 2 : 1); + }; + ChartInternal.prototype.getCurrentPaddingTop = function () { + var $$ = this, config = $$.config, padding = isValue(config.padding_top) ? config.padding_top : 0; + if ($$.title && $$.title.node()) { + padding += $$.getTitlePadding(); + } + return padding; + }; + ChartInternal.prototype.getCurrentPaddingBottom = function () { + var config = this.config; + return isValue(config.padding_bottom) ? config.padding_bottom : 0; + }; + ChartInternal.prototype.getCurrentPaddingLeft = function (withoutRecompute) { + var $$ = this, config = $$.config; + if (isValue(config.padding_left)) { + return config.padding_left; + } + else if (config.axis_rotated) { + return !config.axis_x_show || config.axis_x_inner + ? 1 + : Math.max(ceil10($$.getAxisWidthByAxisId('x', withoutRecompute)), 40); + } + else if (!config.axis_y_show || config.axis_y_inner) { + // && !config.axis_rotated + return $$.axis.getYAxisLabelPosition().isOuter ? 30 : 1; + } + else { + return ceil10($$.getAxisWidthByAxisId('y', withoutRecompute)); + } + }; + ChartInternal.prototype.getCurrentPaddingRight = function () { + var $$ = this, config = $$.config, padding = 0, defaultPadding = 10, legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0; + if (isValue(config.padding_right)) { + padding = config.padding_right + 1; // 1 is needed not to hide tick line + } + else if (config.axis_rotated) { + padding = defaultPadding + legendWidthOnRight; + } + else if (!config.axis_y2_show || config.axis_y2_inner) { + // && !config.axis_rotated + padding = + 2 + + legendWidthOnRight + + ($$.axis.getY2AxisLabelPosition().isOuter ? 20 : 0); + } + else { + padding = ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight; + } + if ($$.colorScale && $$.colorScale.node()) { + padding += $$.getColorScalePadding(); + } + return padding; + }; + ChartInternal.prototype.getParentRectValue = function (key) { + var parent = this.selectChart.node(), v; + while (parent && parent.tagName !== 'BODY') { + try { + v = parent.getBoundingClientRect()[key]; + } + catch (e) { + if (key === 'width') { + // In IE in certain cases getBoundingClientRect + // will cause an "unspecified error" + v = parent.offsetWidth; + } + } + if (v) { + break; + } + parent = parent.parentNode; + } + return v; + }; + ChartInternal.prototype.getParentWidth = function () { + return this.getParentRectValue('width'); + }; + ChartInternal.prototype.getParentHeight = function () { + var h = this.selectChart.style('height'); + return h.indexOf('px') > 0 ? +h.replace('px', '') : 0; + }; + ChartInternal.prototype.getSvgLeft = function (withoutRecompute) { + var $$ = this, config = $$.config, hasLeftAxisRect = config.axis_rotated || (!config.axis_rotated && !config.axis_y_inner), leftAxisClass = config.axis_rotated ? CLASS.axisX : CLASS.axisY, leftAxis = $$.main.select('.' + leftAxisClass).node(), svgRect = leftAxis && hasLeftAxisRect + ? leftAxis.getBoundingClientRect() + : { right: 0 }, chartRect = $$.selectChart.node().getBoundingClientRect(), hasArc = $$.hasArcType(), svgLeft = svgRect.right - + chartRect.left - + (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute)); + return svgLeft > 0 ? svgLeft : 0; + }; + ChartInternal.prototype.getAxisWidthByAxisId = function (id, withoutRecompute) { + var $$ = this, position = $$.axis.getLabelPositionById(id); + return ($$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40)); + }; + ChartInternal.prototype.getHorizontalAxisHeight = function (axisId, isSubchart) { + var $$ = this, config = $$.config, h = 30; + if (axisId === 'x' && !(isDefined(isSubchart) && isSubchart ? config.subchart_axis_x_show : config.axis_x_show)) { + return 8; + } + if (axisId === 'x' && config.axis_x_height) { + return config.axis_x_height; + } + if (axisId === 'y' && !config.axis_y_show) { + return config.legend_show && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1; + } + if (axisId === 'y2' && !config.axis_y2_show) { + return $$.rotated_padding_top; + } + // Calculate x axis height when tick rotated + if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) { + h = + 30 + + $$.axis.getMaxTickWidth(axisId) * + Math.cos((Math.PI * (90 - Math.abs(config.axis_x_tick_rotate))) / 180); + } + // Calculate y axis height when tick rotated + if (axisId === 'y' && config.axis_rotated && config.axis_y_tick_rotate) { + h = + 30 + + $$.axis.getMaxTickWidth(axisId) * + Math.cos((Math.PI * (90 - Math.abs(config.axis_y_tick_rotate))) / 180); + } + return (h + + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + + (axisId === 'y2' ? -10 : 0)); + }; + + ChartInternal.prototype.initBrush = function (scale) { + var $$ = this, d3 = $$.d3; + // TODO: dynamically change brushY/brushX according to axis_rotated. + $$.brush = ($$.config.axis_rotated ? d3.brushY() : d3.brushX()) + .on('brush', function () { + var event = d3.event.sourceEvent; + if (event && event.type === 'zoom') { + return; + } + $$.redrawForBrush(); + }) + .on('end', function () { + var event = d3.event.sourceEvent; + if (event && event.type === 'zoom') { + return; + } + if ($$.brush.empty() && event && event.type !== 'end') { + $$.brush.clear(); + } + }); + $$.brush.updateExtent = function () { + var range = this.scale.range(), extent; + if ($$.config.axis_rotated) { + extent = [ + [0, range[0]], + [$$.width2, range[1]] + ]; + } + else { + extent = [ + [range[0], 0], + [range[1], $$.height2] + ]; + } + this.extent(extent); + return this; + }; + $$.brush.updateScale = function (scale) { + this.scale = scale; + return this; + }; + $$.brush.update = function (scale) { + this.updateScale(scale || $$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call(this); + }; + $$.brush.clear = function () { + $$.context.select('.' + CLASS.brush).call($$.brush.move, null); + }; + $$.brush.selection = function () { + return d3.brushSelection($$.context.select('.' + CLASS.brush).node()); + }; + $$.brush.selectionAsValue = function (selectionAsValue, withTransition) { + var selection, brush; + if (selectionAsValue) { + if ($$.context) { + selection = [ + this.scale(selectionAsValue[0]), + this.scale(selectionAsValue[1]) + ]; + brush = $$.context.select('.' + CLASS.brush); + if (withTransition) { + brush = brush.transition(); + } + $$.brush.move(brush, selection); + } + return []; + } + selection = $$.brush.selection() || [0, 0]; + return [this.scale.invert(selection[0]), this.scale.invert(selection[1])]; + }; + $$.brush.empty = function () { + var selection = $$.brush.selection(); + return !selection || selection[0] === selection[1]; + }; + return $$.brush.updateScale(scale); + }; + ChartInternal.prototype.initSubchart = function () { + var $$ = this, config = $$.config, context = ($$.context = $$.svg + .append('g') + .attr('transform', $$.getTranslate('context'))); + // set style + context.style('visibility', 'visible'); + // Define g for chart area + context + .append('g') + .attr('clip-path', $$.clipPathForSubchart) + .attr('class', CLASS.chart); + // Define g for bar chart area + context + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartBars); + // Define g for line chart area + context + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartLines); + // Add extent rect for Brush + context + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.brush); + // ATTENTION: This must be called AFTER chart added + // Add Axis + $$.axes.subx = context + .append('g') + .attr('class', CLASS.axisX) + .attr('transform', $$.getTranslate('subx')) + .attr('clip-path', config.axis_rotated ? '' : $$.clipPathForXAxis) + .style('visibility', config.subchart_axis_x_show ? 'visible' : 'hidden'); + }; + ChartInternal.prototype.initSubchartBrush = function () { + var $$ = this; + // Add extent rect for Brush + $$.initBrush($$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call($$.brush); + }; + ChartInternal.prototype.updateTargetsForSubchart = function (targets) { + var $$ = this, context = $$.context, config = $$.config, contextLineEnter, contextLine, contextBarEnter, contextBar, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$), classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$); + //-- Bar --// + contextBar = context + .select('.' + CLASS.chartBars) + .selectAll('.' + CLASS.chartBar) + .data(targets); + contextBarEnter = contextBar + .enter() + .append('g') + .style('opacity', 0); + contextBarEnter.merge(contextBar).attr('class', classChartBar); + // Bars for each data + contextBarEnter.append('g').attr('class', classBars); + //-- Line --// + contextLine = context + .select('.' + CLASS.chartLines) + .selectAll('.' + CLASS.chartLine) + .data(targets); + contextLineEnter = contextLine + .enter() + .append('g') + .style('opacity', 0); + contextLineEnter.merge(contextLine).attr('class', classChartLine); + // Lines for each data + contextLineEnter.append('g').attr('class', classLines); + // Area + contextLineEnter.append('g').attr('class', classAreas); + //-- Brush --// + context + .selectAll('.' + CLASS.brush + ' rect') + .attr(config.axis_rotated ? 'width' : 'height', config.axis_rotated ? $$.width2 : $$.height2); + }; + ChartInternal.prototype.updateBarForSubchart = function (durationForExit) { + var $$ = this; + var contextBar = $$.context + .selectAll('.' + CLASS.bars) + .selectAll('.' + CLASS.bar) + .data($$.barData.bind($$)); + var contextBarEnter = contextBar + .enter() + .append('path') + .attr('class', $$.classBar.bind($$)) + .style('stroke', 'none') + .style('fill', $$.color); + contextBar + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextBar = contextBarEnter + .merge(contextBar) + .style('opacity', $$.initialOpacity.bind($$)); + }; + ChartInternal.prototype.redrawBarForSubchart = function (drawBarOnSub, withTransition, duration) { + (withTransition + ? this.contextBar.transition(Math.random().toString()).duration(duration) + : this.contextBar) + .attr('d', drawBarOnSub) + .style('opacity', 1); + }; + ChartInternal.prototype.updateLineForSubchart = function (durationForExit) { + var $$ = this; + var contextLine = $$.context + .selectAll('.' + CLASS.lines) + .selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + var contextLineEnter = contextLine + .enter() + .append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + contextLine + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextLine = contextLineEnter + .merge(contextLine) + .style('opacity', $$.initialOpacity.bind($$)); + }; + ChartInternal.prototype.redrawLineForSubchart = function (drawLineOnSub, withTransition, duration) { + (withTransition + ? this.contextLine.transition(Math.random().toString()).duration(duration) + : this.contextLine) + .attr('d', drawLineOnSub) + .style('opacity', 1); + }; + ChartInternal.prototype.updateAreaForSubchart = function (durationForExit) { + var $$ = this, d3 = $$.d3; + var contextArea = $$.context + .selectAll('.' + CLASS.areas) + .selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + var contextAreaEnter = contextArea + .enter() + .append('path') + .attr('class', $$.classArea.bind($$)) + .style('fill', $$.color) + .style('opacity', function () { + $$.orgAreaOpacity = +d3.select(this).style('opacity'); + return 0; + }); + contextArea + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextArea = contextAreaEnter.merge(contextArea).style('opacity', 0); + }; + ChartInternal.prototype.redrawAreaForSubchart = function (drawAreaOnSub, withTransition, duration) { + (withTransition + ? this.contextArea.transition(Math.random().toString()).duration(duration) + : this.contextArea) + .attr('d', drawAreaOnSub) + .style('fill', this.color) + .style('opacity', this.orgAreaOpacity); + }; + ChartInternal.prototype.redrawSubchart = function (withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices) { + var $$ = this, d3 = $$.d3, drawAreaOnSub, drawBarOnSub, drawLineOnSub; + // reflect main chart to extent on subchart if zoomed + if (d3.event && d3.event.type === 'zoom') { + $$.brush.selectionAsValue($$.x.orgDomain()); + } + // update subchart elements if needed + if (withSubchart) { + // extent rect + if (!$$.brush.empty()) { + $$.brush.selectionAsValue($$.x.orgDomain()); + } + // setup drawer - MEMO: this must be called after axis updated + drawAreaOnSub = $$.generateDrawArea(areaIndices, true); + drawBarOnSub = $$.generateDrawBar(barIndices, true); + drawLineOnSub = $$.generateDrawLine(lineIndices, true); + $$.updateBarForSubchart(duration); + $$.updateLineForSubchart(duration); + $$.updateAreaForSubchart(duration); + $$.redrawBarForSubchart(drawBarOnSub, duration, duration); + $$.redrawLineForSubchart(drawLineOnSub, duration, duration); + $$.redrawAreaForSubchart(drawAreaOnSub, duration, duration); + } + }; + ChartInternal.prototype.redrawForBrush = function () { + var $$ = this, x = $$.x, d3 = $$.d3, s; + $$.redraw({ + withTransition: false, + withY: $$.config.zoom_rescale, + withSubchart: false, + withUpdateXDomain: true, + withEventRect: false, + withDimension: false + }); + // update zoom transation binded to event rect + s = d3.event.selection || $$.brush.scale.range(); + $$.main + .select('.' + CLASS.eventRect) + .call($$.zoom.transform, d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0)); + $$.config.subchart_onbrush.call($$.api, x.orgDomain()); + }; + ChartInternal.prototype.transformContext = function (withTransition, transitions) { + var $$ = this, subXAxis; + if (transitions && transitions.axisSubX) { + subXAxis = transitions.axisSubX; + } + else { + subXAxis = $$.context.select('.' + CLASS.axisX); + if (withTransition) { + subXAxis = subXAxis.transition(); + } + } + $$.context.attr('transform', $$.getTranslate('context')); + subXAxis.attr('transform', $$.getTranslate('subx')); + }; + ChartInternal.prototype.getDefaultSelection = function () { + var $$ = this, config = $$.config, selection = isFunction(config.axis_x_selection) + ? config.axis_x_selection($$.getXDomain($$.data.targets)) + : config.axis_x_selection; + if ($$.isTimeSeries()) { + selection = [$$.parseDate(selection[0]), $$.parseDate(selection[1])]; + } + return selection; + }; + ChartInternal.prototype.removeSubchart = function () { + var $$ = this; + $$.brush = null; + $$.context.remove(); + $$.context = null; + }; + + ChartInternal.prototype.initText = function () { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartTexts); + $$.mainText = $$.d3.selectAll([]); + }; + ChartInternal.prototype.updateTargetsForText = function (targets) { + var $$ = this, classChartText = $$.classChartText.bind($$), classTexts = $$.classTexts.bind($$), classFocus = $$.classFocus.bind($$); + var mainText = $$.main + .select('.' + CLASS.chartTexts) + .selectAll('.' + CLASS.chartText) + .data(targets); + var mainTextEnter = mainText + .enter() + .append('g') + .attr('class', classChartText) + .style('opacity', 0) + .style('pointer-events', 'none'); + mainTextEnter.append('g').attr('class', classTexts); + mainTextEnter.merge(mainText).attr('class', function (d) { + return classChartText(d) + classFocus(d); + }); + }; + ChartInternal.prototype.updateText = function (xForText, yForText, durationForExit) { + var $$ = this, config = $$.config, barOrLineData = $$.barOrLineData.bind($$), classText = $$.classText.bind($$); + var mainText = $$.main + .selectAll('.' + CLASS.texts) + .selectAll('.' + CLASS.text) + .data(barOrLineData); + var mainTextEnter = mainText + .enter() + .append('text') + .attr('class', classText) + .attr('text-anchor', function (d) { + return config.axis_rotated ? (d.value < 0 ? 'end' : 'start') : 'middle'; + }) + .style('stroke', 'none') + .attr('x', xForText) + .attr('y', yForText) + .style('fill', function (d) { + return $$.color(d); + }) + .style('fill-opacity', 0); + $$.mainText = mainTextEnter.merge(mainText).text(function (d, i, j) { + return $$.dataLabelFormat(d.id)(d.value, d.id, i, j); + }); + mainText + .exit() + .transition() + .duration(durationForExit) + .style('fill-opacity', 0) + .remove(); + }; + ChartInternal.prototype.redrawText = function (xForText, yForText, forFlow, withTransition, transition) { + return [ + (withTransition ? this.mainText.transition(transition) : this.mainText) + .attr('x', xForText) + .attr('y', yForText) + .style('fill', this.color) + .style('fill-opacity', forFlow ? 0 : this.opacityForText.bind(this)) + ]; + }; + ChartInternal.prototype.getTextRect = function (text, cls, element) { + var dummy = this.d3 + .select('body') + .append('div') + .classed('c3', true), svg = dummy + .append('svg') + .style('visibility', 'hidden') + .style('position', 'fixed') + .style('top', 0) + .style('left', 0), font = this.d3.select(element).style('font'), rect; + svg + .selectAll('.dummy') + .data([text]) + .enter() + .append('text') + .classed(cls ? cls : '', true) + .style('font', font) + .text(text) + .each(function () { + rect = getBBox(this); + }); + dummy.remove(); + return rect; + }; + ChartInternal.prototype.generateXYForText = function (areaIndices, barIndices, lineIndices, forX) { + var $$ = this, getAreaPoints = $$.generateGetAreaPoints(areaIndices, false), getBarPoints = $$.generateGetBarPoints(barIndices, false), getLinePoints = $$.generateGetLinePoints(lineIndices, false), getter = forX ? $$.getXForText : $$.getYForText; + return function (d, i) { + var getPoints = $$.isAreaType(d) + ? getAreaPoints + : $$.isBarType(d) + ? getBarPoints + : getLinePoints; + return getter.call($$, getPoints(d, i), d, this); + }; + }; + ChartInternal.prototype.getXForText = function (points, d, textElement) { + var $$ = this, box = getBBox(textElement), xPos, padding; + if ($$.config.axis_rotated) { + padding = $$.isBarType(d) ? 4 : 6; + xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1); + } + else { + xPos = $$.hasType('bar') ? (points[2][0] + points[0][0]) / 2 : points[0][0]; + } + // show labels regardless of the domain if value is null + if (d.value === null) { + if (xPos > $$.width) { + xPos = $$.width - box.width; + } + else if (xPos < 0) { + xPos = 4; + } + } + return xPos; + }; + ChartInternal.prototype.getYForText = function (points, d, textElement) { + var $$ = this, box = getBBox(textElement), yPos; + if ($$.config.axis_rotated) { + yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2; + } + else { + yPos = points[2][1]; + if (d.value < 0 || (d.value === 0 && !$$.hasPositiveValue)) { + yPos += box.height; + if ($$.isBarType(d) && $$.isSafari()) { + yPos -= 3; + } + else if (!$$.isBarType(d) && $$.isChrome()) { + yPos += 3; + } + } + else { + yPos += $$.isBarType(d) ? -3 : -6; + } + } + // show labels regardless of the domain if value is null + if (d.value === null && !$$.config.axis_rotated) { + if (yPos < box.height) { + yPos = box.height; + } + else if (yPos > this.height) { + yPos = this.height - 4; + } + } + return yPos; + }; + + ChartInternal.prototype.initTitle = function () { + var $$ = this; + $$.title = $$.svg + .append('text') + .text($$.config.title_text) + .attr('class', $$.CLASS.title); + }; + ChartInternal.prototype.redrawTitle = function () { + var $$ = this; + $$.title.attr('x', $$.xForTitle.bind($$)).attr('y', $$.yForTitle.bind($$)); + }; + ChartInternal.prototype.xForTitle = function () { + var $$ = this, config = $$.config, position = config.title_position || 'left', x; + if (position.indexOf('right') >= 0) { + x = + $$.currentWidth - + $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()).width - + config.title_padding.right; + } + else if (position.indexOf('center') >= 0) { + x = Math.max(($$.currentWidth - + $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()).width) / + 2, 0); + } + else { + // left + x = config.title_padding.left; + } + return x; + }; + ChartInternal.prototype.yForTitle = function () { + var $$ = this; + return ($$.config.title_padding.top + + $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()) + .height); + }; + ChartInternal.prototype.getTitlePadding = function () { + var $$ = this; + return $$.yForTitle() + $$.config.title_padding.bottom; + }; + + function powerOfTen(d) { + return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1; + } + ChartInternal.prototype.drawColorScale = function () { + var $$ = this, d3 = $$.d3, config = $$.config, target = $$.data.targets[0], barWidth, barHeight, axis, points, legendAxis, axisScale, inverseScale, height; + barWidth = !isNaN(config.stanford_scaleWidth) + ? config.stanford_scaleWidth + : 20; + barHeight = 5; + if (barHeight < 0 || barWidth < 0) { + throw Error("Colorscale's barheight and barwidth must be greater than 0."); + } + height = + $$.height - config.stanford_padding.bottom - config.stanford_padding.top; + points = d3.range(config.stanford_padding.bottom, height, barHeight); + inverseScale = d3 + .scaleSequential(target.colors) + .domain([points[points.length - 1], points[0]]); + if ($$.colorScale) { + $$.colorScale.remove(); + } + $$.colorScale = $$.svg + .append('g') + .attr('width', 50) + .attr('height', height) + .attr('class', CLASS.colorScale); + $$.colorScale + .append('g') + .attr('transform', "translate(0, " + config.stanford_padding.top + ")") + .selectAll('bars') + .data(points) + .enter() + .append('rect') + .attr('y', function (d, i) { return i * barHeight; }) + .attr('x', 0) + .attr('width', barWidth) + .attr('height', barHeight) + .attr('fill', function (d) { + return inverseScale(d); + }); + // Legend Axis + axisScale = d3 + .scaleLog() + .domain([target.minEpochs, target.maxEpochs]) + .range([ + points[0] + + config.stanford_padding.top + + points[points.length - 1] + + barHeight - + 1, + points[0] + config.stanford_padding.top + ]); + legendAxis = d3.axisRight(axisScale); + if (config.stanford_scaleFormat === 'pow10') { + legendAxis.tickValues([1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]); + } + else if (isFunction(config.stanford_scaleFormat)) { + legendAxis.tickFormat(config.stanford_scaleFormat); + } + else { + legendAxis.tickFormat(d3.format('d')); + } + if (isFunction(config.stanford_scaleValues)) { + legendAxis.tickValues(config.stanford_scaleValues(target.minEpochs, target.maxEpochs)); + } + // Draw Axis + axis = $$.colorScale + .append('g') + .attr('class', 'legend axis') + .attr('transform', "translate(" + barWidth + ",0)") + .call(legendAxis); + if (config.stanford_scaleFormat === 'pow10') { + axis + .selectAll('.tick text') + .text(null) + .filter(powerOfTen) + .text(10) + .append('tspan') + .attr('dy', '-.7em') // https://bl.ocks.org/mbostock/6738229 + .text(function (d) { + return Math.round(Math.log(d) / Math.LN10); + }); + } + $$.colorScale.attr('transform', "translate(" + ($$.currentWidth - $$.xForColorScale()) + ", 0)"); + }; + ChartInternal.prototype.xForColorScale = function () { + var $$ = this; + return $$.config.stanford_padding.right + getBBox($$.colorScale.node()).width; + }; + ChartInternal.prototype.getColorScalePadding = function () { + var $$ = this; + return $$.xForColorScale() + $$.config.stanford_padding.left + 20; + }; + + ChartInternal.prototype.isStanfordGraphType = function () { + var $$ = this; + return $$.config.data_type === 'stanford'; + }; + ChartInternal.prototype.initStanfordData = function () { + var $$ = this, d3 = $$.d3, config = $$.config, target = $$.data.targets[0], epochs, maxEpochs, minEpochs; + // Make larger values appear on top + target.values.sort(compareEpochs); + // Get array of epochs + epochs = target.values.map(function (a) { return a.epochs; }); + minEpochs = !isNaN(config.stanford_scaleMin) + ? config.stanford_scaleMin + : d3.min(epochs); + maxEpochs = !isNaN(config.stanford_scaleMax) + ? config.stanford_scaleMax + : d3.max(epochs); + if (minEpochs > maxEpochs) { + throw Error('Number of minEpochs has to be smaller than maxEpochs'); + } + target.colors = isFunction(config.stanford_colors) + ? config.stanford_colors + : d3.interpolateHslLong(d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)); + target.colorscale = d3 + .scaleSequentialLog(target.colors) + .domain([minEpochs, maxEpochs]); + target.minEpochs = minEpochs; + target.maxEpochs = maxEpochs; + }; + ChartInternal.prototype.getStanfordPointColor = function (d) { + var $$ = this, target = $$.data.targets[0]; + return target.colorscale(d.epochs); + }; + // http://jsfiddle.net/Xotic750/KtzLq/ + ChartInternal.prototype.getCentroid = function (points) { + var area = getRegionArea(points); + var x = 0, y = 0, i, j, f, point1, point2; + for (i = 0, j = points.length - 1; i < points.length; j = i, i += 1) { + point1 = points[i]; + point2 = points[j]; + f = point1.x * point2.y - point2.x * point1.y; + x += (point1.x + point2.x) * f; + y += (point1.y + point2.y) * f; + } + f = area * 6; + return { + x: x / f, + y: y / f + }; + }; + ChartInternal.prototype.getStanfordTooltipTitle = function (d) { + var $$ = this, labelX = $$.axis.getLabelText('x'), labelY = $$.axis.getLabelText('y'); + return "\n " + (labelX ? sanitise(labelX) : 'x') + "" + d.x + "\n " + (labelY ? sanitise(labelY) : 'y') + "" + d.value + "\n "; + }; + ChartInternal.prototype.countEpochsInRegion = function (region) { + var $$ = this, target = $$.data.targets[0], total, count; + total = target.values.reduce(function (accumulator, currentValue) { return accumulator + Number(currentValue.epochs); }, 0); + count = target.values.reduce(function (accumulator, currentValue) { + if (pointInRegion(currentValue, region)) { + return accumulator + Number(currentValue.epochs); + } + return accumulator; + }, 0); + return { + value: count, + percentage: count !== 0 ? ((count / total) * 100).toFixed(1) : 0 + }; + }; + var getRegionArea = function (points) { + // thanks to: https://stackoverflow.com/questions/16282330/find-centerpoint-of-polygon-in-javascript + var area = 0, i, j, point1, point2; + for (i = 0, j = points.length - 1; i < points.length; j = i, i += 1) { + point1 = points[i]; + point2 = points[j]; + area += point1.x * point2.y; + area -= point1.y * point2.x; + } + area /= 2; + return area; + }; + var pointInRegion = function (point, region) { + // thanks to: http://bl.ocks.org/bycoffe/5575904 + // ray-casting algorithm based on + // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html + var xi, yi, yj, xj, intersect, x = point.x, y = point.value, inside = false; + for (var i = 0, j = region.length - 1; i < region.length; j = i++) { + xi = region[i].x; + yi = region[i].y; + xj = region[j].x; + yj = region[j].y; + intersect = yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi; + if (intersect) { + inside = !inside; + } + } + return inside; + }; + var compareEpochs = function (a, b) { + if (a.epochs < b.epochs) { + return -1; + } + if (a.epochs > b.epochs) { + return 1; + } + return 0; + }; + + ChartInternal.prototype.initStanfordElements = function () { + var $$ = this; + // Avoid blocking eventRect + $$.stanfordElements = $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.stanfordElements); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordLines); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordTexts); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordRegions); + }; + ChartInternal.prototype.updateStanfordElements = function (duration) { + var $$ = this, main = $$.main, config = $$.config, stanfordLine, stanfordLineEnter, stanfordRegion, stanfordRegionEnter, stanfordText, stanfordTextEnter, xvCustom = $$.xvCustom.bind($$), yvCustom = $$.yvCustom.bind($$), countPointsInRegion = $$.countEpochsInRegion.bind($$); + // Stanford-Lines + stanfordLine = main + .select('.' + CLASS.stanfordLines) + .style('shape-rendering', 'geometricprecision') + .selectAll('.' + CLASS.stanfordLine) + .data(config.stanford_lines); + // enter + stanfordLineEnter = stanfordLine + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.stanfordLine + (d['class'] ? ' ' + d['class'] : ''); + }); + stanfordLineEnter + .append('line') + .attr('x1', function (d) { + return config.axis_rotated ? yvCustom(d, 'value_y1') : xvCustom(d, 'value_x1'); + }) + .attr('x2', function (d) { + return config.axis_rotated ? yvCustom(d, 'value_y2') : xvCustom(d, 'value_x2'); + }) + .attr('y1', function (d) { + return config.axis_rotated ? xvCustom(d, 'value_x1') : yvCustom(d, 'value_y1'); + }) + .attr('y2', function (d) { + return config.axis_rotated ? xvCustom(d, 'value_x2') : yvCustom(d, 'value_y2'); + }) + .style('opacity', 0); + // update + $$.stanfordLines = stanfordLineEnter.merge(stanfordLine); + $$.stanfordLines + .select('line') + .transition() + .duration(duration) + .attr('x1', function (d) { + return config.axis_rotated ? yvCustom(d, 'value_y1') : xvCustom(d, 'value_x1'); + }) + .attr('x2', function (d) { + return config.axis_rotated ? yvCustom(d, 'value_y2') : xvCustom(d, 'value_x2'); + }) + .attr('y1', function (d) { + return config.axis_rotated ? xvCustom(d, 'value_x1') : yvCustom(d, 'value_y1'); + }) + .attr('y2', function (d) { + return config.axis_rotated ? xvCustom(d, 'value_x2') : yvCustom(d, 'value_y2'); + }) + .style('opacity', 1); + // exit + stanfordLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + // Stanford-Text + stanfordText = main + .select('.' + CLASS.stanfordTexts) + .selectAll('.' + CLASS.stanfordText) + .data(config.stanford_texts); + // enter + stanfordTextEnter = stanfordText + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.stanfordText + (d['class'] ? ' ' + d['class'] : ''); + }); + stanfordTextEnter + .append('text') + .attr('x', function (d) { return (config.axis_rotated ? yvCustom(d, 'y') : xvCustom(d, 'x')); }) + .attr('y', function (d) { return (config.axis_rotated ? xvCustom(d, 'x') : yvCustom(d, 'y')); }) + .style('opacity', 0); + // update + $$.stanfordTexts = stanfordTextEnter.merge(stanfordText); + $$.stanfordTexts + .select('text') + .transition() + .duration(duration) + .attr('x', function (d) { return (config.axis_rotated ? yvCustom(d, 'y') : xvCustom(d, 'x')); }) + .attr('y', function (d) { return (config.axis_rotated ? xvCustom(d, 'x') : yvCustom(d, 'y')); }) + .text(function (d) { + return d.content; + }) + .style('opacity', 1); + // exit + stanfordText + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + // Stanford-Regions + stanfordRegion = main + .select('.' + CLASS.stanfordRegions) + .selectAll('.' + CLASS.stanfordRegion) + .data(config.stanford_regions); + // enter + stanfordRegionEnter = stanfordRegion + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.stanfordRegion + (d['class'] ? ' ' + d['class'] : ''); + }); + stanfordRegionEnter + .append('polygon') + .attr('points', function (d) { + return d.points + .map(function (value) { + return [ + config.axis_rotated ? yvCustom(value, 'y') : xvCustom(value, 'x'), + config.axis_rotated ? xvCustom(value, 'x') : yvCustom(value, 'y') + ].join(','); + }) + .join(' '); + }) + .style('opacity', 0); + stanfordRegionEnter + .append('text') + .attr('x', function (d) { return $$.getCentroid(d.points).x; }) + .attr('y', function (d) { return $$.getCentroid(d.points).y; }) + .style('opacity', 0); + // update + $$.stanfordRegions = stanfordRegionEnter.merge(stanfordRegion); + $$.stanfordRegions + .select('polygon') + .transition() + .duration(duration) + .attr('points', function (d) { + return d.points + .map(function (value) { + return [ + config.axis_rotated ? yvCustom(value, 'y') : xvCustom(value, 'x'), + config.axis_rotated ? xvCustom(value, 'x') : yvCustom(value, 'y') + ].join(','); + }) + .join(' '); + }) + .style('opacity', function (d) { + return d.opacity ? d.opacity : 0.2; + }); + $$.stanfordRegions + .select('text') + .transition() + .duration(duration) + .attr('x', function (d) { + return config.axis_rotated + ? yvCustom($$.getCentroid(d.points), 'y') + : xvCustom($$.getCentroid(d.points), 'x'); + }) + .attr('y', function (d) { + return config.axis_rotated + ? xvCustom($$.getCentroid(d.points), 'x') + : yvCustom($$.getCentroid(d.points), 'y'); + }) + .text(function (d) { + if (d.text) { + var value, percentage, temp; + if ($$.isStanfordGraphType()) { + temp = countPointsInRegion(d.points); + value = temp.value; + percentage = temp.percentage; + } + return d.text(value, percentage); + } + return ''; + }) + .attr('text-anchor', 'middle') + .attr('dominant-baseline', 'middle') + .style('opacity', 1); + // exit + stanfordRegion + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + }; + + ChartInternal.prototype.initTooltip = function () { + var $$ = this, config = $$.config, i; + $$.tooltip = $$.selectChart + .style('position', 'relative') + .append('div') + .attr('class', CLASS.tooltipContainer) + .style('position', 'absolute') + .style('pointer-events', 'none') + .style('display', 'none'); + // Show tooltip if needed + if (config.tooltip_init_show) { + if ($$.isTimeSeries() && isString(config.tooltip_init_x)) { + config.tooltip_init_x = $$.parseDate(config.tooltip_init_x); + for (i = 0; i < $$.data.targets[0].values.length; i++) { + if ($$.data.targets[0].values[i].x - config.tooltip_init_x === 0) { + break; + } + } + config.tooltip_init_x = i; + } + $$.tooltip.html(config.tooltip_contents.call($$, $$.data.targets.map(function (d) { + return $$.addName(d.values[config.tooltip_init_x]); + }), $$.axis.getXAxisTickFormat(), $$.getYFormat($$.hasArcType()), $$.color)); + $$.tooltip + .style('top', config.tooltip_init_position.top) + .style('left', config.tooltip_init_position.left) + .style('display', 'block'); + } + }; + ChartInternal.prototype.getTooltipSortFunction = function () { + var $$ = this, config = $$.config; + if (config.data_groups.length === 0 || config.tooltip_order !== undefined) { + // if data are not grouped or if an order is specified + // for the tooltip values we sort them by their values + var order = config.tooltip_order; + if (order === undefined) { + order = config.data_order; + } + var valueOf = function (obj) { + return obj ? obj.value : null; + }; + // if data are not grouped, we sort them by their value + if (isString(order) && order.toLowerCase() === 'asc') { + return function (a, b) { + return valueOf(a) - valueOf(b); + }; + } + else if (isString(order) && order.toLowerCase() === 'desc') { + return function (a, b) { + return valueOf(b) - valueOf(a); + }; + } + else if (isFunction(order)) { + // if the function is from data_order we need + // to wrap the returned function in order to format + // the sorted value to the expected format + var sortFunction = order; + if (config.tooltip_order === undefined) { + sortFunction = function (a, b) { + return order(a + ? { + id: a.id, + values: [a] + } + : null, b + ? { + id: b.id, + values: [b] + } + : null); + }; + } + return sortFunction; + } + else if (isArray(order)) { + return function (a, b) { + return order.indexOf(a.id) - order.indexOf(b.id); + }; + } + } + else { + // if data are grouped, we follow the order of grouped targets + var ids = $$.orderTargets($$.data.targets).map(function (i) { + return i.id; + }); + // if it was either asc or desc we need to invert the order + // returned by orderTargets + if ($$.isOrderAsc() || $$.isOrderDesc()) { + ids = ids.reverse(); + } + return function (a, b) { + return ids.indexOf(a.id) - ids.indexOf(b.id); + }; + } + }; + ChartInternal.prototype.getTooltipContent = function (d, defaultTitleFormat, defaultValueFormat, color) { + var $$ = this, config = $$.config, titleFormat = config.tooltip_format_title || defaultTitleFormat, nameFormat = config.tooltip_format_name || + function (name) { + return name; + }, text, i, title, value, name, bgcolor; + var valueFormat = config.tooltip_format_value; + if (!valueFormat) { + valueFormat = $$.isTargetNormalized(d.id) + ? function (v, ratio) { return (ratio * 100).toFixed(2) + "%"; } + : defaultValueFormat; + } + var tooltipSortFunction = this.getTooltipSortFunction(); + if (tooltipSortFunction) { + d.sort(tooltipSortFunction); + } + for (i = 0; i < d.length; i++) { + if (!(d[i] && (d[i].value || d[i].value === 0))) { + continue; + } + if ($$.isStanfordGraphType()) { + // Custom tooltip for stanford plots + if (!text) { + title = $$.getStanfordTooltipTitle(d[i]); + text = "" + title; + } + bgcolor = $$.getStanfordPointColor(d[i]); + name = sanitise(config.data_epochs); // Epochs key name + value = d[i].epochs; + } + else { + // Regular tooltip + if (!text) { + title = sanitise(titleFormat ? titleFormat(d[i].x, d[i].index) : d[i].x); + text = + "
" + + (title || title === 0 + ? "' + : ''); + } + value = sanitise(valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index, d)); + if (value !== undefined) { + // Skip elements when their name is set to null + if (d[i].name === null) { + continue; + } + name = sanitise(nameFormat(d[i].name, d[i].ratio, d[i].id, d[i].index)); + bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); + } + } + if (value !== undefined) { + text += + ""; + text += + "'; + text += "'; + text += ''; + } + } + return text + '
" + title + '
" + + name + + '" + value + '
'; + }; + ChartInternal.prototype.tooltipPosition = function (dataToShow, tWidth, tHeight, element) { + var $$ = this, config = $$.config, d3 = $$.d3; + var svgLeft, tooltipLeft, tooltipRight, tooltipTop, chartRight; + var forArc = $$.hasArcType(), mouse = d3.mouse(element); + // Determin tooltip position + if (forArc) { + tooltipLeft = + ($$.width - ($$.isLegendRight ? $$.getLegendWidth() : 0)) / 2 + mouse[0]; + tooltipTop = + ($$.hasType('gauge') ? $$.height : $$.height / 2) + mouse[1] + 20; + } + else { + svgLeft = $$.getSvgLeft(true); + if (config.axis_rotated) { + tooltipLeft = svgLeft + mouse[0] + 100; + tooltipRight = tooltipLeft + tWidth; + chartRight = $$.currentWidth - $$.getCurrentPaddingRight(); + tooltipTop = $$.x(dataToShow[0].x) + 20; + } + else { + tooltipLeft = + svgLeft + $$.getCurrentPaddingLeft(true) + $$.x(dataToShow[0].x) + 20; + tooltipRight = tooltipLeft + tWidth; + chartRight = svgLeft + $$.currentWidth - $$.getCurrentPaddingRight(); + tooltipTop = mouse[1] + 15; + } + if (tooltipRight > chartRight) { + // 20 is needed for Firefox to keep tooltip width + tooltipLeft -= tooltipRight - chartRight + 20; + } + if (tooltipTop + tHeight > $$.currentHeight) { + tooltipTop -= tHeight + 30; + } + } + if (tooltipTop < 0) { + tooltipTop = 0; + } + return { + top: tooltipTop, + left: tooltipLeft + }; + }; + ChartInternal.prototype.showTooltip = function (selectedData, element) { + var $$ = this, config = $$.config; + var tWidth, tHeight, position; + var forArc = $$.hasArcType(), dataToShow = selectedData.filter(function (d) { + return d && isValue(d.value); + }), positionFunction = config.tooltip_position || ChartInternal.prototype.tooltipPosition; + if (dataToShow.length === 0 || !config.tooltip_show) { + $$.hideTooltip(); + return; + } + $$.tooltip + .html(config.tooltip_contents.call($$, selectedData, $$.axis.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)) + .style('display', 'block'); + // Get tooltip dimensions + tWidth = $$.tooltip.property('offsetWidth'); + tHeight = $$.tooltip.property('offsetHeight'); + position = positionFunction.call(this, dataToShow, tWidth, tHeight, element); + // Set tooltip + $$.tooltip + .style('top', position.top + 'px') + .style('left', position.left + 'px'); + }; + ChartInternal.prototype.hideTooltip = function () { + this.tooltip.style('display', 'none'); + }; + + ChartInternal.prototype.setTargetType = function (targetIds, type) { + var $$ = this, config = $$.config; + $$.mapToTargetIds(targetIds).forEach(function (id) { + $$.withoutFadeIn[id] = type === config.data_types[id]; + config.data_types[id] = type; + }); + if (!targetIds) { + config.data_type = type; + } + }; + ChartInternal.prototype.hasType = function (type, targets) { + var $$ = this, types = $$.config.data_types, has = false; + targets = targets || $$.data.targets; + if (targets && targets.length) { + targets.forEach(function (target) { + var t = types[target.id]; + if ((t && t.indexOf(type) >= 0) || (!t && type === 'line')) { + has = true; + } + }); + } + else if (Object.keys(types).length) { + Object.keys(types).forEach(function (id) { + if (types[id] === type) { + has = true; + } + }); + } + else { + has = $$.config.data_type === type; + } + return has; + }; + ChartInternal.prototype.hasArcType = function (targets) { + return (this.hasType('pie', targets) || + this.hasType('donut', targets) || + this.hasType('gauge', targets)); + }; + ChartInternal.prototype.isLineType = function (d) { + var config = this.config, id = isString(d) ? d : d.id; + return (!config.data_types[id] || + ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf(config.data_types[id]) >= 0); + }; + ChartInternal.prototype.isStepType = function (d) { + var id = isString(d) ? d : d.id; + return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0; + }; + ChartInternal.prototype.isSplineType = function (d) { + var id = isString(d) ? d : d.id; + return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0; + }; + ChartInternal.prototype.isAreaType = function (d) { + var id = isString(d) ? d : d.id; + return (['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= + 0); + }; + ChartInternal.prototype.isBarType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'bar'; + }; + ChartInternal.prototype.isScatterType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'scatter'; + }; + ChartInternal.prototype.isStanfordType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'stanford'; + }; + ChartInternal.prototype.isPieType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'pie'; + }; + ChartInternal.prototype.isGaugeType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'gauge'; + }; + ChartInternal.prototype.isDonutType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'donut'; + }; + ChartInternal.prototype.isArcType = function (d) { + return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d); + }; + ChartInternal.prototype.lineData = function (d) { + return this.isLineType(d) ? [d] : []; + }; + ChartInternal.prototype.arcData = function (d) { + return this.isArcType(d.data) ? [d] : []; + }; + /* not used + function scatterData(d) { + return isScatterType(d) ? d.values : []; + } + */ + ChartInternal.prototype.barData = function (d) { + return this.isBarType(d) ? d.values : []; + }; + ChartInternal.prototype.lineOrScatterOrStanfordData = function (d) { + return this.isLineType(d) || this.isScatterType(d) || this.isStanfordType(d) + ? d.values + : []; + }; + ChartInternal.prototype.barOrLineData = function (d) { + return this.isBarType(d) || this.isLineType(d) ? d.values : []; + }; + + ChartInternal.prototype.isSafari = function () { + var ua = window.navigator.userAgent; + return ua.indexOf('Safari') >= 0 && ua.indexOf('Chrome') < 0; + }; + ChartInternal.prototype.isChrome = function () { + var ua = window.navigator.userAgent; + return ua.indexOf('Chrome') >= 0; + }; + + ChartInternal.prototype.initZoom = function () { + var $$ = this, d3 = $$.d3, config = $$.config, startEvent; + $$.zoom = d3 + .zoom() + .on('start', function () { + if (config.zoom_type !== 'scroll') { + return; + } + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return; + } + startEvent = e; + config.zoom_onzoomstart.call($$.api, e); + }) + .on('zoom', function () { + if (config.zoom_type !== 'scroll') { + return; + } + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return; + } + $$.redrawForZoom(); + config.zoom_onzoom.call($$.api, $$.x.orgDomain()); + }) + .on('end', function () { + if (config.zoom_type !== 'scroll') { + return; + } + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return; + } + // if click, do nothing. otherwise, click interaction will be canceled. + if (e && + startEvent.clientX === e.clientX && + startEvent.clientY === e.clientY) { + return; + } + config.zoom_onzoomend.call($$.api, $$.x.orgDomain()); + }); + $$.zoom.updateDomain = function () { + if (d3.event && d3.event.transform) { + if (config.axis_rotated && config.zoom_type === 'scroll' && d3.event.sourceEvent.type === 'mousemove') { + // we're moving the mouse in a rotated chart with zoom = "scroll", so we need rescaleY (i.e. vertical) + $$.x.domain(d3.event.transform.rescaleY($$.subX).domain()); + } + else { + $$.x.domain(d3.event.transform.rescaleX($$.subX).domain()); + } + } + return this; + }; + $$.zoom.updateExtent = function () { + this.scaleExtent([1, Infinity]) + .translateExtent([ + [0, 0], + [$$.width, $$.height] + ]) + .extent([ + [0, 0], + [$$.width, $$.height] + ]); + return this; + }; + $$.zoom.update = function () { + return this.updateExtent().updateDomain(); + }; + return $$.zoom.updateExtent(); + }; + ChartInternal.prototype.zoomTransform = function (range) { + var $$ = this, s = [$$.x(range[0]), $$.x(range[1])]; + return $$.d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0); + }; + ChartInternal.prototype.initDragZoom = function () { + var $$ = this; + var d3 = $$.d3; + var config = $$.config; + var context = ($$.context = $$.svg); + var brushXPos = $$.margin.left + 20.5; + var brushYPos = $$.margin.top + 0.5; + if (!(config.zoom_type === 'drag' && config.zoom_enabled)) { + return; + } + var getZoomedDomain = function (selection) { + return selection && selection.map(function (x) { return $$.x.invert(x); }); + }; + var brush = ($$.dragZoomBrush = d3 + .brushX() + .on('start', function () { + $$.api.unzoom(); + $$.svg.select('.' + CLASS.dragZoom).classed('disabled', false); + config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent); + }) + .on('brush', function () { + config.zoom_onzoom.call($$.api, getZoomedDomain(d3.event.selection)); + }) + .on('end', function () { + if (d3.event.selection == null) { + return; + } + var zoomedDomain = getZoomedDomain(d3.event.selection); + if (!config.zoom_disableDefaultBehavior) { + $$.api.zoom(zoomedDomain); + } + $$.svg.select('.' + CLASS.dragZoom).classed('disabled', true); + config.zoom_onzoomend.call($$.api, zoomedDomain); + })); + context + .append('g') + .classed(CLASS.dragZoom, true) + .attr('clip-path', $$.clipPath) + .attr('transform', 'translate(' + brushXPos + ',' + brushYPos + ')') + .call(brush); + }; + ChartInternal.prototype.getZoomDomain = function () { + var $$ = this, config = $$.config, d3 = $$.d3, min = d3.min([$$.orgXDomain[0], config.zoom_x_min]), max = d3.max([$$.orgXDomain[1], config.zoom_x_max]); + return [min, max]; + }; + ChartInternal.prototype.redrawForZoom = function () { + var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x; + if (!config.zoom_enabled) { + return; + } + if ($$.filterTargetsToShow($$.data.targets).length === 0) { + return; + } + zoom.update(); + if (config.zoom_disableDefaultBehavior) { + return; + } + if ($$.isCategorized() && x.orgDomain()[0] === $$.orgXDomain[0]) { + x.domain([$$.orgXDomain[0] - 1e-10, x.orgDomain()[1]]); + } + $$.redraw({ + withTransition: false, + withY: config.zoom_rescale, + withSubchart: false, + withEventRect: false, + withDimension: false + }); + if (d3.event.sourceEvent && d3.event.sourceEvent.type === 'mousemove') { + $$.cancelClick = true; + } + }; + + return c3; + +}))); diff --git a/server/static/server/c3/c3.min.css b/server/static/server/c3/c3.min.css new file mode 100644 index 0000000..86778eb --- /dev/null +++ b/server/static/server/c3/c3.min.css @@ -0,0 +1 @@ +.c3 svg{font:10px sans-serif;-webkit-tap-highlight-color:transparent}.c3 line,.c3 path{fill:none;stroke:#000}.c3 text{-webkit-user-select:none;-moz-user-select:none;user-select:none}.c3-bars path,.c3-event-rect,.c3-legend-item-tile,.c3-xgrid-focus,.c3-ygrid{shape-rendering:crispEdges}.c3-chart-arc path{stroke:#fff}.c3-chart-arc rect{stroke:#fff;stroke-width:1}.c3-chart-arc text{fill:#fff;font-size:13px}.c3-grid line{stroke:#aaa}.c3-grid text{fill:#aaa}.c3-xgrid,.c3-ygrid{stroke-dasharray:3 3}.c3-text.c3-empty{fill:grey;font-size:2em}.c3-line{stroke-width:1px}.c3-circle{fill:currentColor}.c3-circle._expanded_{stroke-width:1px;stroke:#fff}.c3-selected-circle{fill:#fff;stroke-width:2px}.c3-bar{stroke-width:0}.c3-bar._expanded_{fill-opacity:1;fill-opacity:.75}.c3-target.c3-focused{opacity:1}.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}.c3-target.c3-defocused{opacity:.3!important}.c3-region{fill:#4682b4;fill-opacity:.1}.c3-region text{fill-opacity:1}.c3-brush .extent{fill-opacity:.1}.c3-legend-item{font-size:12px}.c3-legend-item-hidden{opacity:.15}.c3-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.c3-title{font:14px sans-serif}.c3-tooltip-container{z-index:10}.c3-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;-webkit-box-shadow:7px 7px 12px -9px #777;-moz-box-shadow:7px 7px 12px -9px #777;box-shadow:7px 7px 12px -9px #777;opacity:.9}.c3-tooltip tr{border:1px solid #ccc}.c3-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#fff}.c3-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.c3-tooltip td>span{display:inline-block;width:10px;height:10px;margin-right:6px}.c3-tooltip .value{text-align:right}.c3-area{stroke-width:0;opacity:.2}.c3-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}.c3-chart-arcs .c3-chart-arcs-background{fill:#e0e0e0;stroke:#fff}.c3-chart-arcs .c3-chart-arcs-gauge-unit{fill:#000;font-size:16px}.c3-chart-arcs .c3-chart-arcs-gauge-max{fill:#777}.c3-chart-arcs .c3-chart-arcs-gauge-min{fill:#777}.c3-chart-arc .c3-gauge-value{fill:#000}.c3-chart-arc.c3-target g path{opacity:1}.c3-chart-arc.c3-target.c3-focused g path{opacity:1}.c3-drag-zoom.enabled{pointer-events:all!important;visibility:visible}.c3-drag-zoom.disabled{pointer-events:none!important;visibility:hidden}.c3-drag-zoom .extent{fill-opacity:.1} \ No newline at end of file diff --git a/server/static/server/c3/c3.min.js b/server/static/server/c3/c3.min.js new file mode 100644 index 0000000..dc30669 --- /dev/null +++ b/server/static/server/c3/c3.min.js @@ -0,0 +1,2 @@ +/* @license C3.js v0.7.20 | (c) C3 Team and other contributors | http://c3js.org/ */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).c3=e()}(this,function(){"use strict";function l(t){var e=this;e.d3=window.d3?window.d3:"undefined"!=typeof require?require("d3"):void 0,e.api=t,e.config=e.getDefaultConfig(),e.data={},e.cache={},e.axes={}}function n(t){this.internal=new l(this),this.internal.loadConfig(t),this.internal.beforeInit(t),this.internal.init(),this.internal.afterInit(t),function e(i,n,r){Object.keys(i).forEach(function(t){n[t]=i[t].bind(r),0/g,">"):t}function c(t){var e=function(t){void 0===t&&(t=window.navigator.userAgent);var e=t.indexOf("MSIE ");return 0e.getTotalLength())break;i--}while(0=this.numberOfItems)throw"INDEX_SIZE_ERR"},window.SVGPathSegList.prototype.getItem=function(t){return this._checkPathSynchronizedToList(),this._checkValidIndex(t),this._list[t]},window.SVGPathSegList.prototype.insertItemBefore=function(t,e){return this._checkPathSynchronizedToList(),e>this.numberOfItems&&(e=this.numberOfItems),t._owningPathSegList&&(t=t.clone()),this._list.splice(e,0,t),(t._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList.prototype.replaceItem=function(t,e){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._checkValidIndex(e),((this._list[e]=t)._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList.prototype.removeItem=function(t){this._checkPathSynchronizedToList(),this._checkValidIndex(t);var e=this._list[t];return this._list.splice(t,1),this._writeListToPath(),e},window.SVGPathSegList.prototype.appendItem=function(t){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._list.push(t),(t._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList._pathSegArrayAsString=function(t){var e="",i=!0;return t.forEach(function(t){i?(i=!1,e+=t._asPathString()):e+=" "+t._asPathString()}),e},window.SVGPathSegList.prototype._parsePath=function(t){if(!t||0==t.length)return[];function e(){this.pathSegList=[]}var n=this;e.prototype.appendSegment=function(t){this.pathSegList.push(t)};function i(t){this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=window.SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}i.prototype._isCurrentSpace=function(){var t=this._string[this._currentIndex];return t<=" "&&(" "==t||"\n"==t||"\t"==t||"\r"==t||"\f"==t)},i.prototype._skipOptionalSpaces=function(){for(;this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||"9"=this._endIndex||this._string.charAt(this._currentIndex)<"0"||"9"=this._endIndex)){var t=!1,e=this._string.charAt(this._currentIndex++);if("0"==e)t=!1;else{if("1"!=e)return;t=!0}return this._skipOptionalSpacesOrDelimiter(),t}},i.prototype.parseSegment=function(){var t=this._string[this._currentIndex],e=this._pathSegTypeFromChar(t);if(e==window.SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==window.SVGPathSeg.PATHSEG_UNKNOWN)return null;if((e=this._nextCommandHelper(t,this._previousCommand))==window.SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=e){case window.SVGPathSeg.PATHSEG_MOVETO_REL:return new window.SVGPathSegMovetoRel(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_MOVETO_ABS:return new window.SVGPathSegMovetoAbs(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_REL:return new window.SVGPathSegLinetoRel(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_ABS:return new window.SVGPathSegLinetoAbs(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new window.SVGPathSegLinetoHorizontalRel(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new window.SVGPathSegLinetoHorizontalAbs(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new window.SVGPathSegLinetoVerticalRel(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new window.SVGPathSegLinetoVerticalAbs(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new window.SVGPathSegClosePath(n);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicRel(n,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicAbs(n,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicSmoothRel(n,i.x,i.y,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicSmoothAbs(n,i.x,i.y,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:i={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoQuadraticRel(n,i.x,i.y,i.x1,i.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:i={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoQuadraticAbs(n,i.x,i.y,i.x1,i.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new window.SVGPathSegCurvetoQuadraticSmoothRel(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new window.SVGPathSegCurvetoQuadraticSmoothAbs(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_ARC_REL:i={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcRel(n,i.x,i.y,i.x1,i.y1,i.arcAngle,i.arcLarge,i.arcSweep);case window.SVGPathSeg.PATHSEG_ARC_ABS:i={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcAbs(n,i.x,i.y,i.x1,i.y1,i.arcAngle,i.arcLarge,i.arcSweep);default:throw"Unknown path seg type."}};var r=new e,a=new i(t);if(!a.initialCommandIsMoveTo())return[];for(;a.hasMoreData();){var o=a.parseSegment();if(!o)return[];r.appendSegment(o)}return r.pathSegList}),String.prototype.padEnd||(String.prototype.padEnd=function(t,e){return t>>=0,e=String(void 0!==e?e:" "),this.length>t?String(this):((t-=this.length)>e.length&&(e+=e.repeat(t/e.length)),String(this)+e.slice(0,t))}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),n=1;n'":;\[\]\/|~`{}\\])/g,"\\$1")},l.prototype.selectorTarget=function(t,e){return(e||"")+"."+Y.target+this.getTargetSelectorSuffix(t)},l.prototype.selectorTargets=function(t,e){var i=this;return(t=t||[]).length?t.map(function(t){return i.selectorTarget(t,e)}):null},l.prototype.selectorLegend=function(t){return"."+Y.legendItem+this.getTargetSelectorSuffix(t)},l.prototype.selectorLegends=function(t){var e=this;return t&&t.length?t.map(function(t){return e.selectorLegend(t)}):null},l.prototype.getClipPath=function(t){return"url("+(c(9)?"":document.URL.split("#")[0])+"#"+t+")"},l.prototype.appendClip=function(t,e){return t.append("clipPath").attr("id",e).append("rect")},l.prototype.getAxisClipX=function(t){var e=Math.max(30,this.margin.left);return t?-(1+e):-(e-1)},l.prototype.getAxisClipY=function(t){return t?-20:-this.margin.top},l.prototype.getXAxisClipX=function(){return this.getAxisClipX(!this.config.axis_rotated)},l.prototype.getXAxisClipY=function(){return this.getAxisClipY(!this.config.axis_rotated)},l.prototype.getYAxisClipX=function(){return this.config.axis_y_inner?-1:this.getAxisClipX(this.config.axis_rotated)},l.prototype.getYAxisClipY=function(){return this.getAxisClipY(this.config.axis_rotated)},l.prototype.getAxisClipWidth=function(t){var e=Math.max(30,this.margin.left),i=Math.max(30,this.margin.right);return t?this.width+2+e+i:this.margin.left+20},l.prototype.getAxisClipHeight=function(t){return(t?this.margin.bottom:this.margin.top+this.height)+20},l.prototype.getXAxisClipWidth=function(){return this.getAxisClipWidth(!this.config.axis_rotated)},l.prototype.getXAxisClipHeight=function(){return this.getAxisClipHeight(!this.config.axis_rotated)},l.prototype.getYAxisClipWidth=function(){return this.getAxisClipWidth(this.config.axis_rotated)+(this.config.axis_y_inner?20:0)},l.prototype.getYAxisClipHeight=function(){return this.getAxisClipHeight(this.config.axis_rotated)},l.prototype.generateColor=function(){var t=this.config,e=this.d3,n=t.data_colors,r=L(t.color_pattern)?t.color_pattern:e.schemeCategory10,a=t.data_color,o=[];return function(t){var e,i=t.id||t.data&&t.data.id||t;return n[i]instanceof Function?e=n[i](t):n[i]?e=n[i]:(o.indexOf(i)<0&&o.push(i),e=r[o.indexOf(i)%r.length],n[i]=e),a instanceof Function?a(e,t):e}},l.prototype.generateLevelColor=function(){var t=this.config,n=t.color_pattern,e=t.color_threshold,r="value"===e.unit,a=e.values&&e.values.length?e.values:[],o=e.max||100;return L(e)&&L(n)?function(t){for(var e=n[n.length-1],i=0;is&&(o=o.filter(function(t){return(""+t).indexOf(".")<0}));return o},l.prototype.getGridFilterToRemove=function(t){return t?function(e){var i=!1;return[].concat(t).forEach(function(t){("value"in t&&e.value===t.value||"class"in t&&e.class===t.class)&&(i=!0)}),i}:function(){return!0}},l.prototype.removeGridLines=function(t,e){function i(t){return!r(t)}var n=this.config,r=this.getGridFilterToRemove(t),a=e?Y.xgridLines:Y.ygridLines,o=e?Y.xgridLine:Y.ygridLine;this.main.select("."+a).selectAll("."+o).filter(r).transition().duration(n.transition_duration).style("opacity",0).remove(),e?n.grid_x_lines=n.grid_x_lines.filter(i):n.grid_y_lines=n.grid_y_lines.filter(i)},l.prototype.initEventRect=function(){var t=this,e=t.config;t.main.select("."+Y.chart).append("g").attr("class",Y.eventRects).style("fill-opacity",0),t.eventRect=t.main.select("."+Y.eventRects).append("rect").attr("class",Y.eventRect),e.zoom_enabled&&t.zoom&&(t.eventRect.call(t.zoom).on("dblclick.zoom",null),e.zoom_initialRange&&t.eventRect.transition().duration(0).call(t.zoom.transform,t.zoomTransform(e.zoom_initialRange)))},l.prototype.redrawEventRect=function(){var s=this,c=s.d3,d=s.config;function l(){s.svg.select("."+Y.eventRect).style("cursor",null),s.hideXGridFocus(),s.hideTooltip(),s.unexpandCircles(),s.unexpandBars()}function u(t,e){return e&&(s.isBarType(e.id)||s.dist(e,t)i.bar_width_max?i.bar_width_max:n},l.prototype.getBars=function(t,e){return(e?this.main.selectAll("."+Y.bars+this.getTargetSelectorSuffix(e)):this.main).selectAll("."+Y.bar+(C(t)?"-"+t:""))},l.prototype.expandBars=function(t,e,i){i&&this.unexpandBars(),this.getBars(t,e).classed(Y.EXPANDED,!0)},l.prototype.unexpandBars=function(t){this.getBars(t).classed(Y.EXPANDED,!1)},l.prototype.generateDrawBar=function(t,e){var a=this.config,o=this.generateGetBarPoints(t,e);return function(t,e){var i=o(t,e),n=a.axis_rotated?1:0,r=a.axis_rotated?0:1;return"M "+i[0][n]+","+i[0][r]+" L"+i[1][n]+","+i[1][r]+" L"+i[2][n]+","+i[2][r]+" L"+i[3][n]+","+i[3][r]+" z"}},l.prototype.generateGetBarPoints=function(t,e){var o=this,i=e?o.subXAxis:o.xAxis,n=t.__max__+1,s=o.getBarW(i,n),c=o.getShapeX(s,n,t,!!e),d=o.getShapeY(!!e),l=o.getShapeOffset(o.isBarType,t,!!e),u=s*(o.config.bar_space/2),h=e?o.getSubYScale:o.getYScale;return function(t,e){var i=h.call(o,t.id)(0),n=l(t,e)||i,r=c(t),a=d(t);return o.config.axis_rotated&&(0r.width?o=r.width-a.width:o<0&&(o=4)),o},l.prototype.getYForText=function(t,e,i){var n,r=this,a=d(i);return r.config.axis_rotated?n=(t[0][0]+t[2][0]+.6*a.height)/2:(n=t[2][1],e.value<0||0===e.value&&!r.hasPositiveValue?(n+=a.height,r.isBarType(e)&&r.isSafari()?n-=3:!r.isBarType(e)&&r.isChrome()&&(n+=3)):n+=r.isBarType(e)?-3:-6),null!==e.value||r.config.axis_rotated||(nthis.height&&(n=this.height-4)),n},l.prototype.initTitle=function(){this.title=this.svg.append("text").text(this.config.title_text).attr("class",this.CLASS.title)},l.prototype.redrawTitle=function(){var t=this;t.title.attr("x",t.xForTitle.bind(t)).attr("y",t.yForTitle.bind(t))},l.prototype.xForTitle=function(){var t=this,e=t.config,i=e.title_position||"left",n=0<=i.indexOf("right")?t.currentWidth-t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).width-e.title_padding.right:0<=i.indexOf("center")?Math.max((t.currentWidth-t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).width)/2,0):e.title_padding.left;return n},l.prototype.yForTitle=function(){var t=this;return t.config.title_padding.top+t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).height},l.prototype.getTitlePadding=function(){return this.yForTitle()+this.config.title_padding.bottom},l.prototype.drawColorScale=function(){var t,e,i,n,r,a,o=this,s=o.d3,c=o.config,d=o.data.targets[0],l=isNaN(c.stanford_scaleWidth)?20:c.stanford_scaleWidth;if(l<0)throw Error("Colorscale's barheight and barwidth must be greater than 0.");a=o.height-c.stanford_padding.bottom-c.stanford_padding.top,e=s.range(c.stanford_padding.bottom,a,5),r=s.scaleSequential(d.colors).domain([e[e.length-1],e[0]]),o.colorScale&&o.colorScale.remove(),o.colorScale=o.svg.append("g").attr("width",50).attr("height",a).attr("class",Y.colorScale),o.colorScale.append("g").attr("transform","translate(0, "+c.stanford_padding.top+")").selectAll("bars").data(e).enter().append("rect").attr("y",function(t,e){return 5*e}).attr("x",0).attr("width",l).attr("height",5).attr("fill",function(t){return r(t)}),n=s.scaleLog().domain([d.minEpochs,d.maxEpochs]).range([e[0]+c.stanford_padding.top+e[e.length-1]+5-1,e[0]+c.stanford_padding.top]),i=s.axisRight(n),"pow10"===c.stanford_scaleFormat?i.tickValues([1,10,100,1e3,1e4,1e5,1e6,1e7]):h(c.stanford_scaleFormat)?i.tickFormat(c.stanford_scaleFormat):i.tickFormat(s.format("d")),h(c.stanford_scaleValues)&&i.tickValues(c.stanford_scaleValues(d.minEpochs,d.maxEpochs)),t=o.colorScale.append("g").attr("class","legend axis").attr("transform","translate("+l+",0)").call(i),"pow10"===c.stanford_scaleFormat&&t.selectAll(".tick text").text(null).filter(x).text(10).append("tspan").attr("dy","-.7em").text(function(t){return Math.round(Math.log(t)/Math.LN10)}),o.colorScale.attr("transform","translate("+(o.currentWidth-o.xForColorScale())+", 0)")},l.prototype.xForColorScale=function(){return this.config.stanford_padding.right+d(this.colorScale.node()).width},l.prototype.getColorScalePadding=function(){return this.xForColorScale()+this.config.stanford_padding.left+20},l.prototype.isStanfordGraphType=function(){return"stanford"===this.config.data_type},l.prototype.initStanfordData=function(){var t,e,i,n=this.d3,r=this.config,a=this.data.targets[0];if(a.values.sort(v),t=a.values.map(function(t){return t.epochs}),i=isNaN(r.stanford_scaleMin)?n.min(t):r.stanford_scaleMin,(e=isNaN(r.stanford_scaleMax)?n.max(t):r.stanford_scaleMax)"+(e?_(e):"x")+""+t.x+"\n "+(i?_(i):"y")+""+t.value+"\n "},l.prototype.countEpochsInRegion=function(i){var t=this.data.targets[0],e=t.values.reduce(function(t,e){return t+Number(e.epochs)},0),n=t.values.reduce(function(t,e){return S(e,i)?t+Number(e.epochs):t},0);return{value:n,percentage:0!==n?(n/e*100).toFixed(1):0}};var y=function(t){for(var e,i,n=0,r=0,a=t.length-1;re.epochs?1:0};return l.prototype.initStanfordElements=function(){var t=this;t.stanfordElements=t.main.select("."+Y.chart).append("g").attr("class",Y.stanfordElements),t.stanfordElements.append("g").attr("class",Y.stanfordLines),t.stanfordElements.append("g").attr("class",Y.stanfordTexts),t.stanfordElements.append("g").attr("class",Y.stanfordRegions)},l.prototype.updateStanfordElements=function(t){var e,i,n,r,a=this,o=a.main,s=a.config,c=a.xvCustom.bind(a),d=a.yvCustom.bind(a),l=a.countEpochsInRegion.bind(a),u=o.select("."+Y.stanfordLines).style("shape-rendering","geometricprecision").selectAll("."+Y.stanfordLine).data(s.stanford_lines),h=u.enter().append("g").attr("class",function(t){return Y.stanfordLine+(t.class?" "+t.class:"")});h.append("line").attr("x1",function(t){return s.axis_rotated?d(t,"value_y1"):c(t,"value_x1")}).attr("x2",function(t){return s.axis_rotated?d(t,"value_y2"):c(t,"value_x2")}).attr("y1",function(t){return s.axis_rotated?c(t,"value_x1"):d(t,"value_y1")}).attr("y2",function(t){return s.axis_rotated?c(t,"value_x2"):d(t,"value_y2")}).style("opacity",0),a.stanfordLines=h.merge(u),a.stanfordLines.select("line").transition().duration(t).attr("x1",function(t){return s.axis_rotated?d(t,"value_y1"):c(t,"value_x1")}).attr("x2",function(t){return s.axis_rotated?d(t,"value_y2"):c(t,"value_x2")}).attr("y1",function(t){return s.axis_rotated?c(t,"value_x1"):d(t,"value_y1")}).attr("y2",function(t){return s.axis_rotated?c(t,"value_x2"):d(t,"value_y2")}).style("opacity",1),u.exit().transition().duration(t).style("opacity",0).remove(),(r=(n=o.select("."+Y.stanfordTexts).selectAll("."+Y.stanfordText).data(s.stanford_texts)).enter().append("g").attr("class",function(t){return Y.stanfordText+(t.class?" "+t.class:"")})).append("text").attr("x",function(t){return s.axis_rotated?d(t,"y"):c(t,"x")}).attr("y",function(t){return s.axis_rotated?c(t,"x"):d(t,"y")}).style("opacity",0),a.stanfordTexts=r.merge(n),a.stanfordTexts.select("text").transition().duration(t).attr("x",function(t){return s.axis_rotated?d(t,"y"):c(t,"x")}).attr("y",function(t){return s.axis_rotated?c(t,"x"):d(t,"y")}).text(function(t){return t.content}).style("opacity",1),n.exit().transition().duration(t).style("opacity",0).remove(),(i=(e=o.select("."+Y.stanfordRegions).selectAll("."+Y.stanfordRegion).data(s.stanford_regions)).enter().append("g").attr("class",function(t){return Y.stanfordRegion+(t.class?" "+t.class:"")})).append("polygon").attr("points",function(t){return t.points.map(function(t){return[s.axis_rotated?d(t,"y"):c(t,"x"),s.axis_rotated?c(t,"x"):d(t,"y")].join(",")}).join(" ")}).style("opacity",0),i.append("text").attr("x",function(t){return a.getCentroid(t.points).x}).attr("y",function(t){return a.getCentroid(t.points).y}).style("opacity",0),a.stanfordRegions=i.merge(e),a.stanfordRegions.select("polygon").transition().duration(t).attr("points",function(t){return t.points.map(function(t){return[s.axis_rotated?d(t,"y"):c(t,"x"),s.axis_rotated?c(t,"x"):d(t,"y")].join(",")}).join(" ")}).style("opacity",function(t){return t.opacity?t.opacity:.2}),a.stanfordRegions.select("text").transition().duration(t).attr("x",function(t){return s.axis_rotated?d(a.getCentroid(t.points),"y"):c(a.getCentroid(t.points),"x")}).attr("y",function(t){return s.axis_rotated?c(a.getCentroid(t.points),"x"):d(a.getCentroid(t.points),"y")}).text(function(t){var e,i,n;return t.text?(a.isStanfordGraphType()&&(e=(n=l(t.points)).value,i=n.percentage),t.text(e,i)):""}).attr("text-anchor","middle").attr("dominant-baseline","middle").style("opacity",1),e.exit().transition().duration(t).style("opacity",0).remove()},l.prototype.initTooltip=function(){var t,e=this,i=e.config;if(e.tooltip=e.selectChart.style("position","relative").append("div").attr("class",Y.tooltipContainer).style("position","absolute").style("pointer-events","none").style("display","none"),i.tooltip_init_show){if(e.isTimeSeries()&&g(i.tooltip_init_x)){for(i.tooltip_init_x=e.parseDate(i.tooltip_init_x),t=0;t"+o),d=l.getStanfordPointColor(t[a]),c=_(u.data_epochs),s=t[a].epochs;else if(r||(o=_(h?h(t[a].x,t[a].index):t[a].x),r=""+(o||0===o?"":"")),void 0!==(s=_(p(t[a].value,t[a].ratio,t[a].id,t[a].index,t)))){if(null===t[a].name)continue;c=_(g(t[a].name,t[a].ratio,t[a].id,t[a].index)),d=l.levelColor?l.levelColor(t[a].value):n(t[a].id)}void 0!==s&&(r+="",r+="",r+="",r+="")}return r+"
"+o+"
"+c+""+s+"
"},l.prototype.tooltipPosition=function(t,e,i,n){var r,a,o,s,c,d=this,l=d.config,u=d.d3,h=d.hasArcType(),g=u.mouse(n);return h?(a=(d.width-(d.isLegendRight?d.getLegendWidth():0))/2+g[0],s=(d.hasType("gauge")?d.height:d.height/2)+g[1]+20):(r=d.getSvgLeft(!0),s=l.axis_rotated?(o=(a=r+g[0]+100)+e,c=d.currentWidth-d.getCurrentPaddingRight(),d.x(t[0].x)+20):(o=(a=r+d.getCurrentPaddingLeft(!0)+d.x(t[0].x)+20)+e,c=r+d.currentWidth-d.getCurrentPaddingRight(),g[1]+15),cd.currentHeight&&(s-=i+30)),s<0&&(s=0),{top:s,left:a}},l.prototype.showTooltip=function(t,e){var i,n,r,a=this,o=a.config,s=a.hasArcType(),c=t.filter(function(t){return t&&C(t.value)}),d=o.tooltip_position||l.prototype.tooltipPosition;0!==c.length&&o.tooltip_show?(a.tooltip.html(o.tooltip_contents.call(a,t,a.axis.getXAxisTickFormat(),a.getYFormat(s),a.color)).style("display","block"),i=a.tooltip.property("offsetWidth"),n=a.tooltip.property("offsetHeight"),r=d.call(this,c,i,n,e),a.tooltip.style("top",r.top+"px").style("left",r.left+"px")):a.hideTooltip()},l.prototype.hideTooltip=function(){this.tooltip.style("display","none")},l.prototype.setTargetType=function(t,e){var i=this,n=i.config;i.mapToTargetIds(t).forEach(function(t){i.withoutFadeIn[t]=e===n.data_types[t],n.data_types[t]=e}),t||(n.data_type=e)},l.prototype.hasType=function(i,t){var n=this.config.data_types,r=!1;return(t=t||this.data.targets)&&t.length?t.forEach(function(t){var e=n[t.id];(e&&0<=e.indexOf(i)||!e&&"line"===i)&&(r=!0)}):Object.keys(n).length?Object.keys(n).forEach(function(t){n[t]===i&&(r=!0)}):r=this.config.data_type===i,r},l.prototype.hasArcType=function(t){return this.hasType("pie",t)||this.hasType("donut",t)||this.hasType("gauge",t)},l.prototype.isLineType=function(t){var e=this.config,i=g(t)?t:t.id;return!e.data_types[i]||0<=["line","spline","area","area-spline","step","area-step"].indexOf(e.data_types[i])},l.prototype.isStepType=function(t){var e=g(t)?t:t.id;return 0<=["step","area-step"].indexOf(this.config.data_types[e])},l.prototype.isSplineType=function(t){var e=g(t)?t:t.id;return 0<=["spline","area-spline"].indexOf(this.config.data_types[e])},l.prototype.isAreaType=function(t){var e=g(t)?t:t.id;return 0<=["area","area-spline","area-step"].indexOf(this.config.data_types[e])},l.prototype.isBarType=function(t){var e=g(t)?t:t.id;return"bar"===this.config.data_types[e]},l.prototype.isScatterType=function(t){var e=g(t)?t:t.id;return"scatter"===this.config.data_types[e]},l.prototype.isStanfordType=function(t){var e=g(t)?t:t.id;return"stanford"===this.config.data_types[e]},l.prototype.isPieType=function(t){var e=g(t)?t:t.id;return"pie"===this.config.data_types[e]},l.prototype.isGaugeType=function(t){var e=g(t)?t:t.id;return"gauge"===this.config.data_types[e]},l.prototype.isDonutType=function(t){var e=g(t)?t:t.id;return"donut"===this.config.data_types[e]},l.prototype.isArcType=function(t){return this.isPieType(t)||this.isDonutType(t)||this.isGaugeType(t)},l.prototype.lineData=function(t){return this.isLineType(t)?[t]:[]},l.prototype.arcData=function(t){return this.isArcType(t.data)?[t]:[]},l.prototype.barData=function(t){return this.isBarType(t)?t.values:[]},l.prototype.lineOrScatterOrStanfordData=function(t){return this.isLineType(t)||this.isScatterType(t)||this.isStanfordType(t)?t.values:[]},l.prototype.barOrLineData=function(t){return this.isBarType(t)||this.isLineType(t)?t.values:[]},l.prototype.isSafari=function(){var t=window.navigator.userAgent;return 0<=t.indexOf("Safari")&&t.indexOf("Chrome")<0},l.prototype.isChrome=function(){return 0<=window.navigator.userAgent.indexOf("Chrome")},l.prototype.initZoom=function(){var e,i=this,n=i.d3,r=i.config;return i.zoom=n.zoom().on("start",function(){var t;"scroll"===r.zoom_type&&((t=n.event.sourceEvent)&&"brush"===t.type||(e=t,r.zoom_onzoomstart.call(i.api,t)))}).on("zoom",function(){var t;"scroll"===r.zoom_type&&((t=n.event.sourceEvent)&&"brush"===t.type||(i.redrawForZoom(),r.zoom_onzoom.call(i.api,i.x.orgDomain())))}).on("end",function(){var t;"scroll"===r.zoom_type&&((t=n.event.sourceEvent)&&"brush"===t.type||t&&e.clientX===t.clientX&&e.clientY===t.clientY||r.zoom_onzoomend.call(i.api,i.x.orgDomain()))}),i.zoom.updateDomain=function(){return n.event&&n.event.transform&&(r.axis_rotated&&"scroll"===r.zoom_type&&"mousemove"===n.event.sourceEvent.type?i.x.domain(n.event.transform.rescaleY(i.subX).domain()):i.x.domain(n.event.transform.rescaleX(i.subX).domain())),this},i.zoom.updateExtent=function(){return this.scaleExtent([1,1/0]).translateExtent([[0,0],[i.width,i.height]]).extent([[0,0],[i.width,i.height]]),this},i.zoom.update=function(){return this.updateExtent().updateDomain()},i.zoom.updateExtent()},l.prototype.zoomTransform=function(t){var e=[this.x(t[0]),this.x(t[1])];return this.d3.zoomIdentity.scale(this.width/(e[1]-e[0])).translate(-e[0],0)},l.prototype.initDragZoom=function(){var e,t,i=this,n=i.d3,r=i.config,a=i.context=i.svg,o=i.margin.left+20.5,s=i.margin.top+.5;"drag"===r.zoom_type&&r.zoom_enabled&&(e=function(t){return t&&t.map(function(t){return i.x.invert(t)})},t=i.dragZoomBrush=n.brushX().on("start",function(){i.api.unzoom(),i.svg.select("."+Y.dragZoom).classed("disabled",!1),r.zoom_onzoomstart.call(i.api,n.event.sourceEvent)}).on("brush",function(){r.zoom_onzoom.call(i.api,e(n.event.selection))}).on("end",function(){var t;null!=n.event.selection&&(t=e(n.event.selection),r.zoom_disableDefaultBehavior||i.api.zoom(t),i.svg.select("."+Y.dragZoom).classed("disabled",!0),r.zoom_onzoomend.call(i.api,t))}),a.append("g").classed(Y.dragZoom,!0).attr("clip-path",i.clipPath).attr("transform","translate("+o+","+s+")").call(t))},l.prototype.getZoomDomain=function(){var t=this.config,e=this.d3;return[e.min([this.orgXDomain[0],t.zoom_x_min]),e.max([this.orgXDomain[1],t.zoom_x_max])]},l.prototype.redrawForZoom=function(){var t=this,e=t.d3,i=t.config,n=t.zoom,r=t.x;i.zoom_enabled&&0!==t.filterTargetsToShow(t.data.targets).length&&(n.update(),i.zoom_disableDefaultBehavior||(t.isCategorized()&&r.orgDomain()[0]===t.orgXDomain[0]&&r.domain([t.orgXDomain[0]-1e-10,r.orgDomain()[1]]),t.redraw({withTransition:!1,withY:i.zoom_rescale,withSubchart:!1,withEventRect:!1,withDimension:!1}),e.event.sourceEvent&&"mousemove"===e.event.sourceEvent.type&&(t.cancelClick=!0)))},i}); \ No newline at end of file diff --git a/server/static/server/c3/codecov.yml b/server/static/server/c3/codecov.yml new file mode 100644 index 0000000..10bd368 --- /dev/null +++ b/server/static/server/c3/codecov.yml @@ -0,0 +1,2 @@ +coverage: + status: no diff --git a/server/static/server/c3/component.json b/server/static/server/c3/component.json new file mode 100644 index 0000000..60aae7d --- /dev/null +++ b/server/static/server/c3/component.json @@ -0,0 +1,15 @@ +{ + "name": "c3", + "repo": "masayuki0812/c3", + "description": "A D3-based reusable chart library", + "version": "0.7.20", + "keywords": [], + "dependencies": { + "mbostock/d3": "v5.0.0" + }, + "development": {}, + "license": "MIT", + "main": "c3.js", + "scripts": ["c3.js"], + "styles": ["c3.css"] +} diff --git a/server/static/server/c3/config.rb b/server/static/server/c3/config.rb new file mode 100644 index 0000000..dfc8fa9 --- /dev/null +++ b/server/static/server/c3/config.rb @@ -0,0 +1,33 @@ +helpers do + def js_as_plain(id) + f = open("docs/js/samples/" + id + ".js") + js = f.read + f.close + js + end + def data_as_plain(name) + f = open("docs/data/" + name) + data = f.read + f.close + data + end + def css_as_plain(name) + f = open("docs/css/samples/" + name) + css = f.read + f.close + css + end + def get_css_name(path) + path.gsub('.html', '') + end +end + +set :source, 'docs' +set :haml, { :ugly => true, :format => :html5 } +set :css_dir, 'css' +set :js_dir, 'js' +set :images_dir, 'img' + +configure :build do + activate :asset_hash, :ignore => %r{^js/ace/.*} +end diff --git a/server/static/server/c3/data/samples.yml b/server/static/server/c3/data/samples.yml new file mode 100644 index 0000000..cf36c5c --- /dev/null +++ b/server/static/server/c3/data/samples.yml @@ -0,0 +1,327 @@ +simple_multiple: + title: 'Line Chart' + desc: 'Line chart with sequential data.' + +timeseries: + title: Timeseries Chart + desc: Simple line chart with timeseries data. + +chart_spline: + title: Spline Chart + desc: Display as Spline Chart. + +simple_xy: + title: Simple XY Line Chart + desc: Simple line chart with custom x. + +simple_xy_multiple: + title: Multiple XY Line Chart + desc: Multiple line chart with multiple custom x. + +simple_regions: + title: Line Chart with Regions + desc: Set regions for each data with style. + +chart_bar: + title: Bar Chart + desc: Display as Bar Chart. + +chart_bar_stacked: + title: Stacked Bar Chart + desc: Display as Stacked Bar Chart. + +chart_scatter: + title: Scatter Plot + desc: Display as Scatter Plot. + +chart_pie: + title: Pie Chart + desc: Display as Pie Chart. + +chart_donut: + title: Donut Chart + desc: Display as Donut Chart. + +chart_gauge: + title: Gauge Chart + desc: Display as Gauge Chart. + +chart_step: + title: Step Chart + desc: Display as Step Chart. + +chart_area: + title: Area Chart + desc: Display as Area Chart. + +chart_area_stacked: + title: Stacked Area Chart + desc: Display as Stacked Area Chart. + +chart_stanford: + title: Stanford Chart + desc: Display as Stanford Chart. + +chart_combination: + title: Combination Chart + desc: Display all kinda charts up in here. + +categorized: + title: Category Axis + desc: Show ticks as categorized by each data. + +axes_y2: + title: Additional Y Axis + desc: Additional y axis can be added. + +axes_rotated: + title: Rotated Axis + desc: Switch x and y axis position. + +axes_x_localtime: + title: X Axis Timezone + desc: Convert time to UTC. + +axes_x_tick_rotate: + title: Rotate X Axis Tick Text + desc: Rotate x axis tick text. + +axes_x_tick_format: + title: X Axis Tick Format + desc: Format x axis tick text. + +axes_y_tick_format: + title: Y Axis Tick Format + desc: Format y axis tick text. + +axes_x_tick_culling: + title: X Axis Tick Culling + desc: Set cull ticks or not on X Axis. + +axes_x_tick_values: + title: X Axis Tick Values + desc: Set tick texts on X Axis. + +axes_x_tick_count: + title: X Axis Tick Count + desc: Set the number of ticks on X Axis. + +axes_x_tick_fit: + title: X Axis Tick Fitting + desc: Set ticks position to x of data. + +axes_label: + title: Axis Label + desc: Set label for axis. + +axes_label_position: + title: Axis Label Position + desc: Set axis label position. + +axes_y_padding: + title: Padding for Y Axis + desc: Set padding for y axis. + +axes_y_range: + title: Range for Y Axis + desc: Set range for y axis. + +data_columned: + title: Column Oriented Data + desc: Column-oriented data can be used as input. + +data_rowed: + title: Row Oriented Data + desc: Row-oriented data can be used as input. + +data_json: + title: JSON Data + desc: JSON can be used as input. + +data_url: + title: Data from URL + desc: Data from URL can be used as input. + +data_load: + title: Load Data + desc: Load data dynamically. + +data_name: + title: Data Name + desc: Set name for each data. + +data_stringx: + title: Category Data + desc: Load data with x values on category axis. + +data_order: + title: Data Order + desc: Define data order. This will be used for stacked bar chart. + +data_label: + title: Data Label + desc: Show label of data. + +data_label_format: + title: Data Label Format + desc: Format label of data. + +data_number_format_l10n: + title: Number Format Localization + desc: Number format localization using D3 locale settings. + +data_color: + title: Data Color + desc: Set color according to data. + +options_legend: + title: Hide Legend + desc: Set visibility of legend. + +legend_position: + title: Legend Position + desc: Show legend on bottom or right side. + +legend_custom: + title: Custom Legend + desc: Build custom legend + +tooltip_show: + title: Hide Tooltip + desc: Set visibility of tooltip. + +tooltip_grouped: + title: Tooltip Grouping + desc: Show tooltips as grouped or not. + +tooltip_format: + title: Tooltip Format + desc: Set format for title and value on tooltip. + +tooltip_horizontal: + title: Horizontal Tooltip + desc: Show tooltips based on the horizontal position of the mouse. + +options_gridline: + title: Grid Lines + desc: Show grid lines for x and y axis. + +grid_x_lines: + title: Optional X Grid Lines + desc: Add optional grid lines on x grid. + +grid_y_lines: + title: Optional Y Grid Lines + desc: Add optional grid lines on y grid. + +options_subchart: + title: Sub Chart + desc: Show sub chart for zoom and selection range. + +interaction_zoom: + title: Zoom + desc: Zoom by mouse wheel event and slide by drag. + +interaction_zoom_by_drag: + title: Zoom by Drag + desc: Zoom by dragging area. + +region: + title: Region + desc: Show rects on chart. + +region_timeseries: + title: Region with Timeseries + desc: Show rects on timeseries chart. + +options_size: + title: Chart Size + desc: Set chart size in px. + +options_color: + title: Color Pattern + desc: Set custom color pattern. + +options_padding: + title: Padding + desc: Change padding for the chart. + +point_show: + title: Hide points + desc: Hide points on line chart + +pie_label_format: + title: Pie Label Format + desc: Change label format on Pie chart + +transition_duration: + title: Duration of Transition + desc: Set duration of transition for chart animation. + +api_flow: + title: Flow + desc: Load/Unload data as flowing + +api_resize: + title: Resize + desc: Resize chart. + +api_data_name: + title: Data Name + desc: Update data names. + +api_data_color: + title: Data Color + desc: Update data colors. + +api_axis_label: + title: Axis Label + desc: Update axis labels. + +api_axis_range: + title: Axis Range + desc: Update axis range. + +api_grid_x: + title: X Grid + desc: Update custom x grids. + +transform_line: + title: To Line Chart + desc: Transform to line chart. + +transform_spline: + title: To Spline Chart + desc: Transform to spline chart. + +transform_bar: + title: To Bar Chart + desc: Transform to bar chart. + +transform_area: + title: To Area Chart + desc: Transform to area chart. + +transform_areaspline: + title: To Area Spline Chart + desc: Transform to area spline chart. + +transform_scatter: + title: To Scatter Plot + desc: Transform to scatter plot. + +transform_pie: + title: To Pie Chart + desc: Transform to pie chart. + +transform_donut: + title: To Donut Chart + desc: Transform to donut chart. + +style_region: + title: Style for Region + desc: Set style for regions. + +style_grid: + title: Style for Grid + desc: Set style for grids. diff --git a/server/static/server/c3/design/c3-logo.sketch b/server/static/server/c3/design/c3-logo.sketch new file mode 100644 index 0000000..20ccc85 Binary files /dev/null and b/server/static/server/c3/design/c3-logo.sketch differ diff --git a/server/static/server/c3/docs/404.html b/server/static/server/c3/docs/404.html new file mode 100644 index 0000000..0446544 --- /dev/null +++ b/server/static/server/c3/docs/404.html @@ -0,0 +1,157 @@ + + + + + Page Not Found :( + + + +
+

Not found :(

+

Sorry, but the page you were trying to view does not exist.

+

It looks like this was the result of either:

+
    +
  • a mistyped address
  • +
  • an out-of-date link
  • +
+ + +
+ + diff --git a/server/static/server/c3/docs/CNAME b/server/static/server/c3/docs/CNAME new file mode 100644 index 0000000..de6075d --- /dev/null +++ b/server/static/server/c3/docs/CNAME @@ -0,0 +1 @@ +c3js.org diff --git a/server/static/server/c3/docs/_footer.haml b/server/static/server/c3/docs/_footer.haml new file mode 100644 index 0000000..eba107a --- /dev/null +++ b/server/static/server/c3/docs/_footer.haml @@ -0,0 +1,3 @@ +%footer + %hr + %p © Masayuki Tanaka 2014 diff --git a/server/static/server/c3/docs/_index_item.haml b/server/static/server/c3/docs/_index_item.haml new file mode 100644 index 0000000..90c9a7b --- /dev/null +++ b/server/static/server/c3/docs/_index_item.haml @@ -0,0 +1,4 @@ +.large-4.columns + %h3 #{data.samples[id].title} + %p.margin-small-bottom #{data.samples[id].desc} + %a.btn.btn-default( href="/samples/#{id}.html" role="button" ) View details » diff --git a/server/static/server/c3/docs/_index_item_title.haml b/server/static/server/c3/docs/_index_item_title.haml new file mode 100644 index 0000000..3b34123 --- /dev/null +++ b/server/static/server/c3/docs/_index_item_title.haml @@ -0,0 +1,4 @@ +%a( href="/examples.html##{id}" name="#{id}" ) + %h2< + \# + %span #{name} diff --git a/server/static/server/c3/docs/_reference_item_link.haml b/server/static/server/c3/docs/_reference_item_link.haml new file mode 100644 index 0000000..9862672 --- /dev/null +++ b/server/static/server/c3/docs/_reference_item_link.haml @@ -0,0 +1,3 @@ +%a( href="##{ id.gsub(/\./, '-') }")< #{ id.gsub(/(api|class)\./, '') } +- if defined? experimental + Experimental diff --git a/server/static/server/c3/docs/_reference_menu_item.haml b/server/static/server/c3/docs/_reference_menu_item.haml new file mode 100644 index 0000000..2dff391 --- /dev/null +++ b/server/static/server/c3/docs/_reference_menu_item.haml @@ -0,0 +1,5 @@ +%li + - if defined? experimental + = partial :reference_item_link, locals: { id: id, experimental: experimental } + - else + = partial :reference_item_link, locals: { id: id } \ No newline at end of file diff --git a/server/static/server/c3/docs/_sample.haml b/server/static/server/c3/docs/_sample.haml new file mode 100644 index 0000000..9a87069 --- /dev/null +++ b/server/static/server/c3/docs/_sample.haml @@ -0,0 +1,34 @@ +.container + + %h1.title #{data.samples[id].title} + + .chart + #chart + + #ace-error + + .sourcecode.margin-medium-v.margin-small-h + %h3 # #{id}.js + #javascript-editor.c3-editor + = js_as_plain id + + - if defined? other_css + .sourcecode + %h3 # #{other_css} + %pre + %code.css + = css_as_plain other_css + + - if defined? other_files + - other_files.each do |f| + .sourcecode + %h3 # #{f} + %pre + %code.html + = data_as_plain f + + = partial :footer + += partial :script += partial :sample_editor, locals: { type: 'javascript' } += javascript_include_tag "samples/#{id}.js" diff --git a/server/static/server/c3/docs/_sample_editor.haml b/server/static/server/c3/docs/_sample_editor.haml new file mode 100644 index 0000000..9821581 --- /dev/null +++ b/server/static/server/c3/docs/_sample_editor.haml @@ -0,0 +1,36 @@ += javascript_include_tag "ace/ace.js" += javascript_include_tag "ace/mode-javascript.js" += javascript_include_tag "ace/theme-tomorrow.js" +:javascript + var editor = ace.edit('#{type}-editor'), + error = document.getElementById('ace-error'); + + function debounce(func, wait) { + var timeout; + return function() { + var context = this, args = arguments; + var later = function() { + func.apply(context, args); + }; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + }; + }; + + editor.on('change', debounce(function(e) { + try { + eval(editor.getValue()); + error.innerHTML = ''; + } + catch(e) { + error.innerHTML = e; + } + }, 300)); + + editor.setOption("maxLines", 100); + editor.setOption("showLineNumbers", false); + editor.setOption("showGutter", false); + + editor.setTheme("ace/theme/tomorrow"); + editor.getSession().setMode("ace/mode/#{type}"); + editor.commands.removeCommand('gotoline') // Disables the override of Command-L diff --git a/server/static/server/c3/docs/_samples_header.haml b/server/static/server/c3/docs/_samples_header.haml new file mode 100644 index 0000000..12d6299 --- /dev/null +++ b/server/static/server/c3/docs/_samples_header.haml @@ -0,0 +1,17 @@ +.nav + %a( href="/") Home + +.page-header.title + %h1 #{data.samples[id].title} + +.chart + #chart + +.sourcecode + %h3 # #{id}.js + %pre + %code.html.javascript + = js_as_plain id + += partial :script += javascript_include_tag "samples/#{id}.js" diff --git a/server/static/server/c3/docs/_script.haml b/server/static/server/c3/docs/_script.haml new file mode 100644 index 0000000..ab53908 --- /dev/null +++ b/server/static/server/c3/docs/_script.haml @@ -0,0 +1,8 @@ += javascript_include_tag 'jquery-1.11.0.min.js' += javascript_include_tag 'foundation.min.js' += javascript_include_tag 'highlight.pack.js' += javascript_include_tag 'd3-5.8.2.min.js' += javascript_include_tag 'c3.min.js' +:javascript + hljs.initHighlightingOnLoad(); + $(document).foundation(); diff --git a/server/static/server/c3/docs/_script_scroll.haml b/server/static/server/c3/docs/_script_scroll.haml new file mode 100644 index 0000000..fb94fe8 --- /dev/null +++ b/server/static/server/c3/docs/_script_scroll.haml @@ -0,0 +1,22 @@ +:javascript + $(function(){ + function scrollToHash() { + var hash = document.location.hash, + target = $('.column-content h3 a[href^=' + hash + ']'), + position; + if (target.length) { + position = target.offset().top - 60; + $("html, body").animate({scrollTop:position}, 250, "swing"); + } + } + $(window).on('hashchange', scrollToHash); + + // When clicked + $('a[href^=#]').click(function(){ + document.location.hash = $(this).attr("href"); + return false; + }); + + // When loaded + $(window).trigger('hashchange'); + }); diff --git a/server/static/server/c3/docs/_sidemenu_item.haml b/server/static/server/c3/docs/_sidemenu_item.haml new file mode 100644 index 0000000..4fa95e0 --- /dev/null +++ b/server/static/server/c3/docs/_sidemenu_item.haml @@ -0,0 +1,2 @@ +%li + %a( href="##{ id }") #{ name } \ No newline at end of file diff --git a/server/static/server/c3/docs/apple-touch-icon-114x114-precomposed.png b/server/static/server/c3/docs/apple-touch-icon-114x114-precomposed.png new file mode 100644 index 0000000..11477d5 Binary files /dev/null and b/server/static/server/c3/docs/apple-touch-icon-114x114-precomposed.png differ diff --git a/server/static/server/c3/docs/apple-touch-icon-144x144-precomposed.png b/server/static/server/c3/docs/apple-touch-icon-144x144-precomposed.png new file mode 100644 index 0000000..33051de Binary files /dev/null and b/server/static/server/c3/docs/apple-touch-icon-144x144-precomposed.png differ diff --git a/server/static/server/c3/docs/apple-touch-icon-57x57-precomposed.png b/server/static/server/c3/docs/apple-touch-icon-57x57-precomposed.png new file mode 100644 index 0000000..214e445 Binary files /dev/null and b/server/static/server/c3/docs/apple-touch-icon-57x57-precomposed.png differ diff --git a/server/static/server/c3/docs/apple-touch-icon-72x72-precomposed.png b/server/static/server/c3/docs/apple-touch-icon-72x72-precomposed.png new file mode 100644 index 0000000..f72c966 Binary files /dev/null and b/server/static/server/c3/docs/apple-touch-icon-72x72-precomposed.png differ diff --git a/server/static/server/c3/docs/apple-touch-icon-precomposed.png b/server/static/server/c3/docs/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..214e445 Binary files /dev/null and b/server/static/server/c3/docs/apple-touch-icon-precomposed.png differ diff --git a/server/static/server/c3/docs/apple-touch-icon.png b/server/static/server/c3/docs/apple-touch-icon.png new file mode 100644 index 0000000..214e445 Binary files /dev/null and b/server/static/server/c3/docs/apple-touch-icon.png differ diff --git a/server/static/server/c3/docs/crossdomain.xml b/server/static/server/c3/docs/crossdomain.xml new file mode 100644 index 0000000..29a035d --- /dev/null +++ b/server/static/server/c3/docs/crossdomain.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/server/static/server/c3/docs/css/bootstrap.min.css b/server/static/server/c3/docs/css/bootstrap.min.css new file mode 100644 index 0000000..4cc4e7a --- /dev/null +++ b/server/static/server/c3/docs/css/bootstrap.min.css @@ -0,0 +1,8 @@ +/*! + * Bootstrap v3.0.0 by @fat and @mdo + * Copyright 2013 Twitter, Inc. + * Licensed under http://www.apache.org/licenses/LICENSE-2.0 + * + * Designed and built with all the love in the world by @mdo and @fat. + */ +/*! normalize.css v2.1.3 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block}audio:not([controls]){display:none;height:0}[hidden],template{display:none}html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a{background:transparent}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{margin:.67em 0;font-size:2em}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}hr{height:0;-moz-box-sizing:content-box;box-sizing:content-box}mark{color:#000;background:#ff0}code,kbd,pre,samp{font-family:monospace,serif;font-size:1em}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:0}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid #c0c0c0}legend{padding:0;border:0}button,input,select,textarea{margin:0;font-family:inherit;font-size:100%}button,input{line-height:normal}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}button[disabled],html input[disabled]{cursor:default}input[type="checkbox"],input[type="radio"]{padding:0;box-sizing:border-box}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}@media print{*{color:#000!important;text-shadow:none!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:2cm .5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}.navbar{display:none}.table td,.table th{background-color:#fff!important}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table-bordered th,.table-bordered td{border:1px solid #ddd!important}}*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:62.5%;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.428571429;color:#333;background-color:#fff}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#428bca;text-decoration:none}a:hover,a:focus{color:#2a6496;text-decoration:underline}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}img{vertical-align:middle}.img-responsive{display:block;height:auto;max-width:100%}.img-rounded{border-radius:6px}.img-thumbnail{display:inline-block;height:auto;max-width:100%;padding:4px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16px;font-weight:200;line-height:1.4}@media(min-width:768px){.lead{font-size:21px}}small,.small{font-size:85%}cite{font-style:normal}.text-muted{color:#999}.text-primary{color:#428bca}.text-primary:hover{color:#3071a9}.text-warning{color:#c09853}.text-warning:hover{color:#a47e3c}.text-danger{color:#b94a48}.text-danger:hover{color:#953b39}.text-success{color:#468847}.text-success:hover{color:#356635}.text-info{color:#3a87ad}.text-info:hover{color:#2d6987}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-weight:500;line-height:1.1;color:inherit}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small,.h1 small,.h2 small,.h3 small,.h4 small,.h5 small,.h6 small,h1 .small,h2 .small,h3 .small,h4 .small,h5 .small,h6 .small,.h1 .small,.h2 .small,.h3 .small,.h4 .small,.h5 .small,.h6 .small{font-weight:normal;line-height:1;color:#999}h1,h2,h3{margin-top:20px;margin-bottom:10px}h1 small,h2 small,h3 small,h1 .small,h2 .small,h3 .small{font-size:65%}h4,h5,h6{margin-top:10px;margin-bottom:10px}h4 small,h5 small,h6 small,h4 .small,h5 .small,h6 .small{font-size:75%}h1,.h1{font-size:36px}h2,.h2{font-size:30px}h3,.h3{font-size:24px}h4,.h4{font-size:18px}h5,.h5{font-size:14px}h6,.h6{font-size:12px}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ul,ol{margin-top:0;margin-bottom:10px}ul ul,ol ul,ul ol,ol ol{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none}.list-inline>li{display:inline-block;padding-right:5px;padding-left:5px}dl{margin-bottom:20px}dt,dd{line-height:1.428571429}dt{font-weight:bold}dd{margin-left:0}@media(min-width:768px){.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}.dl-horizontal dd:before,.dl-horizontal dd:after{display:table;content:" "}.dl-horizontal dd:after{clear:both}}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #999}abbr.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;border-left:5px solid #eee}blockquote p{font-size:17.5px;font-weight:300;line-height:1.25}blockquote p:last-child{margin-bottom:0}blockquote small{display:block;line-height:1.428571429;color:#999}blockquote small:before{content:'\2014 \00A0'}blockquote.pull-right{padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small,blockquote.pull-right .small{text-align:right}blockquote.pull-right small:before,blockquote.pull-right .small:before{content:''}blockquote.pull-right small:after,blockquote.pull-right .small:after{content:'\00A0 \2014'}blockquote:before,blockquote:after{content:""}address{margin-bottom:20px;font-style:normal;line-height:1.428571429}code,kbd,pre,samp{font-family:Monaco,Menlo,Consolas,"Courier New",monospace}code{padding:2px 4px;font-size:90%;color:#c7254e;white-space:nowrap;background-color:#f9f2f4;border-radius:4px}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:1.428571429;color:#333;word-break:break-all;word-wrap:break-word;background-color:#f5f5f5;border:1px solid #ccc;border-radius:4px}pre code{padding:0;font-size:inherit;color:inherit;white-space:pre-wrap;background-color:transparent;border-radius:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}.container:before,.container:after{display:table;content:" "}.container:after{clear:both}.row{margin-right:-15px;margin-left:-15px}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.row:before,.row:after{display:table;content:" "}.row:after{clear:both}.col-xs-1,.col-sm-1,.col-md-1,.col-lg-1,.col-xs-2,.col-sm-2,.col-md-2,.col-lg-2,.col-xs-3,.col-sm-3,.col-md-3,.col-lg-3,.col-xs-4,.col-sm-4,.col-md-4,.col-lg-4,.col-xs-5,.col-sm-5,.col-md-5,.col-lg-5,.col-xs-6,.col-sm-6,.col-md-6,.col-lg-6,.col-xs-7,.col-sm-7,.col-md-7,.col-lg-7,.col-xs-8,.col-sm-8,.col-md-8,.col-lg-8,.col-xs-9,.col-sm-9,.col-md-9,.col-lg-9,.col-xs-10,.col-sm-10,.col-md-10,.col-lg-10,.col-xs-11,.col-sm-11,.col-md-11,.col-lg-11,.col-xs-12,.col-sm-12,.col-md-12,.col-lg-12{position:relative;min-height:1px;padding-right:15px;padding-left:15px}.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666666666666%}.col-xs-10{width:83.33333333333334%}.col-xs-9{width:75%}.col-xs-8{width:66.66666666666666%}.col-xs-7{width:58.333333333333336%}.col-xs-6{width:50%}.col-xs-5{width:41.66666666666667%}.col-xs-4{width:33.33333333333333%}.col-xs-3{width:25%}.col-xs-2{width:16.666666666666664%}.col-xs-1{width:8.333333333333332%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666666666666%}.col-xs-pull-10{right:83.33333333333334%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666666666666%}.col-xs-pull-7{right:58.333333333333336%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666666666667%}.col-xs-pull-4{right:33.33333333333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.666666666666664%}.col-xs-pull-1{right:8.333333333333332%}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666666666666%}.col-xs-push-10{left:83.33333333333334%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666666666666%}.col-xs-push-7{left:58.333333333333336%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666666666667%}.col-xs-push-4{left:33.33333333333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.666666666666664%}.col-xs-push-1{left:8.333333333333332%}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666666666666%}.col-xs-offset-10{margin-left:83.33333333333334%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666666666666%}.col-xs-offset-7{margin-left:58.333333333333336%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666666666667%}.col-xs-offset-4{margin-left:33.33333333333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.666666666666664%}.col-xs-offset-1{margin-left:8.333333333333332%}@media(min-width:768px){.container{width:750px}.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666666666666%}.col-sm-10{width:83.33333333333334%}.col-sm-9{width:75%}.col-sm-8{width:66.66666666666666%}.col-sm-7{width:58.333333333333336%}.col-sm-6{width:50%}.col-sm-5{width:41.66666666666667%}.col-sm-4{width:33.33333333333333%}.col-sm-3{width:25%}.col-sm-2{width:16.666666666666664%}.col-sm-1{width:8.333333333333332%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666666666666%}.col-sm-pull-10{right:83.33333333333334%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666666666666%}.col-sm-pull-7{right:58.333333333333336%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666666666667%}.col-sm-pull-4{right:33.33333333333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.666666666666664%}.col-sm-pull-1{right:8.333333333333332%}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666666666666%}.col-sm-push-10{left:83.33333333333334%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666666666666%}.col-sm-push-7{left:58.333333333333336%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666666666667%}.col-sm-push-4{left:33.33333333333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.666666666666664%}.col-sm-push-1{left:8.333333333333332%}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666666666666%}.col-sm-offset-10{margin-left:83.33333333333334%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666666666666%}.col-sm-offset-7{margin-left:58.333333333333336%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666666666667%}.col-sm-offset-4{margin-left:33.33333333333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.666666666666664%}.col-sm-offset-1{margin-left:8.333333333333332%}}@media(min-width:992px){.container{width:970px}.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666666666666%}.col-md-10{width:83.33333333333334%}.col-md-9{width:75%}.col-md-8{width:66.66666666666666%}.col-md-7{width:58.333333333333336%}.col-md-6{width:50%}.col-md-5{width:41.66666666666667%}.col-md-4{width:33.33333333333333%}.col-md-3{width:25%}.col-md-2{width:16.666666666666664%}.col-md-1{width:8.333333333333332%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666666666666%}.col-md-pull-10{right:83.33333333333334%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666666666666%}.col-md-pull-7{right:58.333333333333336%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666666666667%}.col-md-pull-4{right:33.33333333333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.666666666666664%}.col-md-pull-1{right:8.333333333333332%}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666666666666%}.col-md-push-10{left:83.33333333333334%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666666666666%}.col-md-push-7{left:58.333333333333336%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666666666667%}.col-md-push-4{left:33.33333333333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.666666666666664%}.col-md-push-1{left:8.333333333333332%}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666666666666%}.col-md-offset-10{margin-left:83.33333333333334%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666666666666%}.col-md-offset-7{margin-left:58.333333333333336%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666666666667%}.col-md-offset-4{margin-left:33.33333333333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.666666666666664%}.col-md-offset-1{margin-left:8.333333333333332%}}@media(min-width:1200px){.container{width:1170px}.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666666666666%}.col-lg-10{width:83.33333333333334%}.col-lg-9{width:75%}.col-lg-8{width:66.66666666666666%}.col-lg-7{width:58.333333333333336%}.col-lg-6{width:50%}.col-lg-5{width:41.66666666666667%}.col-lg-4{width:33.33333333333333%}.col-lg-3{width:25%}.col-lg-2{width:16.666666666666664%}.col-lg-1{width:8.333333333333332%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666666666666%}.col-lg-pull-10{right:83.33333333333334%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666666666666%}.col-lg-pull-7{right:58.333333333333336%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666666666667%}.col-lg-pull-4{right:33.33333333333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.666666666666664%}.col-lg-pull-1{right:8.333333333333332%}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666666666666%}.col-lg-push-10{left:83.33333333333334%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666666666666%}.col-lg-push-7{left:58.333333333333336%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666666666667%}.col-lg-push-4{left:33.33333333333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.666666666666664%}.col-lg-push-1{left:8.333333333333332%}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666666666666%}.col-lg-offset-10{margin-left:83.33333333333334%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666666666666%}.col-lg-offset-7{margin-left:58.333333333333336%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666666666667%}.col-lg-offset-4{margin-left:33.33333333333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.666666666666664%}.col-lg-offset-1{margin-left:8.333333333333332%}}table{max-width:100%;background-color:transparent}th{text-align:left}.table{width:100%;margin-bottom:20px}.table>thead>tr>th,.table>tbody>tr>th,.table>tfoot>tr>th,.table>thead>tr>td,.table>tbody>tr>td,.table>tfoot>tr>td{padding:8px;line-height:1.428571429;vertical-align:top;border-top:1px solid #ddd}.table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd}.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>th,.table>caption+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>td,.table>thead:first-child>tr:first-child>td{border-top:0}.table>tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed>thead>tr>th,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>tbody>tr>td,.table-condensed>tfoot>tr>td{padding:5px}.table-bordered{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>tbody>tr>td,.table-bordered>tfoot>tr>td{border:1px solid #ddd}.table-bordered>thead>tr>th,.table-bordered>thead>tr>td{border-bottom-width:2px}.table-striped>tbody>tr:nth-child(odd)>td,.table-striped>tbody>tr:nth-child(odd)>th{background-color:#f9f9f9}.table-hover>tbody>tr:hover>td,.table-hover>tbody>tr:hover>th{background-color:#f5f5f5}table col[class*="col-"]{display:table-column;float:none}table td[class*="col-"],table th[class*="col-"]{display:table-cell;float:none}.table>thead>tr>td.active,.table>tbody>tr>td.active,.table>tfoot>tr>td.active,.table>thead>tr>th.active,.table>tbody>tr>th.active,.table>tfoot>tr>th.active,.table>thead>tr.active>td,.table>tbody>tr.active>td,.table>tfoot>tr.active>td,.table>thead>tr.active>th,.table>tbody>tr.active>th,.table>tfoot>tr.active>th{background-color:#f5f5f5}.table>thead>tr>td.success,.table>tbody>tr>td.success,.table>tfoot>tr>td.success,.table>thead>tr>th.success,.table>tbody>tr>th.success,.table>tfoot>tr>th.success,.table>thead>tr.success>td,.table>tbody>tr.success>td,.table>tfoot>tr.success>td,.table>thead>tr.success>th,.table>tbody>tr.success>th,.table>tfoot>tr.success>th{background-color:#dff0d8;border-color:#d6e9c6}.table-hover>tbody>tr>td.success:hover,.table-hover>tbody>tr>th.success:hover,.table-hover>tbody>tr.success:hover>td,.table-hover>tbody>tr.success:hover>th{background-color:#d0e9c6;border-color:#c9e2b3}.table>thead>tr>td.danger,.table>tbody>tr>td.danger,.table>tfoot>tr>td.danger,.table>thead>tr>th.danger,.table>tbody>tr>th.danger,.table>tfoot>tr>th.danger,.table>thead>tr.danger>td,.table>tbody>tr.danger>td,.table>tfoot>tr.danger>td,.table>thead>tr.danger>th,.table>tbody>tr.danger>th,.table>tfoot>tr.danger>th{background-color:#f2dede;border-color:#ebccd1}.table-hover>tbody>tr>td.danger:hover,.table-hover>tbody>tr>th.danger:hover,.table-hover>tbody>tr.danger:hover>td,.table-hover>tbody>tr.danger:hover>th{background-color:#ebcccc;border-color:#e4b9c0}.table>thead>tr>td.warning,.table>tbody>tr>td.warning,.table>tfoot>tr>td.warning,.table>thead>tr>th.warning,.table>tbody>tr>th.warning,.table>tfoot>tr>th.warning,.table>thead>tr.warning>td,.table>tbody>tr.warning>td,.table>tfoot>tr.warning>td,.table>thead>tr.warning>th,.table>tbody>tr.warning>th,.table>tfoot>tr.warning>th{background-color:#fcf8e3;border-color:#faebcc}.table-hover>tbody>tr>td.warning:hover,.table-hover>tbody>tr>th.warning:hover,.table-hover>tbody>tr.warning:hover>td,.table-hover>tbody>tr.warning:hover>th{background-color:#faf2cc;border-color:#f7e1b5}@media(max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-x:scroll;overflow-y:hidden;border:1px solid #ddd;-ms-overflow-style:-ms-autohiding-scrollbar;-webkit-overflow-scrolling:touch}.table-responsive>.table{margin-bottom:0}.table-responsive>.table>thead>tr>th,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tfoot>tr>td{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>thead>tr>th:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.table-responsive>.table-bordered>thead>tr>th:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>th,.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:inherit;color:#333;border:0;border-bottom:1px solid #e5e5e5}label{display:inline-block;margin-bottom:5px;font-weight:bold}input[type="search"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;line-height:normal}input[type="file"]{display:block}select[multiple],select[size]{height:auto}select optgroup{font-family:inherit;font-size:inherit;font-style:inherit}input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}input[type="number"]::-webkit-outer-spin-button,input[type="number"]::-webkit-inner-spin-button{height:auto}output{display:block;padding-top:7px;font-size:14px;line-height:1.428571429;color:#555;vertical-align:middle}.form-control:-moz-placeholder{color:#999}.form-control::-moz-placeholder{color:#999}.form-control:-ms-input-placeholder{color:#999}.form-control::-webkit-input-placeholder{color:#999}.form-control{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.428571429;color:#555;vertical-align:middle;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.form-control:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(102,175,233,0.6)}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{cursor:not-allowed;background-color:#eee}textarea.form-control{height:auto}.form-group{margin-bottom:15px}.radio,.checkbox{display:block;min-height:20px;padding-left:20px;margin-top:10px;margin-bottom:10px;vertical-align:middle}.radio label,.checkbox label{display:inline;margin-bottom:0;font-weight:normal;cursor:pointer}.radio input[type="radio"],.radio-inline input[type="radio"],.checkbox input[type="checkbox"],.checkbox-inline input[type="checkbox"]{float:left;margin-left:-20px}.radio+.radio,.checkbox+.checkbox{margin-top:-5px}.radio-inline,.checkbox-inline{display:inline-block;padding-left:20px;margin-bottom:0;font-weight:normal;vertical-align:middle;cursor:pointer}.radio-inline+.radio-inline,.checkbox-inline+.checkbox-inline{margin-top:0;margin-left:10px}input[type="radio"][disabled],input[type="checkbox"][disabled],.radio[disabled],.radio-inline[disabled],.checkbox[disabled],.checkbox-inline[disabled],fieldset[disabled] input[type="radio"],fieldset[disabled] input[type="checkbox"],fieldset[disabled] .radio,fieldset[disabled] .radio-inline,fieldset[disabled] .checkbox,fieldset[disabled] .checkbox-inline{cursor:not-allowed}.input-sm{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-sm{height:30px;line-height:30px}textarea.input-sm{height:auto}.input-lg{height:45px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-lg{height:45px;line-height:45px}textarea.input-lg{height:auto}.has-warning .help-block,.has-warning .control-label,.has-warning .radio,.has-warning .checkbox,.has-warning .radio-inline,.has-warning .checkbox-inline{color:#c09853}.has-warning .form-control{border-color:#c09853;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-warning .form-control:focus{border-color:#a47e3c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e}.has-warning .input-group-addon{color:#c09853;background-color:#fcf8e3;border-color:#c09853}.has-error .help-block,.has-error .control-label,.has-error .radio,.has-error .checkbox,.has-error .radio-inline,.has-error .checkbox-inline{color:#b94a48}.has-error .form-control{border-color:#b94a48;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-error .form-control:focus{border-color:#953b39;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392}.has-error .input-group-addon{color:#b94a48;background-color:#f2dede;border-color:#b94a48}.has-success .help-block,.has-success .control-label,.has-success .radio,.has-success .checkbox,.has-success .radio-inline,.has-success .checkbox-inline{color:#468847}.has-success .form-control{border-color:#468847;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.has-success .form-control:focus{border-color:#356635;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b}.has-success .input-group-addon{color:#468847;background-color:#dff0d8;border-color:#468847}.form-control-static{margin-bottom:0}.help-block{display:block;margin-top:5px;margin-bottom:10px;color:#737373}@media(min-width:768px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block}.form-inline .radio,.form-inline .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:none;margin-left:0}}.form-horizontal .control-label,.form-horizontal .radio,.form-horizontal .checkbox,.form-horizontal .radio-inline,.form-horizontal .checkbox-inline{padding-top:7px;margin-top:0;margin-bottom:0}.form-horizontal .form-group{margin-right:-15px;margin-left:-15px}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}.form-horizontal .form-group:before,.form-horizontal .form-group:after{display:table;content:" "}.form-horizontal .form-group:after{clear:both}.form-horizontal .form-control-static{padding-top:7px}@media(min-width:768px){.form-horizontal .control-label{text-align:right}}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:normal;line-height:1.428571429;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;background-image:none;border:1px solid transparent;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn:hover,.btn:focus{color:#333;text-decoration:none}.btn:active,.btn.active{background-image:none;outline:0;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{pointer-events:none;cursor:not-allowed;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default:hover,.btn-default:focus,.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{color:#333;background-color:#ebebeb;border-color:#adadad}.btn-default:active,.btn-default.active,.open .dropdown-toggle.btn-default{background-image:none}.btn-default.disabled,.btn-default[disabled],fieldset[disabled] .btn-default,.btn-default.disabled:hover,.btn-default[disabled]:hover,fieldset[disabled] .btn-default:hover,.btn-default.disabled:focus,.btn-default[disabled]:focus,fieldset[disabled] .btn-default:focus,.btn-default.disabled:active,.btn-default[disabled]:active,fieldset[disabled] .btn-default:active,.btn-default.disabled.active,.btn-default[disabled].active,fieldset[disabled] .btn-default.active{background-color:#fff;border-color:#ccc}.btn-primary{color:#fff;background-color:#428bca;border-color:#357ebd}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{color:#fff;background-color:#3276b1;border-color:#285e8e}.btn-primary:active,.btn-primary.active,.open .dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled,.btn-primary[disabled],fieldset[disabled] .btn-primary,.btn-primary.disabled:hover,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary:hover,.btn-primary.disabled:focus,.btn-primary[disabled]:focus,fieldset[disabled] .btn-primary:focus,.btn-primary.disabled:active,.btn-primary[disabled]:active,fieldset[disabled] .btn-primary:active,.btn-primary.disabled.active,.btn-primary[disabled].active,fieldset[disabled] .btn-primary.active{background-color:#428bca;border-color:#357ebd}.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.btn-warning:hover,.btn-warning:focus,.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{color:#fff;background-color:#ed9c28;border-color:#d58512}.btn-warning:active,.btn-warning.active,.open .dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled,.btn-warning[disabled],fieldset[disabled] .btn-warning,.btn-warning.disabled:hover,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning:hover,.btn-warning.disabled:focus,.btn-warning[disabled]:focus,fieldset[disabled] .btn-warning:focus,.btn-warning.disabled:active,.btn-warning[disabled]:active,fieldset[disabled] .btn-warning:active,.btn-warning.disabled.active,.btn-warning[disabled].active,fieldset[disabled] .btn-warning.active{background-color:#f0ad4e;border-color:#eea236}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger:hover,.btn-danger:focus,.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{color:#fff;background-color:#d2322d;border-color:#ac2925}.btn-danger:active,.btn-danger.active,.open .dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled,.btn-danger[disabled],fieldset[disabled] .btn-danger,.btn-danger.disabled:hover,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger:hover,.btn-danger.disabled:focus,.btn-danger[disabled]:focus,fieldset[disabled] .btn-danger:focus,.btn-danger.disabled:active,.btn-danger[disabled]:active,fieldset[disabled] .btn-danger:active,.btn-danger.disabled.active,.btn-danger[disabled].active,fieldset[disabled] .btn-danger.active{background-color:#d9534f;border-color:#d43f3a}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success:hover,.btn-success:focus,.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{color:#fff;background-color:#47a447;border-color:#398439}.btn-success:active,.btn-success.active,.open .dropdown-toggle.btn-success{background-image:none}.btn-success.disabled,.btn-success[disabled],fieldset[disabled] .btn-success,.btn-success.disabled:hover,.btn-success[disabled]:hover,fieldset[disabled] .btn-success:hover,.btn-success.disabled:focus,.btn-success[disabled]:focus,fieldset[disabled] .btn-success:focus,.btn-success.disabled:active,.btn-success[disabled]:active,fieldset[disabled] .btn-success:active,.btn-success.disabled.active,.btn-success[disabled].active,fieldset[disabled] .btn-success.active{background-color:#5cb85c;border-color:#4cae4c}.btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.btn-info:hover,.btn-info:focus,.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{color:#fff;background-color:#39b3d7;border-color:#269abc}.btn-info:active,.btn-info.active,.open .dropdown-toggle.btn-info{background-image:none}.btn-info.disabled,.btn-info[disabled],fieldset[disabled] .btn-info,.btn-info.disabled:hover,.btn-info[disabled]:hover,fieldset[disabled] .btn-info:hover,.btn-info.disabled:focus,.btn-info[disabled]:focus,fieldset[disabled] .btn-info:focus,.btn-info.disabled:active,.btn-info[disabled]:active,fieldset[disabled] .btn-info:active,.btn-info.disabled.active,.btn-info[disabled].active,fieldset[disabled] .btn-info.active{background-color:#5bc0de;border-color:#46b8da}.btn-link{font-weight:normal;color:#428bca;cursor:pointer;border-radius:0}.btn-link,.btn-link:active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:hover,.btn-link:focus,.btn-link:active{border-color:transparent}.btn-link:hover,.btn-link:focus{color:#2a6496;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover,fieldset[disabled] .btn-link:hover,.btn-link[disabled]:focus,fieldset[disabled] .btn-link:focus{color:#999;text-decoration:none}.btn-lg{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-sm,.btn-xs{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-xs{padding:1px 5px}.btn-block{display:block;width:100%;padding-right:0;padding-left:0}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.fade{opacity:0;-webkit-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;transition:height .35s ease}@font-face{font-family:'Glyphicons Halflings';src:url('../fonts/glyphicons-halflings-regular.eot');src:url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),url('../fonts/glyphicons-halflings-regular.woff') format('woff'),url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';-webkit-font-smoothing:antialiased;font-style:normal;font-weight:normal;line-height:1}.glyphicon:empty{width:1em}.glyphicon-asterisk:before{content:"\2a"}.glyphicon-plus:before{content:"\2b"}.glyphicon-euro:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-lock:before{content:"\e033"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-bookmark:before{content:"\e044"}.glyphicon-print:before{content:"\e045"}.glyphicon-camera:before{content:"\e046"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-fire:before{content:"\e104"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-calendar:before{content:"\e109"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-bell:before{content:"\e123"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-wrench:before{content:"\e136"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-briefcase:before{content:"\e139"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-paperclip:before{content:"\e142"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-pushpin:before{content:"\e146"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse-down:before{content:"\e159"}.glyphicon-collapse-up:before{content:"\e160"}.glyphicon-log-in:before{content:"\e161"}.glyphicon-flash:before{content:"\e162"}.glyphicon-log-out:before{content:"\e163"}.glyphicon-new-window:before{content:"\e164"}.glyphicon-record:before{content:"\e165"}.glyphicon-save:before{content:"\e166"}.glyphicon-open:before{content:"\e167"}.glyphicon-saved:before{content:"\e168"}.glyphicon-import:before{content:"\e169"}.glyphicon-export:before{content:"\e170"}.glyphicon-send:before{content:"\e171"}.glyphicon-floppy-disk:before{content:"\e172"}.glyphicon-floppy-saved:before{content:"\e173"}.glyphicon-floppy-remove:before{content:"\e174"}.glyphicon-floppy-save:before{content:"\e175"}.glyphicon-floppy-open:before{content:"\e176"}.glyphicon-credit-card:before{content:"\e177"}.glyphicon-transfer:before{content:"\e178"}.glyphicon-cutlery:before{content:"\e179"}.glyphicon-header:before{content:"\e180"}.glyphicon-compressed:before{content:"\e181"}.glyphicon-earphone:before{content:"\e182"}.glyphicon-phone-alt:before{content:"\e183"}.glyphicon-tower:before{content:"\e184"}.glyphicon-stats:before{content:"\e185"}.glyphicon-sd-video:before{content:"\e186"}.glyphicon-hd-video:before{content:"\e187"}.glyphicon-subtitles:before{content:"\e188"}.glyphicon-sound-stereo:before{content:"\e189"}.glyphicon-sound-dolby:before{content:"\e190"}.glyphicon-sound-5-1:before{content:"\e191"}.glyphicon-sound-6-1:before{content:"\e192"}.glyphicon-sound-7-1:before{content:"\e193"}.glyphicon-copyright-mark:before{content:"\e194"}.glyphicon-registration-mark:before{content:"\e195"}.glyphicon-cloud-download:before{content:"\e197"}.glyphicon-cloud-upload:before{content:"\e198"}.glyphicon-tree-conifer:before{content:"\e199"}.glyphicon-tree-deciduous:before{content:"\e200"}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px solid #000;border-right:4px solid transparent;border-bottom:0 dotted;border-left:4px solid transparent}.dropdown{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.175);box-shadow:0 6px 12px rgba(0,0,0,0.175);background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:1.428571429;color:#333;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus{color:#262626;text-decoration:none;background-color:#f5f5f5}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;background-color:#428bca;outline:0}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#999}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.428571429;color:#999}.dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0 dotted;border-bottom:4px solid #000;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}@media(min-width:768px){.navbar-right .dropdown-menu{right:0;left:auto}}.btn-default .caret{border-top-color:#333}.btn-primary .caret,.btn-success .caret,.btn-warning .caret,.btn-danger .caret,.btn-info .caret{border-top-color:#fff}.dropup .btn-default .caret{border-bottom-color:#333}.dropup .btn-primary .caret,.dropup .btn-success .caret,.dropup .btn-warning .caret,.dropup .btn-danger .caret,.dropup .btn-info .caret{border-bottom-color:#fff}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group>.btn,.btn-group-vertical>.btn{position:relative;float:left}.btn-group>.btn:hover,.btn-group-vertical>.btn:hover,.btn-group>.btn:focus,.btn-group-vertical>.btn:focus,.btn-group>.btn:active,.btn-group-vertical>.btn:active,.btn-group>.btn.active,.btn-group-vertical>.btn.active{z-index:2}.btn-group>.btn:focus,.btn-group-vertical>.btn:focus{outline:0}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-left:-1px}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar:before,.btn-toolbar:after{display:table;content:" "}.btn-toolbar:after{clear:both}.btn-toolbar .btn-group{float:left}.btn-toolbar>.btn+.btn,.btn-toolbar>.btn-group+.btn,.btn-toolbar>.btn+.btn-group,.btn-toolbar>.btn-group+.btn-group{margin-left:5px}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-left:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.btn-group>.btn-group{float:left}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child>.btn:last-child,.btn-group>.btn-group:first-child>.dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn-group:last-child>.btn:first-child{border-bottom-left-radius:0;border-top-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group-xs>.btn{padding:5px 10px;padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-sm>.btn{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-lg>.btn{padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}.btn-group>.btn+.dropdown-toggle{padding-right:8px;padding-left:8px}.btn-group>.btn-lg+.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}.btn-group.open .dropdown-toggle.btn-link{-webkit-box-shadow:none;box-shadow:none}.btn .caret{margin-left:0}.btn-lg .caret{border-width:5px 5px 0;border-bottom-width:0}.dropup .btn-lg .caret{border-width:0 5px 5px}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group:before,.btn-group-vertical>.btn-group:after{display:table;content:" "}.btn-group-vertical>.btn-group:after{clear:both}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-right-radius:0;border-bottom-left-radius:4px;border-top-left-radius:0}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child>.btn:last-child,.btn-group-vertical>.btn-group:first-child>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child>.btn:first-child{border-top-right-radius:0;border-top-left-radius:0}.btn-group-justified{display:table;width:100%;border-collapse:separate;table-layout:fixed}.btn-group-justified .btn{display:table-cell;float:none;width:1%}[data-toggle="buttons"]>.btn>input[type="radio"],[data-toggle="buttons"]>.btn>input[type="checkbox"]{display:none}.input-group{position:relative;display:table;border-collapse:separate}.input-group.col{float:none;padding-right:0;padding-left:0}.input-group .form-control{width:100%;margin-bottom:0}.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{height:45px;padding:10px 16px;font-size:18px;line-height:1.33;border-radius:6px}select.input-group-lg>.form-control,select.input-group-lg>.input-group-addon,select.input-group-lg>.input-group-btn>.btn{height:45px;line-height:45px}textarea.input-group-lg>.form-control,textarea.input-group-lg>.input-group-addon,textarea.input-group-lg>.input-group-btn>.btn{height:auto}.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-group-sm>.form-control,select.input-group-sm>.input-group-addon,select.input-group-sm>.input-group-btn>.btn{height:30px;line-height:30px}textarea.input-group-sm>.form-control,textarea.input-group-sm>.input-group-addon,textarea.input-group-sm>.input-group-btn>.btn{height:auto}.input-group-addon,.input-group-btn,.input-group .form-control{display:table-cell}.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child),.input-group .form-control:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:6px 12px;font-size:14px;font-weight:normal;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px}.input-group-addon.input-sm{padding:5px 10px;font-size:12px;border-radius:3px}.input-group-addon.input-lg{padding:10px 16px;font-size:18px;border-radius:6px}.input-group-addon input[type="radio"],.input-group-addon input[type="checkbox"]{margin-top:0}.input-group .form-control:first-child,.input-group-addon:first-child,.input-group-btn:first-child>.btn,.input-group-btn:first-child>.dropdown-toggle,.input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.input-group-addon:first-child{border-right:0}.input-group .form-control:last-child,.input-group-addon:last-child,.input-group-btn:last-child>.btn,.input-group-btn:last-child>.dropdown-toggle,.input-group-btn:first-child>.btn:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.input-group-addon:last-child{border-left:0}.input-group-btn{position:relative;white-space:nowrap}.input-group-btn:first-child>.btn{margin-right:-1px}.input-group-btn:last-child>.btn{margin-left:-1px}.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-4px}.input-group-btn>.btn:hover,.input-group-btn>.btn:active{z-index:2}.nav{padding-left:0;margin-bottom:0;list-style:none}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav:before,.nav:after{display:table;content:" "}.nav:after{clear:both}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:hover,.nav>li>a:focus{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#999}.nav>li.disabled>a:hover,.nav>li.disabled>a:focus{color:#999;text-decoration:none;cursor:not-allowed;background-color:transparent}.nav .open>a,.nav .open>a:hover,.nav .open>a:focus{background-color:#eee;border-color:#428bca}.nav .open>a .caret,.nav .open>a:hover .caret,.nav .open>a:focus .caret{border-top-color:#2a6496;border-bottom-color:#2a6496}.nav .nav-divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.nav>li>a>img{max-width:none}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{float:left;margin-bottom:-1px}.nav-tabs>li>a{margin-right:2px;line-height:1.428571429;border:1px solid transparent;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>li.active>a,.nav-tabs>li.active>a:hover,.nav-tabs>li.active>a:focus{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-tabs.nav-justified{width:100%;border-bottom:0}.nav-tabs.nav-justified>li{float:none}.nav-tabs.nav-justified>li>a{margin-bottom:5px;text-align:center}@media(min-width:768px){.nav-tabs.nav-justified>li{display:table-cell;width:1%}.nav-tabs.nav-justified>li>a{margin-bottom:0}}.nav-tabs.nav-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border:1px solid #ddd}@media(min-width:768px){.nav-tabs.nav-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:hover,.nav-tabs.nav-justified>.active>a:focus{border-bottom-color:#fff}}.nav-pills>li{float:left}.nav-pills>li>a{border-radius:4px}.nav-pills>li+li{margin-left:2px}.nav-pills>li.active>a,.nav-pills>li.active>a:hover,.nav-pills>li.active>a:focus{color:#fff;background-color:#428bca}.nav-pills>li.active>a .caret,.nav-pills>li.active>a:hover .caret,.nav-pills>li.active>a:focus .caret{border-top-color:#fff;border-bottom-color:#fff}.nav-stacked>li{float:none}.nav-stacked>li+li{margin-top:2px;margin-left:0}.nav-justified{width:100%}.nav-justified>li{float:none}.nav-justified>li>a{margin-bottom:5px;text-align:center}@media(min-width:768px){.nav-justified>li{display:table-cell;width:1%}.nav-justified>li>a{margin-bottom:0}}.nav-tabs-justified{border-bottom:0}.nav-tabs-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border:1px solid #ddd}@media(min-width:768px){.nav-tabs-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:hover,.nav-tabs-justified>.active>a:focus{border-bottom-color:#fff}}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.nav .caret{border-top-color:#428bca;border-bottom-color:#428bca}.nav a:hover .caret{border-top-color:#2a6496;border-bottom-color:#2a6496}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-right-radius:0;border-top-left-radius:0}.navbar{position:relative;min-height:50px;margin-bottom:20px;border:1px solid transparent}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}.navbar:before,.navbar:after{display:table;content:" "}.navbar:after{clear:both}@media(min-width:768px){.navbar{border-radius:4px}}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}.navbar-header:before,.navbar-header:after{display:table;content:" "}.navbar-header:after{clear:both}@media(min-width:768px){.navbar-header{float:left}}.navbar-collapse{max-height:340px;padding-right:15px;padding-left:15px;overflow-x:visible;border-top:1px solid transparent;box-shadow:inset 0 1px 0 rgba(255,255,255,0.1);-webkit-overflow-scrolling:touch}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse:before,.navbar-collapse:after{display:table;content:" "}.navbar-collapse:after{clear:both}.navbar-collapse.in{overflow-y:auto}@media(min-width:768px){.navbar-collapse{width:auto;border-top:0;box-shadow:none}.navbar-collapse.collapse{display:block!important;height:auto!important;padding-bottom:0;overflow:visible!important}.navbar-collapse.in{overflow-y:auto}.navbar-collapse .navbar-nav.navbar-left:first-child{margin-left:-15px}.navbar-collapse .navbar-nav.navbar-right:last-child{margin-right:-15px}.navbar-collapse .navbar-text:last-child{margin-right:0}}.container>.navbar-header,.container>.navbar-collapse{margin-right:-15px;margin-left:-15px}@media(min-width:768px){.container>.navbar-header,.container>.navbar-collapse{margin-right:0;margin-left:0}}.navbar-static-top{z-index:1000;border-width:0 0 1px}@media(min-width:768px){.navbar-static-top{border-radius:0}}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030}@media(min-width:768px){.navbar-fixed-top,.navbar-fixed-bottom{border-radius:0}}.navbar-fixed-top{top:0;border-width:0 0 1px}.navbar-fixed-bottom{bottom:0;margin-bottom:0;border-width:1px 0 0}.navbar-brand{float:left;padding:15px 15px;font-size:18px;line-height:20px}.navbar-brand:hover,.navbar-brand:focus{text-decoration:none}@media(min-width:768px){.navbar>.container .navbar-brand{margin-left:-15px}}.navbar-toggle{position:relative;float:right;padding:9px 10px;margin-top:8px;margin-right:15px;margin-bottom:8px;background-color:transparent;border:1px solid transparent;border-radius:4px}.navbar-toggle .icon-bar{display:block;width:22px;height:2px;border-radius:1px}.navbar-toggle .icon-bar+.icon-bar{margin-top:4px}@media(min-width:768px){.navbar-toggle{display:none}}.navbar-nav{margin:7.5px -15px}.navbar-nav>li>a{padding-top:10px;padding-bottom:10px;line-height:20px}@media(max-width:767px){.navbar-nav .open .dropdown-menu{position:static;float:none;width:auto;margin-top:0;background-color:transparent;border:0;box-shadow:none}.navbar-nav .open .dropdown-menu>li>a,.navbar-nav .open .dropdown-menu .dropdown-header{padding:5px 15px 5px 25px}.navbar-nav .open .dropdown-menu>li>a{line-height:20px}.navbar-nav .open .dropdown-menu>li>a:hover,.navbar-nav .open .dropdown-menu>li>a:focus{background-image:none}}@media(min-width:768px){.navbar-nav{float:left;margin:0}.navbar-nav>li{float:left}.navbar-nav>li>a{padding-top:15px;padding-bottom:15px}}@media(min-width:768px){.navbar-left{float:left!important}.navbar-right{float:right!important}}.navbar-form{padding:10px 15px;margin-top:8px;margin-right:-15px;margin-bottom:8px;margin-left:-15px;border-top:1px solid transparent;border-bottom:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}@media(min-width:768px){.navbar-form .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.navbar-form .form-control{display:inline-block}.navbar-form .radio,.navbar-form .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}.navbar-form .radio input[type="radio"],.navbar-form .checkbox input[type="checkbox"]{float:none;margin-left:0}}@media(max-width:767px){.navbar-form .form-group{margin-bottom:5px}}@media(min-width:768px){.navbar-form{width:auto;padding-top:0;padding-bottom:0;margin-right:0;margin-left:0;border:0;-webkit-box-shadow:none;box-shadow:none}}.navbar-nav>li>.dropdown-menu{margin-top:0;border-top-right-radius:0;border-top-left-radius:0}.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu{border-bottom-right-radius:0;border-bottom-left-radius:0}.navbar-nav.pull-right>li>.dropdown-menu,.navbar-nav>li>.dropdown-menu.pull-right{right:0;left:auto}.navbar-btn{margin-top:8px;margin-bottom:8px}.navbar-text{float:left;margin-top:15px;margin-bottom:15px}@media(min-width:768px){.navbar-text{margin-right:15px;margin-left:15px}}.navbar-default{background-color:#f8f8f8;border-color:#e7e7e7}.navbar-default .navbar-brand{color:#777}.navbar-default .navbar-brand:hover,.navbar-default .navbar-brand:focus{color:#5e5e5e;background-color:transparent}.navbar-default .navbar-text{color:#777}.navbar-default .navbar-nav>li>a{color:#777}.navbar-default .navbar-nav>li>a:hover,.navbar-default .navbar-nav>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:hover,.navbar-default .navbar-nav>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.disabled>a,.navbar-default .navbar-nav>.disabled>a:hover,.navbar-default .navbar-nav>.disabled>a:focus{color:#ccc;background-color:transparent}.navbar-default .navbar-toggle{border-color:#ddd}.navbar-default .navbar-toggle:hover,.navbar-default .navbar-toggle:focus{background-color:#ddd}.navbar-default .navbar-toggle .icon-bar{background-color:#ccc}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#e7e7e7}.navbar-default .navbar-nav>.dropdown>a:hover .caret,.navbar-default .navbar-nav>.dropdown>a:focus .caret{border-top-color:#333;border-bottom-color:#333}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:hover,.navbar-default .navbar-nav>.open>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.open>a .caret,.navbar-default .navbar-nav>.open>a:hover .caret,.navbar-default .navbar-nav>.open>a:focus .caret{border-top-color:#555;border-bottom-color:#555}.navbar-default .navbar-nav>.dropdown>a .caret{border-top-color:#777;border-bottom-color:#777}@media(max-width:767px){.navbar-default .navbar-nav .open .dropdown-menu>li>a{color:#777}.navbar-default .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>li>a:focus{color:#333;background-color:transparent}.navbar-default .navbar-nav .open .dropdown-menu>.active>a,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#ccc;background-color:transparent}}.navbar-default .navbar-link{color:#777}.navbar-default .navbar-link:hover{color:#333}.navbar-inverse{background-color:#222;border-color:#080808}.navbar-inverse .navbar-brand{color:#999}.navbar-inverse .navbar-brand:hover,.navbar-inverse .navbar-brand:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-text{color:#999}.navbar-inverse .navbar-nav>li>a{color:#999}.navbar-inverse .navbar-nav>li>a:hover,.navbar-inverse .navbar-nav>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.active>a:hover,.navbar-inverse .navbar-nav>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.disabled>a,.navbar-inverse .navbar-nav>.disabled>a:hover,.navbar-inverse .navbar-nav>.disabled>a:focus{color:#444;background-color:transparent}.navbar-inverse .navbar-toggle{border-color:#333}.navbar-inverse .navbar-toggle:hover,.navbar-inverse .navbar-toggle:focus{background-color:#333}.navbar-inverse .navbar-toggle .icon-bar{background-color:#fff}.navbar-inverse .navbar-collapse,.navbar-inverse .navbar-form{border-color:#101010}.navbar-inverse .navbar-nav>.open>a,.navbar-inverse .navbar-nav>.open>a:hover,.navbar-inverse .navbar-nav>.open>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.dropdown>a:hover .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar-inverse .navbar-nav>.dropdown>a .caret{border-top-color:#999;border-bottom-color:#999}.navbar-inverse .navbar-nav>.open>a .caret,.navbar-inverse .navbar-nav>.open>a:hover .caret,.navbar-inverse .navbar-nav>.open>a:focus .caret{border-top-color:#fff;border-bottom-color:#fff}@media(max-width:767px){.navbar-inverse .navbar-nav .open .dropdown-menu>.dropdown-header{border-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a{color:#999}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:focus{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:focus{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:hover,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:focus{color:#444;background-color:transparent}}.navbar-inverse .navbar-link{color:#999}.navbar-inverse .navbar-link:hover{color:#fff}.breadcrumb{padding:8px 15px;margin-bottom:20px;list-style:none;background-color:#f5f5f5;border-radius:4px}.breadcrumb>li{display:inline-block}.breadcrumb>li+li:before{padding:0 5px;color:#ccc;content:"/\00a0"}.breadcrumb>.active{color:#999}.pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.428571429;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-bottom-left-radius:4px;border-top-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}.pagination>li>a:hover,.pagination>li>span:hover,.pagination>li>a:focus,.pagination>li>span:focus{background-color:#eee}.pagination>.active>a,.pagination>.active>span,.pagination>.active>a:hover,.pagination>.active>span:hover,.pagination>.active>a:focus,.pagination>.active>span:focus{z-index:2;color:#fff;cursor:default;background-color:#428bca;border-color:#428bca}.pagination>.disabled>span,.pagination>.disabled>span:hover,.pagination>.disabled>span:focus,.pagination>.disabled>a,.pagination>.disabled>a:hover,.pagination>.disabled>a:focus{color:#999;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-bottom-left-radius:6px;border-top-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-bottom-left-radius:3px;border-top-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px}.pager{padding-left:0;margin:20px 0;text-align:center;list-style:none}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager:before,.pager:after{display:table;content:" "}.pager:after{clear:both}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;border-radius:15px}.pager li>a:hover,.pager li>a:focus{text-decoration:none;background-color:#eee}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:#999;cursor:not-allowed;background-color:#fff}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}.label[href]:hover,.label[href]:focus{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.label-default{background-color:#999}.label-default[href]:hover,.label-default[href]:focus{background-color:#808080}.label-primary{background-color:#428bca}.label-primary[href]:hover,.label-primary[href]:focus{background-color:#3071a9}.label-success{background-color:#5cb85c}.label-success[href]:hover,.label-success[href]:focus{background-color:#449d44}.label-info{background-color:#5bc0de}.label-info[href]:hover,.label-info[href]:focus{background-color:#31b0d5}.label-warning{background-color:#f0ad4e}.label-warning[href]:hover,.label-warning[href]:focus{background-color:#ec971f}.label-danger{background-color:#d9534f}.label-danger[href]:hover,.label-danger[href]:focus{background-color:#c9302c}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:bold;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;background-color:#999;border-radius:10px}.badge:empty{display:none}a.badge:hover,a.badge:focus{color:#fff;text-decoration:none;cursor:pointer}.btn .badge{position:relative;top:-1px}a.list-group-item.active>.badge,.nav-pills>.active>a>.badge{color:#428bca;background-color:#fff}.nav-pills>li>a>.badge{margin-left:3px}.jumbotron{padding:30px;margin-bottom:30px;font-size:21px;font-weight:200;line-height:2.1428571435;color:inherit;background-color:#eee}.jumbotron h1{line-height:1;color:inherit}.jumbotron p{line-height:1.4}.container .jumbotron{border-radius:6px}@media screen and (min-width:768px){.jumbotron{padding-top:48px;padding-bottom:48px}.container .jumbotron{padding-right:60px;padding-left:60px}.jumbotron h1{font-size:63px}}.thumbnail{display:inline-block;display:block;height:auto;max-width:100%;padding:4px;margin-bottom:20px;line-height:1.428571429;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.thumbnail>img{display:block;height:auto;max-width:100%}a.thumbnail:hover,a.thumbnail:focus,a.thumbnail.active{border-color:#428bca}.thumbnail>img{margin-right:auto;margin-left:auto}.thumbnail .caption{padding:9px;color:#333}.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px}.alert h4{margin-top:0;color:inherit}.alert .alert-link{font-weight:bold}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable{padding-right:35px}.alert-dismissable .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-success hr{border-top-color:#c9e2b3}.alert-success .alert-link{color:#356635}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.alert-info hr{border-top-color:#a6e1ec}.alert-info .alert-link{color:#2d6987}.alert-warning{color:#c09853;background-color:#fcf8e3;border-color:#faebcc}.alert-warning hr{border-top-color:#f7e1b5}.alert-warning .alert-link{color:#a47e3c}.alert-danger{color:#b94a48;background-color:#f2dede;border-color:#ebccd1}.alert-danger hr{border-top-color:#e4b9c0}.alert-danger .alert-link{color:#953b39}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:0 0}to{background-position:40px 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress-bar{float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#428bca;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-transition:width .6s ease;transition:width .6s ease}.progress-striped .progress-bar{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-size:40px 40px}.progress.active .progress-bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-bar-success{background-color:#5cb85c}.progress-striped .progress-bar-success{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-info{background-color:#5bc0de}.progress-striped .progress-bar-info{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-warning{background-color:#f0ad4e}.progress-striped .progress-bar-warning{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-bar-danger{background-color:#d9534f}.progress-striped .progress-bar-danger{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.media,.media-body{overflow:hidden;zoom:1}.media,.media .media{margin-top:15px}.media:first-child{margin-top:0}.media-object{display:block}.media-heading{margin:0 0 5px}.media>.pull-left{margin-right:10px}.media>.pull-right{margin-left:10px}.media-list{padding-left:0;list-style:none}.list-group{padding-left:0;margin-bottom:20px}.list-group-item{position:relative;display:block;padding:10px 15px;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-right-radius:4px;border-top-left-radius:4px}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}.list-group-item>.badge{float:right}.list-group-item>.badge+.badge{margin-right:5px}a.list-group-item{color:#555}a.list-group-item .list-group-item-heading{color:#333}a.list-group-item:hover,a.list-group-item:focus{text-decoration:none;background-color:#f5f5f5}a.list-group-item.active,a.list-group-item.active:hover,a.list-group-item.active:focus{z-index:2;color:#fff;background-color:#428bca;border-color:#428bca}a.list-group-item.active .list-group-item-heading,a.list-group-item.active:hover .list-group-item-heading,a.list-group-item.active:focus .list-group-item-heading{color:inherit}a.list-group-item.active .list-group-item-text,a.list-group-item.active:hover .list-group-item-text,a.list-group-item.active:focus .list-group-item-text{color:#e1edf7}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.05);box-shadow:0 1px 1px rgba(0,0,0,0.05)}.panel-body{padding:15px}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel-body:before,.panel-body:after{display:table;content:" "}.panel-body:after{clear:both}.panel>.list-group{margin-bottom:0}.panel>.list-group .list-group-item{border-width:1px 0}.panel>.list-group .list-group-item:first-child{border-top-right-radius:0;border-top-left-radius:0}.panel>.list-group .list-group-item:last-child{border-bottom:0}.panel-heading+.list-group .list-group-item:first-child{border-top-width:0}.panel>.table,.panel>.table-responsive{margin-bottom:0}.panel>.panel-body+.table,.panel>.panel-body+.table-responsive{border-top:1px solid #ddd}.panel>.table-bordered,.panel>.table-responsive>.table-bordered{border:0}.panel>.table-bordered>thead>tr>th:first-child,.panel>.table-responsive>.table-bordered>thead>tr>th:first-child,.panel>.table-bordered>tbody>tr>th:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:first-child,.panel>.table-bordered>tfoot>tr>th:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:first-child,.panel>.table-bordered>thead>tr>td:first-child,.panel>.table-responsive>.table-bordered>thead>tr>td:first-child,.panel>.table-bordered>tbody>tr>td:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:first-child,.panel>.table-bordered>tfoot>tr>td:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:first-child{border-left:0}.panel>.table-bordered>thead>tr>th:last-child,.panel>.table-responsive>.table-bordered>thead>tr>th:last-child,.panel>.table-bordered>tbody>tr>th:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:last-child,.panel>.table-bordered>tfoot>tr>th:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:last-child,.panel>.table-bordered>thead>tr>td:last-child,.panel>.table-responsive>.table-bordered>thead>tr>td:last-child,.panel>.table-bordered>tbody>tr>td:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:last-child,.panel>.table-bordered>tfoot>tr>td:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:last-child{border-right:0}.panel>.table-bordered>thead>tr:last-child>th,.panel>.table-responsive>.table-bordered>thead>tr:last-child>th,.panel>.table-bordered>tbody>tr:last-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>th,.panel>.table-bordered>tfoot>tr:last-child>th,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>th,.panel>.table-bordered>thead>tr:last-child>td,.panel>.table-responsive>.table-bordered>thead>tr:last-child>td,.panel>.table-bordered>tbody>tr:last-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>td,.panel>.table-bordered>tfoot>tr:last-child>td,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>td{border-bottom:0}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-right-radius:3px;border-top-left-radius:3px}.panel-heading>.dropdown .dropdown-toggle{color:inherit}.panel-title{margin-top:0;margin-bottom:0;font-size:16px}.panel-title>a{color:inherit}.panel-footer{padding:10px 15px;background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel-group .panel{margin-bottom:0;overflow:hidden;border-radius:4px}.panel-group .panel+.panel{margin-top:5px}.panel-group .panel-heading{border-bottom:0}.panel-group .panel-heading+.panel-collapse .panel-body{border-top:1px solid #ddd}.panel-group .panel-footer{border-top:0}.panel-group .panel-footer+.panel-collapse .panel-body{border-bottom:1px solid #ddd}.panel-default{border-color:#ddd}.panel-default>.panel-heading{color:#333;background-color:#f5f5f5;border-color:#ddd}.panel-default>.panel-heading+.panel-collapse .panel-body{border-top-color:#ddd}.panel-default>.panel-heading>.dropdown .caret{border-color:#333 transparent}.panel-default>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#ddd}.panel-primary{border-color:#428bca}.panel-primary>.panel-heading{color:#fff;background-color:#428bca;border-color:#428bca}.panel-primary>.panel-heading+.panel-collapse .panel-body{border-top-color:#428bca}.panel-primary>.panel-heading>.dropdown .caret{border-color:#fff transparent}.panel-primary>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#428bca}.panel-success{border-color:#d6e9c6}.panel-success>.panel-heading{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.panel-success>.panel-heading+.panel-collapse .panel-body{border-top-color:#d6e9c6}.panel-success>.panel-heading>.dropdown .caret{border-color:#468847 transparent}.panel-success>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#d6e9c6}.panel-warning{border-color:#faebcc}.panel-warning>.panel-heading{color:#c09853;background-color:#fcf8e3;border-color:#faebcc}.panel-warning>.panel-heading+.panel-collapse .panel-body{border-top-color:#faebcc}.panel-warning>.panel-heading>.dropdown .caret{border-color:#c09853 transparent}.panel-warning>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#faebcc}.panel-danger{border-color:#ebccd1}.panel-danger>.panel-heading{color:#b94a48;background-color:#f2dede;border-color:#ebccd1}.panel-danger>.panel-heading+.panel-collapse .panel-body{border-top-color:#ebccd1}.panel-danger>.panel-heading>.dropdown .caret{border-color:#b94a48 transparent}.panel-danger>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#ebccd1}.panel-info{border-color:#bce8f1}.panel-info>.panel-heading{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.panel-info>.panel-heading+.panel-collapse .panel-body{border-top-color:#bce8f1}.panel-info>.panel-heading>.dropdown .caret{border-color:#3a87ad transparent}.panel-info>.panel-footer+.panel-collapse .panel-body{border-bottom-color:#bce8f1}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-lg{padding:24px;border-radius:6px}.well-sm{padding:9px;border-radius:3px}.close{float:right;font-size:21px;font-weight:bold;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer;opacity:.5;filter:alpha(opacity=50)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.modal-open{overflow:hidden}.modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;display:none;overflow:auto;overflow-y:scroll}.modal.fade .modal-dialog{-webkit-transform:translate(0,-25%);-ms-transform:translate(0,-25%);transform:translate(0,-25%);-webkit-transition:-webkit-transform .3s ease-out;-moz-transition:-moz-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out}.modal.in .modal-dialog{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.modal-dialog{position:relative;z-index:1050;width:auto;padding:10px;margin-right:auto;margin-left:auto}.modal-content{position:relative;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.2);border-radius:6px;outline:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,0.5);box-shadow:0 3px 9px rgba(0,0,0,0.5);background-clip:padding-box}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1030;background-color:#000}.modal-backdrop.fade{opacity:0;filter:alpha(opacity=0)}.modal-backdrop.in{opacity:.5;filter:alpha(opacity=50)}.modal-header{min-height:16.428571429px;padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.428571429}.modal-body{position:relative;padding:20px}.modal-footer{padding:19px 20px 20px;margin-top:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer:before,.modal-footer:after{display:table;content:" "}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}@media screen and (min-width:768px){.modal-dialog{width:600px;padding-top:30px;padding-bottom:30px}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,0.5);box-shadow:0 5px 15px rgba(0,0,0,0.5)}}.tooltip{position:absolute;z-index:1030;display:block;font-size:12px;line-height:1.4;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.9;filter:alpha(opacity=90)}.tooltip.top{padding:5px 0;margin-top:-3px}.tooltip.right{padding:0 5px;margin-left:3px}.tooltip.bottom{padding:5px 0;margin-top:3px}.tooltip.left{padding:0 5px;margin-left:-3px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-left .tooltip-arrow{bottom:0;left:5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.top-right .tooltip-arrow{right:5px;bottom:0;border-top-color:#000;border-width:5px 5px 0}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-right-color:#000;border-width:5px 5px 5px 0}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-left-color:#000;border-width:5px 0 5px 5px}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-left .tooltip-arrow{top:0;left:5px;border-bottom-color:#000;border-width:0 5px 5px}.tooltip.bottom-right .tooltip-arrow{top:0;right:5px;border-bottom-color:#000;border-width:0 5px 5px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;max-width:276px;padding:1px;text-align:left;white-space:normal;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);background-clip:padding-box}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover .arrow,.popover .arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover .arrow{border-width:11px}.popover .arrow:after{border-width:10px;content:""}.popover.top .arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);border-bottom-width:0}.popover.top .arrow:after{bottom:1px;margin-left:-10px;border-top-color:#fff;border-bottom-width:0;content:" "}.popover.right .arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,0.25);border-left-width:0}.popover.right .arrow:after{bottom:-10px;left:1px;border-right-color:#fff;border-left-width:0;content:" "}.popover.bottom .arrow{top:-11px;left:50%;margin-left:-11px;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);border-top-width:0}.popover.bottom .arrow:after{top:1px;margin-left:-10px;border-bottom-color:#fff;border-top-width:0;content:" "}.popover.left .arrow{top:50%;right:-11px;margin-top:-11px;border-left-color:#999;border-left-color:rgba(0,0,0,0.25);border-right-width:0}.popover.left .arrow:after{right:1px;bottom:-10px;border-left-color:#fff;border-right-width:0;content:" "}.carousel{position:relative}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>img,.carousel-inner>.item>a>img{display:block;height:auto;max-width:100%;line-height:1}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:0;bottom:0;left:0;width:15%;font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6);opacity:.5;filter:alpha(opacity=50)}.carousel-control.left{background-image:-webkit-gradient(linear,0 top,100% top,from(rgba(0,0,0,0.5)),to(rgba(0,0,0,0.0001)));background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.5) 0),color-stop(rgba(0,0,0,0.0001) 100%));background-image:-moz-linear-gradient(left,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.0001) 100%);background-image:linear-gradient(to right,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.0001) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000',endColorstr='#00000000',GradientType=1)}.carousel-control.right{right:0;left:auto;background-image:-webkit-gradient(linear,0 top,100% top,from(rgba(0,0,0,0.0001)),to(rgba(0,0,0,0.5)));background-image:-webkit-linear-gradient(left,color-stop(rgba(0,0,0,0.0001) 0),color-stop(rgba(0,0,0,0.5) 100%));background-image:-moz-linear-gradient(left,rgba(0,0,0,0.0001) 0,rgba(0,0,0,0.5) 100%);background-image:linear-gradient(to right,rgba(0,0,0,0.0001) 0,rgba(0,0,0,0.5) 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000',endColorstr='#80000000',GradientType=1)}.carousel-control:hover,.carousel-control:focus{color:#fff;text-decoration:none;opacity:.9;filter:alpha(opacity=90)}.carousel-control .icon-prev,.carousel-control .icon-next,.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right{position:absolute;top:50%;z-index:5;display:inline-block}.carousel-control .icon-prev,.carousel-control .glyphicon-chevron-left{left:50%}.carousel-control .icon-next,.carousel-control .glyphicon-chevron-right{right:50%}.carousel-control .icon-prev,.carousel-control .icon-next{width:20px;height:20px;margin-top:-10px;margin-left:-10px;font-family:serif}.carousel-control .icon-prev:before{content:'\2039'}.carousel-control .icon-next:before{content:'\203a'}.carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;padding-left:0;margin-left:-30%;text-align:center;list-style:none}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:#000 \9;background-color:rgba(0,0,0,0);border:1px solid #fff;border-radius:10px}.carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff}.carousel-caption{position:absolute;right:15%;bottom:20px;left:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,0.6)}.carousel-caption .btn{text-shadow:none}@media screen and (min-width:768px){.carousel-control .glyphicons-chevron-left,.carousel-control .glyphicons-chevron-right,.carousel-control .icon-prev,.carousel-control .icon-next{width:30px;height:30px;margin-top:-15px;margin-left:-15px;font-size:30px}.carousel-caption{right:20%;left:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.clearfix:before,.clearfix:after{display:table;content:" "}.clearfix:after{clear:both}.center-block{display:block;margin-right:auto;margin-left:auto}.pull-right{float:right!important}.pull-left{float:left!important}.hide{display:none!important}.show{display:block!important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.hidden{display:none!important;visibility:hidden!important}.affix{position:fixed}@-ms-viewport{width:device-width}.visible-xs,tr.visible-xs,th.visible-xs,td.visible-xs{display:none!important}@media(max-width:767px){.visible-xs{display:block!important}tr.visible-xs{display:table-row!important}th.visible-xs,td.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-xs.visible-sm{display:block!important}tr.visible-xs.visible-sm{display:table-row!important}th.visible-xs.visible-sm,td.visible-xs.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-xs.visible-md{display:block!important}tr.visible-xs.visible-md{display:table-row!important}th.visible-xs.visible-md,td.visible-xs.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-xs.visible-lg{display:block!important}tr.visible-xs.visible-lg{display:table-row!important}th.visible-xs.visible-lg,td.visible-xs.visible-lg{display:table-cell!important}}.visible-sm,tr.visible-sm,th.visible-sm,td.visible-sm{display:none!important}@media(max-width:767px){.visible-sm.visible-xs{display:block!important}tr.visible-sm.visible-xs{display:table-row!important}th.visible-sm.visible-xs,td.visible-sm.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-sm{display:block!important}tr.visible-sm{display:table-row!important}th.visible-sm,td.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-sm.visible-md{display:block!important}tr.visible-sm.visible-md{display:table-row!important}th.visible-sm.visible-md,td.visible-sm.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-sm.visible-lg{display:block!important}tr.visible-sm.visible-lg{display:table-row!important}th.visible-sm.visible-lg,td.visible-sm.visible-lg{display:table-cell!important}}.visible-md,tr.visible-md,th.visible-md,td.visible-md{display:none!important}@media(max-width:767px){.visible-md.visible-xs{display:block!important}tr.visible-md.visible-xs{display:table-row!important}th.visible-md.visible-xs,td.visible-md.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-md.visible-sm{display:block!important}tr.visible-md.visible-sm{display:table-row!important}th.visible-md.visible-sm,td.visible-md.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-md{display:block!important}tr.visible-md{display:table-row!important}th.visible-md,td.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-md.visible-lg{display:block!important}tr.visible-md.visible-lg{display:table-row!important}th.visible-md.visible-lg,td.visible-md.visible-lg{display:table-cell!important}}.visible-lg,tr.visible-lg,th.visible-lg,td.visible-lg{display:none!important}@media(max-width:767px){.visible-lg.visible-xs{display:block!important}tr.visible-lg.visible-xs{display:table-row!important}th.visible-lg.visible-xs,td.visible-lg.visible-xs{display:table-cell!important}}@media(min-width:768px) and (max-width:991px){.visible-lg.visible-sm{display:block!important}tr.visible-lg.visible-sm{display:table-row!important}th.visible-lg.visible-sm,td.visible-lg.visible-sm{display:table-cell!important}}@media(min-width:992px) and (max-width:1199px){.visible-lg.visible-md{display:block!important}tr.visible-lg.visible-md{display:table-row!important}th.visible-lg.visible-md,td.visible-lg.visible-md{display:table-cell!important}}@media(min-width:1200px){.visible-lg{display:block!important}tr.visible-lg{display:table-row!important}th.visible-lg,td.visible-lg{display:table-cell!important}}.hidden-xs{display:block!important}tr.hidden-xs{display:table-row!important}th.hidden-xs,td.hidden-xs{display:table-cell!important}@media(max-width:767px){.hidden-xs,tr.hidden-xs,th.hidden-xs,td.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-xs.hidden-sm,tr.hidden-xs.hidden-sm,th.hidden-xs.hidden-sm,td.hidden-xs.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-xs.hidden-md,tr.hidden-xs.hidden-md,th.hidden-xs.hidden-md,td.hidden-xs.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-xs.hidden-lg,tr.hidden-xs.hidden-lg,th.hidden-xs.hidden-lg,td.hidden-xs.hidden-lg{display:none!important}}.hidden-sm{display:block!important}tr.hidden-sm{display:table-row!important}th.hidden-sm,td.hidden-sm{display:table-cell!important}@media(max-width:767px){.hidden-sm.hidden-xs,tr.hidden-sm.hidden-xs,th.hidden-sm.hidden-xs,td.hidden-sm.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-sm,tr.hidden-sm,th.hidden-sm,td.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-sm.hidden-md,tr.hidden-sm.hidden-md,th.hidden-sm.hidden-md,td.hidden-sm.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-sm.hidden-lg,tr.hidden-sm.hidden-lg,th.hidden-sm.hidden-lg,td.hidden-sm.hidden-lg{display:none!important}}.hidden-md{display:block!important}tr.hidden-md{display:table-row!important}th.hidden-md,td.hidden-md{display:table-cell!important}@media(max-width:767px){.hidden-md.hidden-xs,tr.hidden-md.hidden-xs,th.hidden-md.hidden-xs,td.hidden-md.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-md.hidden-sm,tr.hidden-md.hidden-sm,th.hidden-md.hidden-sm,td.hidden-md.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-md,tr.hidden-md,th.hidden-md,td.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-md.hidden-lg,tr.hidden-md.hidden-lg,th.hidden-md.hidden-lg,td.hidden-md.hidden-lg{display:none!important}}.hidden-lg{display:block!important}tr.hidden-lg{display:table-row!important}th.hidden-lg,td.hidden-lg{display:table-cell!important}@media(max-width:767px){.hidden-lg.hidden-xs,tr.hidden-lg.hidden-xs,th.hidden-lg.hidden-xs,td.hidden-lg.hidden-xs{display:none!important}}@media(min-width:768px) and (max-width:991px){.hidden-lg.hidden-sm,tr.hidden-lg.hidden-sm,th.hidden-lg.hidden-sm,td.hidden-lg.hidden-sm{display:none!important}}@media(min-width:992px) and (max-width:1199px){.hidden-lg.hidden-md,tr.hidden-lg.hidden-md,th.hidden-lg.hidden-md,td.hidden-lg.hidden-md{display:none!important}}@media(min-width:1200px){.hidden-lg,tr.hidden-lg,th.hidden-lg,td.hidden-lg{display:none!important}}.visible-print,tr.visible-print,th.visible-print,td.visible-print{display:none!important}@media print{.visible-print{display:block!important}tr.visible-print{display:table-row!important}th.visible-print,td.visible-print{display:table-cell!important}.hidden-print,tr.hidden-print,th.hidden-print,td.hidden-print{display:none!important}} \ No newline at end of file diff --git a/server/static/server/c3/docs/css/c3.css b/server/static/server/c3/docs/css/c3.css new file mode 100644 index 0000000..2087cc1 --- /dev/null +++ b/server/static/server/c3/docs/css/c3.css @@ -0,0 +1,241 @@ +/*-- Chart --*/ +.c3 svg { + font: 10px sans-serif; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} + +.c3 path, .c3 line { + fill: none; + stroke: #000; +} + +.c3 text { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; +} + +.c3-legend-item-tile, +.c3-xgrid-focus, +.c3-ygrid, +.c3-event-rect, +.c3-bars path { + shape-rendering: crispEdges; +} + +.c3-chart-arc path { + stroke: #fff; +} + +.c3-chart-arc rect { + stroke: white; + stroke-width: 1; +} + +.c3-chart-arc text { + fill: #fff; + font-size: 13px; +} + +/*-- Axis --*/ +/*-- Grid --*/ +.c3-grid line { + stroke: #aaa; +} + +.c3-grid text { + fill: #aaa; +} + +.c3-xgrid, .c3-ygrid { + stroke-dasharray: 3 3; +} + +/*-- Text on Chart --*/ +.c3-text.c3-empty { + fill: #808080; + font-size: 2em; +} + +/*-- Line --*/ +.c3-line { + stroke-width: 1px; +} + +/*-- Point --*/ +.c3-circle { + fill: currentColor; +} + +.c3-circle._expanded_ { + stroke-width: 1px; + stroke: white; +} + +.c3-selected-circle { + fill: white; + stroke-width: 2px; +} + +/*-- Bar --*/ +.c3-bar { + stroke-width: 0; +} + +.c3-bar._expanded_ { + fill-opacity: 1; + fill-opacity: 0.75; +} + +/*-- Focus --*/ +.c3-target.c3-focused { + opacity: 1; +} + +.c3-target.c3-focused path.c3-line, .c3-target.c3-focused path.c3-step { + stroke-width: 2px; +} + +.c3-target.c3-defocused { + opacity: 0.3 !important; +} + +/*-- Region --*/ +.c3-region { + fill: steelblue; + fill-opacity: 0.1; +} +.c3-region text { + fill-opacity: 1; +} + +/*-- Brush --*/ +.c3-brush .extent { + fill-opacity: 0.1; +} + +/*-- Select - Drag --*/ +/*-- Legend --*/ +.c3-legend-item { + font-size: 12px; +} + +.c3-legend-item-hidden { + opacity: 0.15; +} + +.c3-legend-background { + opacity: 0.75; + fill: white; + stroke: lightgray; + stroke-width: 1; +} + +/*-- Title --*/ +.c3-title { + font: 14px sans-serif; +} + +/*-- Tooltip --*/ +.c3-tooltip-container { + z-index: 10; +} + +.c3-tooltip { + border-collapse: collapse; + border-spacing: 0; + background-color: #fff; + empty-cells: show; + -webkit-box-shadow: 7px 7px 12px -9px #777777; + -moz-box-shadow: 7px 7px 12px -9px #777777; + box-shadow: 7px 7px 12px -9px #777777; + opacity: 0.9; +} + +.c3-tooltip tr { + border: 1px solid #CCC; +} + +.c3-tooltip th { + background-color: #aaa; + font-size: 14px; + padding: 2px 5px; + text-align: left; + color: #FFF; +} + +.c3-tooltip td { + font-size: 13px; + padding: 3px 6px; + background-color: #fff; + border-left: 1px dotted #999; +} + +.c3-tooltip td > span { + display: inline-block; + width: 10px; + height: 10px; + margin-right: 6px; +} + +.c3-tooltip .value { + text-align: right; +} + +/*-- Area --*/ +.c3-area { + stroke-width: 0; + opacity: 0.2; +} + +/*-- Arc --*/ +.c3-chart-arcs-title { + dominant-baseline: middle; + font-size: 1.3em; +} + +.c3-chart-arcs .c3-chart-arcs-background { + fill: #e0e0e0; + stroke: #FFF; +} + +.c3-chart-arcs .c3-chart-arcs-gauge-unit { + fill: #000; + font-size: 16px; +} + +.c3-chart-arcs .c3-chart-arcs-gauge-max { + fill: #777; +} + +.c3-chart-arcs .c3-chart-arcs-gauge-min { + fill: #777; +} + +.c3-chart-arc .c3-gauge-value { + fill: #000; + /* font-size: 28px !important;*/ +} + +.c3-chart-arc.c3-target g path { + opacity: 1; +} + +.c3-chart-arc.c3-target.c3-focused g path { + opacity: 1; +} + +/*-- Zoom --*/ +.c3-drag-zoom.enabled { + pointer-events: all !important; + visibility: visible; +} + +.c3-drag-zoom.disabled { + pointer-events: none !important; + visibility: hidden; +} + +.c3-drag-zoom .extent { + fill-opacity: 0.1; +} diff --git a/server/static/server/c3/docs/css/c3.min.css b/server/static/server/c3/docs/css/c3.min.css new file mode 100644 index 0000000..86778eb --- /dev/null +++ b/server/static/server/c3/docs/css/c3.min.css @@ -0,0 +1 @@ +.c3 svg{font:10px sans-serif;-webkit-tap-highlight-color:transparent}.c3 line,.c3 path{fill:none;stroke:#000}.c3 text{-webkit-user-select:none;-moz-user-select:none;user-select:none}.c3-bars path,.c3-event-rect,.c3-legend-item-tile,.c3-xgrid-focus,.c3-ygrid{shape-rendering:crispEdges}.c3-chart-arc path{stroke:#fff}.c3-chart-arc rect{stroke:#fff;stroke-width:1}.c3-chart-arc text{fill:#fff;font-size:13px}.c3-grid line{stroke:#aaa}.c3-grid text{fill:#aaa}.c3-xgrid,.c3-ygrid{stroke-dasharray:3 3}.c3-text.c3-empty{fill:grey;font-size:2em}.c3-line{stroke-width:1px}.c3-circle{fill:currentColor}.c3-circle._expanded_{stroke-width:1px;stroke:#fff}.c3-selected-circle{fill:#fff;stroke-width:2px}.c3-bar{stroke-width:0}.c3-bar._expanded_{fill-opacity:1;fill-opacity:.75}.c3-target.c3-focused{opacity:1}.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}.c3-target.c3-defocused{opacity:.3!important}.c3-region{fill:#4682b4;fill-opacity:.1}.c3-region text{fill-opacity:1}.c3-brush .extent{fill-opacity:.1}.c3-legend-item{font-size:12px}.c3-legend-item-hidden{opacity:.15}.c3-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.c3-title{font:14px sans-serif}.c3-tooltip-container{z-index:10}.c3-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;-webkit-box-shadow:7px 7px 12px -9px #777;-moz-box-shadow:7px 7px 12px -9px #777;box-shadow:7px 7px 12px -9px #777;opacity:.9}.c3-tooltip tr{border:1px solid #ccc}.c3-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#fff}.c3-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.c3-tooltip td>span{display:inline-block;width:10px;height:10px;margin-right:6px}.c3-tooltip .value{text-align:right}.c3-area{stroke-width:0;opacity:.2}.c3-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}.c3-chart-arcs .c3-chart-arcs-background{fill:#e0e0e0;stroke:#fff}.c3-chart-arcs .c3-chart-arcs-gauge-unit{fill:#000;font-size:16px}.c3-chart-arcs .c3-chart-arcs-gauge-max{fill:#777}.c3-chart-arcs .c3-chart-arcs-gauge-min{fill:#777}.c3-chart-arc .c3-gauge-value{fill:#000}.c3-chart-arc.c3-target g path{opacity:1}.c3-chart-arc.c3-target.c3-focused g path{opacity:1}.c3-drag-zoom.enabled{pointer-events:all!important;visibility:visible}.c3-drag-zoom.disabled{pointer-events:none!important;visibility:hidden}.c3-drag-zoom .extent{fill-opacity:.1} \ No newline at end of file diff --git a/server/static/server/c3/docs/css/examples.css b/server/static/server/c3/docs/css/examples.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/foundation.css b/server/static/server/c3/docs/css/foundation.css new file mode 100644 index 0000000..bedfc34 --- /dev/null +++ b/server/static/server/c3/docs/css/foundation.css @@ -0,0 +1,5264 @@ +meta.foundation-version { + font-family: "/5.2.2/"; } + +meta.foundation-mq-small { + font-family: "/only screen/"; + width: 0em; } + +meta.foundation-mq-medium { + font-family: "/only screen and (min-width:40.063em)/"; + width: 40.063em; } + +meta.foundation-mq-large { + font-family: "/only screen and (min-width:64.063em)/"; + width: 64.063em; } + +meta.foundation-mq-xlarge { + font-family: "/only screen and (min-width:90.063em)/"; + width: 90.063em; } + +meta.foundation-mq-xxlarge { + font-family: "/only screen and (min-width:120.063em)/"; + width: 120.063em; } + +meta.foundation-data-attribute-namespace { + font-family: false; } + +html, body { + height: 100%; } + +*, +*:before, +*:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + +html, +body { + font-size: 100%; } + +body { + background: white; + color: #222222; + padding: 0; + margin: 0; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; + font-weight: normal; + font-style: normal; + line-height: 1; + position: relative; + cursor: default; } + +a:hover { + cursor: pointer; } + +img { + max-width: 100%; + height: auto; } + +img { + -ms-interpolation-mode: bicubic; } + +#map_canvas img, +#map_canvas embed, +#map_canvas object, +.map_canvas img, +.map_canvas embed, +.map_canvas object { + max-width: none !important; } + +.left { + float: left !important; } + +.right { + float: right !important; } + +.clearfix { + *zoom: 1; } + .clearfix:before, .clearfix:after { + content: " "; + display: table; } + .clearfix:after { + clear: both; } + +.hide { + display: none; } + +.antialiased { + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } + +img { + display: inline-block; + vertical-align: middle; } + +textarea { + height: auto; + min-height: 50px; } + +select { + width: 100%; } + +.row { + width: 100%; + margin-left: auto; + margin-right: auto; + margin-top: 0; + margin-bottom: 0; + max-width: 62.5rem; + *zoom: 1; } + .row:before, .row:after { + content: " "; + display: table; } + .row:after { + clear: both; } + .row.collapse > .column, + .row.collapse > .columns { + padding-left: 0; + padding-right: 0; } + .row.collapse .row { + margin-left: 0; + margin-right: 0; } + .row .row { + width: auto; + margin-left: -0.9375rem; + margin-right: -0.9375rem; + margin-top: 0; + margin-bottom: 0; + max-width: none; + *zoom: 1; } + .row .row:before, .row .row:after { + content: " "; + display: table; } + .row .row:after { + clear: both; } + .row .row.collapse { + width: auto; + margin: 0; + max-width: none; + *zoom: 1; } + .row .row.collapse:before, .row .row.collapse:after { + content: " "; + display: table; } + .row .row.collapse:after { + clear: both; } + +.column, +.columns { + padding-left: 0.9375rem; + padding-right: 0.9375rem; + width: 100%; + float: left; } + +@media only screen { + .small-push-0 { + position: relative; + left: 0%; + right: auto; } + + .small-pull-0 { + position: relative; + right: 0%; + left: auto; } + + .small-push-1 { + position: relative; + left: 8.33333%; + right: auto; } + + .small-pull-1 { + position: relative; + right: 8.33333%; + left: auto; } + + .small-push-2 { + position: relative; + left: 16.66667%; + right: auto; } + + .small-pull-2 { + position: relative; + right: 16.66667%; + left: auto; } + + .small-push-3 { + position: relative; + left: 25%; + right: auto; } + + .small-pull-3 { + position: relative; + right: 25%; + left: auto; } + + .small-push-4 { + position: relative; + left: 33.33333%; + right: auto; } + + .small-pull-4 { + position: relative; + right: 33.33333%; + left: auto; } + + .small-push-5 { + position: relative; + left: 41.66667%; + right: auto; } + + .small-pull-5 { + position: relative; + right: 41.66667%; + left: auto; } + + .small-push-6 { + position: relative; + left: 50%; + right: auto; } + + .small-pull-6 { + position: relative; + right: 50%; + left: auto; } + + .small-push-7 { + position: relative; + left: 58.33333%; + right: auto; } + + .small-pull-7 { + position: relative; + right: 58.33333%; + left: auto; } + + .small-push-8 { + position: relative; + left: 66.66667%; + right: auto; } + + .small-pull-8 { + position: relative; + right: 66.66667%; + left: auto; } + + .small-push-9 { + position: relative; + left: 75%; + right: auto; } + + .small-pull-9 { + position: relative; + right: 75%; + left: auto; } + + .small-push-10 { + position: relative; + left: 83.33333%; + right: auto; } + + .small-pull-10 { + position: relative; + right: 83.33333%; + left: auto; } + + .small-push-11 { + position: relative; + left: 91.66667%; + right: auto; } + + .small-pull-11 { + position: relative; + right: 91.66667%; + left: auto; } + + .column, + .columns { + position: relative; + padding-left: 0.9375rem; + padding-right: 0.9375rem; + float: left; } + + .small-1 { + width: 8.33333%; } + + .small-2 { + width: 16.66667%; } + + .small-3 { + width: 25%; } + + .small-4 { + width: 33.33333%; } + + .small-5 { + width: 41.66667%; } + + .small-6 { + width: 50%; } + + .small-7 { + width: 58.33333%; } + + .small-8 { + width: 66.66667%; } + + .small-9 { + width: 75%; } + + .small-10 { + width: 83.33333%; } + + .small-11 { + width: 91.66667%; } + + .small-12 { + width: 100%; } + + [class*="column"] + [class*="column"]:last-child { + float: right; } + + [class*="column"] + [class*="column"].end { + float: left; } + + .small-offset-0 { + margin-left: 0% !important; } + + .small-offset-1 { + margin-left: 8.33333% !important; } + + .small-offset-2 { + margin-left: 16.66667% !important; } + + .small-offset-3 { + margin-left: 25% !important; } + + .small-offset-4 { + margin-left: 33.33333% !important; } + + .small-offset-5 { + margin-left: 41.66667% !important; } + + .small-offset-6 { + margin-left: 50% !important; } + + .small-offset-7 { + margin-left: 58.33333% !important; } + + .small-offset-8 { + margin-left: 66.66667% !important; } + + .small-offset-9 { + margin-left: 75% !important; } + + .small-offset-10 { + margin-left: 83.33333% !important; } + + .small-offset-11 { + margin-left: 91.66667% !important; } + + .small-reset-order, + .small-reset-order { + margin-left: 0; + margin-right: 0; + left: auto; + right: auto; + float: left; } + + .column.small-centered, + .columns.small-centered { + margin-left: auto; + margin-right: auto; + float: none; } + + .column.small-uncentered, + .columns.small-uncentered { + margin-left: 0; + margin-right: 0; + float: left !important; } + + .column.small-uncentered.opposite, + .columns.small-uncentered.opposite { + float: right; } } +@media only screen and (min-width: 40.063em) { + .medium-push-0 { + position: relative; + left: 0%; + right: auto; } + + .medium-pull-0 { + position: relative; + right: 0%; + left: auto; } + + .medium-push-1 { + position: relative; + left: 8.33333%; + right: auto; } + + .medium-pull-1 { + position: relative; + right: 8.33333%; + left: auto; } + + .medium-push-2 { + position: relative; + left: 16.66667%; + right: auto; } + + .medium-pull-2 { + position: relative; + right: 16.66667%; + left: auto; } + + .medium-push-3 { + position: relative; + left: 25%; + right: auto; } + + .medium-pull-3 { + position: relative; + right: 25%; + left: auto; } + + .medium-push-4 { + position: relative; + left: 33.33333%; + right: auto; } + + .medium-pull-4 { + position: relative; + right: 33.33333%; + left: auto; } + + .medium-push-5 { + position: relative; + left: 41.66667%; + right: auto; } + + .medium-pull-5 { + position: relative; + right: 41.66667%; + left: auto; } + + .medium-push-6 { + position: relative; + left: 50%; + right: auto; } + + .medium-pull-6 { + position: relative; + right: 50%; + left: auto; } + + .medium-push-7 { + position: relative; + left: 58.33333%; + right: auto; } + + .medium-pull-7 { + position: relative; + right: 58.33333%; + left: auto; } + + .medium-push-8 { + position: relative; + left: 66.66667%; + right: auto; } + + .medium-pull-8 { + position: relative; + right: 66.66667%; + left: auto; } + + .medium-push-9 { + position: relative; + left: 75%; + right: auto; } + + .medium-pull-9 { + position: relative; + right: 75%; + left: auto; } + + .medium-push-10 { + position: relative; + left: 83.33333%; + right: auto; } + + .medium-pull-10 { + position: relative; + right: 83.33333%; + left: auto; } + + .medium-push-11 { + position: relative; + left: 91.66667%; + right: auto; } + + .medium-pull-11 { + position: relative; + right: 91.66667%; + left: auto; } + + .column, + .columns { + position: relative; + padding-left: 0.9375rem; + padding-right: 0.9375rem; + float: left; } + + .medium-1 { + width: 8.33333%; } + + .medium-2 { + width: 16.66667%; } + + .medium-3 { + width: 25%; } + + .medium-4 { + width: 33.33333%; } + + .medium-5 { + width: 41.66667%; } + + .medium-6 { + width: 50%; } + + .medium-7 { + width: 58.33333%; } + + .medium-8 { + width: 66.66667%; } + + .medium-9 { + width: 75%; } + + .medium-10 { + width: 83.33333%; } + + .medium-11 { + width: 91.66667%; } + + .medium-12 { + width: 100%; } + + [class*="column"] + [class*="column"]:last-child { + float: right; } + + [class*="column"] + [class*="column"].end { + float: left; } + + .medium-offset-0 { + margin-left: 0% !important; } + + .medium-offset-1 { + margin-left: 8.33333% !important; } + + .medium-offset-2 { + margin-left: 16.66667% !important; } + + .medium-offset-3 { + margin-left: 25% !important; } + + .medium-offset-4 { + margin-left: 33.33333% !important; } + + .medium-offset-5 { + margin-left: 41.66667% !important; } + + .medium-offset-6 { + margin-left: 50% !important; } + + .medium-offset-7 { + margin-left: 58.33333% !important; } + + .medium-offset-8 { + margin-left: 66.66667% !important; } + + .medium-offset-9 { + margin-left: 75% !important; } + + .medium-offset-10 { + margin-left: 83.33333% !important; } + + .medium-offset-11 { + margin-left: 91.66667% !important; } + + .medium-reset-order, + .medium-reset-order { + margin-left: 0; + margin-right: 0; + left: auto; + right: auto; + float: left; } + + .column.medium-centered, + .columns.medium-centered { + margin-left: auto; + margin-right: auto; + float: none; } + + .column.medium-uncentered, + .columns.medium-uncentered { + margin-left: 0; + margin-right: 0; + float: left !important; } + + .column.medium-uncentered.opposite, + .columns.medium-uncentered.opposite { + float: right; } + + .push-0 { + position: relative; + left: 0%; + right: auto; } + + .pull-0 { + position: relative; + right: 0%; + left: auto; } + + .push-1 { + position: relative; + left: 8.33333%; + right: auto; } + + .pull-1 { + position: relative; + right: 8.33333%; + left: auto; } + + .push-2 { + position: relative; + left: 16.66667%; + right: auto; } + + .pull-2 { + position: relative; + right: 16.66667%; + left: auto; } + + .push-3 { + position: relative; + left: 25%; + right: auto; } + + .pull-3 { + position: relative; + right: 25%; + left: auto; } + + .push-4 { + position: relative; + left: 33.33333%; + right: auto; } + + .pull-4 { + position: relative; + right: 33.33333%; + left: auto; } + + .push-5 { + position: relative; + left: 41.66667%; + right: auto; } + + .pull-5 { + position: relative; + right: 41.66667%; + left: auto; } + + .push-6 { + position: relative; + left: 50%; + right: auto; } + + .pull-6 { + position: relative; + right: 50%; + left: auto; } + + .push-7 { + position: relative; + left: 58.33333%; + right: auto; } + + .pull-7 { + position: relative; + right: 58.33333%; + left: auto; } + + .push-8 { + position: relative; + left: 66.66667%; + right: auto; } + + .pull-8 { + position: relative; + right: 66.66667%; + left: auto; } + + .push-9 { + position: relative; + left: 75%; + right: auto; } + + .pull-9 { + position: relative; + right: 75%; + left: auto; } + + .push-10 { + position: relative; + left: 83.33333%; + right: auto; } + + .pull-10 { + position: relative; + right: 83.33333%; + left: auto; } + + .push-11 { + position: relative; + left: 91.66667%; + right: auto; } + + .pull-11 { + position: relative; + right: 91.66667%; + left: auto; } } +@media only screen and (min-width: 64.063em) { + .large-push-0 { + position: relative; + left: 0%; + right: auto; } + + .large-pull-0 { + position: relative; + right: 0%; + left: auto; } + + .large-push-1 { + position: relative; + left: 8.33333%; + right: auto; } + + .large-pull-1 { + position: relative; + right: 8.33333%; + left: auto; } + + .large-push-2 { + position: relative; + left: 16.66667%; + right: auto; } + + .large-pull-2 { + position: relative; + right: 16.66667%; + left: auto; } + + .large-push-3 { + position: relative; + left: 25%; + right: auto; } + + .large-pull-3 { + position: relative; + right: 25%; + left: auto; } + + .large-push-4 { + position: relative; + left: 33.33333%; + right: auto; } + + .large-pull-4 { + position: relative; + right: 33.33333%; + left: auto; } + + .large-push-5 { + position: relative; + left: 41.66667%; + right: auto; } + + .large-pull-5 { + position: relative; + right: 41.66667%; + left: auto; } + + .large-push-6 { + position: relative; + left: 50%; + right: auto; } + + .large-pull-6 { + position: relative; + right: 50%; + left: auto; } + + .large-push-7 { + position: relative; + left: 58.33333%; + right: auto; } + + .large-pull-7 { + position: relative; + right: 58.33333%; + left: auto; } + + .large-push-8 { + position: relative; + left: 66.66667%; + right: auto; } + + .large-pull-8 { + position: relative; + right: 66.66667%; + left: auto; } + + .large-push-9 { + position: relative; + left: 75%; + right: auto; } + + .large-pull-9 { + position: relative; + right: 75%; + left: auto; } + + .large-push-10 { + position: relative; + left: 83.33333%; + right: auto; } + + .large-pull-10 { + position: relative; + right: 83.33333%; + left: auto; } + + .large-push-11 { + position: relative; + left: 91.66667%; + right: auto; } + + .large-pull-11 { + position: relative; + right: 91.66667%; + left: auto; } + + .column, + .columns { + position: relative; + padding-left: 0.9375rem; + padding-right: 0.9375rem; + float: left; } + + .large-1 { + width: 8.33333%; } + + .large-2 { + width: 16.66667%; } + + .large-3 { + width: 25%; } + + .large-4 { + width: 33.33333%; } + + .large-5 { + width: 41.66667%; } + + .large-6 { + width: 50%; } + + .large-7 { + width: 58.33333%; } + + .large-8 { + width: 66.66667%; } + + .large-9 { + width: 75%; } + + .large-10 { + width: 83.33333%; } + + .large-11 { + width: 91.66667%; } + + .large-12 { + width: 100%; } + + [class*="column"] + [class*="column"]:last-child { + float: right; } + + [class*="column"] + [class*="column"].end { + float: left; } + + .large-offset-0 { + margin-left: 0% !important; } + + .large-offset-1 { + margin-left: 8.33333% !important; } + + .large-offset-2 { + margin-left: 16.66667% !important; } + + .large-offset-3 { + margin-left: 25% !important; } + + .large-offset-4 { + margin-left: 33.33333% !important; } + + .large-offset-5 { + margin-left: 41.66667% !important; } + + .large-offset-6 { + margin-left: 50% !important; } + + .large-offset-7 { + margin-left: 58.33333% !important; } + + .large-offset-8 { + margin-left: 66.66667% !important; } + + .large-offset-9 { + margin-left: 75% !important; } + + .large-offset-10 { + margin-left: 83.33333% !important; } + + .large-offset-11 { + margin-left: 91.66667% !important; } + + .large-reset-order, + .large-reset-order { + margin-left: 0; + margin-right: 0; + left: auto; + right: auto; + float: left; } + + .column.large-centered, + .columns.large-centered { + margin-left: auto; + margin-right: auto; + float: none; } + + .column.large-uncentered, + .columns.large-uncentered { + margin-left: 0; + margin-right: 0; + float: left !important; } + + .column.large-uncentered.opposite, + .columns.large-uncentered.opposite { + float: right; } + + .push-0 { + position: relative; + left: 0%; + right: auto; } + + .pull-0 { + position: relative; + right: 0%; + left: auto; } + + .push-1 { + position: relative; + left: 8.33333%; + right: auto; } + + .pull-1 { + position: relative; + right: 8.33333%; + left: auto; } + + .push-2 { + position: relative; + left: 16.66667%; + right: auto; } + + .pull-2 { + position: relative; + right: 16.66667%; + left: auto; } + + .push-3 { + position: relative; + left: 25%; + right: auto; } + + .pull-3 { + position: relative; + right: 25%; + left: auto; } + + .push-4 { + position: relative; + left: 33.33333%; + right: auto; } + + .pull-4 { + position: relative; + right: 33.33333%; + left: auto; } + + .push-5 { + position: relative; + left: 41.66667%; + right: auto; } + + .pull-5 { + position: relative; + right: 41.66667%; + left: auto; } + + .push-6 { + position: relative; + left: 50%; + right: auto; } + + .pull-6 { + position: relative; + right: 50%; + left: auto; } + + .push-7 { + position: relative; + left: 58.33333%; + right: auto; } + + .pull-7 { + position: relative; + right: 58.33333%; + left: auto; } + + .push-8 { + position: relative; + left: 66.66667%; + right: auto; } + + .pull-8 { + position: relative; + right: 66.66667%; + left: auto; } + + .push-9 { + position: relative; + left: 75%; + right: auto; } + + .pull-9 { + position: relative; + right: 75%; + left: auto; } + + .push-10 { + position: relative; + left: 83.33333%; + right: auto; } + + .pull-10 { + position: relative; + right: 83.33333%; + left: auto; } + + .push-11 { + position: relative; + left: 91.66667%; + right: auto; } + + .pull-11 { + position: relative; + right: 91.66667%; + left: auto; } } +button, .button { + border-style: solid; + border-width: 0px; + cursor: pointer; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; + font-weight: normal; + line-height: normal; + margin: 0 0 1.25rem; + position: relative; + text-decoration: none; + text-align: center; + -webkit-appearance: none; + -webkit-border-radius: 0; + display: inline-block; + padding-top: 1rem; + padding-right: 2rem; + padding-bottom: 1.0625rem; + padding-left: 2rem; + font-size: 1rem; + background-color: #008cba; + border-color: #007095; + color: white; + transition: background-color 300ms ease-out; } + button:hover, button:focus, .button:hover, .button:focus { + background-color: #007095; } + button:hover, button:focus, .button:hover, .button:focus { + color: white; } + button.secondary, .button.secondary { + background-color: #e7e7e7; + border-color: #b9b9b9; + color: #333333; } + button.secondary:hover, button.secondary:focus, .button.secondary:hover, .button.secondary:focus { + background-color: #b9b9b9; } + button.secondary:hover, button.secondary:focus, .button.secondary:hover, .button.secondary:focus { + color: #333333; } + button.success, .button.success { + background-color: #43ac6a; + border-color: #368a55; + color: white; } + button.success:hover, button.success:focus, .button.success:hover, .button.success:focus { + background-color: #368a55; } + button.success:hover, button.success:focus, .button.success:hover, .button.success:focus { + color: white; } + button.alert, .button.alert { + background-color: #f04124; + border-color: #cf2a0e; + color: white; } + button.alert:hover, button.alert:focus, .button.alert:hover, .button.alert:focus { + background-color: #cf2a0e; } + button.alert:hover, button.alert:focus, .button.alert:hover, .button.alert:focus { + color: white; } + button.large, .button.large { + padding-top: 1.125rem; + padding-right: 2.25rem; + padding-bottom: 1.1875rem; + padding-left: 2.25rem; + font-size: 1.25rem; } + button.small, .button.small { + padding-top: 0.875rem; + padding-right: 1.75rem; + padding-bottom: 0.9375rem; + padding-left: 1.75rem; + font-size: 0.8125rem; } + button.tiny, .button.tiny { + padding-top: 0.625rem; + padding-right: 1.25rem; + padding-bottom: 0.6875rem; + padding-left: 1.25rem; + font-size: 0.6875rem; } + button.expand, .button.expand { + padding-right: 0; + padding-left: 0; + width: 100%; } + button.left-align, .button.left-align { + text-align: left; + text-indent: 0.75rem; } + button.right-align, .button.right-align { + text-align: right; + padding-right: 0.75rem; } + button.radius, .button.radius { + border-radius: 3px; } + button.round, .button.round { + border-radius: 1000px; } + button.disabled, button[disabled], .button.disabled, .button[disabled] { + background-color: #008cba; + border-color: #007095; + color: white; + cursor: default; + opacity: 0.7; + box-shadow: none; } + button.disabled:hover, button.disabled:focus, button[disabled]:hover, button[disabled]:focus, .button.disabled:hover, .button.disabled:focus, .button[disabled]:hover, .button[disabled]:focus { + background-color: #007095; } + button.disabled:hover, button.disabled:focus, button[disabled]:hover, button[disabled]:focus, .button.disabled:hover, .button.disabled:focus, .button[disabled]:hover, .button[disabled]:focus { + color: white; } + button.disabled:hover, button.disabled:focus, button[disabled]:hover, button[disabled]:focus, .button.disabled:hover, .button.disabled:focus, .button[disabled]:hover, .button[disabled]:focus { + background-color: #008cba; } + button.disabled.secondary, button[disabled].secondary, .button.disabled.secondary, .button[disabled].secondary { + background-color: #e7e7e7; + border-color: #b9b9b9; + color: #333333; + cursor: default; + opacity: 0.7; + box-shadow: none; } + button.disabled.secondary:hover, button.disabled.secondary:focus, button[disabled].secondary:hover, button[disabled].secondary:focus, .button.disabled.secondary:hover, .button.disabled.secondary:focus, .button[disabled].secondary:hover, .button[disabled].secondary:focus { + background-color: #b9b9b9; } + button.disabled.secondary:hover, button.disabled.secondary:focus, button[disabled].secondary:hover, button[disabled].secondary:focus, .button.disabled.secondary:hover, .button.disabled.secondary:focus, .button[disabled].secondary:hover, .button[disabled].secondary:focus { + color: #333333; } + button.disabled.secondary:hover, button.disabled.secondary:focus, button[disabled].secondary:hover, button[disabled].secondary:focus, .button.disabled.secondary:hover, .button.disabled.secondary:focus, .button[disabled].secondary:hover, .button[disabled].secondary:focus { + background-color: #e7e7e7; } + button.disabled.success, button[disabled].success, .button.disabled.success, .button[disabled].success { + background-color: #43ac6a; + border-color: #368a55; + color: white; + cursor: default; + opacity: 0.7; + box-shadow: none; } + button.disabled.success:hover, button.disabled.success:focus, button[disabled].success:hover, button[disabled].success:focus, .button.disabled.success:hover, .button.disabled.success:focus, .button[disabled].success:hover, .button[disabled].success:focus { + background-color: #368a55; } + button.disabled.success:hover, button.disabled.success:focus, button[disabled].success:hover, button[disabled].success:focus, .button.disabled.success:hover, .button.disabled.success:focus, .button[disabled].success:hover, .button[disabled].success:focus { + color: white; } + button.disabled.success:hover, button.disabled.success:focus, button[disabled].success:hover, button[disabled].success:focus, .button.disabled.success:hover, .button.disabled.success:focus, .button[disabled].success:hover, .button[disabled].success:focus { + background-color: #43ac6a; } + button.disabled.alert, button[disabled].alert, .button.disabled.alert, .button[disabled].alert { + background-color: #f04124; + border-color: #cf2a0e; + color: white; + cursor: default; + opacity: 0.7; + box-shadow: none; } + button.disabled.alert:hover, button.disabled.alert:focus, button[disabled].alert:hover, button[disabled].alert:focus, .button.disabled.alert:hover, .button.disabled.alert:focus, .button[disabled].alert:hover, .button[disabled].alert:focus { + background-color: #cf2a0e; } + button.disabled.alert:hover, button.disabled.alert:focus, button[disabled].alert:hover, button[disabled].alert:focus, .button.disabled.alert:hover, .button.disabled.alert:focus, .button[disabled].alert:hover, .button[disabled].alert:focus { + color: white; } + button.disabled.alert:hover, button.disabled.alert:focus, button[disabled].alert:hover, button[disabled].alert:focus, .button.disabled.alert:hover, .button.disabled.alert:focus, .button[disabled].alert:hover, .button[disabled].alert:focus { + background-color: #f04124; } + +@media only screen and (min-width: 40.063em) { + button, .button { + display: inline-block; } } +meta.foundation-mq-topbar { + font-family: "/only screen and (min-width:40.063em)/"; + width: 40.063em; } + +/* Wrapped around .top-bar to contain to grid width */ +.contain-to-grid { + width: 100%; + background: #333333; } + .contain-to-grid .top-bar { + margin-bottom: 0; } + +.fixed { + width: 100%; + left: 0; + position: fixed; + top: 0; + z-index: 99; } + .fixed.expanded:not(.top-bar) { + overflow-y: auto; + height: auto; + width: 100%; + max-height: 100%; } + .fixed.expanded:not(.top-bar) .title-area { + position: fixed; + width: 100%; + z-index: 99; } + .fixed.expanded:not(.top-bar) .top-bar-section { + z-index: 98; + margin-top: 45px; } + +.top-bar { + overflow: hidden; + height: 45px; + line-height: 45px; + position: relative; + background: #333333; + margin-bottom: 0; } + .top-bar ul { + margin-bottom: 0; + list-style: none; } + .top-bar .row { + max-width: none; } + .top-bar form, + .top-bar input { + margin-bottom: 0; } + .top-bar input { + height: auto; + padding-top: .35rem; + padding-bottom: .35rem; + font-size: 0.75rem; } + .top-bar .button, .top-bar button { + padding-top: .45rem; + padding-bottom: .35rem; + margin-bottom: 0; + font-size: 0.75rem; } + .top-bar .title-area { + position: relative; + margin: 0; } + .top-bar .name { + height: 45px; + margin: 0; + font-size: 16px; } + .top-bar .name h1 { + line-height: 45px; +/* font-size: 1.0625rem;*/ + font-size: 0.94444rem; + margin: 0; } + .top-bar .name h1 a { + font-weight: normal; + color: white; + width: 75%; + display: block; + padding: 0 15px; } + .top-bar .toggle-topbar { + position: absolute; + right: 0; + top: 0; } + .top-bar .toggle-topbar a { + color: white; + text-transform: uppercase; + font-size: 0.8125rem; + font-weight: bold; + position: relative; + display: block; + padding: 0 15px; + height: 45px; + line-height: 45px; } + .top-bar .toggle-topbar.menu-icon { + right: 15px; + top: 50%; + margin-top: -16px; + padding-left: 40px; } + .top-bar .toggle-topbar.menu-icon a { + height: 34px; + line-height: 33px; + padding: 0; + padding-right: 25px; + color: white; + position: relative; } + .top-bar .toggle-topbar.menu-icon a::after { + content: ""; + position: absolute; + right: 0; + display: block; + width: 16px; + top: 0; + height: 0; + box-shadow: 0 10px 0 1px white, 0 16px 0 1px white, 0 22px 0 1px white; } + .top-bar.expanded { + height: auto; + background: transparent; } + .top-bar.expanded .title-area { + background: #333333; } + .top-bar.expanded .toggle-topbar a { + color: #888888; } + .top-bar.expanded .toggle-topbar a::after { + box-shadow: 0 10px 0 1px #888888, 0 16px 0 1px #888888, 0 22px 0 1px #888888; } + +.top-bar-section { + left: 0; + position: relative; + width: auto; + transition: left 300ms ease-out; } + .top-bar-section ul { + width: 100%; + height: auto; + display: block; + background: #333333; + font-size: 16px; + margin: 0; } + .top-bar-section .divider, + .top-bar-section [role="separator"] { + border-top: solid 1px #1a1a1a; + clear: both; + height: 1px; + width: 100%; } + .top-bar-section ul li > a { + display: block; + width: 100%; + color: white; + padding: 12px 0 12px 0; + padding-left: 15px; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; + font-size: 0.8125rem; + font-weight: normal; + text-transform: none; + background: #333333; } + .top-bar-section ul li > a.button { + font-size: 0.8125rem; + padding-right: 15px; + padding-left: 15px; + background-color: #008cba; + border-color: #007095; + color: white; } + .top-bar-section ul li > a.button:hover, .top-bar-section ul li > a.button:focus { + background-color: #007095; } + .top-bar-section ul li > a.button:hover, .top-bar-section ul li > a.button:focus { + color: white; } + .top-bar-section ul li > a.button.secondary { + background-color: #e7e7e7; + border-color: #b9b9b9; + color: #333333; } + .top-bar-section ul li > a.button.secondary:hover, .top-bar-section ul li > a.button.secondary:focus { + background-color: #b9b9b9; } + .top-bar-section ul li > a.button.secondary:hover, .top-bar-section ul li > a.button.secondary:focus { + color: #333333; } + .top-bar-section ul li > a.button.success { + background-color: #43ac6a; + border-color: #368a55; + color: white; } + .top-bar-section ul li > a.button.success:hover, .top-bar-section ul li > a.button.success:focus { + background-color: #368a55; } + .top-bar-section ul li > a.button.success:hover, .top-bar-section ul li > a.button.success:focus { + color: white; } + .top-bar-section ul li > a.button.alert { + background-color: #f04124; + border-color: #cf2a0e; + color: white; } + .top-bar-section ul li > a.button.alert:hover, .top-bar-section ul li > a.button.alert:focus { + background-color: #cf2a0e; } + .top-bar-section ul li > a.button.alert:hover, .top-bar-section ul li > a.button.alert:focus { + color: white; } + .top-bar-section ul li > button { + font-size: 0.8125rem; + padding-right: 15px; + padding-left: 15px; + background-color: #008cba; + border-color: #007095; + color: white; } + .top-bar-section ul li > button:hover, .top-bar-section ul li > button:focus { + background-color: #007095; } + .top-bar-section ul li > button:hover, .top-bar-section ul li > button:focus { + color: white; } + .top-bar-section ul li > button.secondary { + background-color: #e7e7e7; + border-color: #b9b9b9; + color: #333333; } + .top-bar-section ul li > button.secondary:hover, .top-bar-section ul li > button.secondary:focus { + background-color: #b9b9b9; } + .top-bar-section ul li > button.secondary:hover, .top-bar-section ul li > button.secondary:focus { + color: #333333; } + .top-bar-section ul li > button.success { + background-color: #43ac6a; + border-color: #368a55; + color: white; } + .top-bar-section ul li > button.success:hover, .top-bar-section ul li > button.success:focus { + background-color: #368a55; } + .top-bar-section ul li > button.success:hover, .top-bar-section ul li > button.success:focus { + color: white; } + .top-bar-section ul li > button.alert { + background-color: #f04124; + border-color: #cf2a0e; + color: white; } + .top-bar-section ul li > button.alert:hover, .top-bar-section ul li > button.alert:focus { + background-color: #cf2a0e; } + .top-bar-section ul li > button.alert:hover, .top-bar-section ul li > button.alert:focus { + color: white; } + .top-bar-section ul li:hover:not(.has-form) > a { + background: #272727; + color: white; } + .top-bar-section ul li.active > a { + background: #008cba; + color: white; } + .top-bar-section ul li.active > a:hover { + background: #0078a0; + color: white; } + .top-bar-section .has-form { + padding: 15px; } + .top-bar-section .has-dropdown { + position: relative; } + .top-bar-section .has-dropdown > a:after { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 5px; + border-color: transparent transparent transparent rgba(255, 255, 255, 0.4); + border-left-style: solid; + margin-right: 15px; + margin-top: -4.5px; + position: absolute; + top: 50%; + right: 0; } + .top-bar-section .has-dropdown.moved { + position: static; } + .top-bar-section .has-dropdown.moved > .dropdown { + display: block; + position: static !important; + height: auto; + width: auto; + overflow: visible; + clip: auto; + position: absolute !important; + width: 100%; } + .top-bar-section .has-dropdown.moved > a:after { + display: none; } + .top-bar-section .dropdown { + position: absolute; + left: 100%; + top: 0; + z-index: 99; + display: block; + position: absolute !important; + height: 1px; + width: 1px; + overflow: hidden; + clip: rect(1px, 1px, 1px, 1px); } + .top-bar-section .dropdown li { + width: 100%; + height: auto; } + .top-bar-section .dropdown li a { + font-weight: normal; + padding: 8px 15px; } + .top-bar-section .dropdown li a.parent-link { + font-weight: normal; } + .top-bar-section .dropdown li.title h5 { + margin-bottom: 0; } + .top-bar-section .dropdown li.title h5 a { + color: white; + line-height: 22.5px; + display: block; } + .top-bar-section .dropdown li.has-form { + padding: 8px 15px; } + .top-bar-section .dropdown li .button, .top-bar-section .dropdown li button { + top: auto; } + .top-bar-section .dropdown label { + padding: 8px 15px 2px; + margin-bottom: 0; + text-transform: uppercase; + color: #777777; + font-weight: bold; + font-size: 0.625rem; } + +.js-generated { + display: block; } + +@media only screen and (min-width: 40.063em) { + .top-bar { + background: #333333; + *zoom: 1; + overflow: visible; } + .top-bar:before, .top-bar:after { + content: " "; + display: table; } + .top-bar:after { + clear: both; } + .top-bar .toggle-topbar { + display: none; } + .top-bar .title-area { + float: left; } + .top-bar .name h1 a { + width: auto; } + .top-bar input, + .top-bar .button, + .top-bar button { + font-size: 0.875rem; + position: relative; + top: 7px; } + .top-bar.expanded { + background: #333333; } + + .contain-to-grid .top-bar { + max-width: 62.5rem; + margin: 0 auto; + margin-bottom: 0; } + + .top-bar-section { + transition: none 0 0; + left: 0 !important; } + .top-bar-section ul { + width: auto; + height: auto !important; + display: inline; } + .top-bar-section ul li { + float: left; } + .top-bar-section ul li .js-generated { + display: none; } + .top-bar-section li.hover > a:not(.button) { + background: #272727; + color: white; } + .top-bar-section li:not(.has-form) a:not(.button) { + padding: 0 15px; + line-height: 45px; + background: #333333; } + .top-bar-section li:not(.has-form) a:not(.button):hover { + background: #272727; } + .top-bar-section li.active:not(.has-form) a:not(.button) { + padding: 0 15px; + line-height: 45px; + color: white; + background: #008cba; } + .top-bar-section li.active:not(.has-form) a:not(.button):hover { + background: #0078a0; } + .top-bar-section .has-dropdown > a { + padding-right: 35px !important; } + .top-bar-section .has-dropdown > a:after { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 5px; + border-color: rgba(255, 255, 255, 0.4) transparent transparent transparent; + border-top-style: solid; + margin-top: -2.5px; + top: 22.5px; } + .top-bar-section .has-dropdown.moved { + position: relative; } + .top-bar-section .has-dropdown.moved > .dropdown { + display: block; + position: absolute !important; + height: 1px; + width: 1px; + overflow: hidden; + clip: rect(1px, 1px, 1px, 1px); } + .top-bar-section .has-dropdown.hover > .dropdown, .top-bar-section .has-dropdown.not-click:hover > .dropdown { + display: block; + position: static !important; + height: auto; + width: auto; + overflow: visible; + clip: auto; + position: absolute !important; } + .top-bar-section .has-dropdown .dropdown li.has-dropdown > a:after { + border: none; + content: "\00bb"; + top: 1rem; + margin-top: -1px; + right: 5px; + line-height: 1.2; } + .top-bar-section .dropdown { + left: 0; + top: auto; + background: transparent; + min-width: 100%; } + .top-bar-section .dropdown li a { + color: white; + line-height: 1; + white-space: nowrap; + padding: 12px 15px; + background: #333333; } + .top-bar-section .dropdown li:not(.has-form) a:not(.button) { + color: white; + background: #333333; } + .top-bar-section .dropdown li:not(.has-form):hover > a:not(.button) { + color: white; + background: #272727; } + .top-bar-section .dropdown li label { + white-space: nowrap; + background: #333333; } + .top-bar-section .dropdown li .dropdown { + left: 100%; + top: 0; } + .top-bar-section > ul > .divider, .top-bar-section > ul > [role="separator"] { + border-bottom: none; + border-top: none; + border-right: solid 1px #4e4e4e; + clear: none; + height: 45px; + width: 0; } + .top-bar-section .has-form { + background: #333333; + padding: 0 15px; + height: 45px; } + .top-bar-section .right li .dropdown { + left: auto; + right: 0; } + .top-bar-section .right li .dropdown li .dropdown { + right: 100%; } + .top-bar-section .left li .dropdown { + right: auto; + left: 0; } + .top-bar-section .left li .dropdown li .dropdown { + left: 100%; } + + .no-js .top-bar-section ul li:hover > a { + background: #272727; + color: white; } + .no-js .top-bar-section ul li:active > a { + background: #008cba; + color: white; } + .no-js .top-bar-section .has-dropdown:hover > .dropdown { + display: block; + position: static !important; + height: auto; + width: auto; + overflow: visible; + clip: auto; + position: absolute !important; } } +.breadcrumbs { + display: block; + padding: 0.5625rem 0.875rem 0.5625rem; + overflow: hidden; + margin-left: 0; + list-style: none; + border-style: solid; + border-width: 1px; + background-color: #f4f4f4; + border-color: gainsboro; + border-radius: 3px; } + .breadcrumbs > * { + margin: 0; + float: left; + font-size: 0.6875rem; + line-height: 0.6875rem; + text-transform: uppercase; + color: #008cba; } + .breadcrumbs > *:hover a, .breadcrumbs > *:focus a { + text-decoration: underline; } + .breadcrumbs > * a { + color: #008cba; } + .breadcrumbs > *.current { + cursor: default; + color: #333333; } + .breadcrumbs > *.current a { + cursor: default; + color: #333333; } + .breadcrumbs > *.current:hover, .breadcrumbs > *.current:hover a, .breadcrumbs > *.current:focus, .breadcrumbs > *.current:focus a { + text-decoration: none; } + .breadcrumbs > *.unavailable { + color: #999999; } + .breadcrumbs > *.unavailable a { + color: #999999; } + .breadcrumbs > *.unavailable:hover, .breadcrumbs > *.unavailable:hover a, .breadcrumbs > *.unavailable:focus, + .breadcrumbs > *.unavailable a:focus { + text-decoration: none; + color: #999999; + cursor: default; } + .breadcrumbs > *:before { + content: "/"; + color: #aaaaaa; + margin: 0 0.75rem; + position: relative; + top: 1px; } + .breadcrumbs > *:first-child:before { + content: " "; + margin: 0; } + +.alert-box { + border-style: solid; + border-width: 1px; + display: block; + font-weight: normal; + margin-bottom: 1.25rem; + position: relative; + padding: 0.875rem 1.5rem 0.875rem 0.875rem; + font-size: 0.8125rem; + transition: opacity 300ms ease-out; + background-color: #008cba; + border-color: #0078a0; + color: white; } + .alert-box .close { + font-size: 1.375rem; + padding: 9px 6px 4px; + line-height: 0; + position: absolute; + top: 50%; + margin-top: -0.6875rem; + right: 0.25rem; + color: #333333; + opacity: 0.3; } + .alert-box .close:hover, .alert-box .close:focus { + opacity: 0.5; } + .alert-box.radius { + border-radius: 3px; } + .alert-box.round { + border-radius: 1000px; } + .alert-box.success { + background-color: #43ac6a; + border-color: #3a945b; + color: white; } + .alert-box.alert { + background-color: #f04124; + border-color: #de2d0f; + color: white; } + .alert-box.secondary { + background-color: #e7e7e7; + border-color: #c7c7c7; + color: #4f4f4f; } + .alert-box.warning { + background-color: #f08a24; + border-color: #de770f; + color: white; } + .alert-box.info { + background-color: #a0d3e8; + border-color: #74bfdd; + color: #4f4f4f; } + .alert-box.alert-close { + opacity: 0; } + +.inline-list { + margin: 0 auto 1.0625rem auto; + margin-left: -1.375rem; + margin-right: 0; + padding: 0; + list-style: none; + overflow: hidden; } + .inline-list > li { + list-style: none; + float: left; + margin-left: 1.375rem; + display: block; } + .inline-list > li > * { + display: block; } + +.button-group { + list-style: none; + margin: 0; + left: 0; + *zoom: 1; } + .button-group:before, .button-group:after { + content: " "; + display: table; } + .button-group:after { + clear: both; } + .button-group li { + margin: 0; + float: left; } + .button-group li > button, .button-group li .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group li:first-child button, .button-group li:first-child .button { + border-left: 0; } + .button-group li:first-child { + margin-left: 0; } + .button-group.radius > * > button, .button-group.radius > * .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group.radius > *:first-child button, .button-group.radius > *:first-child .button { + border-left: 0; } + .button-group.radius > *:first-child, .button-group.radius > *:first-child > a, .button-group.radius > *:first-child > button, .button-group.radius > *:first-child > .button { + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; } + .button-group.radius > *:last-child, .button-group.radius > *:last-child > a, .button-group.radius > *:last-child > button, .button-group.radius > *:last-child > .button { + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; } + .button-group.round > * > button, .button-group.round > * .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group.round > *:first-child button, .button-group.round > *:first-child .button { + border-left: 0; } + .button-group.round > *:first-child, .button-group.round > *:first-child > a, .button-group.round > *:first-child > button, .button-group.round > *:first-child > .button { + border-bottom-left-radius: 1000px; + border-top-left-radius: 1000px; } + .button-group.round > *:last-child, .button-group.round > *:last-child > a, .button-group.round > *:last-child > button, .button-group.round > *:last-child > .button { + border-bottom-right-radius: 1000px; + border-top-right-radius: 1000px; } + .button-group.even-2 li { + width: 50%; } + .button-group.even-2 li > button, .button-group.even-2 li .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group.even-2 li:first-child button, .button-group.even-2 li:first-child .button { + border-left: 0; } + .button-group.even-2 li button, .button-group.even-2 li .button { + width: 100%; } + .button-group.even-3 li { + width: 33.33333%; } + .button-group.even-3 li > button, .button-group.even-3 li .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group.even-3 li:first-child button, .button-group.even-3 li:first-child .button { + border-left: 0; } + .button-group.even-3 li button, .button-group.even-3 li .button { + width: 100%; } + .button-group.even-4 li { + width: 25%; } + .button-group.even-4 li > button, .button-group.even-4 li .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group.even-4 li:first-child button, .button-group.even-4 li:first-child .button { + border-left: 0; } + .button-group.even-4 li button, .button-group.even-4 li .button { + width: 100%; } + .button-group.even-5 li { + width: 20%; } + .button-group.even-5 li > button, .button-group.even-5 li .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group.even-5 li:first-child button, .button-group.even-5 li:first-child .button { + border-left: 0; } + .button-group.even-5 li button, .button-group.even-5 li .button { + width: 100%; } + .button-group.even-6 li { + width: 16.66667%; } + .button-group.even-6 li > button, .button-group.even-6 li .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group.even-6 li:first-child button, .button-group.even-6 li:first-child .button { + border-left: 0; } + .button-group.even-6 li button, .button-group.even-6 li .button { + width: 100%; } + .button-group.even-7 li { + width: 14.28571%; } + .button-group.even-7 li > button, .button-group.even-7 li .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group.even-7 li:first-child button, .button-group.even-7 li:first-child .button { + border-left: 0; } + .button-group.even-7 li button, .button-group.even-7 li .button { + width: 100%; } + .button-group.even-8 li { + width: 12.5%; } + .button-group.even-8 li > button, .button-group.even-8 li .button { + border-left: 1px solid; + border-color: rgba(255, 255, 255, 0.5); } + .button-group.even-8 li:first-child button, .button-group.even-8 li:first-child .button { + border-left: 0; } + .button-group.even-8 li button, .button-group.even-8 li .button { + width: 100%; } + +.button-bar { + *zoom: 1; } + .button-bar:before, .button-bar:after { + content: " "; + display: table; } + .button-bar:after { + clear: both; } + .button-bar .button-group { + float: left; + margin-right: 0.625rem; } + .button-bar .button-group div { + overflow: hidden; } + +/* Panels */ +.panel { + border-style: solid; + border-width: 1px; + border-color: #d8d8d8; + margin-bottom: 1.25rem; + padding: 1.25rem; + background: #f2f2f2; } + .panel > :first-child { + margin-top: 0; } + .panel > :last-child { + margin-bottom: 0; } + .panel h1, .panel h2, .panel h3, .panel h4, .panel h5, .panel h6, .panel p { + color: #333333; } + .panel h1, .panel h2, .panel h3, .panel h4, .panel h5, .panel h6 { + line-height: 1; + margin-bottom: 0.625rem; } + .panel h1.subheader, .panel h2.subheader, .panel h3.subheader, .panel h4.subheader, .panel h5.subheader, .panel h6.subheader { + line-height: 1.4; } + .panel.callout { + border-style: solid; + border-width: 1px; + border-color: #b6edff; + margin-bottom: 1.25rem; + padding: 1.25rem; + background: #ecfaff; } + .panel.callout > :first-child { + margin-top: 0; } + .panel.callout > :last-child { + margin-bottom: 0; } + .panel.callout h1, .panel.callout h2, .panel.callout h3, .panel.callout h4, .panel.callout h5, .panel.callout h6, .panel.callout p { + color: #333333; } + .panel.callout h1, .panel.callout h2, .panel.callout h3, .panel.callout h4, .panel.callout h5, .panel.callout h6 { + line-height: 1; + margin-bottom: 0.625rem; } + .panel.callout h1.subheader, .panel.callout h2.subheader, .panel.callout h3.subheader, .panel.callout h4.subheader, .panel.callout h5.subheader, .panel.callout h6.subheader { + line-height: 1.4; } + .panel.callout a:not(.button) { + color: #008cba; } + .panel.radius { + border-radius: 3px; } + +.dropdown.button, button.dropdown { + position: relative; + padding-right: 3.5625rem; } + .dropdown.button:before, button.dropdown:before { + position: absolute; + content: ""; + width: 0; + height: 0; + display: block; + border-style: solid; + border-color: white transparent transparent transparent; + top: 50%; } + .dropdown.button:before, button.dropdown:before { + border-width: 0.375rem; + right: 1.40625rem; + margin-top: -0.15625rem; } + .dropdown.button:before, button.dropdown:before { + border-color: white transparent transparent transparent; } + .dropdown.button.tiny, button.dropdown.tiny { + padding-right: 2.625rem; } + .dropdown.button.tiny:before, button.dropdown.tiny:before { + border-width: 0.375rem; + right: 1.125rem; + margin-top: -0.125rem; } + .dropdown.button.tiny:before, button.dropdown.tiny:before { + border-color: white transparent transparent transparent; } + .dropdown.button.small, button.dropdown.small { + padding-right: 3.0625rem; } + .dropdown.button.small:before, button.dropdown.small:before { + border-width: 0.4375rem; + right: 1.3125rem; + margin-top: -0.15625rem; } + .dropdown.button.small:before, button.dropdown.small:before { + border-color: white transparent transparent transparent; } + .dropdown.button.large, button.dropdown.large { + padding-right: 3.625rem; } + .dropdown.button.large:before, button.dropdown.large:before { + border-width: 0.3125rem; + right: 1.71875rem; + margin-top: -0.15625rem; } + .dropdown.button.large:before, button.dropdown.large:before { + border-color: white transparent transparent transparent; } + .dropdown.button.secondary:before, button.dropdown.secondary:before { + border-color: #333333 transparent transparent transparent; } + +div.switch { + position: relative; + padding: 0; + display: block; + overflow: hidden; + border-style: solid; + border-width: 1px; + margin-bottom: 1.25rem; + height: 2.25rem; + background: white; + border-color: #cccccc; } + div.switch label { + position: relative; + left: 0; + z-index: 2; + float: left; + width: 50%; + height: 100%; + margin: 0; + font-weight: bold; + text-align: left; + transition: all 0.1s ease-out; } + div.switch input { + position: absolute; + z-index: 3; + opacity: 0; + width: 100%; + height: 100%; + -moz-appearance: none; } + div.switch input:hover, div.switch input:focus { + cursor: pointer; } + div.switch span:last-child { + position: absolute; + top: -1px; + left: -1px; + z-index: 1; + display: block; + padding: 0; + border-width: 1px; + border-style: solid; + transition: all 0.1s ease-out; } + div.switch input:not(:checked) + label { + opacity: 0; } + div.switch input:checked { + display: none !important; } + div.switch input { + left: 0; + display: block !important; } + div.switch input:first-of-type + label, + div.switch input:first-of-type + span + label { + left: -50%; } + div.switch input:first-of-type:checked + label, + div.switch input:first-of-type:checked + span + label { + left: 0%; } + div.switch input:last-of-type + label, + div.switch input:last-of-type + span + label { + right: -50%; + left: auto; + text-align: right; } + div.switch input:last-of-type:checked + label, + div.switch input:last-of-type:checked + span + label { + right: 0%; + left: auto; } + div.switch span.custom { + display: none !important; } + form.custom div.switch .hidden-field { + margin-left: auto; + position: absolute; + visibility: visible; } + div.switch label { + padding: 0; + line-height: 2.3rem; + font-size: 0.875rem; } + div.switch input:first-of-type:checked ~ span:last-child { + left: 100%; + margin-left: -2.1875rem; } + div.switch span:last-child { + width: 2.25rem; + height: 2.25rem; } + div.switch span:last-child { + border-color: #b3b3b3; + background: white; + background: linear-gradient(to bottom, white 0%, #f2f2f2 100%); + box-shadow: 2px 0 10px 0 rgba(0, 0, 0, 0.07), 1000px 0 0 980px #f3faf6, -2px 0 10px 0 rgba(0, 0, 0, 0.07), -1000px 0 0 1000px whitesmoke; } + div.switch:hover span:last-child, div.switch:focus span:last-child { + background: white; + background: linear-gradient(to bottom, white 0%, #e6e6e6 100%); } + div.switch:active { + background: transparent; } + div.switch.large { + height: 2.75rem; } + div.switch.large label { + padding: 0; + line-height: 2.3rem; + font-size: 1.0625rem; } + div.switch.large input:first-of-type:checked ~ span:last-child { + left: 100%; + margin-left: -2.6875rem; } + div.switch.large span:last-child { + width: 2.75rem; + height: 2.75rem; } + div.switch.small { + height: 1.75rem; } + div.switch.small label { + padding: 0; + line-height: 2.1rem; + font-size: 0.75rem; } + div.switch.small input:first-of-type:checked ~ span:last-child { + left: 100%; + margin-left: -1.6875rem; } + div.switch.small span:last-child { + width: 1.75rem; + height: 1.75rem; } + div.switch.tiny { + height: 1.375rem; } + div.switch.tiny label { + padding: 0; + line-height: 1.9rem; + font-size: 0.6875rem; } + div.switch.tiny input:first-of-type:checked ~ span:last-child { + left: 100%; + margin-left: -1.3125rem; } + div.switch.tiny span:last-child { + width: 1.375rem; + height: 1.375rem; } + div.switch.radius { + border-radius: 4px; } + div.switch.radius span:last-child { + border-radius: 3px; } + div.switch.round { + border-radius: 1000px; } + div.switch.round span:last-child { + border-radius: 999px; } + div.switch.round label { + padding: 0 0.5625rem; } + +/* Image Thumbnails */ +.th { + line-height: 0; + display: inline-block; + border: solid 4px white; + max-width: 100%; + box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2); + transition: all 200ms ease-out; } + .th:hover, .th:focus { + box-shadow: 0 0 6px 1px rgba(0, 140, 186, 0.5); } + .th.radius { + border-radius: 3px; } + +/* Pricing Tables */ +.pricing-table { + border: solid 1px #dddddd; + margin-left: 0; + margin-bottom: 1.25rem; } + .pricing-table * { + list-style: none; + line-height: 1; } + .pricing-table .title { + background-color: #333333; + padding: 0.9375rem 1.25rem; + text-align: center; + color: #eeeeee; + font-weight: normal; + font-size: 1rem; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; } + .pricing-table .price { + background-color: #f6f6f6; + padding: 0.9375rem 1.25rem; + text-align: center; + color: #333333; + font-weight: normal; + font-size: 2rem; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; } + .pricing-table .description { + background-color: white; + padding: 0.9375rem; + text-align: center; + color: #777777; + font-size: 0.75rem; + font-weight: normal; + line-height: 1.4; + border-bottom: dotted 1px #dddddd; } + .pricing-table .bullet-item { + background-color: white; + padding: 0.9375rem; + text-align: center; + color: #333333; + font-size: 0.875rem; + font-weight: normal; + border-bottom: dotted 1px #dddddd; } + .pricing-table .cta-button { + background-color: white; + text-align: center; + padding: 1.25rem 1.25rem 0; } + +@keyframes rotate { + from { + -webkit-transform: rotate(0deg); + -moz-transform: rotate(0deg); + -ms-transform: rotate(0deg); + -o-transform: rotate(0deg); + transform: rotate(0deg); } + + to { + -webkit-transform: rotate(360deg); + -moz-transform: rotate(360deg); + -ms-transform: rotate(360deg); + -o-transform: rotate(360deg); + transform: rotate(360deg); } } + +/* Orbit Graceful Loading */ +.slideshow-wrapper { + position: relative; } + .slideshow-wrapper ul { + list-style-type: none; + margin: 0; } + .slideshow-wrapper ul li, + .slideshow-wrapper ul li .orbit-caption { + display: none; } + .slideshow-wrapper ul li:first-child { + display: block; } + .slideshow-wrapper .orbit-container { + background-color: transparent; } + .slideshow-wrapper .orbit-container li { + display: block; } + .slideshow-wrapper .orbit-container li .orbit-caption { + display: block; } + .slideshow-wrapper .preloader { + display: block; + width: 40px; + height: 40px; + position: absolute; + top: 50%; + left: 50%; + margin-top: -20px; + margin-left: -20px; + border: solid 3px; + border-color: #555555 white; + border-radius: 1000px; + animation-name: rotate; + animation-duration: 1.5s; + animation-iteration-count: infinite; + animation-timing-function: linear; } + +.orbit-container { + overflow: hidden; + width: 100%; + position: relative; + background: none; } + .orbit-container .orbit-slides-container { + list-style: none; + margin: 0; + padding: 0; + position: relative; + -webkit-transform: translateZ(0); } + .orbit-container .orbit-slides-container img { + display: block; + max-width: 100%; } + .orbit-container .orbit-slides-container.fade li { + opacity: 0; + transition: opacity 500ms ease-in-out; + -ms-transform: translate(0, 0); + -webkit-transform: translate3d(0, 0, 0); + -moz-transform: translate3d(0, 0, 0); + -o-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); } + .orbit-container .orbit-slides-container.fade li.animate-in { + opacity: 1; + z-index: 20; + transition: opacity 500ms ease-in-out; } + .orbit-container .orbit-slides-container.fade li.animate-out { + z-index: 10; + transition: opacity 500ms ease-in-out; } + .orbit-container .orbit-slides-container.swipe-next li { + -ms-transform: translate(100%, 0); + -webkit-transform: translate3d(100%, 0, 0); + -moz-transform: translate3d(100%, 0, 0); + -o-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); } + .orbit-container .orbit-slides-container.swipe-next li.animate-in { + -ms-transform: translate(0, 0); + -webkit-transform: translate3d(0, 0, 0); + -moz-transform: translate3d(0, 0, 0); + -o-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + transition-duration: 500ms; } + .orbit-container .orbit-slides-container.swipe-next li.animate-out { + -ms-transform: translate(-100%, 0); + -webkit-transform: translate3d(-100%, 0, 0); + -moz-transform: translate3d(-100%, 0, 0); + -o-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + transition-duration: 500ms; } + .orbit-container .orbit-slides-container.swipe-prev li { + -ms-transform: translate(-100%, 0); + -webkit-transform: translate3d(-100%, 0, 0); + -moz-transform: translate3d(-100%, 0, 0); + -o-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); } + .orbit-container .orbit-slides-container.swipe-prev li.animate-in { + -ms-transform: translate(0, 0); + -webkit-transform: translate3d(0, 0, 0); + -moz-transform: translate3d(0, 0, 0); + -o-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + transition-duration: 500ms; } + .orbit-container .orbit-slides-container.swipe-prev li.animate-out { + -ms-transform: translate(100%, 0); + -webkit-transform: translate3d(100%, 0, 0); + -moz-transform: translate3d(100%, 0, 0); + -o-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + transition-duration: 500ms; } + .orbit-container .orbit-slides-container li { + position: absolute; + top: 0; + left: 0; + width: 100%; + -ms-transform: translate(100%, 0); + -webkit-transform: translate3d(100%, 0, 0); + -moz-transform: translate3d(100%, 0, 0); + -o-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); } + .orbit-container .orbit-slides-container li.active { + opacity: 1; + top: 0; + left: 0; + -ms-transform: translate(0, 0); + -webkit-transform: translate3d(0, 0, 0); + -moz-transform: translate3d(0, 0, 0); + -o-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); } + .orbit-container .orbit-slides-container li .orbit-caption { + position: absolute; + bottom: 0; + background-color: rgba(51, 51, 51, 0.8); + color: white; + width: 100%; + padding: 0.625rem 0.875rem; + font-size: 0.875rem; } + .orbit-container .orbit-slide-number { + position: absolute; + top: 10px; + left: 10px; + font-size: 12px; + color: white; + background: rgba(0, 0, 0, 0); + z-index: 10; } + .orbit-container .orbit-slide-number span { + font-weight: 700; + padding: 0.3125rem; } + .orbit-container .orbit-timer { + position: absolute; + top: 12px; + right: 10px; + height: 6px; + width: 100px; + z-index: 10; } + .orbit-container .orbit-timer .orbit-progress { + height: 3px; + background-color: rgba(255, 255, 255, 0.3); + display: block; + width: 0%; + position: relative; + right: 20px; + top: 5px; } + .orbit-container .orbit-timer > span { + display: none; + position: absolute; + top: 0px; + right: 0; + width: 11px; + height: 14px; + border: solid 4px white; + border-top: none; + border-bottom: none; } + .orbit-container .orbit-timer.paused > span { + right: -4px; + top: 0px; + width: 11px; + height: 14px; + border: inset 8px; + border-left-style: solid; + -webkit-transform: rotate(180deg); + -moz-transform: rotate(180deg); + -ms-transform: rotate(180deg); + -o-transform: rotate(180deg); + transform: rotate(180deg); + border-color: transparent white transparent transparent; } + .orbit-container .orbit-timer.paused > span.dark { + border-color: transparent #333333 transparent transparent; } + .orbit-container:hover .orbit-timer > span { + display: block; } + .orbit-container .orbit-prev, + .orbit-container .orbit-next { + position: absolute; + top: 45%; + margin-top: -25px; + width: 36px; + height: 60px; + line-height: 50px; + color: white; + background-color: transparent; + text-indent: -9999px !important; + z-index: 10; } + .orbit-container .orbit-prev:hover, + .orbit-container .orbit-next:hover { + background-color: rgba(0, 0, 0, 0.3); } + .orbit-container .orbit-prev > span, + .orbit-container .orbit-next > span { + position: absolute; + top: 50%; + margin-top: -10px; + display: block; + width: 0; + height: 0; + border: inset 10px; } + .orbit-container .orbit-prev { + left: 0; } + .orbit-container .orbit-prev > span { + border-right-style: solid; + border-color: transparent; + border-right-color: white; } + .orbit-container .orbit-prev:hover > span { + border-right-color: white; } + .orbit-container .orbit-next { + right: 0; } + .orbit-container .orbit-next > span { + border-color: transparent; + border-left-style: solid; + border-left-color: white; + left: 50%; + margin-left: -4px; } + .orbit-container .orbit-next:hover > span { + border-left-color: white; } + .orbit-container .orbit-bullets-container { + text-align: center; } + .orbit-container .orbit-bullets { + margin: 0 auto 30px auto; + overflow: hidden; + position: relative; + top: 10px; + float: none; + text-align: center; + display: block; } + .orbit-container .orbit-bullets li { + display: inline-block; + width: 0.5625rem; + height: 0.5625rem; + background: #cccccc; + float: none; + margin-right: 6px; + border-radius: 1000px; } + .orbit-container .orbit-bullets li.active { + background: #999999; } + .orbit-container .orbit-bullets li:last-child { + margin-right: 0; } + +.touch .orbit-container .orbit-prev, +.touch .orbit-container .orbit-next { + display: none; } +.touch .orbit-bullets { + display: none; } + +@media only screen and (min-width: 40.063em) { + .touch .orbit-container .orbit-prev, + .touch .orbit-container .orbit-next { + display: inherit; } + .touch .orbit-bullets { + display: block; } } +@media only screen and (max-width: 40em) { + .orbit-stack-on-small .orbit-slides-container { + height: auto !important; } + .orbit-stack-on-small .orbit-slides-container > * { + position: relative; + margin-left: 0% !important; + opacity: 1 !important; + -webkit-transform: none !important; + -moz-transform: none !important; + -ms-transform: none !important; + -o-transform: none !important; + transform: none !important; + transition: none !important; } + .orbit-stack-on-small .orbit-timer { + display: none; } + .orbit-stack-on-small .orbit-next, .orbit-stack-on-small .orbit-prev { + display: none; } + .orbit-stack-on-small .orbit-bullets { + display: none; } } +[data-magellan-expedition], [data-magellan-expedition-clone] { + background: white; + z-index: 50; + min-width: 100%; + padding: 10px; } + [data-magellan-expedition] .sub-nav, [data-magellan-expedition-clone] .sub-nav { + margin-bottom: 0; } + [data-magellan-expedition] .sub-nav dd, [data-magellan-expedition-clone] .sub-nav dd { + margin-bottom: 0; } + [data-magellan-expedition] .sub-nav a, [data-magellan-expedition-clone] .sub-nav a { + line-height: 1.8em; } + +.tabs { + *zoom: 1; + margin-bottom: 0 !important; } + .tabs:before, .tabs:after { + content: " "; + display: table; } + .tabs:after { + clear: both; } + .tabs dd { + position: relative; + margin-bottom: 0 !important; + float: left; } + .tabs dd > a { + display: block; + background: #efefef; + color: #222222; + padding: 1rem 2rem; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; + font-size: 1rem; } + .tabs dd > a:hover { + background: #e1e1e1; } + .tabs dd.active a { + background: white; } + .tabs.radius dd:first-child a { + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; } + .tabs.radius dd:last-child a { + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; } + .tabs.vertical dd { + position: inherit; + float: none; + display: block; + top: auto; } + +.tabs-content { + *zoom: 1; + margin-bottom: 1.5rem; + width: 100%; } + .tabs-content:before, .tabs-content:after { + content: " "; + display: table; } + .tabs-content:after { + clear: both; } + .tabs-content > .content { + display: none; + float: left; + padding: 0.9375rem 0; + width: 100%; } + .tabs-content > .content.active { + display: block; + float: none; } + .tabs-content > .content.contained { + padding: 0.9375rem; } + .tabs-content.vertical { + display: block; } + .tabs-content.vertical > .content { + padding: 0 0.9375rem; } + +@media only screen and (min-width: 40.063em) { + .tabs.vertical { + width: 20%; + float: left; + margin-bottom: 1.25rem; } + + .tabs-content.vertical { + width: 80%; + float: left; + margin-left: -1px; } } +.no-js .tabs-content > .content { + display: block; + float: none; } + +ul.pagination { + display: block; + height: 1.5rem; + margin-left: -0.3125rem; } + ul.pagination li { + height: 1.5rem; + color: #222222; + font-size: 0.875rem; + margin-left: 0.3125rem; } + ul.pagination li a { + display: block; + padding: 0.0625rem 0.625rem 0.0625rem; + color: #999999; + border-radius: 3px; } + ul.pagination li:hover a, + ul.pagination li a:focus { + background: #e6e6e6; } + ul.pagination li.unavailable a { + cursor: default; + color: #999999; } + ul.pagination li.unavailable:hover a, ul.pagination li.unavailable a:focus { + background: transparent; } + ul.pagination li.current a { + background: #008cba; + color: white; + font-weight: bold; + cursor: default; } + ul.pagination li.current a:hover, ul.pagination li.current a:focus { + background: #008cba; } + ul.pagination li { + float: left; + display: block; } + +/* Pagination centred wrapper */ +.pagination-centered { + text-align: center; } + .pagination-centered ul.pagination li { + float: none; + display: inline-block; } + +.side-nav { + display: block; + margin: 0; + padding: 0.875rem 0; + list-style-type: none; + list-style-position: inside; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; } + .side-nav li { + margin: 0 0 0.4375rem 0; + font-size: 0.875rem; } + .side-nav li a:not(.button) { + display: block; + color: #008cba; } + .side-nav li a:not(.button):hover, .side-nav li a:not(.button):focus { + color: #1cc7ff; } + .side-nav li.active > a:first-child:not(.button) { + color: #1cc7ff; + font-weight: normal; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; } + .side-nav li.divider { + border-top: 1px solid; + height: 0; + padding: 0; + list-style: none; + border-top-color: white; } + +.accordion { + *zoom: 1; + margin-bottom: 0; } + .accordion:before, .accordion:after { + content: " "; + display: table; } + .accordion:after { + clear: both; } + .accordion dd { + display: block; + margin-bottom: 0 !important; } + .accordion dd.active > a { + background: #e8e8e8; } + .accordion dd > a { + background: #efefef; + color: #222222; + padding: 1rem; + display: block; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; + font-size: 1rem; } + .accordion dd > a:hover { + background: #e3e3e3; } + .accordion .content { + display: none; + padding: 0.9375rem; } + .accordion .content.active { + display: block; + background: white; } + +.text-left { + text-align: left !important; } + +.text-right { + text-align: right !important; } + +.text-center { + text-align: center !important; } + +.text-justify { + text-align: justify !important; } + +@media only screen and (max-width: 40em) { + .small-only-text-left { + text-align: left !important; } + + .small-only-text-right { + text-align: right !important; } + + .small-only-text-center { + text-align: center !important; } + + .small-only-text-justify { + text-align: justify !important; } } +@media only screen { + .small-text-left { + text-align: left !important; } + + .small-text-right { + text-align: right !important; } + + .small-text-center { + text-align: center !important; } + + .small-text-justify { + text-align: justify !important; } } +@media only screen and (min-width: 40.063em) and (max-width: 64em) { + .medium-only-text-left { + text-align: left !important; } + + .medium-only-text-right { + text-align: right !important; } + + .medium-only-text-center { + text-align: center !important; } + + .medium-only-text-justify { + text-align: justify !important; } } +@media only screen and (min-width: 40.063em) { + .medium-text-left { + text-align: left !important; } + + .medium-text-right { + text-align: right !important; } + + .medium-text-center { + text-align: center !important; } + + .medium-text-justify { + text-align: justify !important; } } +@media only screen and (min-width: 64.063em) and (max-width: 90em) { + .large-only-text-left { + text-align: left !important; } + + .large-only-text-right { + text-align: right !important; } + + .large-only-text-center { + text-align: center !important; } + + .large-only-text-justify { + text-align: justify !important; } } +@media only screen and (min-width: 64.063em) { + .large-text-left { + text-align: left !important; } + + .large-text-right { + text-align: right !important; } + + .large-text-center { + text-align: center !important; } + + .large-text-justify { + text-align: justify !important; } } +@media only screen and (min-width: 90.063em) and (max-width: 120em) { + .xlarge-only-text-left { + text-align: left !important; } + + .xlarge-only-text-right { + text-align: right !important; } + + .xlarge-only-text-center { + text-align: center !important; } + + .xlarge-only-text-justify { + text-align: justify !important; } } +@media only screen and (min-width: 90.063em) { + .xlarge-text-left { + text-align: left !important; } + + .xlarge-text-right { + text-align: right !important; } + + .xlarge-text-center { + text-align: center !important; } + + .xlarge-text-justify { + text-align: justify !important; } } +@media only screen and (min-width: 120.063em) and (max-width: 99999999em) { + .xxlarge-only-text-left { + text-align: left !important; } + + .xxlarge-only-text-right { + text-align: right !important; } + + .xxlarge-only-text-center { + text-align: center !important; } + + .xxlarge-only-text-justify { + text-align: justify !important; } } +@media only screen and (min-width: 120.063em) { + .xxlarge-text-left { + text-align: left !important; } + + .xxlarge-text-right { + text-align: right !important; } + + .xxlarge-text-center { + text-align: center !important; } + + .xxlarge-text-justify { + text-align: justify !important; } } +/* Typography resets */ +div, +dl, +dt, +dd, +ul, +ol, +li, +h1, +h2, +h3, +h4, +h5, +h6, +pre, +form, +p, +blockquote, +th, +td { + margin: 0; + padding: 0; } + +/* Default Link Styles */ +a { + color: #008cba; + text-decoration: none; + line-height: inherit; } + a:hover, a:focus { + color: #0078a0; } + a img { + border: none; } + +/* Default paragraph styles */ +p { + font-family: inherit; + font-weight: normal; + font-size: 1rem; + line-height: 1.6; + margin-bottom: 1.25rem; + text-rendering: optimizeLegibility; } + p.lead { + font-size: 1.21875rem; + line-height: 1.6; } + p aside { + font-size: 0.875rem; + line-height: 1.35; + font-style: italic; } + +/* Default header styles */ +h1, h2, h3, h4, h5, h6 { + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif !important; + font-weight: normal; + font-style: normal; + color: #222222; + text-rendering: optimizeLegibility; + margin-top: 0.2rem; + margin-bottom: 0.5rem; + line-height: 1.4; } + h1 small, h2 small, h3 small, h4 small, h5 small, h6 small { + font-size: 60%; + color: #6f6f6f; + line-height: 0; } + +h1 { + font-size: 2.125rem; } + +h2 { + font-size: 1.6875rem; } + +h3 { + font-size: 1.375rem; } + +h4 { + font-size: 1.125rem; } + +h5 { + font-size: 1.125rem; } + +h6 { + font-size: 1rem; } + +.subheader { + line-height: 1.4; + color: #6f6f6f; + font-weight: normal; + margin-top: 0.2rem; + margin-bottom: 0.5rem; } + +hr { + border: solid #dddddd; + border-width: 1px 0 0; + clear: both; + margin: 1.25rem 0 1.1875rem; + height: 0; } + +/* Helpful Typography Defaults */ +em, +i { + font-style: italic; + line-height: inherit; } + +strong, +b { + font-weight: bold; + line-height: inherit; } + +small { + font-size: 60%; + line-height: inherit; } + +code { + font-family: Consolas, "Liberation Mono", Courier, monospace; + font-weight: bold; + color: #bd260d; } + +/* Lists */ +ul, +ol, +dl { + font-size: 1rem; + line-height: 1.6; + margin-bottom: 1.25rem; + list-style-position: outside; + font-family: inherit; } + +ul { + margin-left: 1.1rem; } + ul.no-bullet { + margin-left: 0; } + ul.no-bullet li ul, + ul.no-bullet li ol { + margin-left: 1.25rem; + margin-bottom: 0; + list-style: none; } + +/* Unordered Lists */ +ul li ul, +ul li ol { + margin-left: 1.25rem; + margin-bottom: 0; } +ul.square li ul, ul.circle li ul, ul.disc li ul { + list-style: inherit; } +ul.square { + list-style-type: square; + margin-left: 1.1rem; } +ul.circle { + list-style-type: circle; + margin-left: 1.1rem; } +ul.disc { + list-style-type: disc; + margin-left: 1.1rem; } +ul.no-bullet { + list-style: none; } + +/* Ordered Lists */ +ol { + margin-left: 1.4rem; } + ol li ul, + ol li ol { + margin-left: 1.25rem; + margin-bottom: 0; } + +/* Definition Lists */ +dl dt { + margin-bottom: 0.3rem; + font-weight: bold; } +dl dd { + margin-bottom: 0.75rem; } + +/* Abbreviations */ +abbr, +acronym { + text-transform: uppercase; + font-size: 90%; + color: #222222; + border-bottom: 1px dotted #dddddd; + cursor: help; } + +abbr { + text-transform: none; } + +/* Blockquotes */ +blockquote { + margin: 0 0 1.25rem; + padding: 0.5625rem 1.25rem 0 1.1875rem; + border-left: 1px solid #dddddd; } + blockquote cite { + display: block; + font-size: 0.8125rem; + color: #555555; } + blockquote cite:before { + content: "\2014 \0020"; } + blockquote cite a, + blockquote cite a:visited { + color: #555555; } + +blockquote, +blockquote p { + line-height: 1.6; + color: #6f6f6f; } + +/* Microformats */ +.vcard { + display: inline-block; + margin: 0 0 1.25rem 0; + border: 1px solid #dddddd; + padding: 0.625rem 0.75rem; } + .vcard li { + margin: 0; + display: block; } + .vcard .fn { + font-weight: bold; + font-size: 0.9375rem; } + +.vevent .summary { + font-weight: bold; } +.vevent abbr { + cursor: default; + text-decoration: none; + font-weight: bold; + border: none; + padding: 0 0.0625rem; } + +@media only screen and (min-width: 40.063em) { + h1, h2, h3, h4, h5, h6 { + line-height: 1.4; } + + h1 { + font-size: 2.75rem; } + + h2 { + font-size: 2.3125rem; } + + h3 { + font-size: 1.6875rem; } + + h4 { + font-size: 1.4375rem; } } +/* + * Print styles. + * + * Inlined to avoid required HTTP connection: www.phpied.com/delay-loading-your-print-css/ + * Credit to Paul Irish and HTML5 Boilerplate (html5boilerplate.com) +*/ +.print-only { + display: none !important; } + +@media print { + * { + background: transparent !important; + color: black !important; + /* Black prints faster: h5bp.com/s */ + box-shadow: none !important; + text-shadow: none !important; } + + a, + a:visited { + text-decoration: underline; } + + a[href]:after { + content: " (" attr(href) ")"; } + + abbr[title]:after { + content: " (" attr(title) ")"; } + + .ir a:after, + a[href^="javascript:"]:after, + a[href^="#"]:after { + content: ""; } + + pre, + blockquote { + border: 1px solid #999999; + page-break-inside: avoid; } + + thead { + display: table-header-group; + /* h5bp.com/t */ } + + tr, + img { + page-break-inside: avoid; } + + img { + max-width: 100% !important; } + + @page { + margin: 0.5cm; } + + p, + h2, + h3 { + orphans: 3; + widows: 3; } + + h2, + h3 { + page-break-after: avoid; } + + .hide-on-print { + display: none !important; } + + .print-only { + display: block !important; } + + .hide-for-print { + display: none !important; } + + .show-for-print { + display: inherit !important; } } +.split.button { + position: relative; + padding-right: 5.0625rem; } + .split.button span { + display: block; + height: 100%; + position: absolute; + right: 0; + top: 0; + border-left: solid 1px; } + .split.button span:before { + position: absolute; + content: ""; + width: 0; + height: 0; + display: block; + border-style: inset; + top: 50%; + left: 50%; } + .split.button span:active { + background-color: rgba(0, 0, 0, 0.1); } + .split.button span { + border-left-color: rgba(255, 255, 255, 0.5); } + .split.button span { + width: 3.09375rem; } + .split.button span:before { + border-top-style: solid; + border-width: 0.375rem; + top: 48%; + margin-left: -0.375rem; } + .split.button span:before { + border-color: white transparent transparent transparent; } + .split.button.secondary span { + border-left-color: rgba(255, 255, 255, 0.5); } + .split.button.secondary span:before { + border-color: white transparent transparent transparent; } + .split.button.alert span { + border-left-color: rgba(255, 255, 255, 0.5); } + .split.button.success span { + border-left-color: rgba(255, 255, 255, 0.5); } + .split.button.tiny { + padding-right: 3.75rem; } + .split.button.tiny span { + width: 2.25rem; } + .split.button.tiny span:before { + border-top-style: solid; + border-width: 0.375rem; + top: 48%; + margin-left: -0.375rem; } + .split.button.small { + padding-right: 4.375rem; } + .split.button.small span { + width: 2.625rem; } + .split.button.small span:before { + border-top-style: solid; + border-width: 0.4375rem; + top: 48%; + margin-left: -0.375rem; } + .split.button.large { + padding-right: 5.5rem; } + .split.button.large span { + width: 3.4375rem; } + .split.button.large span:before { + border-top-style: solid; + border-width: 0.3125rem; + top: 48%; + margin-left: -0.375rem; } + .split.button.expand { + padding-left: 2rem; } + .split.button.secondary span:before { + border-color: #333333 transparent transparent transparent; } + .split.button.radius span { + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; } + .split.button.round span { + border-bottom-right-radius: 1000px; + border-top-right-radius: 1000px; } + +.reveal-modal-bg { + position: fixed; + height: 100%; + width: 100%; + background: black; + background: rgba(0, 0, 0, 0.45); + z-index: 99; + display: none; + top: 0; + left: 0; } + +dialog, .reveal-modal { + visibility: hidden; + display: none; + position: absolute; + z-index: 100; + width: 100vw; + top: 0; + left: 0; + background-color: white; + padding: 1.25rem; + border: solid 1px #666666; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.4); } + @media only screen and (max-width: 40em) { + dialog, .reveal-modal { + min-height: 100vh; } } + @media only screen and (min-width: 40.063em) { + dialog, .reveal-modal { + left: 50%; } } + dialog .column, + dialog .columns, .reveal-modal .column, + .reveal-modal .columns { + min-width: 0; } + dialog > :first-child, .reveal-modal > :first-child { + margin-top: 0; } + dialog > :last-child, .reveal-modal > :last-child { + margin-bottom: 0; } + @media only screen and (min-width: 40.063em) { + dialog, .reveal-modal { + margin-left: -40%; + width: 80%; } } + @media only screen and (min-width: 40.063em) { + dialog, .reveal-modal { + top: 6.25rem; } } + dialog .close-reveal-modal, .reveal-modal .close-reveal-modal { + font-size: 2.5rem; + line-height: 1; + position: absolute; + top: 0.5rem; + right: 0.6875rem; + color: #aaaaaa; + font-weight: bold; + cursor: pointer; } + +dialog[open] { + display: block; + visibility: visible; } + +@media only screen and (min-width: 40.063em) { + dialog, .reveal-modal { + padding: 1.875rem; } + dialog.radius, .reveal-modal.radius { + border-radius: 3px; } + dialog.round, .reveal-modal.round { + border-radius: 1000px; } + dialog.collapse, .reveal-modal.collapse { + padding: 0; } + dialog.full, .reveal-modal.full { + top: 0; + left: 0; + height: 100vh; + min-height: 100vh; + margin-left: 0 !important; } } + @media only screen and (min-width: 40.063em) and (min-width: 40.063em) { + dialog.tiny, .reveal-modal.tiny { + margin-left: -15%; + width: 30%; } } + @media only screen and (min-width: 40.063em) and (min-width: 40.063em) { + dialog.small, .reveal-modal.small { + margin-left: -20%; + width: 40%; } } + @media only screen and (min-width: 40.063em) and (min-width: 40.063em) { + dialog.medium, .reveal-modal.medium { + margin-left: -30%; + width: 60%; } } + @media only screen and (min-width: 40.063em) and (min-width: 40.063em) { + dialog.large, .reveal-modal.large { + margin-left: -35%; + width: 70%; } } + @media only screen and (min-width: 40.063em) and (min-width: 40.063em) { + dialog.xlarge, .reveal-modal.xlarge { + margin-left: -47.5%; + width: 95%; } } + + @media only screen and (min-width: 40.063em) and (min-width: 40.063em) { + dialog.full, .reveal-modal.full { + margin-left: -50vw; + width: 100vw; } } + +@media print { + dialog, .reveal-modal { + background: white !important; } } +/* Tooltips */ +.has-tip { + border-bottom: dotted 1px #cccccc; + cursor: help; + font-weight: bold; + color: #333333; } + .has-tip:hover, .has-tip:focus { + border-bottom: dotted 1px #003f54; + color: #008cba; } + .has-tip.tip-left, .has-tip.tip-right { + float: none !important; } + +.tooltip { + display: none; + position: absolute; + z-index: 999; + font-weight: normal; + font-size: 0.875rem; + line-height: 1.3; + padding: 0.75rem; + max-width: 85%; + left: 50%; + width: 100%; + color: white; + background: #333333; } + .tooltip > .nub { + display: block; + left: 5px; + position: absolute; + width: 0; + height: 0; + border: solid 5px; + border-color: transparent transparent #333333 transparent; + top: -10px; } + .tooltip > .nub.rtl { + left: auto; + right: 5px; } + .tooltip.radius { + border-radius: 3px; } + .tooltip.round { + border-radius: 1000px; } + .tooltip.round > .nub { + left: 2rem; } + .tooltip.opened { + color: #008cba !important; + border-bottom: dotted 1px #003f54 !important; } + +.tap-to-close { + display: block; + font-size: 0.625rem; + color: #777777; + font-weight: normal; } + +@media only screen and (min-width: 40.063em) { + .tooltip > .nub { + border-color: transparent transparent #333333 transparent; + top: -10px; } + .tooltip.tip-top > .nub { + border-color: #333333 transparent transparent transparent; + top: auto; + bottom: -10px; } + .tooltip.tip-left, .tooltip.tip-right { + float: none !important; } + .tooltip.tip-left > .nub { + border-color: transparent transparent transparent #333333; + right: -10px; + left: auto; + top: 50%; + margin-top: -5px; } + .tooltip.tip-right > .nub { + border-color: transparent #333333 transparent transparent; + right: auto; + left: -10px; + top: 50%; + margin-top: -5px; } } +/* Clearing Styles */ +.clearing-thumbs, [data-clearing] { + *zoom: 1; + margin-bottom: 0; + margin-left: 0; + list-style: none; } + .clearing-thumbs:before, .clearing-thumbs:after, [data-clearing]:before, [data-clearing]:after { + content: " "; + display: table; } + .clearing-thumbs:after, [data-clearing]:after { + clear: both; } + .clearing-thumbs li, [data-clearing] li { + float: left; + margin-right: 10px; } + .clearing-thumbs[class*="block-grid-"] li, [data-clearing][class*="block-grid-"] li { + margin-right: 0; } + +.clearing-blackout { + background: #333333; + position: fixed; + width: 100%; + height: 100%; + top: 0; + left: 0; + z-index: 998; } + .clearing-blackout .clearing-close { + display: block; } + +.clearing-container { + position: relative; + z-index: 998; + height: 100%; + overflow: hidden; + margin: 0; } + +.clearing-touch-label { + position: absolute; + top: 50%; + left: 50%; + color: #aaa; + font-size: 0.6em; } + +.visible-img { + height: 95%; + position: relative; } + .visible-img img { + position: absolute; + left: 50%; + top: 50%; + margin-left: -50%; + max-height: 100%; + max-width: 100%; } + +.clearing-caption { + color: #cccccc; + font-size: 0.875em; + line-height: 1.3; + margin-bottom: 0; + text-align: center; + bottom: 0; + background: #333333; + width: 100%; + padding: 10px 30px 20px; + position: absolute; + left: 0; } + +.clearing-close { + z-index: 999; + padding-left: 20px; + padding-top: 10px; + font-size: 30px; + line-height: 1; + color: #cccccc; + display: none; } + .clearing-close:hover, .clearing-close:focus { + color: #ccc; } + +.clearing-assembled .clearing-container { + height: 100%; } + .clearing-assembled .clearing-container .carousel > ul { + display: none; } + +.clearing-feature li { + display: none; } + .clearing-feature li.clearing-featured-img { + display: block; } + +@media only screen and (min-width: 40.063em) { + .clearing-main-prev, + .clearing-main-next { + position: absolute; + height: 100%; + width: 40px; + top: 0; } + .clearing-main-prev > span, + .clearing-main-next > span { + position: absolute; + top: 50%; + display: block; + width: 0; + height: 0; + border: solid 12px; } + .clearing-main-prev > span:hover, + .clearing-main-next > span:hover { + opacity: 0.8; } + + .clearing-main-prev { + left: 0; } + .clearing-main-prev > span { + left: 5px; + border-color: transparent; + border-right-color: #cccccc; } + + .clearing-main-next { + right: 0; } + .clearing-main-next > span { + border-color: transparent; + border-left-color: #cccccc; } + + .clearing-main-prev.disabled, + .clearing-main-next.disabled { + opacity: 0.3; } + + .clearing-assembled .clearing-container .carousel { + background: rgba(51, 51, 51, 0.8); + height: 120px; + margin-top: 10px; + text-align: center; } + .clearing-assembled .clearing-container .carousel > ul { + display: inline-block; + z-index: 999; + height: 100%; + position: relative; + float: none; } + .clearing-assembled .clearing-container .carousel > ul li { + display: block; + width: 120px; + min-height: inherit; + float: left; + overflow: hidden; + margin-right: 0; + padding: 0; + position: relative; + cursor: pointer; + opacity: 0.4; + clear: none; } + .clearing-assembled .clearing-container .carousel > ul li.fix-height img { + height: 100%; + max-width: none; } + .clearing-assembled .clearing-container .carousel > ul li a.th { + border: none; + box-shadow: none; + display: block; } + .clearing-assembled .clearing-container .carousel > ul li img { + cursor: pointer !important; + width: 100% !important; } + .clearing-assembled .clearing-container .carousel > ul li.visible { + opacity: 1; } + .clearing-assembled .clearing-container .carousel > ul li:hover { + opacity: 0.8; } + .clearing-assembled .clearing-container .visible-img { + background: #333333; + overflow: hidden; + height: 85%; } + + .clearing-close { + position: absolute; + top: 10px; + right: 20px; + padding-left: 0; + padding-top: 0; } } +/* Progress Bar */ +.progress { + background-color: #f6f6f6; + height: 1.5625rem; + border: 1px solid white; + padding: 0.125rem; + margin-bottom: 0.625rem; } + .progress .meter { + background: #008cba; + height: 100%; + display: block; } + .progress.secondary .meter { + background: #e7e7e7; + height: 100%; + display: block; } + .progress.success .meter { + background: #43ac6a; + height: 100%; + display: block; } + .progress.alert .meter { + background: #f04124; + height: 100%; + display: block; } + .progress.radius { + border-radius: 3px; } + .progress.radius .meter { + border-radius: 2px; } + .progress.round { + border-radius: 1000px; } + .progress.round .meter { + border-radius: 999px; } + +.sub-nav { + display: block; + width: auto; + overflow: hidden; + margin: -0.25rem 0 1.125rem; + padding-top: 0.25rem; + margin-right: 0; + margin-left: -0.75rem; } + .sub-nav dt { + text-transform: uppercase; } + .sub-nav dt, + .sub-nav dd, + .sub-nav li { + float: left; + display: inline; + margin-left: 1rem; + margin-bottom: 0.625rem; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; + font-weight: normal; + font-size: 0.875rem; + color: #999999; } + .sub-nav dt a, + .sub-nav dd a, + .sub-nav li a { + text-decoration: none; + color: #999999; + padding: 0.1875rem 1rem; } + .sub-nav dt a:hover, + .sub-nav dd a:hover, + .sub-nav li a:hover { + color: #737373; } + .sub-nav dt.active a, + .sub-nav dd.active a, + .sub-nav li.active a { + border-radius: 3px; + font-weight: normal; + background: #008cba; + padding: 0.1875rem 1rem; + cursor: default; + color: white; } + .sub-nav dt.active a:hover, + .sub-nav dd.active a:hover, + .sub-nav li.active a:hover { + background: #0078a0; } + +/* Foundation Joyride */ +.joyride-list { + display: none; } + +/* Default styles for the container */ +.joyride-tip-guide { + display: none; + position: absolute; + background: #333333; + color: white; + z-index: 101; + top: 0; + left: 2.5%; + font-family: inherit; + font-weight: normal; + width: 95%; } + +.lt-ie9 .joyride-tip-guide { + max-width: 800px; + left: 50%; + margin-left: -400px; } + +.joyride-content-wrapper { + width: 100%; + padding: 1.125rem 1.25rem 1.5rem; } + .joyride-content-wrapper .button { + margin-bottom: 0 !important; } + +/* Add a little css triangle pip, older browser just miss out on the fanciness of it */ +.joyride-tip-guide .joyride-nub { + display: block; + position: absolute; + left: 22px; + width: 0; + height: 0; + border: 10px solid #333333; } + .joyride-tip-guide .joyride-nub.top { + border-top-style: solid; + border-color: #333333; + border-top-color: transparent !important; + border-left-color: transparent !important; + border-right-color: transparent !important; + top: -20px; } + .joyride-tip-guide .joyride-nub.bottom { + border-bottom-style: solid; + border-color: #333333 !important; + border-bottom-color: transparent !important; + border-left-color: transparent !important; + border-right-color: transparent !important; + bottom: -20px; } + .joyride-tip-guide .joyride-nub.right { + right: -20px; } + .joyride-tip-guide .joyride-nub.left { + left: -20px; } + +/* Typography */ +.joyride-tip-guide h1, +.joyride-tip-guide h2, +.joyride-tip-guide h3, +.joyride-tip-guide h4, +.joyride-tip-guide h5, +.joyride-tip-guide h6 { + line-height: 1.25; + margin: 0; + font-weight: bold; + color: white; } + +.joyride-tip-guide p { + margin: 0 0 1.125rem 0; + font-size: 0.875rem; + line-height: 1.3; } + +.joyride-timer-indicator-wrap { + width: 50px; + height: 3px; + border: solid 1px #555555; + position: absolute; + right: 1.0625rem; + bottom: 1rem; } + +.joyride-timer-indicator { + display: block; + width: 0; + height: inherit; + background: #666666; } + +.joyride-close-tip { + position: absolute; + right: 12px; + top: 10px; + color: #777777 !important; + text-decoration: none; + font-size: 24px; + font-weight: normal; + line-height: 0.5 !important; } + .joyride-close-tip:hover, .joyride-close-tip:focus { + color: #eeeeee !important; } + +.joyride-modal-bg { + position: fixed; + height: 100%; + width: 100%; + background: transparent; + background: rgba(0, 0, 0, 0.5); + z-index: 100; + display: none; + top: 0; + left: 0; + cursor: pointer; } + +.joyride-expose-wrapper { + background-color: #ffffff; + position: absolute; + border-radius: 3px; + z-index: 102; + box-shadow: 0 0 15px white; } + +.joyride-expose-cover { + background: transparent; + border-radius: 3px; + position: absolute; + z-index: 9999; + top: 0; + left: 0; } + +/* Styles for screens that are at least 768px; */ +@media only screen and (min-width: 40.063em) { + .joyride-tip-guide { + width: 300px; + left: inherit; } + .joyride-tip-guide .joyride-nub.bottom { + border-color: #333333 !important; + border-bottom-color: transparent !important; + border-left-color: transparent !important; + border-right-color: transparent !important; + bottom: -20px; } + .joyride-tip-guide .joyride-nub.right { + border-color: #333333 !important; + border-top-color: transparent !important; + border-right-color: transparent !important; + border-bottom-color: transparent !important; + top: 22px; + left: auto; + right: -20px; } + .joyride-tip-guide .joyride-nub.left { + border-color: #333333 !important; + border-top-color: transparent !important; + border-left-color: transparent !important; + border-bottom-color: transparent !important; + top: 22px; + left: -20px; + right: auto; } } +.label { + font-weight: normal; + font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif; + text-align: center; + text-decoration: none; + line-height: 1; + white-space: nowrap; + display: inline-block; + position: relative; + margin-bottom: inherit; + padding: 0.25rem 0.5rem 0.375rem; + font-size: 0.6875rem; + background-color: #008cba; + color: white; } + .label.radius { + border-radius: 3px; } + .label.round { + border-radius: 1000px; } + .label.alert { + background-color: #f04124; + color: white; } + .label.success { + background-color: #43ac6a; + color: white; } + .label.secondary { + background-color: #e7e7e7; + color: #333333; } + +.off-canvas-wrap { + -webkit-backface-visibility: hidden; + position: relative; + width: 100%; + overflow: hidden; } + .off-canvas-wrap.move-right, .off-canvas-wrap.move-left { + min-height: 100%; + -webkit-overflow-scrolling: touch; } + +.inner-wrap { + -webkit-backface-visibility: hidden; + position: relative; + width: 100%; + *zoom: 1; + -webkit-transition: -webkit-transform 500ms ease; + -moz-transition: -moz-transform 500ms ease; + -ms-transition: -ms-transform 500ms ease; + -o-transition: -o-transform 500ms ease; + transition: transform 500ms ease; } + .inner-wrap:before, .inner-wrap:after { + content: " "; + display: table; } + .inner-wrap:after { + clear: both; } + +.tab-bar { + -webkit-backface-visibility: hidden; + background: #333333; + color: white; + height: 2.8125rem; + line-height: 2.8125rem; + position: relative; } + .tab-bar h1, .tab-bar h2, .tab-bar h3, .tab-bar h4, .tab-bar h5, .tab-bar h6 { + color: white; + font-weight: bold; + line-height: 2.8125rem; + margin: 0; } + .tab-bar h1, .tab-bar h2, .tab-bar h3, .tab-bar h4 { + font-size: 1.125rem; } + +.left-small { + width: 2.8125rem; + height: 2.8125rem; + position: absolute; + top: 0; + border-right: solid 1px #1a1a1a; + left: 0; } + +.right-small { + width: 2.8125rem; + height: 2.8125rem; + position: absolute; + top: 0; + border-left: solid 1px #1a1a1a; + right: 0; } + +.tab-bar-section { + padding: 0 0.625rem; + position: absolute; + text-align: center; + height: 2.8125rem; + top: 0; } + @media only screen and (min-width: 40.063em) { + .tab-bar-section { + text-align: left; } } + .tab-bar-section.left { + left: 0; + right: 2.8125rem; } + .tab-bar-section.right { + left: 2.8125rem; + right: 0; } + .tab-bar-section.middle { + left: 2.8125rem; + right: 2.8125rem; } + +.tab-bar .menu-icon { + text-indent: 2.1875rem; + width: 2.8125rem; + height: 2.8125rem; + display: block; + line-height: 2.0625rem; + padding: 0; + color: white; + position: relative; + -ms-transform: translate(0, 0); + -webkit-transform: translate3d(0, 0, 0); + -moz-transform: translate3d(0, 0, 0); + -ms-transform: translate3d(0, 0, 0); + -o-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); } + .tab-bar .menu-icon span { + position: absolute; + display: block; + height: 0; + width: 1rem; + line-height: 1; + top: 0.9375rem; + left: 0.90625rem; + box-shadow: 0 0px 0 1px white, 0 7px 0 1px white, 0 14px 0 1px white; } + .tab-bar .menu-icon:hover span { + box-shadow: 0 0px 0 1px #b3b3b3, 0 7px 0 1px #b3b3b3, 0 14px 0 1px #b3b3b3; } + +.left-off-canvas-menu { + -webkit-backface-visibility: hidden; + width: 15.625rem; + top: 0; + bottom: 0; + position: absolute; + overflow-y: auto; + background: #333333; + z-index: 1001; + box-sizing: content-box; + -webkit-overflow-scrolling: touch; + -ms-transform: translate(-100%, 0); + -webkit-transform: translate3d(-100%, 0, 0); + -moz-transform: translate3d(-100%, 0, 0); + -ms-transform: translate3d(-100%, 0, 0); + -o-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + left: 0; } + .left-off-canvas-menu * { + -webkit-backface-visibility: hidden; } + +.right-off-canvas-menu { + -webkit-backface-visibility: hidden; + width: 15.625rem; + top: 0; + bottom: 0; + position: absolute; + overflow-y: auto; + background: #333333; + z-index: 1001; + box-sizing: content-box; + -webkit-overflow-scrolling: touch; + -ms-transform: translate(100%, 0); + -webkit-transform: translate3d(100%, 0, 0); + -moz-transform: translate3d(100%, 0, 0); + -ms-transform: translate3d(100%, 0, 0); + -o-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + right: 0; } + .right-off-canvas-menu * { + -webkit-backface-visibility: hidden; } + +ul.off-canvas-list { + list-style-type: none; + padding: 0; + margin: 0; } + ul.off-canvas-list li label { + padding: 0.3rem 0.9375rem; + color: #999999; + text-transform: uppercase; + font-weight: bold; + background: #444444; + border-top: 1px solid #5e5e5e; + border-bottom: none; + margin: 0; } + ul.off-canvas-list li a { + display: block; + padding: 0.66667rem; + color: rgba(255, 255, 255, 0.7); + border-bottom: 1px solid #262626; + transition: background 300ms ease; } + ul.off-canvas-list li a:hover { + background: #242424; } + +.move-right > .inner-wrap { + -ms-transform: translate(15.625rem, 0); + -webkit-transform: translate3d(15.625rem, 0, 0); + -moz-transform: translate3d(15.625rem, 0, 0); + -ms-transform: translate3d(15.625rem, 0, 0); + -o-transform: translate3d(15.625rem, 0, 0); + transform: translate3d(15.625rem, 0, 0); } +.move-right .exit-off-canvas { + -webkit-backface-visibility: hidden; + transition: background 300ms ease; + cursor: pointer; + box-shadow: -4px 0 4px rgba(0, 0, 0, 0.5), 4px 0 4px rgba(0, 0, 0, 0.5); + display: block; + position: absolute; + background: rgba(255, 255, 255, 0.2); + top: 0; + bottom: 0; + left: 0; + right: 0; + z-index: 1002; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } + @media only screen and (min-width: 40.063em) { + .move-right .exit-off-canvas:hover { + background: rgba(255, 255, 255, 0.05); } } + +.move-left > .inner-wrap { + -ms-transform: translate(-15.625rem, 0); + -webkit-transform: translate3d(-15.625rem, 0, 0); + -moz-transform: translate3d(-15.625rem, 0, 0); + -ms-transform: translate3d(-15.625rem, 0, 0); + -o-transform: translate3d(-15.625rem, 0, 0); + transform: translate3d(-15.625rem, 0, 0); } +.move-left .exit-off-canvas { + -webkit-backface-visibility: hidden; + transition: background 300ms ease; + cursor: pointer; + box-shadow: -4px 0 4px rgba(0, 0, 0, 0.5), 4px 0 4px rgba(0, 0, 0, 0.5); + display: block; + position: absolute; + background: rgba(255, 255, 255, 0.2); + top: 0; + bottom: 0; + left: 0; + right: 0; + z-index: 1002; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } + @media only screen and (min-width: 40.063em) { + .move-left .exit-off-canvas:hover { + background: rgba(255, 255, 255, 0.05); } } + +.no-csstransforms .left-off-canvas-menu { + left: -15.625rem; } +.no-csstransforms .right-off-canvas-menu { + right: -15.625rem; } +.no-csstransforms .move-left > .inner-wrap { + right: 15.625rem; } +.no-csstransforms .move-right > .inner-wrap { + left: 15.625rem; } + +/* Foundation Dropdowns */ +.f-dropdown { + position: absolute; + left: -9999px; + list-style: none; + margin-left: 0; + width: 100%; + max-height: none; + height: auto; + background: white; + border: solid 1px #cccccc; + font-size: 0.875rem; + z-index: 99; + margin-top: 2px; + max-width: 200px; } + .f-dropdown > *:first-child { + margin-top: 0; } + .f-dropdown > *:last-child { + margin-bottom: 0; } + .f-dropdown:before { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 6px; + border-color: transparent transparent white transparent; + border-bottom-style: solid; + position: absolute; + top: -12px; + left: 10px; + z-index: 99; } + .f-dropdown:after { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 7px; + border-color: transparent transparent #cccccc transparent; + border-bottom-style: solid; + position: absolute; + top: -14px; + left: 9px; + z-index: 98; } + .f-dropdown.right:before { + left: auto; + right: 10px; } + .f-dropdown.right:after { + left: auto; + right: 9px; } + .f-dropdown.drop-right { + position: absolute; + left: -9999px; + list-style: none; + margin-left: 0; + width: 100%; + max-height: none; + height: auto; + background: white; + border: solid 1px #cccccc; + font-size: 0.875rem; + z-index: 99; + margin-top: 0; + margin-left: 2px; + max-width: 200px; } + .f-dropdown.drop-right > *:first-child { + margin-top: 0; } + .f-dropdown.drop-right > *:last-child { + margin-bottom: 0; } + .f-dropdown.drop-right:before { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 6px; + border-color: transparent white transparent transparent; + border-right-style: solid; + position: absolute; + top: 10px; + left: -12px; + z-index: 99; } + .f-dropdown.drop-right:after { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 7px; + border-color: transparent #cccccc transparent transparent; + border-right-style: solid; + position: absolute; + top: 9px; + left: -14px; + z-index: 98; } + .f-dropdown.drop-left { + position: absolute; + left: -9999px; + list-style: none; + margin-left: 0; + width: 100%; + max-height: none; + height: auto; + background: white; + border: solid 1px #cccccc; + font-size: 0.875rem; + z-index: 99; + margin-top: 0; + margin-left: -2px; + max-width: 200px; } + .f-dropdown.drop-left > *:first-child { + margin-top: 0; } + .f-dropdown.drop-left > *:last-child { + margin-bottom: 0; } + .f-dropdown.drop-left:before { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 6px; + border-color: transparent transparent transparent white; + border-left-style: solid; + position: absolute; + top: 10px; + right: -12px; + left: auto; + z-index: 99; } + .f-dropdown.drop-left:after { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 7px; + border-color: transparent transparent transparent #cccccc; + border-left-style: solid; + position: absolute; + top: 9px; + right: -14px; + left: auto; + z-index: 98; } + .f-dropdown.drop-top { + position: absolute; + left: -9999px; + list-style: none; + margin-left: 0; + width: 100%; + max-height: none; + height: auto; + background: white; + border: solid 1px #cccccc; + font-size: 0.875rem; + z-index: 99; + margin-top: -2px; + margin-left: 0; + max-width: 200px; } + .f-dropdown.drop-top > *:first-child { + margin-top: 0; } + .f-dropdown.drop-top > *:last-child { + margin-bottom: 0; } + .f-dropdown.drop-top:before { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 6px; + border-color: white transparent transparent transparent; + border-top-style: solid; + position: absolute; + top: auto; + bottom: -12px; + left: 10px; + right: auto; + z-index: 99; } + .f-dropdown.drop-top:after { + content: ""; + display: block; + width: 0; + height: 0; + border: inset 7px; + border-color: #cccccc transparent transparent transparent; + border-top-style: solid; + position: absolute; + top: auto; + bottom: -14px; + left: 9px; + right: auto; + z-index: 98; } + .f-dropdown li { + font-size: 0.875rem; + cursor: pointer; + line-height: 1.125rem; + margin: 0; } + .f-dropdown li:hover, .f-dropdown li:focus { + background: #eeeeee; } + .f-dropdown li a { + display: block; + padding: 0.5rem; + color: #555555; } + .f-dropdown.content { + position: absolute; + left: -9999px; + list-style: none; + margin-left: 0; + padding: 1.25rem; + width: 100%; + height: auto; + max-height: none; + background: white; + border: solid 1px #cccccc; + font-size: 0.875rem; + z-index: 99; + max-width: 200px; } + .f-dropdown.content > *:first-child { + margin-top: 0; } + .f-dropdown.content > *:last-child { + margin-bottom: 0; } + .f-dropdown.tiny { + max-width: 200px; } + .f-dropdown.small { + max-width: 300px; } + .f-dropdown.medium { + max-width: 500px; } + .f-dropdown.large { + max-width: 800px; } + +table { + background: white; + margin-bottom: 1.25rem; + border: solid 1px #dddddd; } + table thead, + table tfoot { + background: whitesmoke; } + table thead tr th, + table thead tr td, + table tfoot tr th, + table tfoot tr td { + padding: 0.5rem 0.625rem 0.625rem; + font-size: 0.875rem; + font-weight: bold; + color: #222222; + text-align: left; } + table tr th, + table tr td { + padding: 0.5625rem 0.625rem; + font-size: 0.875rem; + color: #222222; } + table tr.even, table tr.alt, table tr:nth-of-type(even) { + background: #f9f9f9; } + table thead tr th, + table tfoot tr th, + table tbody tr td, + table tr td, + table tfoot tr td { + display: table-cell; + line-height: 1.125rem; } + +/* Standard Forms */ +form { + margin: 0 0 1rem; } + +/* Using forms within rows, we need to set some defaults */ +form .row .row { + margin: 0 -0.5rem; } + form .row .row .column, + form .row .row .columns { + padding: 0 0.5rem; } + form .row .row.collapse { + margin: 0; } + form .row .row.collapse .column, + form .row .row.collapse .columns { + padding: 0; } + form .row .row.collapse input { + border-bottom-right-radius: 0; + border-top-right-radius: 0; } +form .row input.column, +form .row input.columns, +form .row textarea.column, +form .row textarea.columns { + padding-left: 0.5rem; } + +/* Label Styles */ +label { + font-size: 0.875rem; + color: #4d4d4d; + cursor: pointer; + display: block; + font-weight: normal; + line-height: 1.5; + margin-bottom: 0; + /* Styles for required inputs */ } + label.right { + float: none; + text-align: right; } + label.inline { + margin: 0 0 1rem 0; + padding: 0.5625rem 0; } + label small { + text-transform: capitalize; + color: #676767; } + +select::-ms-expand { + display: none; } + +@-moz-document url-prefix() { + select { + background: #fafafa; } + + select:hover { + background: #f3f3f3; } } + +/* Attach elements to the beginning or end of an input */ +.prefix, +.postfix { + display: block; + position: relative; + z-index: 2; + text-align: center; + width: 100%; + padding-top: 0; + padding-bottom: 0; + border-style: solid; + border-width: 1px; + overflow: hidden; + font-size: 0.875rem; + height: 2.3125rem; + line-height: 2.3125rem; } + +/* Adjust padding, alignment and radius if pre/post element is a button */ +.postfix.button { + padding-left: 0; + padding-right: 0; + padding-top: 0; + padding-bottom: 0; + text-align: center; + line-height: 2.125rem; + border: none; } + +.prefix.button { + padding-left: 0; + padding-right: 0; + padding-top: 0; + padding-bottom: 0; + text-align: center; + line-height: 2.125rem; + border: none; } + +.prefix.button.radius { + border-radius: 0; + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; } + +.postfix.button.radius { + border-radius: 0; + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; } + +.prefix.button.round { + border-radius: 0; + border-bottom-left-radius: 1000px; + border-top-left-radius: 1000px; } + +.postfix.button.round { + border-radius: 0; + border-bottom-right-radius: 1000px; + border-top-right-radius: 1000px; } + +/* Separate prefix and postfix styles when on span or label so buttons keep their own */ +span.prefix, label.prefix { + background: #f2f2f2; + border-right: none; + color: #333333; + border-color: #cccccc; } + span.prefix.radius, label.prefix.radius { + border-radius: 0; + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; } + +span.postfix, label.postfix { + background: #f2f2f2; + border-left: none; + color: #333333; + border-color: #cccccc; } + span.postfix.radius, label.postfix.radius { + border-radius: 0; + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; } + +/* We use this to get basic styling on all basic form elements */ +input[type="text"], +input[type="password"], +input[type="date"], +input[type="datetime"], +input[type="datetime-local"], +input[type="month"], +input[type="week"], +input[type="email"], +input[type="number"], +input[type="search"], +input[type="tel"], +input[type="time"], +input[type="url"], +textarea { + -webkit-appearance: none; + background-color: white; + font-family: inherit; + border: 1px solid #cccccc; + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + color: rgba(0, 0, 0, 0.75); + display: block; + font-size: 0.875rem; + margin: 0 0 1rem 0; + padding: 0.5rem; + height: 2.3125rem; + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + transition: box-shadow 0.45s, border-color 0.45s ease-in-out; } + input[type="text"]:focus, + input[type="password"]:focus, + input[type="date"]:focus, + input[type="datetime"]:focus, + input[type="datetime-local"]:focus, + input[type="month"]:focus, + input[type="week"]:focus, + input[type="email"]:focus, + input[type="number"]:focus, + input[type="search"]:focus, + input[type="tel"]:focus, + input[type="time"]:focus, + input[type="url"]:focus, + textarea:focus { + box-shadow: 0 0 5px #999999; + border-color: #999999; } + input[type="text"]:focus, + input[type="password"]:focus, + input[type="date"]:focus, + input[type="datetime"]:focus, + input[type="datetime-local"]:focus, + input[type="month"]:focus, + input[type="week"]:focus, + input[type="email"]:focus, + input[type="number"]:focus, + input[type="search"]:focus, + input[type="tel"]:focus, + input[type="time"]:focus, + input[type="url"]:focus, + textarea:focus { + background: #fafafa; + border-color: #999999; + outline: none; } + input[type="text"][disabled], fieldset[disabled] input[type="text"], + input[type="password"][disabled], fieldset[disabled] + input[type="password"], + input[type="date"][disabled], fieldset[disabled] + input[type="date"], + input[type="datetime"][disabled], fieldset[disabled] + input[type="datetime"], + input[type="datetime-local"][disabled], fieldset[disabled] + input[type="datetime-local"], + input[type="month"][disabled], fieldset[disabled] + input[type="month"], + input[type="week"][disabled], fieldset[disabled] + input[type="week"], + input[type="email"][disabled], fieldset[disabled] + input[type="email"], + input[type="number"][disabled], fieldset[disabled] + input[type="number"], + input[type="search"][disabled], fieldset[disabled] + input[type="search"], + input[type="tel"][disabled], fieldset[disabled] + input[type="tel"], + input[type="time"][disabled], fieldset[disabled] + input[type="time"], + input[type="url"][disabled], fieldset[disabled] + input[type="url"], + textarea[disabled], fieldset[disabled] + textarea { + background-color: #dddddd; } + input[type="text"].radius, + input[type="password"].radius, + input[type="date"].radius, + input[type="datetime"].radius, + input[type="datetime-local"].radius, + input[type="month"].radius, + input[type="week"].radius, + input[type="email"].radius, + input[type="number"].radius, + input[type="search"].radius, + input[type="tel"].radius, + input[type="time"].radius, + input[type="url"].radius, + textarea.radius { + border-radius: 3px; } + +input[type="submit"] { + -webkit-appearance: none; } + +/* Respect enforced amount of rows for textarea */ +textarea[rows] { + height: auto; } + +/* Add height value for select elements to match text input height */ +select { + -webkit-appearance: none !important; + background-color: #fafafa; + background-image: url("data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iM3B4IiB2aWV3Qm94PSIwIDAgNiAzIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA2IDMiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwb2x5Z29uIHBvaW50cz0iNS45OTIsMCAyLjk5MiwzIC0wLjAwOCwwICIvPjwvc3ZnPg=="); + background-repeat: no-repeat; + background-position: 97% center; + border: 1px solid #cccccc; + padding: 0.5rem; + font-size: 0.875rem; + border-radius: 0; + height: 2.3125rem; } + select.radius { + border-radius: 3px; } + select:hover { + background-color: #f3f3f3; + border-color: #999999; } + +/* Adjust margin for form elements below */ +input[type="file"], +input[type="checkbox"], +input[type="radio"], +select { + margin: 0 0 1rem 0; } + +input[type="checkbox"] + label, +input[type="radio"] + label { + display: inline-block; + margin-left: 0.5rem; + margin-right: 1rem; + margin-bottom: 0; + vertical-align: baseline; } + +/* Normalize file input width */ +input[type="file"] { + width: 100%; } + +/* We add basic fieldset styling */ +fieldset { + border: 1px solid #dddddd; + padding: 1.25rem; + margin: 1.125rem 0; } + fieldset legend { + font-weight: bold; + background: white; + padding: 0 0.1875rem; + margin: 0; + margin-left: -0.1875rem; } + +/* Error Handling */ +[data-abide] .error small.error, [data-abide] span.error, [data-abide] small.error { + display: block; + padding: 0.375rem 0.5625rem 0.5625rem; + margin-top: -1px; + margin-bottom: 1rem; + font-size: 0.75rem; + font-weight: normal; + font-style: italic; + background: #f04124; + color: white; } +[data-abide] span.error, [data-abide] small.error { + display: none; } + +span.error, small.error { + display: block; + padding: 0.375rem 0.5625rem 0.5625rem; + margin-top: -1px; + margin-bottom: 1rem; + font-size: 0.75rem; + font-weight: normal; + font-style: italic; + background: #f04124; + color: white; } + +.error input, +.error textarea, +.error select { + margin-bottom: 0; } +.error input[type="checkbox"], +.error input[type="radio"] { + margin-bottom: 1rem; } +.error label, +.error label.error { + color: #f04124; } +.error small.error { + display: block; + padding: 0.375rem 0.5625rem 0.5625rem; + margin-top: -1px; + margin-bottom: 1rem; + font-size: 0.75rem; + font-weight: normal; + font-style: italic; + background: #f04124; + color: white; } +.error > label > small { + color: #676767; + background: transparent; + padding: 0; + text-transform: capitalize; + font-style: normal; + font-size: 60%; + margin: 0; + display: inline; } +.error span.error-message { + display: block; } + +input.error, +textarea.error { + margin-bottom: 0; } + +label.error { + color: #f04124; } + +.range-slider { + display: block; + position: relative; + width: 100%; + height: 1rem; + border: 1px solid #dddddd; + margin: 1.25rem 0; + -ms-touch-action: none; + touch-action: none; + background: #fafafa; } + .range-slider.vertical-range { + display: block; + position: relative; + width: 100%; + height: 1rem; + border: 1px solid #dddddd; + margin: 1.25rem 0; + -ms-touch-action: none; + touch-action: none; + display: inline-block; + width: 1rem; + height: 12.5rem; } + .range-slider.vertical-range .range-slider-handle { + margin-top: 0; + margin-left: -0.5rem; + position: absolute; + bottom: -10.5rem; } + .range-slider.vertical-range .range-slider-active-segment { + width: 0.875rem; + height: auto; + bottom: 0; } + .range-slider.radius { + background: #fafafa; + border-radius: 3px; } + .range-slider.radius .range-slider-handle { + background: #008cba; + border-radius: 3px; } + .range-slider.radius .range-slider-handle:hover { + background: #007ba4; } + .range-slider.round { + background: #fafafa; + border-radius: 1000px; } + .range-slider.round .range-slider-handle { + background: #008cba; + border-radius: 1000px; } + .range-slider.round .range-slider-handle:hover { + background: #007ba4; } + +.range-slider-active-segment { + display: inline-block; + position: absolute; + height: 0.875rem; + background: #e5e5e5; } + +.range-slider-handle { + display: inline-block; + position: absolute; + z-index: 1; + top: -0.3125rem; + width: 2rem; + height: 1.375rem; + border: 1px solid none; + cursor: pointer; + background: #008cba; } + .range-slider-handle:hover { + background: #007ba4; } + +[class*="block-grid-"] { + display: block; + padding: 0; + margin: 0 -0.625rem; + *zoom: 1; } + [class*="block-grid-"]:before, [class*="block-grid-"]:after { + content: " "; + display: table; } + [class*="block-grid-"]:after { + clear: both; } + [class*="block-grid-"] > li { + display: block; + height: auto; + float: left; + padding: 0 0.625rem 1.25rem; } + +@media only screen { + .small-block-grid-1 > li { + width: 100%; + list-style: none; } + .small-block-grid-1 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-1 > li:nth-of-type(1n+1) { + clear: both; } + + .small-block-grid-2 > li { + width: 50%; + list-style: none; } + .small-block-grid-2 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-2 > li:nth-of-type(2n+1) { + clear: both; } + + .small-block-grid-3 > li { + width: 33.33333%; + list-style: none; } + .small-block-grid-3 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-3 > li:nth-of-type(3n+1) { + clear: both; } + + .small-block-grid-4 > li { + width: 25%; + list-style: none; } + .small-block-grid-4 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-4 > li:nth-of-type(4n+1) { + clear: both; } + + .small-block-grid-5 > li { + width: 20%; + list-style: none; } + .small-block-grid-5 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-5 > li:nth-of-type(5n+1) { + clear: both; } + + .small-block-grid-6 > li { + width: 16.66667%; + list-style: none; } + .small-block-grid-6 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-6 > li:nth-of-type(6n+1) { + clear: both; } + + .small-block-grid-7 > li { + width: 14.28571%; + list-style: none; } + .small-block-grid-7 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-7 > li:nth-of-type(7n+1) { + clear: both; } + + .small-block-grid-8 > li { + width: 12.5%; + list-style: none; } + .small-block-grid-8 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-8 > li:nth-of-type(8n+1) { + clear: both; } + + .small-block-grid-9 > li { + width: 11.11111%; + list-style: none; } + .small-block-grid-9 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-9 > li:nth-of-type(9n+1) { + clear: both; } + + .small-block-grid-10 > li { + width: 10%; + list-style: none; } + .small-block-grid-10 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-10 > li:nth-of-type(10n+1) { + clear: both; } + + .small-block-grid-11 > li { + width: 9.09091%; + list-style: none; } + .small-block-grid-11 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-11 > li:nth-of-type(11n+1) { + clear: both; } + + .small-block-grid-12 > li { + width: 8.33333%; + list-style: none; } + .small-block-grid-12 > li:nth-of-type(n) { + clear: none; } + .small-block-grid-12 > li:nth-of-type(12n+1) { + clear: both; } } +@media only screen and (min-width: 40.063em) { + .medium-block-grid-1 > li { + width: 100%; + list-style: none; } + .medium-block-grid-1 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-1 > li:nth-of-type(1n+1) { + clear: both; } + + .medium-block-grid-2 > li { + width: 50%; + list-style: none; } + .medium-block-grid-2 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-2 > li:nth-of-type(2n+1) { + clear: both; } + + .medium-block-grid-3 > li { + width: 33.33333%; + list-style: none; } + .medium-block-grid-3 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-3 > li:nth-of-type(3n+1) { + clear: both; } + + .medium-block-grid-4 > li { + width: 25%; + list-style: none; } + .medium-block-grid-4 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-4 > li:nth-of-type(4n+1) { + clear: both; } + + .medium-block-grid-5 > li { + width: 20%; + list-style: none; } + .medium-block-grid-5 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-5 > li:nth-of-type(5n+1) { + clear: both; } + + .medium-block-grid-6 > li { + width: 16.66667%; + list-style: none; } + .medium-block-grid-6 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-6 > li:nth-of-type(6n+1) { + clear: both; } + + .medium-block-grid-7 > li { + width: 14.28571%; + list-style: none; } + .medium-block-grid-7 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-7 > li:nth-of-type(7n+1) { + clear: both; } + + .medium-block-grid-8 > li { + width: 12.5%; + list-style: none; } + .medium-block-grid-8 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-8 > li:nth-of-type(8n+1) { + clear: both; } + + .medium-block-grid-9 > li { + width: 11.11111%; + list-style: none; } + .medium-block-grid-9 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-9 > li:nth-of-type(9n+1) { + clear: both; } + + .medium-block-grid-10 > li { + width: 10%; + list-style: none; } + .medium-block-grid-10 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-10 > li:nth-of-type(10n+1) { + clear: both; } + + .medium-block-grid-11 > li { + width: 9.09091%; + list-style: none; } + .medium-block-grid-11 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-11 > li:nth-of-type(11n+1) { + clear: both; } + + .medium-block-grid-12 > li { + width: 8.33333%; + list-style: none; } + .medium-block-grid-12 > li:nth-of-type(n) { + clear: none; } + .medium-block-grid-12 > li:nth-of-type(12n+1) { + clear: both; } } +@media only screen and (min-width: 64.063em) { + .large-block-grid-1 > li { + width: 100%; + list-style: none; } + .large-block-grid-1 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-1 > li:nth-of-type(1n+1) { + clear: both; } + + .large-block-grid-2 > li { + width: 50%; + list-style: none; } + .large-block-grid-2 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-2 > li:nth-of-type(2n+1) { + clear: both; } + + .large-block-grid-3 > li { + width: 33.33333%; + list-style: none; } + .large-block-grid-3 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-3 > li:nth-of-type(3n+1) { + clear: both; } + + .large-block-grid-4 > li { + width: 25%; + list-style: none; } + .large-block-grid-4 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-4 > li:nth-of-type(4n+1) { + clear: both; } + + .large-block-grid-5 > li { + width: 20%; + list-style: none; } + .large-block-grid-5 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-5 > li:nth-of-type(5n+1) { + clear: both; } + + .large-block-grid-6 > li { + width: 16.66667%; + list-style: none; } + .large-block-grid-6 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-6 > li:nth-of-type(6n+1) { + clear: both; } + + .large-block-grid-7 > li { + width: 14.28571%; + list-style: none; } + .large-block-grid-7 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-7 > li:nth-of-type(7n+1) { + clear: both; } + + .large-block-grid-8 > li { + width: 12.5%; + list-style: none; } + .large-block-grid-8 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-8 > li:nth-of-type(8n+1) { + clear: both; } + + .large-block-grid-9 > li { + width: 11.11111%; + list-style: none; } + .large-block-grid-9 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-9 > li:nth-of-type(9n+1) { + clear: both; } + + .large-block-grid-10 > li { + width: 10%; + list-style: none; } + .large-block-grid-10 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-10 > li:nth-of-type(10n+1) { + clear: both; } + + .large-block-grid-11 > li { + width: 9.09091%; + list-style: none; } + .large-block-grid-11 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-11 > li:nth-of-type(11n+1) { + clear: both; } + + .large-block-grid-12 > li { + width: 8.33333%; + list-style: none; } + .large-block-grid-12 > li:nth-of-type(n) { + clear: none; } + .large-block-grid-12 > li:nth-of-type(12n+1) { + clear: both; } } +.flex-video { + position: relative; + padding-top: 1.5625rem; + padding-bottom: 67.5%; + height: 0; + margin-bottom: 1rem; + overflow: hidden; } + .flex-video.widescreen { + padding-bottom: 56.34%; } + .flex-video.vimeo { + padding-top: 0; } + .flex-video iframe, + .flex-video object, + .flex-video embed, + .flex-video video { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; } + +.keystroke, +kbd { + background-color: #ededed; + border-color: #dddddd; + color: #222222; + border-style: solid; + border-width: 1px; + margin: 0; + font-family: "Consolas", "Menlo", "Courier", monospace; + font-size: inherit; + padding: 0.125rem 0.25rem 0; + border-radius: 3px; } + +/* small displays */ +@media only screen { + .show-for-small-only, .show-for-small-up, .show-for-small, .show-for-small-down, .hide-for-medium-only, .hide-for-medium-up, .hide-for-medium, .show-for-medium-down, .hide-for-large-only, .hide-for-large-up, .hide-for-large, .show-for-large-down, .hide-for-xlarge-only, .hide-for-xlarge-up, .hide-for-xxlarge-only, .hide-for-xxlarge-up { + display: inherit !important; } + + .hide-for-small-only, .hide-for-small-up, .hide-for-small, .hide-for-small-down, .show-for-medium-only, .show-for-medium-up, .show-for-medium, .hide-for-medium-down, .show-for-large-only, .show-for-large-up, .show-for-large, .hide-for-large-down, .show-for-xlarge-only, .show-for-xlarge-up, .show-for-xxlarge-only, .show-for-xxlarge-up { + display: none !important; } + + table.show-for-small-only, table.show-for-small-up, table.show-for-small, table.show-for-small-down, table.hide-for-medium-only, table.hide-for-medium-up, table.hide-for-medium, table.show-for-medium-down, table.hide-for-large-only, table.hide-for-large-up, table.hide-for-large, table.show-for-large-down, table.hide-for-xlarge-only, table.hide-for-xlarge-up, table.hide-for-xxlarge-only, table.hide-for-xxlarge-up { + display: table; } + + thead.show-for-small-only, thead.show-for-small-up, thead.show-for-small, thead.show-for-small-down, thead.hide-for-medium-only, thead.hide-for-medium-up, thead.hide-for-medium, thead.show-for-medium-down, thead.hide-for-large-only, thead.hide-for-large-up, thead.hide-for-large, thead.show-for-large-down, thead.hide-for-xlarge-only, thead.hide-for-xlarge-up, thead.hide-for-xxlarge-only, thead.hide-for-xxlarge-up { + display: table-header-group !important; } + + tbody.show-for-small-only, tbody.show-for-small-up, tbody.show-for-small, tbody.show-for-small-down, tbody.hide-for-medium-only, tbody.hide-for-medium-up, tbody.hide-for-medium, tbody.show-for-medium-down, tbody.hide-for-large-only, tbody.hide-for-large-up, tbody.hide-for-large, tbody.show-for-large-down, tbody.hide-for-xlarge-only, tbody.hide-for-xlarge-up, tbody.hide-for-xxlarge-only, tbody.hide-for-xxlarge-up { + display: table-row-group !important; } + + tr.show-for-small-only, tr.show-for-small-up, tr.show-for-small, tr.show-for-small-down, tr.hide-for-medium-only, tr.hide-for-medium-up, tr.hide-for-medium, tr.show-for-medium-down, tr.hide-for-large-only, tr.hide-for-large-up, tr.hide-for-large, tr.show-for-large-down, tr.hide-for-xlarge-only, tr.hide-for-xlarge-up, tr.hide-for-xxlarge-only, tr.hide-for-xxlarge-up { + display: table-row !important; } + + th.show-for-small-only, td.show-for-small-only, th.show-for-small-up, td.show-for-small-up, th.show-for-small, td.show-for-small, th.show-for-small-down, td.show-for-small-down, th.hide-for-medium-only, td.hide-for-medium-only, th.hide-for-medium-up, td.hide-for-medium-up, th.hide-for-medium, td.hide-for-medium, th.show-for-medium-down, td.show-for-medium-down, th.hide-for-large-only, td.hide-for-large-only, th.hide-for-large-up, td.hide-for-large-up, th.hide-for-large, td.hide-for-large, th.show-for-large-down, td.show-for-large-down, th.hide-for-xlarge-only, td.hide-for-xlarge-only, th.hide-for-xlarge-up, td.hide-for-xlarge-up, th.hide-for-xxlarge-only, td.hide-for-xxlarge-only, th.hide-for-xxlarge-up, td.hide-for-xxlarge-up { + display: table-cell !important; } } +/* medium displays */ +@media only screen and (min-width: 40.063em) { + .hide-for-small-only, .show-for-small-up, .hide-for-small, .hide-for-small-down, .show-for-medium-only, .show-for-medium-up, .show-for-medium, .show-for-medium-down, .hide-for-large-only, .hide-for-large-up, .hide-for-large, .show-for-large-down, .hide-for-xlarge-only, .hide-for-xlarge-up, .hide-for-xxlarge-only, .hide-for-xxlarge-up { + display: inherit !important; } + + .show-for-small-only, .hide-for-small-up, .show-for-small, .show-for-small-down, .hide-for-medium-only, .hide-for-medium-up, .hide-for-medium, .hide-for-medium-down, .show-for-large-only, .show-for-large-up, .show-for-large, .hide-for-large-down, .show-for-xlarge-only, .show-for-xlarge-up, .show-for-xxlarge-only, .show-for-xxlarge-up { + display: none !important; } + + table.hide-for-small-only, table.show-for-small-up, table.hide-for-small, table.hide-for-small-down, table.show-for-medium-only, table.show-for-medium-up, table.show-for-medium, table.show-for-medium-down, table.hide-for-large-only, table.hide-for-large-up, table.hide-for-large, table.show-for-large-down, table.hide-for-xlarge-only, table.hide-for-xlarge-up, table.hide-for-xxlarge-only, table.hide-for-xxlarge-up { + display: table; } + + thead.hide-for-small-only, thead.show-for-small-up, thead.hide-for-small, thead.hide-for-small-down, thead.show-for-medium-only, thead.show-for-medium-up, thead.show-for-medium, thead.show-for-medium-down, thead.hide-for-large-only, thead.hide-for-large-up, thead.hide-for-large, thead.show-for-large-down, thead.hide-for-xlarge-only, thead.hide-for-xlarge-up, thead.hide-for-xxlarge-only, thead.hide-for-xxlarge-up { + display: table-header-group !important; } + + tbody.hide-for-small-only, tbody.show-for-small-up, tbody.hide-for-small, tbody.hide-for-small-down, tbody.show-for-medium-only, tbody.show-for-medium-up, tbody.show-for-medium, tbody.show-for-medium-down, tbody.hide-for-large-only, tbody.hide-for-large-up, tbody.hide-for-large, tbody.show-for-large-down, tbody.hide-for-xlarge-only, tbody.hide-for-xlarge-up, tbody.hide-for-xxlarge-only, tbody.hide-for-xxlarge-up { + display: table-row-group !important; } + + tr.hide-for-small-only, tr.show-for-small-up, tr.hide-for-small, tr.hide-for-small-down, tr.show-for-medium-only, tr.show-for-medium-up, tr.show-for-medium, tr.show-for-medium-down, tr.hide-for-large-only, tr.hide-for-large-up, tr.hide-for-large, tr.show-for-large-down, tr.hide-for-xlarge-only, tr.hide-for-xlarge-up, tr.hide-for-xxlarge-only, tr.hide-for-xxlarge-up { + display: table-row !important; } + + th.hide-for-small-only, td.hide-for-small-only, th.show-for-small-up, td.show-for-small-up, th.hide-for-small, td.hide-for-small, th.hide-for-small-down, td.hide-for-small-down, th.show-for-medium-only, td.show-for-medium-only, th.show-for-medium-up, td.show-for-medium-up, th.show-for-medium, td.show-for-medium, th.show-for-medium-down, td.show-for-medium-down, th.hide-for-large-only, td.hide-for-large-only, th.hide-for-large-up, td.hide-for-large-up, th.hide-for-large, td.hide-for-large, th.show-for-large-down, td.show-for-large-down, th.hide-for-xlarge-only, td.hide-for-xlarge-only, th.hide-for-xlarge-up, td.hide-for-xlarge-up, th.hide-for-xxlarge-only, td.hide-for-xxlarge-only, th.hide-for-xxlarge-up, td.hide-for-xxlarge-up { + display: table-cell !important; } } +/* large displays */ +@media only screen and (min-width: 64.063em) { + .hide-for-small-only, .show-for-small-up, .hide-for-small, .hide-for-small-down, .hide-for-medium-only, .show-for-medium-up, .hide-for-medium, .hide-for-medium-down, .show-for-large-only, .show-for-large-up, .show-for-large, .show-for-large-down, .hide-for-xlarge-only, .hide-for-xlarge-up, .hide-for-xxlarge-only, .hide-for-xxlarge-up { + display: inherit !important; } + + .show-for-small-only, .hide-for-small-up, .show-for-small, .show-for-small-down, .show-for-medium-only, .hide-for-medium-up, .show-for-medium, .show-for-medium-down, .hide-for-large-only, .hide-for-large-up, .hide-for-large, .hide-for-large-down, .show-for-xlarge-only, .show-for-xlarge-up, .show-for-xxlarge-only, .show-for-xxlarge-up { + display: none !important; } + + table.hide-for-small-only, table.show-for-small-up, table.hide-for-small, table.hide-for-small-down, table.hide-for-medium-only, table.show-for-medium-up, table.hide-for-medium, table.hide-for-medium-down, table.show-for-large-only, table.show-for-large-up, table.show-for-large, table.show-for-large-down, table.hide-for-xlarge-only, table.hide-for-xlarge-up, table.hide-for-xxlarge-only, table.hide-for-xxlarge-up { + display: table; } + + thead.hide-for-small-only, thead.show-for-small-up, thead.hide-for-small, thead.hide-for-small-down, thead.hide-for-medium-only, thead.show-for-medium-up, thead.hide-for-medium, thead.hide-for-medium-down, thead.show-for-large-only, thead.show-for-large-up, thead.show-for-large, thead.show-for-large-down, thead.hide-for-xlarge-only, thead.hide-for-xlarge-up, thead.hide-for-xxlarge-only, thead.hide-for-xxlarge-up { + display: table-header-group !important; } + + tbody.hide-for-small-only, tbody.show-for-small-up, tbody.hide-for-small, tbody.hide-for-small-down, tbody.hide-for-medium-only, tbody.show-for-medium-up, tbody.hide-for-medium, tbody.hide-for-medium-down, tbody.show-for-large-only, tbody.show-for-large-up, tbody.show-for-large, tbody.show-for-large-down, tbody.hide-for-xlarge-only, tbody.hide-for-xlarge-up, tbody.hide-for-xxlarge-only, tbody.hide-for-xxlarge-up { + display: table-row-group !important; } + + tr.hide-for-small-only, tr.show-for-small-up, tr.hide-for-small, tr.hide-for-small-down, tr.hide-for-medium-only, tr.show-for-medium-up, tr.hide-for-medium, tr.hide-for-medium-down, tr.show-for-large-only, tr.show-for-large-up, tr.show-for-large, tr.show-for-large-down, tr.hide-for-xlarge-only, tr.hide-for-xlarge-up, tr.hide-for-xxlarge-only, tr.hide-for-xxlarge-up { + display: table-row !important; } + + th.hide-for-small-only, td.hide-for-small-only, th.show-for-small-up, td.show-for-small-up, th.hide-for-small, td.hide-for-small, th.hide-for-small-down, td.hide-for-small-down, th.hide-for-medium-only, td.hide-for-medium-only, th.show-for-medium-up, td.show-for-medium-up, th.hide-for-medium, td.hide-for-medium, th.hide-for-medium-down, td.hide-for-medium-down, th.show-for-large-only, td.show-for-large-only, th.show-for-large-up, td.show-for-large-up, th.show-for-large, td.show-for-large, th.show-for-large-down, td.show-for-large-down, th.hide-for-xlarge-only, td.hide-for-xlarge-only, th.hide-for-xlarge-up, td.hide-for-xlarge-up, th.hide-for-xxlarge-only, td.hide-for-xxlarge-only, th.hide-for-xxlarge-up, td.hide-for-xxlarge-up { + display: table-cell !important; } } +/* xlarge displays */ +@media only screen and (min-width: 90.063em) { + .hide-for-small-only, .show-for-small-up, .hide-for-small, .hide-for-small-down, .hide-for-medium-only, .show-for-medium-up, .hide-for-medium, .hide-for-medium-down, .hide-for-large-only, .show-for-large-up, .hide-for-large, .hide-for-large-down, .show-for-xlarge-only, .show-for-xlarge-up, .hide-for-xxlarge-only, .hide-for-xxlarge-up { + display: inherit !important; } + + .show-for-small-only, .hide-for-small-up, .show-for-small, .show-for-small-down, .show-for-medium-only, .hide-for-medium-up, .show-for-medium, .show-for-medium-down, .show-for-large-only, .hide-for-large-up, .show-for-large, .show-for-large-down, .hide-for-xlarge-only, .hide-for-xlarge-up, .show-for-xxlarge-only, .show-for-xxlarge-up { + display: none !important; } + + table.hide-for-small-only, table.show-for-small-up, table.hide-for-small, table.hide-for-small-down, table.hide-for-medium-only, table.show-for-medium-up, table.hide-for-medium, table.hide-for-medium-down, table.hide-for-large-only, table.show-for-large-up, table.hide-for-large, table.hide-for-large-down, table.show-for-xlarge-only, table.show-for-xlarge-up, table.hide-for-xxlarge-only, table.hide-for-xxlarge-up { + display: table; } + + thead.hide-for-small-only, thead.show-for-small-up, thead.hide-for-small, thead.hide-for-small-down, thead.hide-for-medium-only, thead.show-for-medium-up, thead.hide-for-medium, thead.hide-for-medium-down, thead.hide-for-large-only, thead.show-for-large-up, thead.hide-for-large, thead.hide-for-large-down, thead.show-for-xlarge-only, thead.show-for-xlarge-up, thead.hide-for-xxlarge-only, thead.hide-for-xxlarge-up { + display: table-header-group !important; } + + tbody.hide-for-small-only, tbody.show-for-small-up, tbody.hide-for-small, tbody.hide-for-small-down, tbody.hide-for-medium-only, tbody.show-for-medium-up, tbody.hide-for-medium, tbody.hide-for-medium-down, tbody.hide-for-large-only, tbody.show-for-large-up, tbody.hide-for-large, tbody.hide-for-large-down, tbody.show-for-xlarge-only, tbody.show-for-xlarge-up, tbody.hide-for-xxlarge-only, tbody.hide-for-xxlarge-up { + display: table-row-group !important; } + + tr.hide-for-small-only, tr.show-for-small-up, tr.hide-for-small, tr.hide-for-small-down, tr.hide-for-medium-only, tr.show-for-medium-up, tr.hide-for-medium, tr.hide-for-medium-down, tr.hide-for-large-only, tr.show-for-large-up, tr.hide-for-large, tr.hide-for-large-down, tr.show-for-xlarge-only, tr.show-for-xlarge-up, tr.hide-for-xxlarge-only, tr.hide-for-xxlarge-up { + display: table-row !important; } + + th.hide-for-small-only, td.hide-for-small-only, th.show-for-small-up, td.show-for-small-up, th.hide-for-small, td.hide-for-small, th.hide-for-small-down, td.hide-for-small-down, th.hide-for-medium-only, td.hide-for-medium-only, th.show-for-medium-up, td.show-for-medium-up, th.hide-for-medium, td.hide-for-medium, th.hide-for-medium-down, td.hide-for-medium-down, th.hide-for-large-only, td.hide-for-large-only, th.show-for-large-up, td.show-for-large-up, th.hide-for-large, td.hide-for-large, th.hide-for-large-down, td.hide-for-large-down, th.show-for-xlarge-only, td.show-for-xlarge-only, th.show-for-xlarge-up, td.show-for-xlarge-up, th.hide-for-xxlarge-only, td.hide-for-xxlarge-only, th.hide-for-xxlarge-up, td.hide-for-xxlarge-up { + display: table-cell !important; } } +/* xxlarge displays */ +@media only screen and (min-width: 120.063em) { + .hide-for-small-only, .show-for-small-up, .hide-for-small, .hide-for-small-down, .hide-for-medium-only, .show-for-medium-up, .hide-for-medium, .hide-for-medium-down, .hide-for-large-only, .show-for-large-up, .hide-for-large, .hide-for-large-down, .hide-for-xlarge-only, .show-for-xlarge-up, .show-for-xxlarge-only, .show-for-xxlarge-up { + display: inherit !important; } + + .show-for-small-only, .hide-for-small-up, .show-for-small, .show-for-small-down, .show-for-medium-only, .hide-for-medium-up, .show-for-medium, .show-for-medium-down, .show-for-large-only, .hide-for-large-up, .show-for-large, .show-for-large-down, .show-for-xlarge-only, .hide-for-xlarge-up, .hide-for-xxlarge-only, .hide-for-xxlarge-up { + display: none !important; } + + table.hide-for-small-only, table.show-for-small-up, table.hide-for-small, table.hide-for-small-down, table.hide-for-medium-only, table.show-for-medium-up, table.hide-for-medium, table.hide-for-medium-down, table.hide-for-large-only, table.show-for-large-up, table.hide-for-large, table.hide-for-large-down, table.hide-for-xlarge-only, table.show-for-xlarge-up, table.show-for-xxlarge-only, table.show-for-xxlarge-up { + display: table; } + + thead.hide-for-small-only, thead.show-for-small-up, thead.hide-for-small, thead.hide-for-small-down, thead.hide-for-medium-only, thead.show-for-medium-up, thead.hide-for-medium, thead.hide-for-medium-down, thead.hide-for-large-only, thead.show-for-large-up, thead.hide-for-large, thead.hide-for-large-down, thead.hide-for-xlarge-only, thead.show-for-xlarge-up, thead.show-for-xxlarge-only, thead.show-for-xxlarge-up { + display: table-header-group !important; } + + tbody.hide-for-small-only, tbody.show-for-small-up, tbody.hide-for-small, tbody.hide-for-small-down, tbody.hide-for-medium-only, tbody.show-for-medium-up, tbody.hide-for-medium, tbody.hide-for-medium-down, tbody.hide-for-large-only, tbody.show-for-large-up, tbody.hide-for-large, tbody.hide-for-large-down, tbody.hide-for-xlarge-only, tbody.show-for-xlarge-up, tbody.show-for-xxlarge-only, tbody.show-for-xxlarge-up { + display: table-row-group !important; } + + tr.hide-for-small-only, tr.show-for-small-up, tr.hide-for-small, tr.hide-for-small-down, tr.hide-for-medium-only, tr.show-for-medium-up, tr.hide-for-medium, tr.hide-for-medium-down, tr.hide-for-large-only, tr.show-for-large-up, tr.hide-for-large, tr.hide-for-large-down, tr.hide-for-xlarge-only, tr.show-for-xlarge-up, tr.show-for-xxlarge-only, tr.show-for-xxlarge-up { + display: table-row !important; } + + th.hide-for-small-only, td.hide-for-small-only, th.show-for-small-up, td.show-for-small-up, th.hide-for-small, td.hide-for-small, th.hide-for-small-down, td.hide-for-small-down, th.hide-for-medium-only, td.hide-for-medium-only, th.show-for-medium-up, td.show-for-medium-up, th.hide-for-medium, td.hide-for-medium, th.hide-for-medium-down, td.hide-for-medium-down, th.hide-for-large-only, td.hide-for-large-only, th.show-for-large-up, td.show-for-large-up, th.hide-for-large, td.hide-for-large, th.hide-for-large-down, td.hide-for-large-down, th.hide-for-xlarge-only, td.hide-for-xlarge-only, th.show-for-xlarge-up, td.show-for-xlarge-up, th.show-for-xxlarge-only, td.show-for-xxlarge-only, th.show-for-xxlarge-up, td.show-for-xxlarge-up { + display: table-cell !important; } } +/* Orientation targeting */ +.show-for-landscape, +.hide-for-portrait { + display: inherit !important; } + +.hide-for-landscape, +.show-for-portrait { + display: none !important; } + +/* Specific visibility for tables */ +table.hide-for-landscape, table.show-for-portrait { + display: table; } + +thead.hide-for-landscape, thead.show-for-portrait { + display: table-header-group !important; } + +tbody.hide-for-landscape, tbody.show-for-portrait { + display: table-row-group !important; } + +tr.hide-for-landscape, tr.show-for-portrait { + display: table-row !important; } + +td.hide-for-landscape, td.show-for-portrait, +th.hide-for-landscape, +th.show-for-portrait { + display: table-cell !important; } + +@media only screen and (orientation: landscape) { + .show-for-landscape, + .hide-for-portrait { + display: inherit !important; } + + .hide-for-landscape, + .show-for-portrait { + display: none !important; } + + /* Specific visibility for tables */ + table.show-for-landscape, table.hide-for-portrait { + display: table; } + + thead.show-for-landscape, thead.hide-for-portrait { + display: table-header-group !important; } + + tbody.show-for-landscape, tbody.hide-for-portrait { + display: table-row-group !important; } + + tr.show-for-landscape, tr.hide-for-portrait { + display: table-row !important; } + + td.show-for-landscape, td.hide-for-portrait, + th.show-for-landscape, + th.hide-for-portrait { + display: table-cell !important; } } +@media only screen and (orientation: portrait) { + .show-for-portrait, + .hide-for-landscape { + display: inherit !important; } + + .hide-for-portrait, + .show-for-landscape { + display: none !important; } + + /* Specific visibility for tables */ + table.show-for-portrait, table.hide-for-landscape { + display: table; } + + thead.show-for-portrait, thead.hide-for-landscape { + display: table-header-group !important; } + + tbody.show-for-portrait, tbody.hide-for-landscape { + display: table-row-group !important; } + + tr.show-for-portrait, tr.hide-for-landscape { + display: table-row !important; } + + td.show-for-portrait, td.hide-for-landscape, + th.show-for-portrait, + th.hide-for-landscape { + display: table-cell !important; } } +/* Touch-enabled device targeting */ +.show-for-touch { + display: none !important; } + +.hide-for-touch { + display: inherit !important; } + +.touch .show-for-touch { + display: inherit !important; } + +.touch .hide-for-touch { + display: none !important; } + +/* Specific visibility for tables */ +table.hide-for-touch { + display: table; } + +.touch table.show-for-touch { + display: table; } + +thead.hide-for-touch { + display: table-header-group !important; } + +.touch thead.show-for-touch { + display: table-header-group !important; } + +tbody.hide-for-touch { + display: table-row-group !important; } + +.touch tbody.show-for-touch { + display: table-row-group !important; } + +tr.hide-for-touch { + display: table-row !important; } + +.touch tr.show-for-touch { + display: table-row !important; } + +td.hide-for-touch { + display: table-cell !important; } + +.touch td.show-for-touch { + display: table-cell !important; } + +th.hide-for-touch { + display: table-cell !important; } + +.touch th.show-for-touch { + display: table-cell !important; } diff --git a/server/static/server/c3/docs/css/foundation.min.css b/server/static/server/c3/docs/css/foundation.min.css new file mode 100644 index 0000000..c471b7e --- /dev/null +++ b/server/static/server/c3/docs/css/foundation.min.css @@ -0,0 +1 @@ +meta.foundation-version{font-family:"/5.2.2/"}meta.foundation-mq-small{font-family:"/only screen/";width:0em}meta.foundation-mq-medium{font-family:"/only screen and (min-width:40.063em)/";width:40.063em}meta.foundation-mq-large{font-family:"/only screen and (min-width:64.063em)/";width:64.063em}meta.foundation-mq-xlarge{font-family:"/only screen and (min-width:90.063em)/";width:90.063em}meta.foundation-mq-xxlarge{font-family:"/only screen and (min-width:120.063em)/";width:120.063em}meta.foundation-data-attribute-namespace{font-family:false}html,body{height:100%}*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html,body{font-size:100%}body{background:#fff;color:#222;padding:0;margin:0;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:normal;font-style:normal;line-height:1;position:relative;cursor:default}a:hover{cursor:pointer}img{max-width:100%;height:auto}img{-ms-interpolation-mode:bicubic}#map_canvas img,#map_canvas embed,#map_canvas object,.map_canvas img,.map_canvas embed,.map_canvas object{max-width:none !important}.left{float:left !important}.right{float:right !important}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{content:" ";display:table}.clearfix:after{clear:both}.hide{display:none}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}img{display:inline-block;vertical-align:middle}textarea{height:auto;min-height:50px}select{width:100%}.row{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5rem;*zoom:1}.row:before,.row:after{content:" ";display:table}.row:after{clear:both}.row.collapse>.column,.row.collapse>.columns{padding-left:0;padding-right:0}.row.collapse .row{margin-left:0;margin-right:0}.row .row{width:auto;margin-left:-0.9375rem;margin-right:-0.9375rem;margin-top:0;margin-bottom:0;max-width:none;*zoom:1}.row .row:before,.row .row:after{content:" ";display:table}.row .row:after{clear:both}.row .row.collapse{width:auto;margin:0;max-width:none;*zoom:1}.row .row.collapse:before,.row .row.collapse:after{content:" ";display:table}.row .row.collapse:after{clear:both}.column,.columns{padding-left:0.9375rem;padding-right:0.9375rem;width:100%;float:left}@media only screen{.small-push-0{position:relative;left:0%;right:auto}.small-pull-0{position:relative;right:0%;left:auto}.small-push-1{position:relative;left:8.33333%;right:auto}.small-pull-1{position:relative;right:8.33333%;left:auto}.small-push-2{position:relative;left:16.66667%;right:auto}.small-pull-2{position:relative;right:16.66667%;left:auto}.small-push-3{position:relative;left:25%;right:auto}.small-pull-3{position:relative;right:25%;left:auto}.small-push-4{position:relative;left:33.33333%;right:auto}.small-pull-4{position:relative;right:33.33333%;left:auto}.small-push-5{position:relative;left:41.66667%;right:auto}.small-pull-5{position:relative;right:41.66667%;left:auto}.small-push-6{position:relative;left:50%;right:auto}.small-pull-6{position:relative;right:50%;left:auto}.small-push-7{position:relative;left:58.33333%;right:auto}.small-pull-7{position:relative;right:58.33333%;left:auto}.small-push-8{position:relative;left:66.66667%;right:auto}.small-pull-8{position:relative;right:66.66667%;left:auto}.small-push-9{position:relative;left:75%;right:auto}.small-pull-9{position:relative;right:75%;left:auto}.small-push-10{position:relative;left:83.33333%;right:auto}.small-pull-10{position:relative;right:83.33333%;left:auto}.small-push-11{position:relative;left:91.66667%;right:auto}.small-pull-11{position:relative;right:91.66667%;left:auto}.column,.columns{position:relative;padding-left:0.9375rem;padding-right:0.9375rem;float:left}.small-1{width:8.33333%}.small-2{width:16.66667%}.small-3{width:25%}.small-4{width:33.33333%}.small-5{width:41.66667%}.small-6{width:50%}.small-7{width:58.33333%}.small-8{width:66.66667%}.small-9{width:75%}.small-10{width:83.33333%}.small-11{width:91.66667%}.small-12{width:100%}[class*="column"]+[class*="column"]:last-child{float:right}[class*="column"]+[class*="column"].end{float:left}.small-offset-0{margin-left:0% !important}.small-offset-1{margin-left:8.33333% !important}.small-offset-2{margin-left:16.66667% !important}.small-offset-3{margin-left:25% !important}.small-offset-4{margin-left:33.33333% !important}.small-offset-5{margin-left:41.66667% !important}.small-offset-6{margin-left:50% !important}.small-offset-7{margin-left:58.33333% !important}.small-offset-8{margin-left:66.66667% !important}.small-offset-9{margin-left:75% !important}.small-offset-10{margin-left:83.33333% !important}.small-offset-11{margin-left:91.66667% !important}.small-reset-order,.small-reset-order{margin-left:0;margin-right:0;left:auto;right:auto;float:left}.column.small-centered,.columns.small-centered{margin-left:auto;margin-right:auto;float:none}.column.small-uncentered,.columns.small-uncentered{margin-left:0;margin-right:0;float:left !important}.column.small-uncentered.opposite,.columns.small-uncentered.opposite{float:right}}@media only screen and (min-width: 40.063em){.medium-push-0{position:relative;left:0%;right:auto}.medium-pull-0{position:relative;right:0%;left:auto}.medium-push-1{position:relative;left:8.33333%;right:auto}.medium-pull-1{position:relative;right:8.33333%;left:auto}.medium-push-2{position:relative;left:16.66667%;right:auto}.medium-pull-2{position:relative;right:16.66667%;left:auto}.medium-push-3{position:relative;left:25%;right:auto}.medium-pull-3{position:relative;right:25%;left:auto}.medium-push-4{position:relative;left:33.33333%;right:auto}.medium-pull-4{position:relative;right:33.33333%;left:auto}.medium-push-5{position:relative;left:41.66667%;right:auto}.medium-pull-5{position:relative;right:41.66667%;left:auto}.medium-push-6{position:relative;left:50%;right:auto}.medium-pull-6{position:relative;right:50%;left:auto}.medium-push-7{position:relative;left:58.33333%;right:auto}.medium-pull-7{position:relative;right:58.33333%;left:auto}.medium-push-8{position:relative;left:66.66667%;right:auto}.medium-pull-8{position:relative;right:66.66667%;left:auto}.medium-push-9{position:relative;left:75%;right:auto}.medium-pull-9{position:relative;right:75%;left:auto}.medium-push-10{position:relative;left:83.33333%;right:auto}.medium-pull-10{position:relative;right:83.33333%;left:auto}.medium-push-11{position:relative;left:91.66667%;right:auto}.medium-pull-11{position:relative;right:91.66667%;left:auto}.column,.columns{position:relative;padding-left:0.9375rem;padding-right:0.9375rem;float:left}.medium-1{width:8.33333%}.medium-2{width:16.66667%}.medium-3{width:25%}.medium-4{width:33.33333%}.medium-5{width:41.66667%}.medium-6{width:50%}.medium-7{width:58.33333%}.medium-8{width:66.66667%}.medium-9{width:75%}.medium-10{width:83.33333%}.medium-11{width:91.66667%}.medium-12{width:100%}[class*="column"]+[class*="column"]:last-child{float:right}[class*="column"]+[class*="column"].end{float:left}.medium-offset-0{margin-left:0% !important}.medium-offset-1{margin-left:8.33333% !important}.medium-offset-2{margin-left:16.66667% !important}.medium-offset-3{margin-left:25% !important}.medium-offset-4{margin-left:33.33333% !important}.medium-offset-5{margin-left:41.66667% !important}.medium-offset-6{margin-left:50% !important}.medium-offset-7{margin-left:58.33333% !important}.medium-offset-8{margin-left:66.66667% !important}.medium-offset-9{margin-left:75% !important}.medium-offset-10{margin-left:83.33333% !important}.medium-offset-11{margin-left:91.66667% !important}.medium-reset-order,.medium-reset-order{margin-left:0;margin-right:0;left:auto;right:auto;float:left}.column.medium-centered,.columns.medium-centered{margin-left:auto;margin-right:auto;float:none}.column.medium-uncentered,.columns.medium-uncentered{margin-left:0;margin-right:0;float:left !important}.column.medium-uncentered.opposite,.columns.medium-uncentered.opposite{float:right}.push-0{position:relative;left:0%;right:auto}.pull-0{position:relative;right:0%;left:auto}.push-1{position:relative;left:8.33333%;right:auto}.pull-1{position:relative;right:8.33333%;left:auto}.push-2{position:relative;left:16.66667%;right:auto}.pull-2{position:relative;right:16.66667%;left:auto}.push-3{position:relative;left:25%;right:auto}.pull-3{position:relative;right:25%;left:auto}.push-4{position:relative;left:33.33333%;right:auto}.pull-4{position:relative;right:33.33333%;left:auto}.push-5{position:relative;left:41.66667%;right:auto}.pull-5{position:relative;right:41.66667%;left:auto}.push-6{position:relative;left:50%;right:auto}.pull-6{position:relative;right:50%;left:auto}.push-7{position:relative;left:58.33333%;right:auto}.pull-7{position:relative;right:58.33333%;left:auto}.push-8{position:relative;left:66.66667%;right:auto}.pull-8{position:relative;right:66.66667%;left:auto}.push-9{position:relative;left:75%;right:auto}.pull-9{position:relative;right:75%;left:auto}.push-10{position:relative;left:83.33333%;right:auto}.pull-10{position:relative;right:83.33333%;left:auto}.push-11{position:relative;left:91.66667%;right:auto}.pull-11{position:relative;right:91.66667%;left:auto}}@media only screen and (min-width: 64.063em){.large-push-0{position:relative;left:0%;right:auto}.large-pull-0{position:relative;right:0%;left:auto}.large-push-1{position:relative;left:8.33333%;right:auto}.large-pull-1{position:relative;right:8.33333%;left:auto}.large-push-2{position:relative;left:16.66667%;right:auto}.large-pull-2{position:relative;right:16.66667%;left:auto}.large-push-3{position:relative;left:25%;right:auto}.large-pull-3{position:relative;right:25%;left:auto}.large-push-4{position:relative;left:33.33333%;right:auto}.large-pull-4{position:relative;right:33.33333%;left:auto}.large-push-5{position:relative;left:41.66667%;right:auto}.large-pull-5{position:relative;right:41.66667%;left:auto}.large-push-6{position:relative;left:50%;right:auto}.large-pull-6{position:relative;right:50%;left:auto}.large-push-7{position:relative;left:58.33333%;right:auto}.large-pull-7{position:relative;right:58.33333%;left:auto}.large-push-8{position:relative;left:66.66667%;right:auto}.large-pull-8{position:relative;right:66.66667%;left:auto}.large-push-9{position:relative;left:75%;right:auto}.large-pull-9{position:relative;right:75%;left:auto}.large-push-10{position:relative;left:83.33333%;right:auto}.large-pull-10{position:relative;right:83.33333%;left:auto}.large-push-11{position:relative;left:91.66667%;right:auto}.large-pull-11{position:relative;right:91.66667%;left:auto}.column,.columns{position:relative;padding-left:0.9375rem;padding-right:0.9375rem;float:left}.large-1{width:8.33333%}.large-2{width:16.66667%}.large-3{width:25%}.large-4{width:33.33333%}.large-5{width:41.66667%}.large-6{width:50%}.large-7{width:58.33333%}.large-8{width:66.66667%}.large-9{width:75%}.large-10{width:83.33333%}.large-11{width:91.66667%}.large-12{width:100%}[class*="column"]+[class*="column"]:last-child{float:right}[class*="column"]+[class*="column"].end{float:left}.large-offset-0{margin-left:0% !important}.large-offset-1{margin-left:8.33333% !important}.large-offset-2{margin-left:16.66667% !important}.large-offset-3{margin-left:25% !important}.large-offset-4{margin-left:33.33333% !important}.large-offset-5{margin-left:41.66667% !important}.large-offset-6{margin-left:50% !important}.large-offset-7{margin-left:58.33333% !important}.large-offset-8{margin-left:66.66667% !important}.large-offset-9{margin-left:75% !important}.large-offset-10{margin-left:83.33333% !important}.large-offset-11{margin-left:91.66667% !important}.large-reset-order,.large-reset-order{margin-left:0;margin-right:0;left:auto;right:auto;float:left}.column.large-centered,.columns.large-centered{margin-left:auto;margin-right:auto;float:none}.column.large-uncentered,.columns.large-uncentered{margin-left:0;margin-right:0;float:left !important}.column.large-uncentered.opposite,.columns.large-uncentered.opposite{float:right}.push-0{position:relative;left:0%;right:auto}.pull-0{position:relative;right:0%;left:auto}.push-1{position:relative;left:8.33333%;right:auto}.pull-1{position:relative;right:8.33333%;left:auto}.push-2{position:relative;left:16.66667%;right:auto}.pull-2{position:relative;right:16.66667%;left:auto}.push-3{position:relative;left:25%;right:auto}.pull-3{position:relative;right:25%;left:auto}.push-4{position:relative;left:33.33333%;right:auto}.pull-4{position:relative;right:33.33333%;left:auto}.push-5{position:relative;left:41.66667%;right:auto}.pull-5{position:relative;right:41.66667%;left:auto}.push-6{position:relative;left:50%;right:auto}.pull-6{position:relative;right:50%;left:auto}.push-7{position:relative;left:58.33333%;right:auto}.pull-7{position:relative;right:58.33333%;left:auto}.push-8{position:relative;left:66.66667%;right:auto}.pull-8{position:relative;right:66.66667%;left:auto}.push-9{position:relative;left:75%;right:auto}.pull-9{position:relative;right:75%;left:auto}.push-10{position:relative;left:83.33333%;right:auto}.pull-10{position:relative;right:83.33333%;left:auto}.push-11{position:relative;left:91.66667%;right:auto}.pull-11{position:relative;right:91.66667%;left:auto}}button,.button{border-style:solid;border-width:0px;cursor:pointer;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:normal;line-height:normal;margin:0 0 1.25rem;position:relative;text-decoration:none;text-align:center;-webkit-appearance:none;-webkit-border-radius:0;display:inline-block;padding-top:1rem;padding-right:2rem;padding-bottom:1.0625rem;padding-left:2rem;font-size:1rem;background-color:#008cba;border-color:#007095;color:#fff;transition:background-color 300ms ease-out}button:hover,button:focus,.button:hover,.button:focus{background-color:#007095}button:hover,button:focus,.button:hover,.button:focus{color:#fff}button.secondary,.button.secondary{background-color:#e7e7e7;border-color:#b9b9b9;color:#333}button.secondary:hover,button.secondary:focus,.button.secondary:hover,.button.secondary:focus{background-color:#b9b9b9}button.secondary:hover,button.secondary:focus,.button.secondary:hover,.button.secondary:focus{color:#333}button.success,.button.success{background-color:#43ac6a;border-color:#368a55;color:#fff}button.success:hover,button.success:focus,.button.success:hover,.button.success:focus{background-color:#368a55}button.success:hover,button.success:focus,.button.success:hover,.button.success:focus{color:#fff}button.alert,.button.alert{background-color:#f04124;border-color:#cf2a0e;color:#fff}button.alert:hover,button.alert:focus,.button.alert:hover,.button.alert:focus{background-color:#cf2a0e}button.alert:hover,button.alert:focus,.button.alert:hover,.button.alert:focus{color:#fff}button.large,.button.large{padding-top:1.125rem;padding-right:2.25rem;padding-bottom:1.1875rem;padding-left:2.25rem;font-size:1.25rem}button.small,.button.small{padding-top:0.875rem;padding-right:1.75rem;padding-bottom:0.9375rem;padding-left:1.75rem;font-size:0.8125rem}button.tiny,.button.tiny{padding-top:0.625rem;padding-right:1.25rem;padding-bottom:0.6875rem;padding-left:1.25rem;font-size:0.6875rem}button.expand,.button.expand{padding-right:0;padding-left:0;width:100%}button.left-align,.button.left-align{text-align:left;text-indent:0.75rem}button.right-align,.button.right-align{text-align:right;padding-right:0.75rem}button.radius,.button.radius{border-radius:3px}button.round,.button.round{border-radius:1000px}button.disabled,button[disabled],.button.disabled,.button[disabled]{background-color:#008cba;border-color:#007095;color:#fff;cursor:default;opacity:0.7;box-shadow:none}button.disabled:hover,button.disabled:focus,button[disabled]:hover,button[disabled]:focus,.button.disabled:hover,.button.disabled:focus,.button[disabled]:hover,.button[disabled]:focus{background-color:#007095}button.disabled:hover,button.disabled:focus,button[disabled]:hover,button[disabled]:focus,.button.disabled:hover,.button.disabled:focus,.button[disabled]:hover,.button[disabled]:focus{color:#fff}button.disabled:hover,button.disabled:focus,button[disabled]:hover,button[disabled]:focus,.button.disabled:hover,.button.disabled:focus,.button[disabled]:hover,.button[disabled]:focus{background-color:#008cba}button.disabled.secondary,button[disabled].secondary,.button.disabled.secondary,.button[disabled].secondary{background-color:#e7e7e7;border-color:#b9b9b9;color:#333;cursor:default;opacity:0.7;box-shadow:none}button.disabled.secondary:hover,button.disabled.secondary:focus,button[disabled].secondary:hover,button[disabled].secondary:focus,.button.disabled.secondary:hover,.button.disabled.secondary:focus,.button[disabled].secondary:hover,.button[disabled].secondary:focus{background-color:#b9b9b9}button.disabled.secondary:hover,button.disabled.secondary:focus,button[disabled].secondary:hover,button[disabled].secondary:focus,.button.disabled.secondary:hover,.button.disabled.secondary:focus,.button[disabled].secondary:hover,.button[disabled].secondary:focus{color:#333}button.disabled.secondary:hover,button.disabled.secondary:focus,button[disabled].secondary:hover,button[disabled].secondary:focus,.button.disabled.secondary:hover,.button.disabled.secondary:focus,.button[disabled].secondary:hover,.button[disabled].secondary:focus{background-color:#e7e7e7}button.disabled.success,button[disabled].success,.button.disabled.success,.button[disabled].success{background-color:#43ac6a;border-color:#368a55;color:#fff;cursor:default;opacity:0.7;box-shadow:none}button.disabled.success:hover,button.disabled.success:focus,button[disabled].success:hover,button[disabled].success:focus,.button.disabled.success:hover,.button.disabled.success:focus,.button[disabled].success:hover,.button[disabled].success:focus{background-color:#368a55}button.disabled.success:hover,button.disabled.success:focus,button[disabled].success:hover,button[disabled].success:focus,.button.disabled.success:hover,.button.disabled.success:focus,.button[disabled].success:hover,.button[disabled].success:focus{color:#fff}button.disabled.success:hover,button.disabled.success:focus,button[disabled].success:hover,button[disabled].success:focus,.button.disabled.success:hover,.button.disabled.success:focus,.button[disabled].success:hover,.button[disabled].success:focus{background-color:#43ac6a}button.disabled.alert,button[disabled].alert,.button.disabled.alert,.button[disabled].alert{background-color:#f04124;border-color:#cf2a0e;color:#fff;cursor:default;opacity:0.7;box-shadow:none}button.disabled.alert:hover,button.disabled.alert:focus,button[disabled].alert:hover,button[disabled].alert:focus,.button.disabled.alert:hover,.button.disabled.alert:focus,.button[disabled].alert:hover,.button[disabled].alert:focus{background-color:#cf2a0e}button.disabled.alert:hover,button.disabled.alert:focus,button[disabled].alert:hover,button[disabled].alert:focus,.button.disabled.alert:hover,.button.disabled.alert:focus,.button[disabled].alert:hover,.button[disabled].alert:focus{color:#fff}button.disabled.alert:hover,button.disabled.alert:focus,button[disabled].alert:hover,button[disabled].alert:focus,.button.disabled.alert:hover,.button.disabled.alert:focus,.button[disabled].alert:hover,.button[disabled].alert:focus{background-color:#f04124}@media only screen and (min-width: 40.063em){button,.button{display:inline-block}}meta.foundation-mq-topbar{font-family:"/only screen and (min-width:40.063em)/";width:40.063em}.contain-to-grid{width:100%;background:#333}.contain-to-grid .top-bar{margin-bottom:0}.fixed{width:100%;left:0;position:fixed;top:0;z-index:99}.fixed.expanded:not(.top-bar){overflow-y:auto;height:auto;width:100%;max-height:100%}.fixed.expanded:not(.top-bar) .title-area{position:fixed;width:100%;z-index:99}.fixed.expanded:not(.top-bar) .top-bar-section{z-index:98;margin-top:45px}.top-bar{overflow:hidden;height:45px;line-height:45px;position:relative;background:#333;margin-bottom:0}.top-bar ul{margin-bottom:0;list-style:none}.top-bar .row{max-width:none}.top-bar form,.top-bar input{margin-bottom:0}.top-bar input{height:auto;padding-top:.35rem;padding-bottom:.35rem;font-size:0.75rem}.top-bar .button,.top-bar button{padding-top:.45rem;padding-bottom:.35rem;margin-bottom:0;font-size:0.75rem}.top-bar .title-area{position:relative;margin:0}.top-bar .name{height:45px;margin:0;font-size:16px}.top-bar .name h1{line-height:45px;font-size:1.0625rem;margin:0}.top-bar .name h1 a{font-weight:normal;color:#fff;width:75%;display:block;padding:0 15px}.top-bar .toggle-topbar{position:absolute;right:0;top:0}.top-bar .toggle-topbar a{color:#fff;text-transform:uppercase;font-size:0.8125rem;font-weight:bold;position:relative;display:block;padding:0 15px;height:45px;line-height:45px}.top-bar .toggle-topbar.menu-icon{right:15px;top:50%;margin-top:-16px;padding-left:40px}.top-bar .toggle-topbar.menu-icon a{height:34px;line-height:33px;padding:0;padding-right:25px;color:#fff;position:relative}.top-bar .toggle-topbar.menu-icon a::after{content:"";position:absolute;right:0;display:block;width:16px;top:0;height:0;box-shadow:0 10px 0 1px #fff,0 16px 0 1px #fff,0 22px 0 1px #fff}.top-bar.expanded{height:auto;background:transparent}.top-bar.expanded .title-area{background:#333}.top-bar.expanded .toggle-topbar a{color:#888}.top-bar.expanded .toggle-topbar a::after{box-shadow:0 10px 0 1px #888,0 16px 0 1px #888,0 22px 0 1px #888}.top-bar-section{left:0;position:relative;width:auto;transition:left 300ms ease-out}.top-bar-section ul{width:100%;height:auto;display:block;background:#333;font-size:16px;margin:0}.top-bar-section .divider,.top-bar-section [role="separator"]{border-top:solid 1px #1a1a1a;clear:both;height:1px;width:100%}.top-bar-section ul li>a{display:block;width:100%;color:#fff;padding:12px 0 12px 0;padding-left:15px;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-size:0.8125rem;font-weight:normal;text-transform:none;background:#333}.top-bar-section ul li>a.button{font-size:0.8125rem;padding-right:15px;padding-left:15px;background-color:#008cba;border-color:#007095;color:#fff}.top-bar-section ul li>a.button:hover,.top-bar-section ul li>a.button:focus{background-color:#007095}.top-bar-section ul li>a.button:hover,.top-bar-section ul li>a.button:focus{color:#fff}.top-bar-section ul li>a.button.secondary{background-color:#e7e7e7;border-color:#b9b9b9;color:#333}.top-bar-section ul li>a.button.secondary:hover,.top-bar-section ul li>a.button.secondary:focus{background-color:#b9b9b9}.top-bar-section ul li>a.button.secondary:hover,.top-bar-section ul li>a.button.secondary:focus{color:#333}.top-bar-section ul li>a.button.success{background-color:#43ac6a;border-color:#368a55;color:#fff}.top-bar-section ul li>a.button.success:hover,.top-bar-section ul li>a.button.success:focus{background-color:#368a55}.top-bar-section ul li>a.button.success:hover,.top-bar-section ul li>a.button.success:focus{color:#fff}.top-bar-section ul li>a.button.alert{background-color:#f04124;border-color:#cf2a0e;color:#fff}.top-bar-section ul li>a.button.alert:hover,.top-bar-section ul li>a.button.alert:focus{background-color:#cf2a0e}.top-bar-section ul li>a.button.alert:hover,.top-bar-section ul li>a.button.alert:focus{color:#fff}.top-bar-section ul li>button{font-size:0.8125rem;padding-right:15px;padding-left:15px;background-color:#008cba;border-color:#007095;color:#fff}.top-bar-section ul li>button:hover,.top-bar-section ul li>button:focus{background-color:#007095}.top-bar-section ul li>button:hover,.top-bar-section ul li>button:focus{color:#fff}.top-bar-section ul li>button.secondary{background-color:#e7e7e7;border-color:#b9b9b9;color:#333}.top-bar-section ul li>button.secondary:hover,.top-bar-section ul li>button.secondary:focus{background-color:#b9b9b9}.top-bar-section ul li>button.secondary:hover,.top-bar-section ul li>button.secondary:focus{color:#333}.top-bar-section ul li>button.success{background-color:#43ac6a;border-color:#368a55;color:#fff}.top-bar-section ul li>button.success:hover,.top-bar-section ul li>button.success:focus{background-color:#368a55}.top-bar-section ul li>button.success:hover,.top-bar-section ul li>button.success:focus{color:#fff}.top-bar-section ul li>button.alert{background-color:#f04124;border-color:#cf2a0e;color:#fff}.top-bar-section ul li>button.alert:hover,.top-bar-section ul li>button.alert:focus{background-color:#cf2a0e}.top-bar-section ul li>button.alert:hover,.top-bar-section ul li>button.alert:focus{color:#fff}.top-bar-section ul li:hover:not(.has-form)>a{background:#272727;color:#fff}.top-bar-section ul li.active>a{background:#008cba;color:#fff}.top-bar-section ul li.active>a:hover{background:#0078a0;color:#fff}.top-bar-section .has-form{padding:15px}.top-bar-section .has-dropdown{position:relative}.top-bar-section .has-dropdown>a:after{content:"";display:block;width:0;height:0;border:inset 5px;border-color:transparent transparent transparent rgba(255,255,255,0.4);border-left-style:solid;margin-right:15px;margin-top:-4.5px;position:absolute;top:50%;right:0}.top-bar-section .has-dropdown.moved{position:static}.top-bar-section .has-dropdown.moved>.dropdown{display:block;position:static !important;height:auto;width:auto;overflow:visible;clip:auto;position:absolute !important;width:100%}.top-bar-section .has-dropdown.moved>a:after{display:none}.top-bar-section .dropdown{position:absolute;left:100%;top:0;z-index:99;display:block;position:absolute !important;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px)}.top-bar-section .dropdown li{width:100%;height:auto}.top-bar-section .dropdown li a{font-weight:normal;padding:8px 15px}.top-bar-section .dropdown li a.parent-link{font-weight:normal}.top-bar-section .dropdown li.title h5{margin-bottom:0}.top-bar-section .dropdown li.title h5 a{color:#fff;line-height:22.5px;display:block}.top-bar-section .dropdown li.has-form{padding:8px 15px}.top-bar-section .dropdown li .button,.top-bar-section .dropdown li button{top:auto}.top-bar-section .dropdown label{padding:8px 15px 2px;margin-bottom:0;text-transform:uppercase;color:#777;font-weight:bold;font-size:0.625rem}.js-generated{display:block}@media only screen and (min-width: 40.063em){.top-bar{background:#333;*zoom:1;overflow:visible}.top-bar:before,.top-bar:after{content:" ";display:table}.top-bar:after{clear:both}.top-bar .toggle-topbar{display:none}.top-bar .title-area{float:left}.top-bar .name h1 a{width:auto}.top-bar input,.top-bar .button,.top-bar button{font-size:0.875rem;position:relative;top:7px}.top-bar.expanded{background:#333}.contain-to-grid .top-bar{max-width:62.5rem;margin:0 auto;margin-bottom:0}.top-bar-section{transition:none 0 0;left:0 !important}.top-bar-section ul{width:auto;height:auto !important;display:inline}.top-bar-section ul li{float:left}.top-bar-section ul li .js-generated{display:none}.top-bar-section li.hover>a:not(.button){background:#272727;color:#fff}.top-bar-section li:not(.has-form) a:not(.button){padding:0 15px;line-height:45px;background:#333}.top-bar-section li:not(.has-form) a:not(.button):hover{background:#272727}.top-bar-section li.active:not(.has-form) a:not(.button){padding:0 15px;line-height:45px;color:#fff;background:#008cba}.top-bar-section li.active:not(.has-form) a:not(.button):hover{background:#0078a0}.top-bar-section .has-dropdown>a{padding-right:35px !important}.top-bar-section .has-dropdown>a:after{content:"";display:block;width:0;height:0;border:inset 5px;border-color:rgba(255,255,255,0.4) transparent transparent transparent;border-top-style:solid;margin-top:-2.5px;top:22.5px}.top-bar-section .has-dropdown.moved{position:relative}.top-bar-section .has-dropdown.moved>.dropdown{display:block;position:absolute !important;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px)}.top-bar-section .has-dropdown.hover>.dropdown,.top-bar-section .has-dropdown.not-click:hover>.dropdown{display:block;position:static !important;height:auto;width:auto;overflow:visible;clip:auto;position:absolute !important}.top-bar-section .has-dropdown .dropdown li.has-dropdown>a:after{border:none;content:"\00bb";top:1rem;margin-top:-1px;right:5px;line-height:1.2}.top-bar-section .dropdown{left:0;top:auto;background:transparent;min-width:100%}.top-bar-section .dropdown li a{color:#fff;line-height:1;white-space:nowrap;padding:12px 15px;background:#333}.top-bar-section .dropdown li:not(.has-form) a:not(.button){color:#fff;background:#333}.top-bar-section .dropdown li:not(.has-form):hover>a:not(.button){color:#fff;background:#272727}.top-bar-section .dropdown li label{white-space:nowrap;background:#333}.top-bar-section .dropdown li .dropdown{left:100%;top:0}.top-bar-section>ul>.divider,.top-bar-section>ul>[role="separator"]{border-bottom:none;border-top:none;border-right:solid 1px #4e4e4e;clear:none;height:45px;width:0}.top-bar-section .has-form{background:#333;padding:0 15px;height:45px}.top-bar-section .right li .dropdown{left:auto;right:0}.top-bar-section .right li .dropdown li .dropdown{right:100%}.top-bar-section .left li .dropdown{right:auto;left:0}.top-bar-section .left li .dropdown li .dropdown{left:100%}.no-js .top-bar-section ul li:hover>a{background:#272727;color:#fff}.no-js .top-bar-section ul li:active>a{background:#008cba;color:#fff}.no-js .top-bar-section .has-dropdown:hover>.dropdown{display:block;position:static !important;height:auto;width:auto;overflow:visible;clip:auto;position:absolute !important}}.breadcrumbs{display:block;padding:0.5625rem 0.875rem 0.5625rem;overflow:hidden;margin-left:0;list-style:none;border-style:solid;border-width:1px;background-color:#f4f4f4;border-color:#dcdcdc;border-radius:3px}.breadcrumbs>*{margin:0;float:left;font-size:0.6875rem;line-height:0.6875rem;text-transform:uppercase;color:#008cba}.breadcrumbs>*:hover a,.breadcrumbs>*:focus a{text-decoration:underline}.breadcrumbs>* a{color:#008cba}.breadcrumbs>*.current{cursor:default;color:#333}.breadcrumbs>*.current a{cursor:default;color:#333}.breadcrumbs>*.current:hover,.breadcrumbs>*.current:hover a,.breadcrumbs>*.current:focus,.breadcrumbs>*.current:focus a{text-decoration:none}.breadcrumbs>*.unavailable{color:#999}.breadcrumbs>*.unavailable a{color:#999}.breadcrumbs>*.unavailable:hover,.breadcrumbs>*.unavailable:hover a,.breadcrumbs>*.unavailable:focus,.breadcrumbs>*.unavailable a:focus{text-decoration:none;color:#999;cursor:default}.breadcrumbs>*:before{content:"/";color:#aaa;margin:0 0.75rem;position:relative;top:1px}.breadcrumbs>*:first-child:before{content:" ";margin:0}.alert-box{border-style:solid;border-width:1px;display:block;font-weight:normal;margin-bottom:1.25rem;position:relative;padding:0.875rem 1.5rem 0.875rem 0.875rem;font-size:0.8125rem;transition:opacity 300ms ease-out;background-color:#008cba;border-color:#0078a0;color:#fff}.alert-box .close{font-size:1.375rem;padding:9px 6px 4px;line-height:0;position:absolute;top:50%;margin-top:-0.6875rem;right:0.25rem;color:#333;opacity:0.3}.alert-box .close:hover,.alert-box .close:focus{opacity:0.5}.alert-box.radius{border-radius:3px}.alert-box.round{border-radius:1000px}.alert-box.success{background-color:#43ac6a;border-color:#3a945b;color:#fff}.alert-box.alert{background-color:#f04124;border-color:#de2d0f;color:#fff}.alert-box.secondary{background-color:#e7e7e7;border-color:#c7c7c7;color:#4f4f4f}.alert-box.warning{background-color:#f08a24;border-color:#de770f;color:#fff}.alert-box.info{background-color:#a0d3e8;border-color:#74bfdd;color:#4f4f4f}.alert-box.alert-close{opacity:0}.inline-list{margin:0 auto 1.0625rem auto;margin-left:-1.375rem;margin-right:0;padding:0;list-style:none;overflow:hidden}.inline-list>li{list-style:none;float:left;margin-left:1.375rem;display:block}.inline-list>li>*{display:block}.button-group{list-style:none;margin:0;left:0;*zoom:1}.button-group:before,.button-group:after{content:" ";display:table}.button-group:after{clear:both}.button-group li{margin:0;float:left}.button-group li>button,.button-group li .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group li:first-child button,.button-group li:first-child .button{border-left:0}.button-group li:first-child{margin-left:0}.button-group.radius>*>button,.button-group.radius>* .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group.radius>*:first-child button,.button-group.radius>*:first-child .button{border-left:0}.button-group.radius>*:first-child,.button-group.radius>*:first-child>a,.button-group.radius>*:first-child>button,.button-group.radius>*:first-child>.button{border-bottom-left-radius:3px;border-top-left-radius:3px}.button-group.radius>*:last-child,.button-group.radius>*:last-child>a,.button-group.radius>*:last-child>button,.button-group.radius>*:last-child>.button{border-bottom-right-radius:3px;border-top-right-radius:3px}.button-group.round>*>button,.button-group.round>* .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group.round>*:first-child button,.button-group.round>*:first-child .button{border-left:0}.button-group.round>*:first-child,.button-group.round>*:first-child>a,.button-group.round>*:first-child>button,.button-group.round>*:first-child>.button{border-bottom-left-radius:1000px;border-top-left-radius:1000px}.button-group.round>*:last-child,.button-group.round>*:last-child>a,.button-group.round>*:last-child>button,.button-group.round>*:last-child>.button{border-bottom-right-radius:1000px;border-top-right-radius:1000px}.button-group.even-2 li{width:50%}.button-group.even-2 li>button,.button-group.even-2 li .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group.even-2 li:first-child button,.button-group.even-2 li:first-child .button{border-left:0}.button-group.even-2 li button,.button-group.even-2 li .button{width:100%}.button-group.even-3 li{width:33.33333%}.button-group.even-3 li>button,.button-group.even-3 li .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group.even-3 li:first-child button,.button-group.even-3 li:first-child .button{border-left:0}.button-group.even-3 li button,.button-group.even-3 li .button{width:100%}.button-group.even-4 li{width:25%}.button-group.even-4 li>button,.button-group.even-4 li .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group.even-4 li:first-child button,.button-group.even-4 li:first-child .button{border-left:0}.button-group.even-4 li button,.button-group.even-4 li .button{width:100%}.button-group.even-5 li{width:20%}.button-group.even-5 li>button,.button-group.even-5 li .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group.even-5 li:first-child button,.button-group.even-5 li:first-child .button{border-left:0}.button-group.even-5 li button,.button-group.even-5 li .button{width:100%}.button-group.even-6 li{width:16.66667%}.button-group.even-6 li>button,.button-group.even-6 li .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group.even-6 li:first-child button,.button-group.even-6 li:first-child .button{border-left:0}.button-group.even-6 li button,.button-group.even-6 li .button{width:100%}.button-group.even-7 li{width:14.28571%}.button-group.even-7 li>button,.button-group.even-7 li .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group.even-7 li:first-child button,.button-group.even-7 li:first-child .button{border-left:0}.button-group.even-7 li button,.button-group.even-7 li .button{width:100%}.button-group.even-8 li{width:12.5%}.button-group.even-8 li>button,.button-group.even-8 li .button{border-left:1px solid;border-color:rgba(255,255,255,0.5)}.button-group.even-8 li:first-child button,.button-group.even-8 li:first-child .button{border-left:0}.button-group.even-8 li button,.button-group.even-8 li .button{width:100%}.button-bar{*zoom:1}.button-bar:before,.button-bar:after{content:" ";display:table}.button-bar:after{clear:both}.button-bar .button-group{float:left;margin-right:0.625rem}.button-bar .button-group div{overflow:hidden}.panel{border-style:solid;border-width:1px;border-color:#d8d8d8;margin-bottom:1.25rem;padding:1.25rem;background:#f2f2f2}.panel>:first-child{margin-top:0}.panel>:last-child{margin-bottom:0}.panel h1,.panel h2,.panel h3,.panel h4,.panel h5,.panel h6,.panel p{color:#333}.panel h1,.panel h2,.panel h3,.panel h4,.panel h5,.panel h6{line-height:1;margin-bottom:0.625rem}.panel h1.subheader,.panel h2.subheader,.panel h3.subheader,.panel h4.subheader,.panel h5.subheader,.panel h6.subheader{line-height:1.4}.panel.callout{border-style:solid;border-width:1px;border-color:#b6edff;margin-bottom:1.25rem;padding:1.25rem;background:#ecfaff}.panel.callout>:first-child{margin-top:0}.panel.callout>:last-child{margin-bottom:0}.panel.callout h1,.panel.callout h2,.panel.callout h3,.panel.callout h4,.panel.callout h5,.panel.callout h6,.panel.callout p{color:#333}.panel.callout h1,.panel.callout h2,.panel.callout h3,.panel.callout h4,.panel.callout h5,.panel.callout h6{line-height:1;margin-bottom:0.625rem}.panel.callout h1.subheader,.panel.callout h2.subheader,.panel.callout h3.subheader,.panel.callout h4.subheader,.panel.callout h5.subheader,.panel.callout h6.subheader{line-height:1.4}.panel.callout a:not(.button){color:#008cba}.panel.radius{border-radius:3px}.dropdown.button,button.dropdown{position:relative;padding-right:3.5625rem}.dropdown.button:before,button.dropdown:before{position:absolute;content:"";width:0;height:0;display:block;border-style:solid;border-color:#fff transparent transparent transparent;top:50%}.dropdown.button:before,button.dropdown:before{border-width:0.375rem;right:1.40625rem;margin-top:-0.15625rem}.dropdown.button:before,button.dropdown:before{border-color:#fff transparent transparent transparent}.dropdown.button.tiny,button.dropdown.tiny{padding-right:2.625rem}.dropdown.button.tiny:before,button.dropdown.tiny:before{border-width:0.375rem;right:1.125rem;margin-top:-0.125rem}.dropdown.button.tiny:before,button.dropdown.tiny:before{border-color:#fff transparent transparent transparent}.dropdown.button.small,button.dropdown.small{padding-right:3.0625rem}.dropdown.button.small:before,button.dropdown.small:before{border-width:0.4375rem;right:1.3125rem;margin-top:-0.15625rem}.dropdown.button.small:before,button.dropdown.small:before{border-color:#fff transparent transparent transparent}.dropdown.button.large,button.dropdown.large{padding-right:3.625rem}.dropdown.button.large:before,button.dropdown.large:before{border-width:0.3125rem;right:1.71875rem;margin-top:-0.15625rem}.dropdown.button.large:before,button.dropdown.large:before{border-color:#fff transparent transparent transparent}.dropdown.button.secondary:before,button.dropdown.secondary:before{border-color:#333 transparent transparent transparent}div.switch{position:relative;padding:0;display:block;overflow:hidden;border-style:solid;border-width:1px;margin-bottom:1.25rem;height:2.25rem;background:#fff;border-color:#ccc}div.switch label{position:relative;left:0;z-index:2;float:left;width:50%;height:100%;margin:0;font-weight:bold;text-align:left;transition:all 0.1s ease-out}div.switch input{position:absolute;z-index:3;opacity:0;width:100%;height:100%;-moz-appearance:none}div.switch input:hover,div.switch input:focus{cursor:pointer}div.switch span:last-child{position:absolute;top:-1px;left:-1px;z-index:1;display:block;padding:0;border-width:1px;border-style:solid;transition:all 0.1s ease-out}div.switch input:not(:checked)+label{opacity:0}div.switch input:checked{display:none !important}div.switch input{left:0;display:block !important}div.switch input:first-of-type+label,div.switch input:first-of-type+span+label{left:-50%}div.switch input:first-of-type:checked+label,div.switch input:first-of-type:checked+span+label{left:0%}div.switch input:last-of-type+label,div.switch input:last-of-type+span+label{right:-50%;left:auto;text-align:right}div.switch input:last-of-type:checked+label,div.switch input:last-of-type:checked+span+label{right:0%;left:auto}div.switch span.custom{display:none !important}form.custom div.switch .hidden-field{margin-left:auto;position:absolute;visibility:visible}div.switch label{padding:0;line-height:2.3rem;font-size:0.875rem}div.switch input:first-of-type:checked ~ span:last-child{left:100%;margin-left:-2.1875rem}div.switch span:last-child{width:2.25rem;height:2.25rem}div.switch span:last-child{border-color:#b3b3b3;background:#fff;background:linear-gradient(to bottom, #fff 0%, #f2f2f2 100%);box-shadow:2px 0 10px 0 rgba(0,0,0,0.07),1000px 0 0 980px #f3faf6,-2px 0 10px 0 rgba(0,0,0,0.07),-1000px 0 0 1000px #f5f5f5}div.switch:hover span:last-child,div.switch:focus span:last-child{background:#fff;background:linear-gradient(to bottom, #fff 0%, #e6e6e6 100%)}div.switch:active{background:transparent}div.switch.large{height:2.75rem}div.switch.large label{padding:0;line-height:2.3rem;font-size:1.0625rem}div.switch.large input:first-of-type:checked ~ span:last-child{left:100%;margin-left:-2.6875rem}div.switch.large span:last-child{width:2.75rem;height:2.75rem}div.switch.small{height:1.75rem}div.switch.small label{padding:0;line-height:2.1rem;font-size:0.75rem}div.switch.small input:first-of-type:checked ~ span:last-child{left:100%;margin-left:-1.6875rem}div.switch.small span:last-child{width:1.75rem;height:1.75rem}div.switch.tiny{height:1.375rem}div.switch.tiny label{padding:0;line-height:1.9rem;font-size:0.6875rem}div.switch.tiny input:first-of-type:checked ~ span:last-child{left:100%;margin-left:-1.3125rem}div.switch.tiny span:last-child{width:1.375rem;height:1.375rem}div.switch.radius{border-radius:4px}div.switch.radius span:last-child{border-radius:3px}div.switch.round{border-radius:1000px}div.switch.round span:last-child{border-radius:999px}div.switch.round label{padding:0 0.5625rem}.th{line-height:0;display:inline-block;border:solid 4px #fff;max-width:100%;box-shadow:0 0 0 1px rgba(0,0,0,0.2);transition:all 200ms ease-out}.th:hover,.th:focus{box-shadow:0 0 6px 1px rgba(0,140,186,0.5)}.th.radius{border-radius:3px}.pricing-table{border:solid 1px #ddd;margin-left:0;margin-bottom:1.25rem}.pricing-table *{list-style:none;line-height:1}.pricing-table .title{background-color:#333;padding:0.9375rem 1.25rem;text-align:center;color:#eee;font-weight:normal;font-size:1rem;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif}.pricing-table .price{background-color:#f6f6f6;padding:0.9375rem 1.25rem;text-align:center;color:#333;font-weight:normal;font-size:2rem;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif}.pricing-table .description{background-color:#fff;padding:0.9375rem;text-align:center;color:#777;font-size:0.75rem;font-weight:normal;line-height:1.4;border-bottom:dotted 1px #ddd}.pricing-table .bullet-item{background-color:#fff;padding:0.9375rem;text-align:center;color:#333;font-size:0.875rem;font-weight:normal;border-bottom:dotted 1px #ddd}.pricing-table .cta-button{background-color:#fff;text-align:center;padding:1.25rem 1.25rem 0}@keyframes rotate{from{-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);-o-transform:rotate(360deg);transform:rotate(360deg)}}.slideshow-wrapper{position:relative}.slideshow-wrapper ul{list-style-type:none;margin:0}.slideshow-wrapper ul li,.slideshow-wrapper ul li .orbit-caption{display:none}.slideshow-wrapper ul li:first-child{display:block}.slideshow-wrapper .orbit-container{background-color:transparent}.slideshow-wrapper .orbit-container li{display:block}.slideshow-wrapper .orbit-container li .orbit-caption{display:block}.slideshow-wrapper .preloader{display:block;width:40px;height:40px;position:absolute;top:50%;left:50%;margin-top:-20px;margin-left:-20px;border:solid 3px;border-color:#555 #fff;border-radius:1000px;animation-name:rotate;animation-duration:1.5s;animation-iteration-count:infinite;animation-timing-function:linear}.orbit-container{overflow:hidden;width:100%;position:relative;background:none}.orbit-container .orbit-slides-container{list-style:none;margin:0;padding:0;position:relative;-webkit-transform:translateZ(0)}.orbit-container .orbit-slides-container img{display:block;max-width:100%}.orbit-container .orbit-slides-container.fade li{opacity:0;transition:opacity 500ms ease-in-out;-ms-transform:translate(0, 0);-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}.orbit-container .orbit-slides-container.fade li.animate-in{opacity:1;z-index:20;transition:opacity 500ms ease-in-out}.orbit-container .orbit-slides-container.fade li.animate-out{z-index:10;transition:opacity 500ms ease-in-out}.orbit-container .orbit-slides-container.swipe-next li{-ms-transform:translate(100%, 0);-webkit-transform:translate3d(100%, 0, 0);-moz-transform:translate3d(100%, 0, 0);-o-transform:translate3d(100%, 0, 0);transform:translate3d(100%, 0, 0)}.orbit-container .orbit-slides-container.swipe-next li.animate-in{-ms-transform:translate(0, 0);-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);transition-duration:500ms}.orbit-container .orbit-slides-container.swipe-next li.animate-out{-ms-transform:translate(-100%, 0);-webkit-transform:translate3d(-100%, 0, 0);-moz-transform:translate3d(-100%, 0, 0);-o-transform:translate3d(-100%, 0, 0);transform:translate3d(-100%, 0, 0);transition-duration:500ms}.orbit-container .orbit-slides-container.swipe-prev li{-ms-transform:translate(-100%, 0);-webkit-transform:translate3d(-100%, 0, 0);-moz-transform:translate3d(-100%, 0, 0);-o-transform:translate3d(-100%, 0, 0);transform:translate3d(-100%, 0, 0)}.orbit-container .orbit-slides-container.swipe-prev li.animate-in{-ms-transform:translate(0, 0);-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0);transition-duration:500ms}.orbit-container .orbit-slides-container.swipe-prev li.animate-out{-ms-transform:translate(100%, 0);-webkit-transform:translate3d(100%, 0, 0);-moz-transform:translate3d(100%, 0, 0);-o-transform:translate3d(100%, 0, 0);transform:translate3d(100%, 0, 0);transition-duration:500ms}.orbit-container .orbit-slides-container li{position:absolute;top:0;left:0;width:100%;-ms-transform:translate(100%, 0);-webkit-transform:translate3d(100%, 0, 0);-moz-transform:translate3d(100%, 0, 0);-o-transform:translate3d(100%, 0, 0);transform:translate3d(100%, 0, 0)}.orbit-container .orbit-slides-container li.active{opacity:1;top:0;left:0;-ms-transform:translate(0, 0);-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}.orbit-container .orbit-slides-container li .orbit-caption{position:absolute;bottom:0;background-color:rgba(51,51,51,0.8);color:#fff;width:100%;padding:0.625rem 0.875rem;font-size:0.875rem}.orbit-container .orbit-slide-number{position:absolute;top:10px;left:10px;font-size:12px;color:#fff;background:rgba(0,0,0,0);z-index:10}.orbit-container .orbit-slide-number span{font-weight:700;padding:0.3125rem}.orbit-container .orbit-timer{position:absolute;top:12px;right:10px;height:6px;width:100px;z-index:10}.orbit-container .orbit-timer .orbit-progress{height:3px;background-color:rgba(255,255,255,0.3);display:block;width:0%;position:relative;right:20px;top:5px}.orbit-container .orbit-timer>span{display:none;position:absolute;top:0px;right:0;width:11px;height:14px;border:solid 4px #fff;border-top:none;border-bottom:none}.orbit-container .orbit-timer.paused>span{right:-4px;top:0px;width:11px;height:14px;border:inset 8px;border-left-style:solid;-webkit-transform:rotate(180deg);-moz-transform:rotate(180deg);-ms-transform:rotate(180deg);-o-transform:rotate(180deg);transform:rotate(180deg);border-color:transparent #fff transparent transparent}.orbit-container .orbit-timer.paused>span.dark{border-color:transparent #333 transparent transparent}.orbit-container:hover .orbit-timer>span{display:block}.orbit-container .orbit-prev,.orbit-container .orbit-next{position:absolute;top:45%;margin-top:-25px;width:36px;height:60px;line-height:50px;color:white;background-color:transparent;text-indent:-9999px !important;z-index:10}.orbit-container .orbit-prev:hover,.orbit-container .orbit-next:hover{background-color:rgba(0,0,0,0.3)}.orbit-container .orbit-prev>span,.orbit-container .orbit-next>span{position:absolute;top:50%;margin-top:-10px;display:block;width:0;height:0;border:inset 10px}.orbit-container .orbit-prev{left:0}.orbit-container .orbit-prev>span{border-right-style:solid;border-color:transparent;border-right-color:#fff}.orbit-container .orbit-prev:hover>span{border-right-color:#fff}.orbit-container .orbit-next{right:0}.orbit-container .orbit-next>span{border-color:transparent;border-left-style:solid;border-left-color:#fff;left:50%;margin-left:-4px}.orbit-container .orbit-next:hover>span{border-left-color:#fff}.orbit-container .orbit-bullets-container{text-align:center}.orbit-container .orbit-bullets{margin:0 auto 30px auto;overflow:hidden;position:relative;top:10px;float:none;text-align:center;display:block}.orbit-container .orbit-bullets li{display:inline-block;width:0.5625rem;height:0.5625rem;background:#ccc;float:none;margin-right:6px;border-radius:1000px}.orbit-container .orbit-bullets li.active{background:#999}.orbit-container .orbit-bullets li:last-child{margin-right:0}.touch .orbit-container .orbit-prev,.touch .orbit-container .orbit-next{display:none}.touch .orbit-bullets{display:none}@media only screen and (min-width: 40.063em){.touch .orbit-container .orbit-prev,.touch .orbit-container .orbit-next{display:inherit}.touch .orbit-bullets{display:block}}@media only screen and (max-width: 40em){.orbit-stack-on-small .orbit-slides-container{height:auto !important}.orbit-stack-on-small .orbit-slides-container>*{position:relative;margin-left:0% !important;opacity:1 !important;-webkit-transform:none !important;-moz-transform:none !important;-ms-transform:none !important;-o-transform:none !important;transform:none !important;transition:none !important}.orbit-stack-on-small .orbit-timer{display:none}.orbit-stack-on-small .orbit-next,.orbit-stack-on-small .orbit-prev{display:none}.orbit-stack-on-small .orbit-bullets{display:none}}[data-magellan-expedition],[data-magellan-expedition-clone]{background:#fff;z-index:50;min-width:100%;padding:10px}[data-magellan-expedition] .sub-nav,[data-magellan-expedition-clone] .sub-nav{margin-bottom:0}[data-magellan-expedition] .sub-nav dd,[data-magellan-expedition-clone] .sub-nav dd{margin-bottom:0}[data-magellan-expedition] .sub-nav a,[data-magellan-expedition-clone] .sub-nav a{line-height:1.8em}.tabs{*zoom:1;margin-bottom:0 !important}.tabs:before,.tabs:after{content:" ";display:table}.tabs:after{clear:both}.tabs dd{position:relative;margin-bottom:0 !important;float:left}.tabs dd>a{display:block;background:#efefef;color:#222;padding:1rem 2rem;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-size:1rem}.tabs dd>a:hover{background:#e1e1e1}.tabs dd.active a{background:#fff}.tabs.radius dd:first-child a{border-bottom-left-radius:3px;border-top-left-radius:3px}.tabs.radius dd:last-child a{border-bottom-right-radius:3px;border-top-right-radius:3px}.tabs.vertical dd{position:inherit;float:none;display:block;top:auto}.tabs-content{*zoom:1;margin-bottom:1.5rem;width:100%}.tabs-content:before,.tabs-content:after{content:" ";display:table}.tabs-content:after{clear:both}.tabs-content>.content{display:none;float:left;padding:0.9375rem 0;width:100%}.tabs-content>.content.active{display:block;float:none}.tabs-content>.content.contained{padding:0.9375rem}.tabs-content.vertical{display:block}.tabs-content.vertical>.content{padding:0 0.9375rem}@media only screen and (min-width: 40.063em){.tabs.vertical{width:20%;float:left;margin-bottom:1.25rem}.tabs-content.vertical{width:80%;float:left;margin-left:-1px}}.no-js .tabs-content>.content{display:block;float:none}ul.pagination{display:block;height:1.5rem;margin-left:-0.3125rem}ul.pagination li{height:1.5rem;color:#222;font-size:0.875rem;margin-left:0.3125rem}ul.pagination li a{display:block;padding:0.0625rem 0.625rem 0.0625rem;color:#999;border-radius:3px}ul.pagination li:hover a,ul.pagination li a:focus{background:#e6e6e6}ul.pagination li.unavailable a{cursor:default;color:#999}ul.pagination li.unavailable:hover a,ul.pagination li.unavailable a:focus{background:transparent}ul.pagination li.current a{background:#008cba;color:#fff;font-weight:bold;cursor:default}ul.pagination li.current a:hover,ul.pagination li.current a:focus{background:#008cba}ul.pagination li{float:left;display:block}.pagination-centered{text-align:center}.pagination-centered ul.pagination li{float:none;display:inline-block}.side-nav{display:block;margin:0;padding:0.875rem 0;list-style-type:none;list-style-position:inside;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif}.side-nav li{margin:0 0 0.4375rem 0;font-size:0.875rem}.side-nav li a:not(.button){display:block;color:#008cba}.side-nav li a:not(.button):hover,.side-nav li a:not(.button):focus{color:#1cc7ff}.side-nav li.active>a:first-child:not(.button){color:#1cc7ff;font-weight:normal;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif}.side-nav li.divider{border-top:1px solid;height:0;padding:0;list-style:none;border-top-color:#fff}.accordion{*zoom:1;margin-bottom:0}.accordion:before,.accordion:after{content:" ";display:table}.accordion:after{clear:both}.accordion dd{display:block;margin-bottom:0 !important}.accordion dd.active>a{background:#e8e8e8}.accordion dd>a{background:#efefef;color:#222;padding:1rem;display:block;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-size:1rem}.accordion dd>a:hover{background:#e3e3e3}.accordion .content{display:none;padding:0.9375rem}.accordion .content.active{display:block;background:#fff}.text-left{text-align:left !important}.text-right{text-align:right !important}.text-center{text-align:center !important}.text-justify{text-align:justify !important}@media only screen and (max-width: 40em){.small-only-text-left{text-align:left !important}.small-only-text-right{text-align:right !important}.small-only-text-center{text-align:center !important}.small-only-text-justify{text-align:justify !important}}@media only screen{.small-text-left{text-align:left !important}.small-text-right{text-align:right !important}.small-text-center{text-align:center !important}.small-text-justify{text-align:justify !important}}@media only screen and (min-width: 40.063em) and (max-width: 64em){.medium-only-text-left{text-align:left !important}.medium-only-text-right{text-align:right !important}.medium-only-text-center{text-align:center !important}.medium-only-text-justify{text-align:justify !important}}@media only screen and (min-width: 40.063em){.medium-text-left{text-align:left !important}.medium-text-right{text-align:right !important}.medium-text-center{text-align:center !important}.medium-text-justify{text-align:justify !important}}@media only screen and (min-width: 64.063em) and (max-width: 90em){.large-only-text-left{text-align:left !important}.large-only-text-right{text-align:right !important}.large-only-text-center{text-align:center !important}.large-only-text-justify{text-align:justify !important}}@media only screen and (min-width: 64.063em){.large-text-left{text-align:left !important}.large-text-right{text-align:right !important}.large-text-center{text-align:center !important}.large-text-justify{text-align:justify !important}}@media only screen and (min-width: 90.063em) and (max-width: 120em){.xlarge-only-text-left{text-align:left !important}.xlarge-only-text-right{text-align:right !important}.xlarge-only-text-center{text-align:center !important}.xlarge-only-text-justify{text-align:justify !important}}@media only screen and (min-width: 90.063em){.xlarge-text-left{text-align:left !important}.xlarge-text-right{text-align:right !important}.xlarge-text-center{text-align:center !important}.xlarge-text-justify{text-align:justify !important}}@media only screen and (min-width: 120.063em) and (max-width: 99999999em){.xxlarge-only-text-left{text-align:left !important}.xxlarge-only-text-right{text-align:right !important}.xxlarge-only-text-center{text-align:center !important}.xxlarge-only-text-justify{text-align:justify !important}}@media only screen and (min-width: 120.063em){.xxlarge-text-left{text-align:left !important}.xxlarge-text-right{text-align:right !important}.xxlarge-text-center{text-align:center !important}.xxlarge-text-justify{text-align:justify !important}}div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}a{color:#008cba;text-decoration:none;line-height:inherit}a:hover,a:focus{color:#0078a0}a img{border:none}p{font-family:inherit;font-weight:normal;font-size:1rem;line-height:1.6;margin-bottom:1.25rem;text-rendering:optimizeLegibility}p.lead{font-size:1.21875rem;line-height:1.6}p aside{font-size:0.875rem;line-height:1.35;font-style:italic}h1,h2,h3,h4,h5,h6{font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:normal;font-style:normal;color:#222;text-rendering:optimizeLegibility;margin-top:0.2rem;margin-bottom:0.5rem;line-height:1.4}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-size:60%;color:#6f6f6f;line-height:0}h1{font-size:2.125rem}h2{font-size:1.6875rem}h3{font-size:1.375rem}h4{font-size:1.125rem}h5{font-size:1.125rem}h6{font-size:1rem}.subheader{line-height:1.4;color:#6f6f6f;font-weight:normal;margin-top:0.2rem;margin-bottom:0.5rem}hr{border:solid #ddd;border-width:1px 0 0;clear:both;margin:1.25rem 0 1.1875rem;height:0}em,i{font-style:italic;line-height:inherit}strong,b{font-weight:bold;line-height:inherit}small{font-size:60%;line-height:inherit}code{font-family:Consolas,"Liberation Mono",Courier,monospace;font-weight:bold;color:#bd260d}ul,ol,dl{font-size:1rem;line-height:1.6;margin-bottom:1.25rem;list-style-position:outside;font-family:inherit}ul{margin-left:1.1rem}ul.no-bullet{margin-left:0}ul.no-bullet li ul,ul.no-bullet li ol{margin-left:1.25rem;margin-bottom:0;list-style:none}ul li ul,ul li ol{margin-left:1.25rem;margin-bottom:0}ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}ul.square{list-style-type:square;margin-left:1.1rem}ul.circle{list-style-type:circle;margin-left:1.1rem}ul.disc{list-style-type:disc;margin-left:1.1rem}ul.no-bullet{list-style:none}ol{margin-left:1.4rem}ol li ul,ol li ol{margin-left:1.25rem;margin-bottom:0}dl dt{margin-bottom:0.3rem;font-weight:bold}dl dd{margin-bottom:0.75rem}abbr,acronym{text-transform:uppercase;font-size:90%;color:#222;border-bottom:1px dotted #ddd;cursor:help}abbr{text-transform:none}blockquote{margin:0 0 1.25rem;padding:0.5625rem 1.25rem 0 1.1875rem;border-left:1px solid #ddd}blockquote cite{display:block;font-size:0.8125rem;color:#555}blockquote cite:before{content:"\2014 \0020"}blockquote cite a,blockquote cite a:visited{color:#555}blockquote,blockquote p{line-height:1.6;color:#6f6f6f}.vcard{display:inline-block;margin:0 0 1.25rem 0;border:1px solid #ddd;padding:0.625rem 0.75rem}.vcard li{margin:0;display:block}.vcard .fn{font-weight:bold;font-size:0.9375rem}.vevent .summary{font-weight:bold}.vevent abbr{cursor:default;text-decoration:none;font-weight:bold;border:none;padding:0 0.0625rem}@media only screen and (min-width: 40.063em){h1,h2,h3,h4,h5,h6{line-height:1.4}h1{font-size:2.75rem}h2{font-size:2.3125rem}h3{font-size:1.6875rem}h4{font-size:1.4375rem}}.print-only{display:none !important}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}.hide-on-print{display:none !important}.print-only{display:block !important}.hide-for-print{display:none !important}.show-for-print{display:inherit !important}}.split.button{position:relative;padding-right:5.0625rem}.split.button span{display:block;height:100%;position:absolute;right:0;top:0;border-left:solid 1px}.split.button span:before{position:absolute;content:"";width:0;height:0;display:block;border-style:inset;top:50%;left:50%}.split.button span:active{background-color:rgba(0,0,0,0.1)}.split.button span{border-left-color:rgba(255,255,255,0.5)}.split.button span{width:3.09375rem}.split.button span:before{border-top-style:solid;border-width:0.375rem;top:48%;margin-left:-0.375rem}.split.button span:before{border-color:#fff transparent transparent transparent}.split.button.secondary span{border-left-color:rgba(255,255,255,0.5)}.split.button.secondary span:before{border-color:#fff transparent transparent transparent}.split.button.alert span{border-left-color:rgba(255,255,255,0.5)}.split.button.success span{border-left-color:rgba(255,255,255,0.5)}.split.button.tiny{padding-right:3.75rem}.split.button.tiny span{width:2.25rem}.split.button.tiny span:before{border-top-style:solid;border-width:0.375rem;top:48%;margin-left:-0.375rem}.split.button.small{padding-right:4.375rem}.split.button.small span{width:2.625rem}.split.button.small span:before{border-top-style:solid;border-width:0.4375rem;top:48%;margin-left:-0.375rem}.split.button.large{padding-right:5.5rem}.split.button.large span{width:3.4375rem}.split.button.large span:before{border-top-style:solid;border-width:0.3125rem;top:48%;margin-left:-0.375rem}.split.button.expand{padding-left:2rem}.split.button.secondary span:before{border-color:#333 transparent transparent transparent}.split.button.radius span{border-bottom-right-radius:3px;border-top-right-radius:3px}.split.button.round span{border-bottom-right-radius:1000px;border-top-right-radius:1000px}.reveal-modal-bg{position:fixed;height:100%;width:100%;background:#000;background:rgba(0,0,0,0.45);z-index:99;display:none;top:0;left:0}dialog,.reveal-modal{visibility:hidden;display:none;position:absolute;z-index:100;width:100vw;top:0;left:0;background-color:#fff;padding:1.25rem;border:solid 1px #666;box-shadow:0 0 10px rgba(0,0,0,0.4)}@media only screen and (max-width: 40em){dialog,.reveal-modal{min-height:100vh}}@media only screen and (min-width: 40.063em){dialog,.reveal-modal{left:50%}}dialog .column,dialog .columns,.reveal-modal .column,.reveal-modal .columns{min-width:0}dialog>:first-child,.reveal-modal>:first-child{margin-top:0}dialog>:last-child,.reveal-modal>:last-child{margin-bottom:0}@media only screen and (min-width: 40.063em){dialog,.reveal-modal{margin-left:-40%;width:80%}}@media only screen and (min-width: 40.063em){dialog,.reveal-modal{top:6.25rem}}dialog .close-reveal-modal,.reveal-modal .close-reveal-modal{font-size:2.5rem;line-height:1;position:absolute;top:0.5rem;right:0.6875rem;color:#aaa;font-weight:bold;cursor:pointer}dialog[open]{display:block;visibility:visible}@media only screen and (min-width: 40.063em){dialog,.reveal-modal{padding:1.875rem}dialog.radius,.reveal-modal.radius{border-radius:3px}dialog.round,.reveal-modal.round{border-radius:1000px}dialog.collapse,.reveal-modal.collapse{padding:0}dialog.full,.reveal-modal.full{top:0;left:0;height:100vh;min-height:100vh;margin-left:0 !important}}@media only screen and (min-width: 40.063em) and (min-width: 40.063em){dialog.tiny,.reveal-modal.tiny{margin-left:-15%;width:30%}}@media only screen and (min-width: 40.063em) and (min-width: 40.063em){dialog.small,.reveal-modal.small{margin-left:-20%;width:40%}}@media only screen and (min-width: 40.063em) and (min-width: 40.063em){dialog.medium,.reveal-modal.medium{margin-left:-30%;width:60%}}@media only screen and (min-width: 40.063em) and (min-width: 40.063em){dialog.large,.reveal-modal.large{margin-left:-35%;width:70%}}@media only screen and (min-width: 40.063em) and (min-width: 40.063em){dialog.xlarge,.reveal-modal.xlarge{margin-left:-47.5%;width:95%}}@media only screen and (min-width: 40.063em) and (min-width: 40.063em){dialog.full,.reveal-modal.full{margin-left:-50vw;width:100vw}}@media print{dialog,.reveal-modal{background:#fff !important}}.has-tip{border-bottom:dotted 1px #ccc;cursor:help;font-weight:bold;color:#333}.has-tip:hover,.has-tip:focus{border-bottom:dotted 1px #003f54;color:#008cba}.has-tip.tip-left,.has-tip.tip-right{float:none !important}.tooltip{display:none;position:absolute;z-index:999;font-weight:normal;font-size:0.875rem;line-height:1.3;padding:0.75rem;max-width:85%;left:50%;width:100%;color:#fff;background:#333}.tooltip>.nub{display:block;left:5px;position:absolute;width:0;height:0;border:solid 5px;border-color:transparent transparent #333 transparent;top:-10px}.tooltip>.nub.rtl{left:auto;right:5px}.tooltip.radius{border-radius:3px}.tooltip.round{border-radius:1000px}.tooltip.round>.nub{left:2rem}.tooltip.opened{color:#008cba !important;border-bottom:dotted 1px #003f54 !important}.tap-to-close{display:block;font-size:0.625rem;color:#777;font-weight:normal}@media only screen and (min-width: 40.063em){.tooltip>.nub{border-color:transparent transparent #333 transparent;top:-10px}.tooltip.tip-top>.nub{border-color:#333 transparent transparent transparent;top:auto;bottom:-10px}.tooltip.tip-left,.tooltip.tip-right{float:none !important}.tooltip.tip-left>.nub{border-color:transparent transparent transparent #333;right:-10px;left:auto;top:50%;margin-top:-5px}.tooltip.tip-right>.nub{border-color:transparent #333 transparent transparent;right:auto;left:-10px;top:50%;margin-top:-5px}}.clearing-thumbs,[data-clearing]{*zoom:1;margin-bottom:0;margin-left:0;list-style:none}.clearing-thumbs:before,.clearing-thumbs:after,[data-clearing]:before,[data-clearing]:after{content:" ";display:table}.clearing-thumbs:after,[data-clearing]:after{clear:both}.clearing-thumbs li,[data-clearing] li{float:left;margin-right:10px}.clearing-thumbs[class*="block-grid-"] li,[data-clearing][class*="block-grid-"] li{margin-right:0}.clearing-blackout{background:#333;position:fixed;width:100%;height:100%;top:0;left:0;z-index:998}.clearing-blackout .clearing-close{display:block}.clearing-container{position:relative;z-index:998;height:100%;overflow:hidden;margin:0}.clearing-touch-label{position:absolute;top:50%;left:50%;color:#aaa;font-size:0.6em}.visible-img{height:95%;position:relative}.visible-img img{position:absolute;left:50%;top:50%;margin-left:-50%;max-height:100%;max-width:100%}.clearing-caption{color:#ccc;font-size:0.875em;line-height:1.3;margin-bottom:0;text-align:center;bottom:0;background:#333;width:100%;padding:10px 30px 20px;position:absolute;left:0}.clearing-close{z-index:999;padding-left:20px;padding-top:10px;font-size:30px;line-height:1;color:#ccc;display:none}.clearing-close:hover,.clearing-close:focus{color:#ccc}.clearing-assembled .clearing-container{height:100%}.clearing-assembled .clearing-container .carousel>ul{display:none}.clearing-feature li{display:none}.clearing-feature li.clearing-featured-img{display:block}@media only screen and (min-width: 40.063em){.clearing-main-prev,.clearing-main-next{position:absolute;height:100%;width:40px;top:0}.clearing-main-prev>span,.clearing-main-next>span{position:absolute;top:50%;display:block;width:0;height:0;border:solid 12px}.clearing-main-prev>span:hover,.clearing-main-next>span:hover{opacity:0.8}.clearing-main-prev{left:0}.clearing-main-prev>span{left:5px;border-color:transparent;border-right-color:#ccc}.clearing-main-next{right:0}.clearing-main-next>span{border-color:transparent;border-left-color:#ccc}.clearing-main-prev.disabled,.clearing-main-next.disabled{opacity:0.3}.clearing-assembled .clearing-container .carousel{background:rgba(51,51,51,0.8);height:120px;margin-top:10px;text-align:center}.clearing-assembled .clearing-container .carousel>ul{display:inline-block;z-index:999;height:100%;position:relative;float:none}.clearing-assembled .clearing-container .carousel>ul li{display:block;width:120px;min-height:inherit;float:left;overflow:hidden;margin-right:0;padding:0;position:relative;cursor:pointer;opacity:0.4;clear:none}.clearing-assembled .clearing-container .carousel>ul li.fix-height img{height:100%;max-width:none}.clearing-assembled .clearing-container .carousel>ul li a.th{border:none;box-shadow:none;display:block}.clearing-assembled .clearing-container .carousel>ul li img{cursor:pointer !important;width:100% !important}.clearing-assembled .clearing-container .carousel>ul li.visible{opacity:1}.clearing-assembled .clearing-container .carousel>ul li:hover{opacity:0.8}.clearing-assembled .clearing-container .visible-img{background:#333;overflow:hidden;height:85%}.clearing-close{position:absolute;top:10px;right:20px;padding-left:0;padding-top:0}}.progress{background-color:#f6f6f6;height:1.5625rem;border:1px solid #fff;padding:0.125rem;margin-bottom:0.625rem}.progress .meter{background:#008cba;height:100%;display:block}.progress.secondary .meter{background:#e7e7e7;height:100%;display:block}.progress.success .meter{background:#43ac6a;height:100%;display:block}.progress.alert .meter{background:#f04124;height:100%;display:block}.progress.radius{border-radius:3px}.progress.radius .meter{border-radius:2px}.progress.round{border-radius:1000px}.progress.round .meter{border-radius:999px}.sub-nav{display:block;width:auto;overflow:hidden;margin:-0.25rem 0 1.125rem;padding-top:0.25rem;margin-right:0;margin-left:-0.75rem}.sub-nav dt{text-transform:uppercase}.sub-nav dt,.sub-nav dd,.sub-nav li{float:left;display:inline;margin-left:1rem;margin-bottom:0.625rem;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:normal;font-size:0.875rem;color:#999}.sub-nav dt a,.sub-nav dd a,.sub-nav li a{text-decoration:none;color:#999;padding:0.1875rem 1rem}.sub-nav dt a:hover,.sub-nav dd a:hover,.sub-nav li a:hover{color:#737373}.sub-nav dt.active a,.sub-nav dd.active a,.sub-nav li.active a{border-radius:3px;font-weight:normal;background:#008cba;padding:0.1875rem 1rem;cursor:default;color:#fff}.sub-nav dt.active a:hover,.sub-nav dd.active a:hover,.sub-nav li.active a:hover{background:#0078a0}.joyride-list{display:none}.joyride-tip-guide{display:none;position:absolute;background:#333;color:#fff;z-index:101;top:0;left:2.5%;font-family:inherit;font-weight:normal;width:95%}.lt-ie9 .joyride-tip-guide{max-width:800px;left:50%;margin-left:-400px}.joyride-content-wrapper{width:100%;padding:1.125rem 1.25rem 1.5rem}.joyride-content-wrapper .button{margin-bottom:0 !important}.joyride-tip-guide .joyride-nub{display:block;position:absolute;left:22px;width:0;height:0;border:10px solid #333}.joyride-tip-guide .joyride-nub.top{border-top-style:solid;border-color:#333;border-top-color:transparent !important;border-left-color:transparent !important;border-right-color:transparent !important;top:-20px}.joyride-tip-guide .joyride-nub.bottom{border-bottom-style:solid;border-color:#333 !important;border-bottom-color:transparent !important;border-left-color:transparent !important;border-right-color:transparent !important;bottom:-20px}.joyride-tip-guide .joyride-nub.right{right:-20px}.joyride-tip-guide .joyride-nub.left{left:-20px}.joyride-tip-guide h1,.joyride-tip-guide h2,.joyride-tip-guide h3,.joyride-tip-guide h4,.joyride-tip-guide h5,.joyride-tip-guide h6{line-height:1.25;margin:0;font-weight:bold;color:#fff}.joyride-tip-guide p{margin:0 0 1.125rem 0;font-size:0.875rem;line-height:1.3}.joyride-timer-indicator-wrap{width:50px;height:3px;border:solid 1px #555;position:absolute;right:1.0625rem;bottom:1rem}.joyride-timer-indicator{display:block;width:0;height:inherit;background:#666}.joyride-close-tip{position:absolute;right:12px;top:10px;color:#777 !important;text-decoration:none;font-size:24px;font-weight:normal;line-height:0.5 !important}.joyride-close-tip:hover,.joyride-close-tip:focus{color:#eee !important}.joyride-modal-bg{position:fixed;height:100%;width:100%;background:transparent;background:rgba(0,0,0,0.5);z-index:100;display:none;top:0;left:0;cursor:pointer}.joyride-expose-wrapper{background-color:#ffffff;position:absolute;border-radius:3px;z-index:102;box-shadow:0 0 15px #fff}.joyride-expose-cover{background:transparent;border-radius:3px;position:absolute;z-index:9999;top:0;left:0}@media only screen and (min-width: 40.063em){.joyride-tip-guide{width:300px;left:inherit}.joyride-tip-guide .joyride-nub.bottom{border-color:#333 !important;border-bottom-color:transparent !important;border-left-color:transparent !important;border-right-color:transparent !important;bottom:-20px}.joyride-tip-guide .joyride-nub.right{border-color:#333 !important;border-top-color:transparent !important;border-right-color:transparent !important;border-bottom-color:transparent !important;top:22px;left:auto;right:-20px}.joyride-tip-guide .joyride-nub.left{border-color:#333 !important;border-top-color:transparent !important;border-left-color:transparent !important;border-bottom-color:transparent !important;top:22px;left:-20px;right:auto}}.label{font-weight:normal;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;text-align:center;text-decoration:none;line-height:1;white-space:nowrap;display:inline-block;position:relative;margin-bottom:inherit;padding:0.25rem 0.5rem 0.375rem;font-size:0.6875rem;background-color:#008cba;color:#fff}.label.radius{border-radius:3px}.label.round{border-radius:1000px}.label.alert{background-color:#f04124;color:#fff}.label.success{background-color:#43ac6a;color:#fff}.label.secondary{background-color:#e7e7e7;color:#333}.off-canvas-wrap{-webkit-backface-visibility:hidden;position:relative;width:100%;overflow:hidden}.off-canvas-wrap.move-right,.off-canvas-wrap.move-left{min-height:100%;-webkit-overflow-scrolling:touch}.inner-wrap{-webkit-backface-visibility:hidden;position:relative;width:100%;*zoom:1;-webkit-transition:-webkit-transform 500ms ease;-moz-transition:-moz-transform 500ms ease;-ms-transition:-ms-transform 500ms ease;-o-transition:-o-transform 500ms ease;transition:transform 500ms ease}.inner-wrap:before,.inner-wrap:after{content:" ";display:table}.inner-wrap:after{clear:both}.tab-bar{-webkit-backface-visibility:hidden;background:#333;color:#fff;height:2.8125rem;line-height:2.8125rem;position:relative}.tab-bar h1,.tab-bar h2,.tab-bar h3,.tab-bar h4,.tab-bar h5,.tab-bar h6{color:#fff;font-weight:bold;line-height:2.8125rem;margin:0}.tab-bar h1,.tab-bar h2,.tab-bar h3,.tab-bar h4{font-size:1.125rem}.left-small{width:2.8125rem;height:2.8125rem;position:absolute;top:0;border-right:solid 1px #1a1a1a;left:0}.right-small{width:2.8125rem;height:2.8125rem;position:absolute;top:0;border-left:solid 1px #1a1a1a;right:0}.tab-bar-section{padding:0 0.625rem;position:absolute;text-align:center;height:2.8125rem;top:0}@media only screen and (min-width: 40.063em){.tab-bar-section{text-align:left}}.tab-bar-section.left{left:0;right:2.8125rem}.tab-bar-section.right{left:2.8125rem;right:0}.tab-bar-section.middle{left:2.8125rem;right:2.8125rem}.tab-bar .menu-icon{text-indent:2.1875rem;width:2.8125rem;height:2.8125rem;display:block;line-height:2.0625rem;padding:0;color:#fff;position:relative;-ms-transform:translate(0, 0);-webkit-transform:translate3d(0, 0, 0);-moz-transform:translate3d(0, 0, 0);-ms-transform:translate3d(0, 0, 0);-o-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}.tab-bar .menu-icon span{position:absolute;display:block;height:0;width:1rem;line-height:1;top:0.9375rem;left:0.90625rem;box-shadow:0 0px 0 1px #fff,0 7px 0 1px #fff,0 14px 0 1px #fff}.tab-bar .menu-icon:hover span{box-shadow:0 0px 0 1px #b3b3b3,0 7px 0 1px #b3b3b3,0 14px 0 1px #b3b3b3}.left-off-canvas-menu{-webkit-backface-visibility:hidden;width:15.625rem;top:0;bottom:0;position:absolute;overflow-y:auto;background:#333;z-index:1001;box-sizing:content-box;-webkit-overflow-scrolling:touch;-ms-transform:translate(-100%, 0);-webkit-transform:translate3d(-100%, 0, 0);-moz-transform:translate3d(-100%, 0, 0);-ms-transform:translate3d(-100%, 0, 0);-o-transform:translate3d(-100%, 0, 0);transform:translate3d(-100%, 0, 0);left:0}.left-off-canvas-menu *{-webkit-backface-visibility:hidden}.right-off-canvas-menu{-webkit-backface-visibility:hidden;width:15.625rem;top:0;bottom:0;position:absolute;overflow-y:auto;background:#333;z-index:1001;box-sizing:content-box;-webkit-overflow-scrolling:touch;-ms-transform:translate(100%, 0);-webkit-transform:translate3d(100%, 0, 0);-moz-transform:translate3d(100%, 0, 0);-ms-transform:translate3d(100%, 0, 0);-o-transform:translate3d(100%, 0, 0);transform:translate3d(100%, 0, 0);right:0}.right-off-canvas-menu *{-webkit-backface-visibility:hidden}ul.off-canvas-list{list-style-type:none;padding:0;margin:0}ul.off-canvas-list li label{padding:0.3rem 0.9375rem;color:#999;text-transform:uppercase;font-weight:bold;background:#444;border-top:1px solid #5e5e5e;border-bottom:none;margin:0}ul.off-canvas-list li a{display:block;padding:0.66667rem;color:rgba(255,255,255,0.7);border-bottom:1px solid #262626;transition:background 300ms ease}ul.off-canvas-list li a:hover{background:#242424}.move-right>.inner-wrap{-ms-transform:translate(15.625rem, 0);-webkit-transform:translate3d(15.625rem, 0, 0);-moz-transform:translate3d(15.625rem, 0, 0);-ms-transform:translate3d(15.625rem, 0, 0);-o-transform:translate3d(15.625rem, 0, 0);transform:translate3d(15.625rem, 0, 0)}.move-right .exit-off-canvas{-webkit-backface-visibility:hidden;transition:background 300ms ease;cursor:pointer;box-shadow:-4px 0 4px rgba(0,0,0,0.5),4px 0 4px rgba(0,0,0,0.5);display:block;position:absolute;background:rgba(255,255,255,0.2);top:0;bottom:0;left:0;right:0;z-index:1002;-webkit-tap-highlight-color:rgba(0,0,0,0)}@media only screen and (min-width: 40.063em){.move-right .exit-off-canvas:hover{background:rgba(255,255,255,0.05)}}.move-left>.inner-wrap{-ms-transform:translate(-15.625rem, 0);-webkit-transform:translate3d(-15.625rem, 0, 0);-moz-transform:translate3d(-15.625rem, 0, 0);-ms-transform:translate3d(-15.625rem, 0, 0);-o-transform:translate3d(-15.625rem, 0, 0);transform:translate3d(-15.625rem, 0, 0)}.move-left .exit-off-canvas{-webkit-backface-visibility:hidden;transition:background 300ms ease;cursor:pointer;box-shadow:-4px 0 4px rgba(0,0,0,0.5),4px 0 4px rgba(0,0,0,0.5);display:block;position:absolute;background:rgba(255,255,255,0.2);top:0;bottom:0;left:0;right:0;z-index:1002;-webkit-tap-highlight-color:rgba(0,0,0,0)}@media only screen and (min-width: 40.063em){.move-left .exit-off-canvas:hover{background:rgba(255,255,255,0.05)}}.no-csstransforms .left-off-canvas-menu{left:-15.625rem}.no-csstransforms .right-off-canvas-menu{right:-15.625rem}.no-csstransforms .move-left>.inner-wrap{right:15.625rem}.no-csstransforms .move-right>.inner-wrap{left:15.625rem}.f-dropdown{position:absolute;left:-9999px;list-style:none;margin-left:0;width:100%;max-height:none;height:auto;background:#fff;border:solid 1px #ccc;font-size:0.875rem;z-index:99;margin-top:2px;max-width:200px}.f-dropdown>*:first-child{margin-top:0}.f-dropdown>*:last-child{margin-bottom:0}.f-dropdown:before{content:"";display:block;width:0;height:0;border:inset 6px;border-color:transparent transparent #fff transparent;border-bottom-style:solid;position:absolute;top:-12px;left:10px;z-index:99}.f-dropdown:after{content:"";display:block;width:0;height:0;border:inset 7px;border-color:transparent transparent #ccc transparent;border-bottom-style:solid;position:absolute;top:-14px;left:9px;z-index:98}.f-dropdown.right:before{left:auto;right:10px}.f-dropdown.right:after{left:auto;right:9px}.f-dropdown.drop-right{position:absolute;left:-9999px;list-style:none;margin-left:0;width:100%;max-height:none;height:auto;background:#fff;border:solid 1px #ccc;font-size:0.875rem;z-index:99;margin-top:0;margin-left:2px;max-width:200px}.f-dropdown.drop-right>*:first-child{margin-top:0}.f-dropdown.drop-right>*:last-child{margin-bottom:0}.f-dropdown.drop-right:before{content:"";display:block;width:0;height:0;border:inset 6px;border-color:transparent #fff transparent transparent;border-right-style:solid;position:absolute;top:10px;left:-12px;z-index:99}.f-dropdown.drop-right:after{content:"";display:block;width:0;height:0;border:inset 7px;border-color:transparent #ccc transparent transparent;border-right-style:solid;position:absolute;top:9px;left:-14px;z-index:98}.f-dropdown.drop-left{position:absolute;left:-9999px;list-style:none;margin-left:0;width:100%;max-height:none;height:auto;background:#fff;border:solid 1px #ccc;font-size:0.875rem;z-index:99;margin-top:0;margin-left:-2px;max-width:200px}.f-dropdown.drop-left>*:first-child{margin-top:0}.f-dropdown.drop-left>*:last-child{margin-bottom:0}.f-dropdown.drop-left:before{content:"";display:block;width:0;height:0;border:inset 6px;border-color:transparent transparent transparent #fff;border-left-style:solid;position:absolute;top:10px;right:-12px;left:auto;z-index:99}.f-dropdown.drop-left:after{content:"";display:block;width:0;height:0;border:inset 7px;border-color:transparent transparent transparent #ccc;border-left-style:solid;position:absolute;top:9px;right:-14px;left:auto;z-index:98}.f-dropdown.drop-top{position:absolute;left:-9999px;list-style:none;margin-left:0;width:100%;max-height:none;height:auto;background:#fff;border:solid 1px #ccc;font-size:0.875rem;z-index:99;margin-top:-2px;margin-left:0;max-width:200px}.f-dropdown.drop-top>*:first-child{margin-top:0}.f-dropdown.drop-top>*:last-child{margin-bottom:0}.f-dropdown.drop-top:before{content:"";display:block;width:0;height:0;border:inset 6px;border-color:#fff transparent transparent transparent;border-top-style:solid;position:absolute;top:auto;bottom:-12px;left:10px;right:auto;z-index:99}.f-dropdown.drop-top:after{content:"";display:block;width:0;height:0;border:inset 7px;border-color:#ccc transparent transparent transparent;border-top-style:solid;position:absolute;top:auto;bottom:-14px;left:9px;right:auto;z-index:98}.f-dropdown li{font-size:0.875rem;cursor:pointer;line-height:1.125rem;margin:0}.f-dropdown li:hover,.f-dropdown li:focus{background:#eee}.f-dropdown li a{display:block;padding:0.5rem;color:#555}.f-dropdown.content{position:absolute;left:-9999px;list-style:none;margin-left:0;padding:1.25rem;width:100%;height:auto;max-height:none;background:#fff;border:solid 1px #ccc;font-size:0.875rem;z-index:99;max-width:200px}.f-dropdown.content>*:first-child{margin-top:0}.f-dropdown.content>*:last-child{margin-bottom:0}.f-dropdown.tiny{max-width:200px}.f-dropdown.small{max-width:300px}.f-dropdown.medium{max-width:500px}.f-dropdown.large{max-width:800px}table{background:#fff;margin-bottom:1.25rem;border:solid 1px #ddd}table thead,table tfoot{background:#f5f5f5}table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:0.5rem 0.625rem 0.625rem;font-size:0.875rem;font-weight:bold;color:#222;text-align:left}table tr th,table tr td{padding:0.5625rem 0.625rem;font-size:0.875rem;color:#222}table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f9f9f9}table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.125rem}form{margin:0 0 1rem}form .row .row{margin:0 -0.5rem}form .row .row .column,form .row .row .columns{padding:0 0.5rem}form .row .row.collapse{margin:0}form .row .row.collapse .column,form .row .row.collapse .columns{padding:0}form .row .row.collapse input{border-bottom-right-radius:0;border-top-right-radius:0}form .row input.column,form .row input.columns,form .row textarea.column,form .row textarea.columns{padding-left:0.5rem}label{font-size:0.875rem;color:#4d4d4d;cursor:pointer;display:block;font-weight:normal;line-height:1.5;margin-bottom:0}label.right{float:none;text-align:right}label.inline{margin:0 0 1rem 0;padding:0.5625rem 0}label small{text-transform:capitalize;color:#676767}select::-ms-expand{display:none}@-moz-document url-prefix(){select{background:#fafafa}select:hover{background:#f3f3f3}}.prefix,.postfix{display:block;position:relative;z-index:2;text-align:center;width:100%;padding-top:0;padding-bottom:0;border-style:solid;border-width:1px;overflow:hidden;font-size:0.875rem;height:2.3125rem;line-height:2.3125rem}.postfix.button{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;text-align:center;line-height:2.125rem;border:none}.prefix.button{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;text-align:center;line-height:2.125rem;border:none}.prefix.button.radius{border-radius:0;border-bottom-left-radius:3px;border-top-left-radius:3px}.postfix.button.radius{border-radius:0;border-bottom-right-radius:3px;border-top-right-radius:3px}.prefix.button.round{border-radius:0;border-bottom-left-radius:1000px;border-top-left-radius:1000px}.postfix.button.round{border-radius:0;border-bottom-right-radius:1000px;border-top-right-radius:1000px}span.prefix,label.prefix{background:#f2f2f2;border-right:none;color:#333;border-color:#ccc}span.prefix.radius,label.prefix.radius{border-radius:0;border-bottom-left-radius:3px;border-top-left-radius:3px}span.postfix,label.postfix{background:#f2f2f2;border-left:none;color:#333;border-color:#ccc}span.postfix.radius,label.postfix.radius{border-radius:0;border-bottom-right-radius:3px;border-top-right-radius:3px}input[type="text"],input[type="password"],input[type="date"],input[type="datetime"],input[type="datetime-local"],input[type="month"],input[type="week"],input[type="email"],input[type="number"],input[type="search"],input[type="tel"],input[type="time"],input[type="url"],textarea{-webkit-appearance:none;background-color:#fff;font-family:inherit;border:1px solid #ccc;box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);color:rgba(0,0,0,0.75);display:block;font-size:0.875rem;margin:0 0 1rem 0;padding:0.5rem;height:2.3125rem;width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;transition:box-shadow 0.45s,border-color 0.45s ease-in-out}input[type="text"]:focus,input[type="password"]:focus,input[type="date"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="month"]:focus,input[type="week"]:focus,input[type="email"]:focus,input[type="number"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="time"]:focus,input[type="url"]:focus,textarea:focus{box-shadow:0 0 5px #999;border-color:#999}input[type="text"]:focus,input[type="password"]:focus,input[type="date"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="month"]:focus,input[type="week"]:focus,input[type="email"]:focus,input[type="number"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="time"]:focus,input[type="url"]:focus,textarea:focus{background:#fafafa;border-color:#999;outline:none}input[type="text"][disabled],fieldset[disabled] input[type="text"],input[type="password"][disabled],fieldset[disabled] input[type="password"],input[type="date"][disabled],fieldset[disabled] input[type="date"],input[type="datetime"][disabled],fieldset[disabled] input[type="datetime"],input[type="datetime-local"][disabled],fieldset[disabled] input[type="datetime-local"],input[type="month"][disabled],fieldset[disabled] input[type="month"],input[type="week"][disabled],fieldset[disabled] input[type="week"],input[type="email"][disabled],fieldset[disabled] input[type="email"],input[type="number"][disabled],fieldset[disabled] input[type="number"],input[type="search"][disabled],fieldset[disabled] input[type="search"],input[type="tel"][disabled],fieldset[disabled] input[type="tel"],input[type="time"][disabled],fieldset[disabled] input[type="time"],input[type="url"][disabled],fieldset[disabled] input[type="url"],textarea[disabled],fieldset[disabled] textarea{background-color:#ddd}input[type="text"].radius,input[type="password"].radius,input[type="date"].radius,input[type="datetime"].radius,input[type="datetime-local"].radius,input[type="month"].radius,input[type="week"].radius,input[type="email"].radius,input[type="number"].radius,input[type="search"].radius,input[type="tel"].radius,input[type="time"].radius,input[type="url"].radius,textarea.radius{border-radius:3px}input[type="submit"]{-webkit-appearance:none}textarea[rows]{height:auto}select{-webkit-appearance:none !important;background-color:#fafafa;background-image:url("data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iM3B4IiB2aWV3Qm94PSIwIDAgNiAzIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA2IDMiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxwb2x5Z29uIHBvaW50cz0iNS45OTIsMCAyLjk5MiwzIC0wLjAwOCwwICIvPjwvc3ZnPg==");background-repeat:no-repeat;background-position:97% center;border:1px solid #ccc;padding:0.5rem;font-size:0.875rem;border-radius:0;height:2.3125rem}select.radius{border-radius:3px}select:hover{background-color:#f3f3f3;border-color:#999}input[type="file"],input[type="checkbox"],input[type="radio"],select{margin:0 0 1rem 0}input[type="checkbox"]+label,input[type="radio"]+label{display:inline-block;margin-left:0.5rem;margin-right:1rem;margin-bottom:0;vertical-align:baseline}input[type="file"]{width:100%}fieldset{border:1px solid #ddd;padding:1.25rem;margin:1.125rem 0}fieldset legend{font-weight:bold;background:#fff;padding:0 0.1875rem;margin:0;margin-left:-0.1875rem}[data-abide] .error small.error,[data-abide] span.error,[data-abide] small.error{display:block;padding:0.375rem 0.5625rem 0.5625rem;margin-top:-1px;margin-bottom:1rem;font-size:0.75rem;font-weight:normal;font-style:italic;background:#f04124;color:#fff}[data-abide] span.error,[data-abide] small.error{display:none}span.error,small.error{display:block;padding:0.375rem 0.5625rem 0.5625rem;margin-top:-1px;margin-bottom:1rem;font-size:0.75rem;font-weight:normal;font-style:italic;background:#f04124;color:#fff}.error input,.error textarea,.error select{margin-bottom:0}.error input[type="checkbox"],.error input[type="radio"]{margin-bottom:1rem}.error label,.error label.error{color:#f04124}.error small.error{display:block;padding:0.375rem 0.5625rem 0.5625rem;margin-top:-1px;margin-bottom:1rem;font-size:0.75rem;font-weight:normal;font-style:italic;background:#f04124;color:#fff}.error>label>small{color:#676767;background:transparent;padding:0;text-transform:capitalize;font-style:normal;font-size:60%;margin:0;display:inline}.error span.error-message{display:block}input.error,textarea.error{margin-bottom:0}label.error{color:#f04124}.range-slider{display:block;position:relative;width:100%;height:1rem;border:1px solid #ddd;margin:1.25rem 0;-ms-touch-action:none;touch-action:none;background:#fafafa}.range-slider.vertical-range{display:block;position:relative;width:100%;height:1rem;border:1px solid #ddd;margin:1.25rem 0;-ms-touch-action:none;touch-action:none;display:inline-block;width:1rem;height:12.5rem}.range-slider.vertical-range .range-slider-handle{margin-top:0;margin-left:-0.5rem;position:absolute;bottom:-10.5rem}.range-slider.vertical-range .range-slider-active-segment{width:0.875rem;height:auto;bottom:0}.range-slider.radius{background:#fafafa;border-radius:3px}.range-slider.radius .range-slider-handle{background:#008cba;border-radius:3px}.range-slider.radius .range-slider-handle:hover{background:#007ba4}.range-slider.round{background:#fafafa;border-radius:1000px}.range-slider.round .range-slider-handle{background:#008cba;border-radius:1000px}.range-slider.round .range-slider-handle:hover{background:#007ba4}.range-slider-active-segment{display:inline-block;position:absolute;height:0.875rem;background:#e5e5e5}.range-slider-handle{display:inline-block;position:absolute;z-index:1;top:-0.3125rem;width:2rem;height:1.375rem;border:1px solid none;cursor:pointer;background:#008cba}.range-slider-handle:hover{background:#007ba4}[class*="block-grid-"]{display:block;padding:0;margin:0 -0.625rem;*zoom:1}[class*="block-grid-"]:before,[class*="block-grid-"]:after{content:" ";display:table}[class*="block-grid-"]:after{clear:both}[class*="block-grid-"]>li{display:block;height:auto;float:left;padding:0 0.625rem 1.25rem}@media only screen{.small-block-grid-1>li{width:100%;list-style:none}.small-block-grid-1>li:nth-of-type(n){clear:none}.small-block-grid-1>li:nth-of-type(1n+1){clear:both}.small-block-grid-2>li{width:50%;list-style:none}.small-block-grid-2>li:nth-of-type(n){clear:none}.small-block-grid-2>li:nth-of-type(2n+1){clear:both}.small-block-grid-3>li{width:33.33333%;list-style:none}.small-block-grid-3>li:nth-of-type(n){clear:none}.small-block-grid-3>li:nth-of-type(3n+1){clear:both}.small-block-grid-4>li{width:25%;list-style:none}.small-block-grid-4>li:nth-of-type(n){clear:none}.small-block-grid-4>li:nth-of-type(4n+1){clear:both}.small-block-grid-5>li{width:20%;list-style:none}.small-block-grid-5>li:nth-of-type(n){clear:none}.small-block-grid-5>li:nth-of-type(5n+1){clear:both}.small-block-grid-6>li{width:16.66667%;list-style:none}.small-block-grid-6>li:nth-of-type(n){clear:none}.small-block-grid-6>li:nth-of-type(6n+1){clear:both}.small-block-grid-7>li{width:14.28571%;list-style:none}.small-block-grid-7>li:nth-of-type(n){clear:none}.small-block-grid-7>li:nth-of-type(7n+1){clear:both}.small-block-grid-8>li{width:12.5%;list-style:none}.small-block-grid-8>li:nth-of-type(n){clear:none}.small-block-grid-8>li:nth-of-type(8n+1){clear:both}.small-block-grid-9>li{width:11.11111%;list-style:none}.small-block-grid-9>li:nth-of-type(n){clear:none}.small-block-grid-9>li:nth-of-type(9n+1){clear:both}.small-block-grid-10>li{width:10%;list-style:none}.small-block-grid-10>li:nth-of-type(n){clear:none}.small-block-grid-10>li:nth-of-type(10n+1){clear:both}.small-block-grid-11>li{width:9.09091%;list-style:none}.small-block-grid-11>li:nth-of-type(n){clear:none}.small-block-grid-11>li:nth-of-type(11n+1){clear:both}.small-block-grid-12>li{width:8.33333%;list-style:none}.small-block-grid-12>li:nth-of-type(n){clear:none}.small-block-grid-12>li:nth-of-type(12n+1){clear:both}}@media only screen and (min-width: 40.063em){.medium-block-grid-1>li{width:100%;list-style:none}.medium-block-grid-1>li:nth-of-type(n){clear:none}.medium-block-grid-1>li:nth-of-type(1n+1){clear:both}.medium-block-grid-2>li{width:50%;list-style:none}.medium-block-grid-2>li:nth-of-type(n){clear:none}.medium-block-grid-2>li:nth-of-type(2n+1){clear:both}.medium-block-grid-3>li{width:33.33333%;list-style:none}.medium-block-grid-3>li:nth-of-type(n){clear:none}.medium-block-grid-3>li:nth-of-type(3n+1){clear:both}.medium-block-grid-4>li{width:25%;list-style:none}.medium-block-grid-4>li:nth-of-type(n){clear:none}.medium-block-grid-4>li:nth-of-type(4n+1){clear:both}.medium-block-grid-5>li{width:20%;list-style:none}.medium-block-grid-5>li:nth-of-type(n){clear:none}.medium-block-grid-5>li:nth-of-type(5n+1){clear:both}.medium-block-grid-6>li{width:16.66667%;list-style:none}.medium-block-grid-6>li:nth-of-type(n){clear:none}.medium-block-grid-6>li:nth-of-type(6n+1){clear:both}.medium-block-grid-7>li{width:14.28571%;list-style:none}.medium-block-grid-7>li:nth-of-type(n){clear:none}.medium-block-grid-7>li:nth-of-type(7n+1){clear:both}.medium-block-grid-8>li{width:12.5%;list-style:none}.medium-block-grid-8>li:nth-of-type(n){clear:none}.medium-block-grid-8>li:nth-of-type(8n+1){clear:both}.medium-block-grid-9>li{width:11.11111%;list-style:none}.medium-block-grid-9>li:nth-of-type(n){clear:none}.medium-block-grid-9>li:nth-of-type(9n+1){clear:both}.medium-block-grid-10>li{width:10%;list-style:none}.medium-block-grid-10>li:nth-of-type(n){clear:none}.medium-block-grid-10>li:nth-of-type(10n+1){clear:both}.medium-block-grid-11>li{width:9.09091%;list-style:none}.medium-block-grid-11>li:nth-of-type(n){clear:none}.medium-block-grid-11>li:nth-of-type(11n+1){clear:both}.medium-block-grid-12>li{width:8.33333%;list-style:none}.medium-block-grid-12>li:nth-of-type(n){clear:none}.medium-block-grid-12>li:nth-of-type(12n+1){clear:both}}@media only screen and (min-width: 64.063em){.large-block-grid-1>li{width:100%;list-style:none}.large-block-grid-1>li:nth-of-type(n){clear:none}.large-block-grid-1>li:nth-of-type(1n+1){clear:both}.large-block-grid-2>li{width:50%;list-style:none}.large-block-grid-2>li:nth-of-type(n){clear:none}.large-block-grid-2>li:nth-of-type(2n+1){clear:both}.large-block-grid-3>li{width:33.33333%;list-style:none}.large-block-grid-3>li:nth-of-type(n){clear:none}.large-block-grid-3>li:nth-of-type(3n+1){clear:both}.large-block-grid-4>li{width:25%;list-style:none}.large-block-grid-4>li:nth-of-type(n){clear:none}.large-block-grid-4>li:nth-of-type(4n+1){clear:both}.large-block-grid-5>li{width:20%;list-style:none}.large-block-grid-5>li:nth-of-type(n){clear:none}.large-block-grid-5>li:nth-of-type(5n+1){clear:both}.large-block-grid-6>li{width:16.66667%;list-style:none}.large-block-grid-6>li:nth-of-type(n){clear:none}.large-block-grid-6>li:nth-of-type(6n+1){clear:both}.large-block-grid-7>li{width:14.28571%;list-style:none}.large-block-grid-7>li:nth-of-type(n){clear:none}.large-block-grid-7>li:nth-of-type(7n+1){clear:both}.large-block-grid-8>li{width:12.5%;list-style:none}.large-block-grid-8>li:nth-of-type(n){clear:none}.large-block-grid-8>li:nth-of-type(8n+1){clear:both}.large-block-grid-9>li{width:11.11111%;list-style:none}.large-block-grid-9>li:nth-of-type(n){clear:none}.large-block-grid-9>li:nth-of-type(9n+1){clear:both}.large-block-grid-10>li{width:10%;list-style:none}.large-block-grid-10>li:nth-of-type(n){clear:none}.large-block-grid-10>li:nth-of-type(10n+1){clear:both}.large-block-grid-11>li{width:9.09091%;list-style:none}.large-block-grid-11>li:nth-of-type(n){clear:none}.large-block-grid-11>li:nth-of-type(11n+1){clear:both}.large-block-grid-12>li{width:8.33333%;list-style:none}.large-block-grid-12>li:nth-of-type(n){clear:none}.large-block-grid-12>li:nth-of-type(12n+1){clear:both}}.flex-video{position:relative;padding-top:1.5625rem;padding-bottom:67.5%;height:0;margin-bottom:1rem;overflow:hidden}.flex-video.widescreen{padding-bottom:56.34%}.flex-video.vimeo{padding-top:0}.flex-video iframe,.flex-video object,.flex-video embed,.flex-video video{position:absolute;top:0;left:0;width:100%;height:100%}.keystroke,kbd{background-color:#ededed;border-color:#ddd;color:#222;border-style:solid;border-width:1px;margin:0;font-family:"Consolas","Menlo","Courier",monospace;font-size:inherit;padding:0.125rem 0.25rem 0;border-radius:3px}@media only screen{.show-for-small-only,.show-for-small-up,.show-for-small,.show-for-small-down,.hide-for-medium-only,.hide-for-medium-up,.hide-for-medium,.show-for-medium-down,.hide-for-large-only,.hide-for-large-up,.hide-for-large,.show-for-large-down,.hide-for-xlarge-only,.hide-for-xlarge-up,.hide-for-xxlarge-only,.hide-for-xxlarge-up{display:inherit !important}.hide-for-small-only,.hide-for-small-up,.hide-for-small,.hide-for-small-down,.show-for-medium-only,.show-for-medium-up,.show-for-medium,.hide-for-medium-down,.show-for-large-only,.show-for-large-up,.show-for-large,.hide-for-large-down,.show-for-xlarge-only,.show-for-xlarge-up,.show-for-xxlarge-only,.show-for-xxlarge-up{display:none !important}table.show-for-small-only,table.show-for-small-up,table.show-for-small,table.show-for-small-down,table.hide-for-medium-only,table.hide-for-medium-up,table.hide-for-medium,table.show-for-medium-down,table.hide-for-large-only,table.hide-for-large-up,table.hide-for-large,table.show-for-large-down,table.hide-for-xlarge-only,table.hide-for-xlarge-up,table.hide-for-xxlarge-only,table.hide-for-xxlarge-up{display:table}thead.show-for-small-only,thead.show-for-small-up,thead.show-for-small,thead.show-for-small-down,thead.hide-for-medium-only,thead.hide-for-medium-up,thead.hide-for-medium,thead.show-for-medium-down,thead.hide-for-large-only,thead.hide-for-large-up,thead.hide-for-large,thead.show-for-large-down,thead.hide-for-xlarge-only,thead.hide-for-xlarge-up,thead.hide-for-xxlarge-only,thead.hide-for-xxlarge-up{display:table-header-group !important}tbody.show-for-small-only,tbody.show-for-small-up,tbody.show-for-small,tbody.show-for-small-down,tbody.hide-for-medium-only,tbody.hide-for-medium-up,tbody.hide-for-medium,tbody.show-for-medium-down,tbody.hide-for-large-only,tbody.hide-for-large-up,tbody.hide-for-large,tbody.show-for-large-down,tbody.hide-for-xlarge-only,tbody.hide-for-xlarge-up,tbody.hide-for-xxlarge-only,tbody.hide-for-xxlarge-up{display:table-row-group !important}tr.show-for-small-only,tr.show-for-small-up,tr.show-for-small,tr.show-for-small-down,tr.hide-for-medium-only,tr.hide-for-medium-up,tr.hide-for-medium,tr.show-for-medium-down,tr.hide-for-large-only,tr.hide-for-large-up,tr.hide-for-large,tr.show-for-large-down,tr.hide-for-xlarge-only,tr.hide-for-xlarge-up,tr.hide-for-xxlarge-only,tr.hide-for-xxlarge-up{display:table-row !important}th.show-for-small-only,td.show-for-small-only,th.show-for-small-up,td.show-for-small-up,th.show-for-small,td.show-for-small,th.show-for-small-down,td.show-for-small-down,th.hide-for-medium-only,td.hide-for-medium-only,th.hide-for-medium-up,td.hide-for-medium-up,th.hide-for-medium,td.hide-for-medium,th.show-for-medium-down,td.show-for-medium-down,th.hide-for-large-only,td.hide-for-large-only,th.hide-for-large-up,td.hide-for-large-up,th.hide-for-large,td.hide-for-large,th.show-for-large-down,td.show-for-large-down,th.hide-for-xlarge-only,td.hide-for-xlarge-only,th.hide-for-xlarge-up,td.hide-for-xlarge-up,th.hide-for-xxlarge-only,td.hide-for-xxlarge-only,th.hide-for-xxlarge-up,td.hide-for-xxlarge-up{display:table-cell !important}}@media only screen and (min-width: 40.063em){.hide-for-small-only,.show-for-small-up,.hide-for-small,.hide-for-small-down,.show-for-medium-only,.show-for-medium-up,.show-for-medium,.show-for-medium-down,.hide-for-large-only,.hide-for-large-up,.hide-for-large,.show-for-large-down,.hide-for-xlarge-only,.hide-for-xlarge-up,.hide-for-xxlarge-only,.hide-for-xxlarge-up{display:inherit !important}.show-for-small-only,.hide-for-small-up,.show-for-small,.show-for-small-down,.hide-for-medium-only,.hide-for-medium-up,.hide-for-medium,.hide-for-medium-down,.show-for-large-only,.show-for-large-up,.show-for-large,.hide-for-large-down,.show-for-xlarge-only,.show-for-xlarge-up,.show-for-xxlarge-only,.show-for-xxlarge-up{display:none !important}table.hide-for-small-only,table.show-for-small-up,table.hide-for-small,table.hide-for-small-down,table.show-for-medium-only,table.show-for-medium-up,table.show-for-medium,table.show-for-medium-down,table.hide-for-large-only,table.hide-for-large-up,table.hide-for-large,table.show-for-large-down,table.hide-for-xlarge-only,table.hide-for-xlarge-up,table.hide-for-xxlarge-only,table.hide-for-xxlarge-up{display:table}thead.hide-for-small-only,thead.show-for-small-up,thead.hide-for-small,thead.hide-for-small-down,thead.show-for-medium-only,thead.show-for-medium-up,thead.show-for-medium,thead.show-for-medium-down,thead.hide-for-large-only,thead.hide-for-large-up,thead.hide-for-large,thead.show-for-large-down,thead.hide-for-xlarge-only,thead.hide-for-xlarge-up,thead.hide-for-xxlarge-only,thead.hide-for-xxlarge-up{display:table-header-group !important}tbody.hide-for-small-only,tbody.show-for-small-up,tbody.hide-for-small,tbody.hide-for-small-down,tbody.show-for-medium-only,tbody.show-for-medium-up,tbody.show-for-medium,tbody.show-for-medium-down,tbody.hide-for-large-only,tbody.hide-for-large-up,tbody.hide-for-large,tbody.show-for-large-down,tbody.hide-for-xlarge-only,tbody.hide-for-xlarge-up,tbody.hide-for-xxlarge-only,tbody.hide-for-xxlarge-up{display:table-row-group !important}tr.hide-for-small-only,tr.show-for-small-up,tr.hide-for-small,tr.hide-for-small-down,tr.show-for-medium-only,tr.show-for-medium-up,tr.show-for-medium,tr.show-for-medium-down,tr.hide-for-large-only,tr.hide-for-large-up,tr.hide-for-large,tr.show-for-large-down,tr.hide-for-xlarge-only,tr.hide-for-xlarge-up,tr.hide-for-xxlarge-only,tr.hide-for-xxlarge-up{display:table-row !important}th.hide-for-small-only,td.hide-for-small-only,th.show-for-small-up,td.show-for-small-up,th.hide-for-small,td.hide-for-small,th.hide-for-small-down,td.hide-for-small-down,th.show-for-medium-only,td.show-for-medium-only,th.show-for-medium-up,td.show-for-medium-up,th.show-for-medium,td.show-for-medium,th.show-for-medium-down,td.show-for-medium-down,th.hide-for-large-only,td.hide-for-large-only,th.hide-for-large-up,td.hide-for-large-up,th.hide-for-large,td.hide-for-large,th.show-for-large-down,td.show-for-large-down,th.hide-for-xlarge-only,td.hide-for-xlarge-only,th.hide-for-xlarge-up,td.hide-for-xlarge-up,th.hide-for-xxlarge-only,td.hide-for-xxlarge-only,th.hide-for-xxlarge-up,td.hide-for-xxlarge-up{display:table-cell !important}}@media only screen and (min-width: 64.063em){.hide-for-small-only,.show-for-small-up,.hide-for-small,.hide-for-small-down,.hide-for-medium-only,.show-for-medium-up,.hide-for-medium,.hide-for-medium-down,.show-for-large-only,.show-for-large-up,.show-for-large,.show-for-large-down,.hide-for-xlarge-only,.hide-for-xlarge-up,.hide-for-xxlarge-only,.hide-for-xxlarge-up{display:inherit !important}.show-for-small-only,.hide-for-small-up,.show-for-small,.show-for-small-down,.show-for-medium-only,.hide-for-medium-up,.show-for-medium,.show-for-medium-down,.hide-for-large-only,.hide-for-large-up,.hide-for-large,.hide-for-large-down,.show-for-xlarge-only,.show-for-xlarge-up,.show-for-xxlarge-only,.show-for-xxlarge-up{display:none !important}table.hide-for-small-only,table.show-for-small-up,table.hide-for-small,table.hide-for-small-down,table.hide-for-medium-only,table.show-for-medium-up,table.hide-for-medium,table.hide-for-medium-down,table.show-for-large-only,table.show-for-large-up,table.show-for-large,table.show-for-large-down,table.hide-for-xlarge-only,table.hide-for-xlarge-up,table.hide-for-xxlarge-only,table.hide-for-xxlarge-up{display:table}thead.hide-for-small-only,thead.show-for-small-up,thead.hide-for-small,thead.hide-for-small-down,thead.hide-for-medium-only,thead.show-for-medium-up,thead.hide-for-medium,thead.hide-for-medium-down,thead.show-for-large-only,thead.show-for-large-up,thead.show-for-large,thead.show-for-large-down,thead.hide-for-xlarge-only,thead.hide-for-xlarge-up,thead.hide-for-xxlarge-only,thead.hide-for-xxlarge-up{display:table-header-group !important}tbody.hide-for-small-only,tbody.show-for-small-up,tbody.hide-for-small,tbody.hide-for-small-down,tbody.hide-for-medium-only,tbody.show-for-medium-up,tbody.hide-for-medium,tbody.hide-for-medium-down,tbody.show-for-large-only,tbody.show-for-large-up,tbody.show-for-large,tbody.show-for-large-down,tbody.hide-for-xlarge-only,tbody.hide-for-xlarge-up,tbody.hide-for-xxlarge-only,tbody.hide-for-xxlarge-up{display:table-row-group !important}tr.hide-for-small-only,tr.show-for-small-up,tr.hide-for-small,tr.hide-for-small-down,tr.hide-for-medium-only,tr.show-for-medium-up,tr.hide-for-medium,tr.hide-for-medium-down,tr.show-for-large-only,tr.show-for-large-up,tr.show-for-large,tr.show-for-large-down,tr.hide-for-xlarge-only,tr.hide-for-xlarge-up,tr.hide-for-xxlarge-only,tr.hide-for-xxlarge-up{display:table-row !important}th.hide-for-small-only,td.hide-for-small-only,th.show-for-small-up,td.show-for-small-up,th.hide-for-small,td.hide-for-small,th.hide-for-small-down,td.hide-for-small-down,th.hide-for-medium-only,td.hide-for-medium-only,th.show-for-medium-up,td.show-for-medium-up,th.hide-for-medium,td.hide-for-medium,th.hide-for-medium-down,td.hide-for-medium-down,th.show-for-large-only,td.show-for-large-only,th.show-for-large-up,td.show-for-large-up,th.show-for-large,td.show-for-large,th.show-for-large-down,td.show-for-large-down,th.hide-for-xlarge-only,td.hide-for-xlarge-only,th.hide-for-xlarge-up,td.hide-for-xlarge-up,th.hide-for-xxlarge-only,td.hide-for-xxlarge-only,th.hide-for-xxlarge-up,td.hide-for-xxlarge-up{display:table-cell !important}}@media only screen and (min-width: 90.063em){.hide-for-small-only,.show-for-small-up,.hide-for-small,.hide-for-small-down,.hide-for-medium-only,.show-for-medium-up,.hide-for-medium,.hide-for-medium-down,.hide-for-large-only,.show-for-large-up,.hide-for-large,.hide-for-large-down,.show-for-xlarge-only,.show-for-xlarge-up,.hide-for-xxlarge-only,.hide-for-xxlarge-up{display:inherit !important}.show-for-small-only,.hide-for-small-up,.show-for-small,.show-for-small-down,.show-for-medium-only,.hide-for-medium-up,.show-for-medium,.show-for-medium-down,.show-for-large-only,.hide-for-large-up,.show-for-large,.show-for-large-down,.hide-for-xlarge-only,.hide-for-xlarge-up,.show-for-xxlarge-only,.show-for-xxlarge-up{display:none !important}table.hide-for-small-only,table.show-for-small-up,table.hide-for-small,table.hide-for-small-down,table.hide-for-medium-only,table.show-for-medium-up,table.hide-for-medium,table.hide-for-medium-down,table.hide-for-large-only,table.show-for-large-up,table.hide-for-large,table.hide-for-large-down,table.show-for-xlarge-only,table.show-for-xlarge-up,table.hide-for-xxlarge-only,table.hide-for-xxlarge-up{display:table}thead.hide-for-small-only,thead.show-for-small-up,thead.hide-for-small,thead.hide-for-small-down,thead.hide-for-medium-only,thead.show-for-medium-up,thead.hide-for-medium,thead.hide-for-medium-down,thead.hide-for-large-only,thead.show-for-large-up,thead.hide-for-large,thead.hide-for-large-down,thead.show-for-xlarge-only,thead.show-for-xlarge-up,thead.hide-for-xxlarge-only,thead.hide-for-xxlarge-up{display:table-header-group !important}tbody.hide-for-small-only,tbody.show-for-small-up,tbody.hide-for-small,tbody.hide-for-small-down,tbody.hide-for-medium-only,tbody.show-for-medium-up,tbody.hide-for-medium,tbody.hide-for-medium-down,tbody.hide-for-large-only,tbody.show-for-large-up,tbody.hide-for-large,tbody.hide-for-large-down,tbody.show-for-xlarge-only,tbody.show-for-xlarge-up,tbody.hide-for-xxlarge-only,tbody.hide-for-xxlarge-up{display:table-row-group !important}tr.hide-for-small-only,tr.show-for-small-up,tr.hide-for-small,tr.hide-for-small-down,tr.hide-for-medium-only,tr.show-for-medium-up,tr.hide-for-medium,tr.hide-for-medium-down,tr.hide-for-large-only,tr.show-for-large-up,tr.hide-for-large,tr.hide-for-large-down,tr.show-for-xlarge-only,tr.show-for-xlarge-up,tr.hide-for-xxlarge-only,tr.hide-for-xxlarge-up{display:table-row !important}th.hide-for-small-only,td.hide-for-small-only,th.show-for-small-up,td.show-for-small-up,th.hide-for-small,td.hide-for-small,th.hide-for-small-down,td.hide-for-small-down,th.hide-for-medium-only,td.hide-for-medium-only,th.show-for-medium-up,td.show-for-medium-up,th.hide-for-medium,td.hide-for-medium,th.hide-for-medium-down,td.hide-for-medium-down,th.hide-for-large-only,td.hide-for-large-only,th.show-for-large-up,td.show-for-large-up,th.hide-for-large,td.hide-for-large,th.hide-for-large-down,td.hide-for-large-down,th.show-for-xlarge-only,td.show-for-xlarge-only,th.show-for-xlarge-up,td.show-for-xlarge-up,th.hide-for-xxlarge-only,td.hide-for-xxlarge-only,th.hide-for-xxlarge-up,td.hide-for-xxlarge-up{display:table-cell !important}}@media only screen and (min-width: 120.063em){.hide-for-small-only,.show-for-small-up,.hide-for-small,.hide-for-small-down,.hide-for-medium-only,.show-for-medium-up,.hide-for-medium,.hide-for-medium-down,.hide-for-large-only,.show-for-large-up,.hide-for-large,.hide-for-large-down,.hide-for-xlarge-only,.show-for-xlarge-up,.show-for-xxlarge-only,.show-for-xxlarge-up{display:inherit !important}.show-for-small-only,.hide-for-small-up,.show-for-small,.show-for-small-down,.show-for-medium-only,.hide-for-medium-up,.show-for-medium,.show-for-medium-down,.show-for-large-only,.hide-for-large-up,.show-for-large,.show-for-large-down,.show-for-xlarge-only,.hide-for-xlarge-up,.hide-for-xxlarge-only,.hide-for-xxlarge-up{display:none !important}table.hide-for-small-only,table.show-for-small-up,table.hide-for-small,table.hide-for-small-down,table.hide-for-medium-only,table.show-for-medium-up,table.hide-for-medium,table.hide-for-medium-down,table.hide-for-large-only,table.show-for-large-up,table.hide-for-large,table.hide-for-large-down,table.hide-for-xlarge-only,table.show-for-xlarge-up,table.show-for-xxlarge-only,table.show-for-xxlarge-up{display:table}thead.hide-for-small-only,thead.show-for-small-up,thead.hide-for-small,thead.hide-for-small-down,thead.hide-for-medium-only,thead.show-for-medium-up,thead.hide-for-medium,thead.hide-for-medium-down,thead.hide-for-large-only,thead.show-for-large-up,thead.hide-for-large,thead.hide-for-large-down,thead.hide-for-xlarge-only,thead.show-for-xlarge-up,thead.show-for-xxlarge-only,thead.show-for-xxlarge-up{display:table-header-group !important}tbody.hide-for-small-only,tbody.show-for-small-up,tbody.hide-for-small,tbody.hide-for-small-down,tbody.hide-for-medium-only,tbody.show-for-medium-up,tbody.hide-for-medium,tbody.hide-for-medium-down,tbody.hide-for-large-only,tbody.show-for-large-up,tbody.hide-for-large,tbody.hide-for-large-down,tbody.hide-for-xlarge-only,tbody.show-for-xlarge-up,tbody.show-for-xxlarge-only,tbody.show-for-xxlarge-up{display:table-row-group !important}tr.hide-for-small-only,tr.show-for-small-up,tr.hide-for-small,tr.hide-for-small-down,tr.hide-for-medium-only,tr.show-for-medium-up,tr.hide-for-medium,tr.hide-for-medium-down,tr.hide-for-large-only,tr.show-for-large-up,tr.hide-for-large,tr.hide-for-large-down,tr.hide-for-xlarge-only,tr.show-for-xlarge-up,tr.show-for-xxlarge-only,tr.show-for-xxlarge-up{display:table-row !important}th.hide-for-small-only,td.hide-for-small-only,th.show-for-small-up,td.show-for-small-up,th.hide-for-small,td.hide-for-small,th.hide-for-small-down,td.hide-for-small-down,th.hide-for-medium-only,td.hide-for-medium-only,th.show-for-medium-up,td.show-for-medium-up,th.hide-for-medium,td.hide-for-medium,th.hide-for-medium-down,td.hide-for-medium-down,th.hide-for-large-only,td.hide-for-large-only,th.show-for-large-up,td.show-for-large-up,th.hide-for-large,td.hide-for-large,th.hide-for-large-down,td.hide-for-large-down,th.hide-for-xlarge-only,td.hide-for-xlarge-only,th.show-for-xlarge-up,td.show-for-xlarge-up,th.show-for-xxlarge-only,td.show-for-xxlarge-only,th.show-for-xxlarge-up,td.show-for-xxlarge-up{display:table-cell !important}}.show-for-landscape,.hide-for-portrait{display:inherit !important}.hide-for-landscape,.show-for-portrait{display:none !important}table.hide-for-landscape,table.show-for-portrait{display:table}thead.hide-for-landscape,thead.show-for-portrait{display:table-header-group !important}tbody.hide-for-landscape,tbody.show-for-portrait{display:table-row-group !important}tr.hide-for-landscape,tr.show-for-portrait{display:table-row !important}td.hide-for-landscape,td.show-for-portrait,th.hide-for-landscape,th.show-for-portrait{display:table-cell !important}@media only screen and (orientation: landscape){.show-for-landscape,.hide-for-portrait{display:inherit !important}.hide-for-landscape,.show-for-portrait{display:none !important}table.show-for-landscape,table.hide-for-portrait{display:table}thead.show-for-landscape,thead.hide-for-portrait{display:table-header-group !important}tbody.show-for-landscape,tbody.hide-for-portrait{display:table-row-group !important}tr.show-for-landscape,tr.hide-for-portrait{display:table-row !important}td.show-for-landscape,td.hide-for-portrait,th.show-for-landscape,th.hide-for-portrait{display:table-cell !important}}@media only screen and (orientation: portrait){.show-for-portrait,.hide-for-landscape{display:inherit !important}.hide-for-portrait,.show-for-landscape{display:none !important}table.show-for-portrait,table.hide-for-landscape{display:table}thead.show-for-portrait,thead.hide-for-landscape{display:table-header-group !important}tbody.show-for-portrait,tbody.hide-for-landscape{display:table-row-group !important}tr.show-for-portrait,tr.hide-for-landscape{display:table-row !important}td.show-for-portrait,td.hide-for-landscape,th.show-for-portrait,th.hide-for-landscape{display:table-cell !important}}.show-for-touch{display:none !important}.hide-for-touch{display:inherit !important}.touch .show-for-touch{display:inherit !important}.touch .hide-for-touch{display:none !important}table.hide-for-touch{display:table}.touch table.show-for-touch{display:table}thead.hide-for-touch{display:table-header-group !important}.touch thead.show-for-touch{display:table-header-group !important}tbody.hide-for-touch{display:table-row-group !important}.touch tbody.show-for-touch{display:table-row-group !important}tr.hide-for-touch{display:table-row !important}.touch tr.show-for-touch{display:table-row !important}td.hide-for-touch{display:table-cell !important}.touch td.show-for-touch{display:table-cell !important}th.hide-for-touch{display:table-cell !important}.touch th.show-for-touch{display:table-cell !important} diff --git a/server/static/server/c3/docs/css/gettingstarted.css b/server/static/server/c3/docs/css/gettingstarted.css new file mode 100644 index 0000000..030f027 --- /dev/null +++ b/server/static/server/c3/docs/css/gettingstarted.css @@ -0,0 +1,3 @@ +#chart5_1 .c3-line-data2 { + stroke-width: 5px; +} \ No newline at end of file diff --git a/server/static/server/c3/docs/css/index.css b/server/static/server/c3/docs/css/index.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/normalize.css b/server/static/server/c3/docs/css/normalize.css new file mode 100644 index 0000000..196d223 --- /dev/null +++ b/server/static/server/c3/docs/css/normalize.css @@ -0,0 +1,423 @@ +/*! normalize.css v3.0.0 | MIT License | git.io/normalize */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Correct `block` display not defined in IE 8/9. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +nav, +section, +summary { + display: block; +} + +/** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ + +audio, +canvas, +progress, +video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ +} + +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Address `[hidden]` styling not present in IE 8/9. + * Hide the `template` element in IE, Safari, and Firefox < 22. + */ + +[hidden], +template { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * Remove the gray background color from active links in IE 10. + */ + +a { + background: transparent; +} + +/** + * Improve readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Address styling not present in IE 8/9, Safari 5, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari 5 and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari 5, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9. + */ + +img { + border: 0; +} + +/** + * Correct overflow displayed oddly in IE 9. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari 5. + */ + +figure { + margin: 1em 40px; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + -moz-box-sizing: content-box; + box-sizing: content-box; + height: 0; +} + +/** + * Contain overflow in all browsers. + */ + +pre { + overflow: auto; +} + +/** + * Address odd `em`-unit font size rendering in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +/* Forms + ========================================================================== */ + +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + +/** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome. + */ + +button, +input, +optgroup, +select, +textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address `overflow` set to `hidden` in IE 8/9/10. + */ + +button { + overflow: visible; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8+, and Opera + * Correct `select` style inheritance in Firefox. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +input { + line-height: normal; +} + +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Remove default vertical scrollbar in IE 8/9. + */ + +textarea { + overflow: auto; +} + +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + +optgroup { + font-weight: bold; +} + +/* Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + +td, +th { + padding: 0; +} diff --git a/server/static/server/c3/docs/css/reference.css b/server/static/server/c3/docs/css/reference.css new file mode 100644 index 0000000..3dec3ed --- /dev/null +++ b/server/static/server/c3/docs/css/reference.css @@ -0,0 +1,21 @@ +section p { + margin-bottom: 0; +} +section h5 { + margin-top: 1rem; +} +section code { + padding-left: 0; +} +.sourcecode { + margin-bottom: 1.25rem; + padding: 6px 10px; + background-color: #f4f4f4; +} +.sourcecode pre { + padding: 0; + font-size: 1em; +} +.sourcecode pre code { + background-color: #f4f4f4; +} diff --git a/server/static/server/c3/docs/css/samples/api_axis_label.css b/server/static/server/c3/docs/css/samples/api_axis_label.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/api_axis_range.css b/server/static/server/c3/docs/css/samples/api_axis_range.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/api_data_color.css b/server/static/server/c3/docs/css/samples/api_data_color.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/api_data_name.css b/server/static/server/c3/docs/css/samples/api_data_name.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/api_flow.css b/server/static/server/c3/docs/css/samples/api_flow.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/api_grid_x.css b/server/static/server/c3/docs/css/samples/api_grid_x.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/api_resize.css b/server/static/server/c3/docs/css/samples/api_resize.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_label.css b/server/static/server/c3/docs/css/samples/axes_label.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_label_position.css b/server/static/server/c3/docs/css/samples/axes_label_position.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_rotated.css b/server/static/server/c3/docs/css/samples/axes_rotated.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_x_localtime.css b/server/static/server/c3/docs/css/samples/axes_x_localtime.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_x_tick_count.css b/server/static/server/c3/docs/css/samples/axes_x_tick_count.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_x_tick_culling.css b/server/static/server/c3/docs/css/samples/axes_x_tick_culling.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_x_tick_fit.css b/server/static/server/c3/docs/css/samples/axes_x_tick_fit.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_x_tick_format.css b/server/static/server/c3/docs/css/samples/axes_x_tick_format.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_x_tick_rotate.css b/server/static/server/c3/docs/css/samples/axes_x_tick_rotate.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_x_tick_values.css b/server/static/server/c3/docs/css/samples/axes_x_tick_values.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_y2.css b/server/static/server/c3/docs/css/samples/axes_y2.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_y_padding.css b/server/static/server/c3/docs/css/samples/axes_y_padding.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_y_range.css b/server/static/server/c3/docs/css/samples/axes_y_range.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/axes_y_tick_format.css b/server/static/server/c3/docs/css/samples/axes_y_tick_format.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/categorized.css b/server/static/server/c3/docs/css/samples/categorized.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_area.css b/server/static/server/c3/docs/css/samples/chart_area.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_area_stacked.css b/server/static/server/c3/docs/css/samples/chart_area_stacked.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_bar.css b/server/static/server/c3/docs/css/samples/chart_bar.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_bar_negative.css b/server/static/server/c3/docs/css/samples/chart_bar_negative.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_bar_stacked.css b/server/static/server/c3/docs/css/samples/chart_bar_stacked.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_combination.css b/server/static/server/c3/docs/css/samples/chart_combination.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_donut.css b/server/static/server/c3/docs/css/samples/chart_donut.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_gauge.css b/server/static/server/c3/docs/css/samples/chart_gauge.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_pie.css b/server/static/server/c3/docs/css/samples/chart_pie.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_scatter.css b/server/static/server/c3/docs/css/samples/chart_scatter.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_spline.css b/server/static/server/c3/docs/css/samples/chart_spline.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_stanford.css b/server/static/server/c3/docs/css/samples/chart_stanford.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/chart_step.css b/server/static/server/c3/docs/css/samples/chart_step.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_color.css b/server/static/server/c3/docs/css/samples/data_color.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_columned.css b/server/static/server/c3/docs/css/samples/data_columned.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_json.css b/server/static/server/c3/docs/css/samples/data_json.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_label.css b/server/static/server/c3/docs/css/samples/data_label.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_label_format.css b/server/static/server/c3/docs/css/samples/data_label_format.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_load.css b/server/static/server/c3/docs/css/samples/data_load.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_name.css b/server/static/server/c3/docs/css/samples/data_name.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_order.css b/server/static/server/c3/docs/css/samples/data_order.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_rowed.css b/server/static/server/c3/docs/css/samples/data_rowed.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_stringx.css b/server/static/server/c3/docs/css/samples/data_stringx.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_url.css b/server/static/server/c3/docs/css/samples/data_url.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/data_xformat.css b/server/static/server/c3/docs/css/samples/data_xformat.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/grid_x_lines.css b/server/static/server/c3/docs/css/samples/grid_x_lines.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/grid_y_lines.css b/server/static/server/c3/docs/css/samples/grid_y_lines.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/interaction_zoom.css b/server/static/server/c3/docs/css/samples/interaction_zoom.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/legend_custom.css b/server/static/server/c3/docs/css/samples/legend_custom.css new file mode 100644 index 0000000..3d30f44 --- /dev/null +++ b/server/static/server/c3/docs/css/samples/legend_custom.css @@ -0,0 +1,7 @@ +.legend span { + width: 33.333333%; + display: inline-block; + text-align: center; + cursor: pointer; + color: white; +} \ No newline at end of file diff --git a/server/static/server/c3/docs/css/samples/legend_position.css b/server/static/server/c3/docs/css/samples/legend_position.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/options_color.css b/server/static/server/c3/docs/css/samples/options_color.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/options_gridline.css b/server/static/server/c3/docs/css/samples/options_gridline.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/options_legend.css b/server/static/server/c3/docs/css/samples/options_legend.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/options_padding.css b/server/static/server/c3/docs/css/samples/options_padding.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/options_size.css b/server/static/server/c3/docs/css/samples/options_size.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/options_subchart.css b/server/static/server/c3/docs/css/samples/options_subchart.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/pie_label_format.css b/server/static/server/c3/docs/css/samples/pie_label_format.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/point_show.css b/server/static/server/c3/docs/css/samples/point_show.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/region.css b/server/static/server/c3/docs/css/samples/region.css new file mode 100644 index 0000000..46cf291 --- /dev/null +++ b/server/static/server/c3/docs/css/samples/region.css @@ -0,0 +1,6 @@ +.c3-region.regionY { + fill: red; +} +.c3-region.regionY2 { + fill: green; +} diff --git a/server/static/server/c3/docs/css/samples/region_timeseries.css b/server/static/server/c3/docs/css/samples/region_timeseries.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/simple_multiple.css b/server/static/server/c3/docs/css/samples/simple_multiple.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/simple_regions.css b/server/static/server/c3/docs/css/samples/simple_regions.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/simple_xy.css b/server/static/server/c3/docs/css/samples/simple_xy.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/simple_xy_multiple.css b/server/static/server/c3/docs/css/samples/simple_xy_multiple.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/style_grid.css b/server/static/server/c3/docs/css/samples/style_grid.css new file mode 100644 index 0000000..58b0cc2 --- /dev/null +++ b/server/static/server/c3/docs/css/samples/style_grid.css @@ -0,0 +1,18 @@ +.c3-xgrid-line line { + stroke: blue; +} +.c3-xgrid-line.grid4 line { + stroke: pink; +} +.c3-xgrid-line.grid4 text { + fill: pink; +} +.c3-ygrid-line line { + stroke: red; +} +.c3-ygrid-line.grid800 line { + stroke: green; +} +.c3-ygrid-line.grid800 text { + fill: green; +} \ No newline at end of file diff --git a/server/static/server/c3/docs/css/samples/style_region.css b/server/static/server/c3/docs/css/samples/style_region.css new file mode 100644 index 0000000..dfa336f --- /dev/null +++ b/server/static/server/c3/docs/css/samples/style_region.css @@ -0,0 +1,6 @@ +.c3-region-0 { + fill: red; +} +.c3-region.foo { + fill: green; +} diff --git a/server/static/server/c3/docs/css/samples/timeseries.css b/server/static/server/c3/docs/css/samples/timeseries.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/tooltip_format.css b/server/static/server/c3/docs/css/samples/tooltip_format.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/tooltip_grouped.css b/server/static/server/c3/docs/css/samples/tooltip_grouped.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/tooltip_show.css b/server/static/server/c3/docs/css/samples/tooltip_show.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/transform_area.css b/server/static/server/c3/docs/css/samples/transform_area.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/transform_areaspline.css b/server/static/server/c3/docs/css/samples/transform_areaspline.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/transform_bar.css b/server/static/server/c3/docs/css/samples/transform_bar.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/transform_donut.css b/server/static/server/c3/docs/css/samples/transform_donut.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/transform_line.css b/server/static/server/c3/docs/css/samples/transform_line.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/transform_pie.css b/server/static/server/c3/docs/css/samples/transform_pie.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/transform_scatter.css b/server/static/server/c3/docs/css/samples/transform_scatter.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/transform_spline.css b/server/static/server/c3/docs/css/samples/transform_spline.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/samples/transition_duration.css b/server/static/server/c3/docs/css/samples/transition_duration.css new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/css/style.css b/server/static/server/c3/docs/css/style.css new file mode 100644 index 0000000..33539b1 --- /dev/null +++ b/server/static/server/c3/docs/css/style.css @@ -0,0 +1,225 @@ +body { + background-color: #fdfdfd; +} +footer { + text-align: right; +} +footer hr { + margin-bottom: 10px; +} +footer p { + margin-bottom: 10px; +} + +#chart { + height: 280px; + margin: 0px auto; + text-align: center; +} + +#message { + font-size: 16px; + text-align: center; +} + +#link { + margin-top: 18px; + float: right; +} +#link .git-icon { + height: 32px; +} + +.antialiased { + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} +.container { + width: 90%; + margin: 0 auto; +} +.container.sidemenu { + position: relative; +} +.container.sidemenu footer { + position: absolute; + bottom: 0; + left: 0; + right: 0; + z-index: 100; + background-color: #fdfdfd; +} +@media only screen and (min-width: 40.063em) { +.container.sidemenu .column-menu { + position: fixed; + overflow: auto; + top: 60px; + bottom: 0; + padding-bottom: 60px; + width: 280px; +} +.container.sidemenu .column-content { + padding-left: 10px; + padding-top: 20px; + padding-bottom: 60px; + margin-left: 280px; + float: none; +} +} +.container.sidemenu .column-menu .side-bar { + position: relative; +} +.container.sidemenu .column-menu .side-bar li > a { + display: inline; + padding-left: 12px; +} +.container.sidemenu .column-menu .side-bar .label { + top: -2px; + padding: 0.22222rem 0.44444rem 0.33333rem; + font-size: 0.5rem; + margin-bottom: 0; +} +.container.sidemenu .column-content section .label { + top: -4px; + padding: 0.22222rem 0.44444rem 0.33333rem; + font-size: 0.61rem; +} +.container hr.large { + margin: 48px 0; +} +.container hr.medium { + margin: 24px 0; +} +.container hr.small { + margin: 12px 0; +} +.container h3.sub { + color: #999; + margin-bottom: 32px; +} + +h1.title { + margin: 16px 0; +} + +.top-bar .name h1 { + font-size: 0.94444rem; +} + +.button { + transition: none; +} +h1, h2, h3, h4, h5 { + font-weight: 300; +} +.row { + max-width: 80rem; +} + +.chart { + margin-top: 42px; +} +.overview { + margin-bottom: 42px; + padding: 0 18px; +} +.features { + margin: 42px auto 30px; +} + + +.side-bar { +} +.side-bar h5 { + font-weight: bold; +} + + +.margin-medium-v { + margin-top: 24px; + margin-bottom: 24px; +} +.margin-medium-top { + margin-top: 24px !important; +} +.margin-small-h { + margin-left: 12px; + margin-right: 12px; +} +.margin-small-bottom { + margin-bottom: 12px !important; +} + +.c3-editor { + font-size: 1.1em !important; +} +.sourcecode { + margin-bottom: 1.25rem; +} +.sourcecode h3 { + border-bottom: 1px solid #ddd; + padding-bottom: 4px; +} +.sourcecode pre { + border: none; + border-radius: 0; + padding: 12px 0px; + font-size: 1.2em; + line-height: 1.428571429; + word-break: break-all; + word-wrap: break-word; +} +.sourcecode pre code { + background-color: #fdfdfd; + padding: 0; + font-family: Monaco,Menlo,Consolas,"Courier New",monospace; + font-weight: normal; + font-size: 0.9em; +} + +.highlight { + border-left: 4px solid #ccc; + padding: 0 8px; +} +.highlight pre { + padding: 0 8px; + line-height: 1.2em; +} + +.section .row { + margin-bottom: 32px; +} +.section > a > h2 { + line-height: 1.2em; + margin-top: 18px; + margin-bottom: 18px; +} + +span.code { + display: inline-block; + background-color: #eee; + padding-left: 4px; + padding-right: 4px; + font-family: Monaco,Menlo,Consolas,"Courier New",monospace; + font-size: 0.9em; +} + +h3 + ul, p + ul { + margin-left: 32px; +} + +.gray { + color: #999; +} + +li .label { + top: -3px; + padding: 0.22222rem 0.44444rem 0.33333rem; + font-size: 0.61rem; + margin: 0 8px; +} + +div.sub-section { + padding-top: 4px; + padding-left: 10px; +} diff --git a/server/static/server/c3/docs/css/tomorrow.css b/server/static/server/c3/docs/css/tomorrow.css new file mode 100644 index 0000000..77f3b97 --- /dev/null +++ b/server/static/server/c3/docs/css/tomorrow.css @@ -0,0 +1,49 @@ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ +.tomorrow-comment, pre .comment, pre .title { + color: #8e908c; +} + +.tomorrow-red, pre .variable, pre .attribute, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo { +/* color: #c82829;*/ +} + +.tomorrow-orange, pre .number, pre .preprocessor, pre .built_in, pre .literal, pre .params, pre .constant { + color: #f5871f; +} + +.tomorrow-yellow, pre .class, pre .ruby .class .title, pre .css .rules .attribute { + color: #eab700; +} + +.tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata { + color: #718c00; +} + +.tomorrow-aqua, pre .css .hexcolor { + color: #3e999f; +} + +.tomorrow-blue, pre .function, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title { + color: #4271ae; +} + +.tomorrow-purple, pre .keyword, pre .javascript .function { + color: #8959a8; +} + +pre code { + display: block; + background: white; + color: #4d4d4c; + padding: 0.5em; +} + +pre .coffeescript .javascript, +pre .javascript .xml, +pre .tex .formula, +pre .xml .javascript, +pre .xml .vbscript, +pre .xml .css, +pre .xml .cdata { + opacity: 0.5; +} diff --git a/server/static/server/c3/docs/data/c3_string_x.csv b/server/static/server/c3/docs/data/c3_string_x.csv new file mode 100644 index 0000000..91329c8 --- /dev/null +++ b/server/static/server/c3/docs/data/c3_string_x.csv @@ -0,0 +1,4 @@ +x,download,loading +www.siteX.com,100,400 +www.siteY.com,200,100 +www.siteZ.com,300,200 diff --git a/server/static/server/c3/docs/data/c3_test.csv b/server/static/server/c3/docs/data/c3_test.csv new file mode 100644 index 0000000..dea2e16 --- /dev/null +++ b/server/static/server/c3/docs/data/c3_test.csv @@ -0,0 +1,6 @@ +data1,data2,data3 +120,80,200 +140,50,210 +170,100,250 +150,70,300 +180,120,280 \ No newline at end of file diff --git a/server/static/server/c3/docs/data/c3_test.json b/server/static/server/c3/docs/data/c3_test.json new file mode 100644 index 0000000..43a76f8 --- /dev/null +++ b/server/static/server/c3/docs/data/c3_test.json @@ -0,0 +1,5 @@ +{ + "data1": [220, 240, 270, 250, 280], + "data2": [180, 150, 300, 70, 120], + "data3": [200, 310, 150, 100, 180] +} diff --git a/server/static/server/c3/docs/data/c3_test2.csv b/server/static/server/c3/docs/data/c3_test2.csv new file mode 100644 index 0000000..ae1a48a --- /dev/null +++ b/server/static/server/c3/docs/data/c3_test2.csv @@ -0,0 +1,6 @@ +data1,data2,data3 +20,180,400 +40,150,310 +70,120,470 +50,170,400 +80,200,380 \ No newline at end of file diff --git a/server/static/server/c3/docs/examples.html.haml b/server/static/server/c3/docs/examples.html.haml new file mode 100644 index 0000000..1c16128 --- /dev/null +++ b/server/static/server/c3/docs/examples.html.haml @@ -0,0 +1,212 @@ +.container + .section + = partial :index_item_title, locals: { id: 'chart', name: 'Chart' } + %div + .row + = partial :index_item, locals: { id: 'simple_multiple' } + = partial :index_item, locals: { id: 'timeseries' } + = partial :index_item, locals: { id: 'chart_spline' } + .row + = partial :index_item, locals: { id: 'simple_xy' } + = partial :index_item, locals: { id: 'simple_xy_multiple' } + = partial :index_item, locals: { id: 'simple_regions' } + .row + = partial :index_item, locals: { id: 'chart_step' } + = partial :index_item, locals: { id: 'chart_area' } + = partial :index_item, locals: { id: 'chart_area_stacked' } + .row + = partial :index_item, locals: { id: 'chart_bar' } + = partial :index_item, locals: { id: 'chart_bar_stacked' } + = partial :index_item, locals: { id: 'chart_scatter' } + .row + = partial :index_item, locals: { id: 'chart_pie' } + = partial :index_item, locals: { id: 'chart_donut' } + = partial :index_item, locals: { id: 'chart_gauge' } + .row + = partial :index_item, locals: { id: 'chart_stanford' } + = partial :index_item, locals: { id: 'chart_combination' } + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'axis', name: 'Axis' } + %div + .row + = partial :index_item, locals: { id: 'categorized' } + = partial :index_item, locals: { id: 'axes_rotated' } + = partial :index_item, locals: { id: 'axes_y2' } + .row + = partial :index_item, locals: { id: 'axes_x_tick_format' } + = partial :index_item, locals: { id: 'axes_x_tick_count' } + = partial :index_item, locals: { id: 'axes_x_tick_values' } + .row + = partial :index_item, locals: { id: 'axes_x_tick_culling' } + = partial :index_item, locals: { id: 'axes_x_tick_fit' } + = partial :index_item, locals: { id: 'axes_x_localtime' } + .row + = partial :index_item, locals: { id: 'axes_x_tick_rotate' } + = partial :index_item, locals: { id: 'axes_y_tick_format' } + = partial :index_item, locals: { id: 'axes_y_padding' } + .row + = partial :index_item, locals: { id: 'axes_y_range' } + = partial :index_item, locals: { id: 'axes_label' } + = partial :index_item, locals: { id: 'axes_label_position' } + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'data', name: 'Data' } + %div + .row + = partial :index_item, locals: { id: 'data_columned' } + = partial :index_item, locals: { id: 'data_rowed' } + = partial :index_item, locals: { id: 'data_json' } + .row + = partial :index_item, locals: { id: 'data_url' } + = partial :index_item, locals: { id: 'data_stringx' } + = partial :index_item, locals: { id: 'data_load' } + .row + = partial :index_item, locals: { id: 'data_name' } + = partial :index_item, locals: { id: 'data_color' } + = partial :index_item, locals: { id: 'data_order' } + .row + = partial :index_item, locals: { id: 'data_label' } + = partial :index_item, locals: { id: 'data_label_format' } + = partial :index_item, locals: { id: 'data_number_format_l10n' } + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'grid', name: 'Grid' } + %div + .row + = partial :index_item, locals: { id: 'options_gridline' } + = partial :index_item, locals: { id: 'grid_x_lines' } + = partial :index_item, locals: { id: 'grid_y_lines' } + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'region', name: 'Region' } + %div + .row + = partial :index_item, locals: { id: 'region' } + = partial :index_item, locals: { id: 'region_timeseries' } + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'interaction', name: 'Interaction' } + %div + .row + = partial :index_item, locals: { id: 'options_subchart' } + = partial :index_item, locals: { id: 'interaction_zoom' } + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'legend', name: 'Legend' } + %div + .row + = partial :index_item, locals: { id: 'options_legend' } + = partial :index_item, locals: { id: 'legend_position' } + = partial :index_item, locals: { id: 'legend_custom' } + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'tooltip', name: 'Tooltip' } + %div + .row + = partial :index_item, locals: { id: 'tooltip_show' } + = partial :index_item, locals: { id: 'tooltip_grouped' } + = partial :index_item, locals: { id: 'tooltip_format' } + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'chart_options', name: 'Chart Options' } + %div + .row + = partial :index_item, locals: { id: 'options_size' } + = partial :index_item, locals: { id: 'options_padding' } + = partial :index_item, locals: { id: 'options_color' } + .row + = partial :index_item, locals: { id: 'transition_duration' } + .large-4.columns + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'line_chart_options', name: 'Line Chart Options' } + %div + .row + = partial :index_item, locals: { id: 'point_show' } + .large-4.columns + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'pie_chart_options', name: 'Pie Chart Options' } + %div + .row + = partial :index_item, locals: { id: 'pie_label_format' } + .large-4.columns + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'api', name: 'API' } + %div + .row + = partial :index_item, locals: { id: 'api_flow' } + = partial :index_item, locals: { id: 'api_data_name' } + = partial :index_item, locals: { id: 'api_data_color' } + .row + = partial :index_item, locals: { id: 'api_axis_label' } + = partial :index_item, locals: { id: 'api_axis_range' } + = partial :index_item, locals: { id: 'api_resize' } + .row + = partial :index_item, locals: { id: 'api_grid_x' } + .large-4.columns + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'transform', name: 'Transform' } + %div + .row + = partial :index_item, locals: { id: 'transform_line' } + = partial :index_item, locals: { id: 'transform_spline' } + = partial :index_item, locals: { id: 'transform_bar' } + .row + = partial :index_item, locals: { id: 'transform_area' } + = partial :index_item, locals: { id: 'transform_areaspline' } + = partial :index_item, locals: { id: 'transform_scatter' } + .row + = partial :index_item, locals: { id: 'transform_pie' } + = partial :index_item, locals: { id: 'transform_donut' } + .large-4.columns + + %hr.medium + + .section + = partial :index_item_title, locals: { id: 'style', name: 'Style' } + %div + .row + = partial :index_item, locals: { id: 'style_region' } + = partial :index_item, locals: { id: 'style_grid' } + .large-4.columns + + = partial :footer + += partial :script diff --git a/server/static/server/c3/docs/gettingstarted.html.haml b/server/static/server/c3/docs/gettingstarted.html.haml new file mode 100644 index 0000000..d9aaa9c --- /dev/null +++ b/server/static/server/c3/docs/gettingstarted.html.haml @@ -0,0 +1,384 @@ +.container.sidemenu + .row + .large-3.medium-4.columns.column-menu + .side-bar + %ul.side-nav + %li GETTING STARTED + %li + %a( href="#setup" ) 1. Setup + %li + %a( href="#generate" ) 2. Generate chart + %li + %a( href="#customize" ) 3. Customize chart + %li + %a( href="#api" ) 4. Use APIs + %li + %a( href="#style" ) 5. Customize style + %li + %a( href="#more" ) 6. And more.. + + .large-9.medium-8.columns.column-content + %section + %h2 Getting Started + %p In this guide, we are going to show you how to get started with C3. + + %hr + + %section + %h3 + %a( href="#setup" ) 1. Setup + %p Download the latest version here: + %ul + %li https://github.com/c3js/c3/releases/latest + %p Installing by Bower/Component is also available with the name c3. + + %p Then, load the scripts and css: + + .sourcecode.highlight + %pre + %code.html.xml + :preserve + <!-- Load c3.css --> + <link href="/path/to/c3.css" rel="stylesheet"> + + <!-- Load d3.js and c3.js --> + <script src="/path/to/d3.v5.min.js" charset="utf-8"></script> + <script src="/path/to/c3.min.js"></script> + + %p C3 depends on D3, so please load D3 too. + + %hr + + %section + %h3 + %a( href="#generate" ) 2. Generate Chart + %p C3 generates a chart by calling generate() with the argument object, and an element including the chart will insert into the element specified as a selector in that argument as bindto. + + %p Prepare the element to bind the chart: + .sourcecode.highlight + %pre + %code.html.xml + :preserve + <div id="chart"></div> + + %p And, call generate() with arguments: + + .sourcecode.highlight + %pre + %code.javascript + :preserve + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + } + }); + + %p C3 supports the asynchronous module definition (AMD) API. If you use RequireJS, you can load like this: + + .sourcecode.highlight + %pre + %code.javascript + :preserve + require.config({ + baseUrl: '/js', + paths: { + d3: "http://d3js.org/d3.v5.min" + } + }); + + require(["d3", "c3"], function(d3, c3) { + c3.generate({ + ... + }); + }); + + %p Then, you will see the chart: + + #chart2_1 + %br + + %p Data can be loaded as columned data / rowed data / csv in URL. + %p There are serveral options to customize the chart and you can see those here: + %ul + %li Examples + + %hr + + %section + %h3 + %a( href="#customize" ) 3. Customize Chart + %p The chart can be customize by giving some options when generating. We will introduce some of them here. + + %h4 1. Additional Axis + %p Introduce additional axis for data2. Add data.axes and axis.y2.show as follows: + + .sourcecode.highlight + %pre + %code.javascript + :preserve + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data2: 'y2' // ADD + } + }, + axis: { + y2: { + show: true // ADD + } + } + }); + + %p Then, the chart will be like this: + + #chart3_1 + %br + + %h4 2. Show Axis Label + %p Show labels for each axis. Add axis.y.label and axis.y2.label as follows: + + .sourcecode.highlight + %pre + %code.javascript + :preserve + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data2: 'y2' + } + }, + axis: { + y: { + label: { // ADD + text: 'Y Label', + position: 'outer-middle' + } + }, + y2: { + show: true, + label: { // ADD + text: 'Y2 Label', + position: 'outer-middle' + } + } + } + }); + + %p Then, the chart will be like this: + + #chart3_2 + %br + + %h4 3. Change Chart Type + %p Show data2 as Bar chart. Add data.types as follows: + + .sourcecode.highlight + %pre + %code.javascript + :preserve + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data2: 'y2' + }, + types: { + data2: 'bar' // ADD + } + }, + axis: { + y: { + label: { + text: 'Y Label', + position: 'outer-middle' + } + }, + y2: { + show: true, + label: { + text: 'Y2 Label', + position: 'outer-middle' + } + } + } + }); + + %p Then, the chart will be like this: + + #chart3_3 + %br + + %h4 4. Format values + %p Format the values of each data. Add axis.y.tick.format as follows: + + .sourcecode.highlight + %pre + %code.javascript + :preserve + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data2: 'y2' + }, + types: { + data2: 'bar' + } + }, + axis: { + y: { + label: { + text: 'Y Label', + position: 'outer-middle' + }, + tick: { + format: d3.format("$,") // ADD + } + }, + y2: { + show: true, + label: { + text: 'Y2 Label', + position: 'outer-middle' + } + } + } + }); + + %p Then, the chart will be like this: + + #chart3_4 + %br + + %p More information about the options, please see Examples. (We'll add the reference soon) + + %hr + + %section + %h3 + %a( href="#api" ) 4. Use APIs + %p By using APIs, you can update the chart after it's been rendered. We will introduce some of APIs here. APIs can be called through the object returned from generate(). + + %h4 1. Load Data + %p By using load() API, you can load data and update the chart dynamically as follows: + + .sourcecode.highlight + %pre + %code.javascript + :preserve + // var chart = c3.generate({ ... }); + + chart.load({ + columns: [ + ['data1', 300, 100, 250, 150, 300, 150, 500], + ['data2', 100, 200, 150, 50, 100, 250] + ] + }); + + %p If you push the button "Load" below, this code will run and the chart will be updated. + + %button.small( onclick="example4_1();" ) Load + + #chart4_1 + %br + + %h4 2. Unload Data + %p By using unload() API, you can unload the data dynamically as follows: + + .sourcecode.highlight + %pre + %code.javascript + :preserve + // var chart = c3.generate({ ... }); + + chart.unload({ + ids: ['data2', 'data3'] + }); + + %p If you push the button "Unload" below, this code will run and the chart will be updated. + + %button.small( onclick="example4_2();" ) Unload + + #chart4_2 + %br + + %p Please use unload param in load() API if load and unload need to run simultaneously. Please see this example. + + %h4 3. Show/Hide Data + %p By using show() and hide() API, you can show/hide the data dynamically as follows: + + .sourcecode.highlight + %pre + %code.javascript + :preserve + // var chart = c3.generate({ ... }); + + chart.hide(['data2', 'data3']); + chart.show(['data2', 'data3']); + + %p If you push the button "Show" and "Hide" below, this code will run and the chart will be updated. + + %button.small( onclick="example4_3_2();" ) Hide + %button.small( onclick="example4_3_1();" ) Show + + #chart4_3 + %br + + %p The documentation about APIs is poor now, so please check the issues on github. There might be some hints about what you want to do. (We will add the document soon) + + %hr + + %section + %h3 + %a( href="#style" ) 5. Customize Style + %p C3 give some classes for each element when generating. So, you can change the style of the elements by using those classes. + %h4 1. Line style + %p The lines have c3-line-[id] class, so this class can be used to define the style in css as follows: + + .sourcecode.highlight + %pre + %code.css + :preserve + #chart .c3-line-data2 { + stroke-width: 5px; + } + + #chart5_1 + %br + + %p Please check the class for each element if you want to change the style. Web Inspector would be useful. (We will add the document for class definition soon) + + %hr + + %section + %h3 + %a( href="#more" ) 6. And More.. + %p Please check the examples and the issues on github for more information. Sorry for the poor documentation. We're working on now and please give me some time. Thank you. + + = partial :footer + += partial :script += partial :script_scroll += javascript_include_tag 'gettingstarted.js' diff --git a/server/static/server/c3/docs/img/.gitignore b/server/static/server/c3/docs/img/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/server/static/server/c3/docs/img/GitHub-Mark-64px.png b/server/static/server/c3/docs/img/GitHub-Mark-64px.png new file mode 100644 index 0000000..182a1a3 Binary files /dev/null and b/server/static/server/c3/docs/img/GitHub-Mark-64px.png differ diff --git a/server/static/server/c3/docs/img/favicon.png b/server/static/server/c3/docs/img/favicon.png new file mode 100644 index 0000000..c23302d Binary files /dev/null and b/server/static/server/c3/docs/img/favicon.png differ diff --git a/server/static/server/c3/docs/index.html.haml b/server/static/server/c3/docs/index.html.haml new file mode 100644 index 0000000..05b5671 --- /dev/null +++ b/server/static/server/c3/docs/index.html.haml @@ -0,0 +1,369 @@ +.container + + %h1.title + C3.js + %small D3-based reusable chart library + + .chart + #message + %a.button.small( onclick="startDemo();") Start Demo + #chart + + %hr.large + + %h2.text-center Why C3? + .row.text-center.features + .medium-4.large-4.columns.supporticons + %h3 Comfortable + %p + C3 makes it easy to generate D3-based charts by wrapping the code required to construct the entire chart. We don't need to write D3 code any more. + .medium-4.large-4.columns.supporticons + %h3 Customizable + %p + C3 gives some classes to each element when generating, so you can define a custom style by the class and it's possible to extend the structure directly by D3. + + .medium-4.large-4.columns.supporticons + %h3 Controllable + %p + C3 provides a variety of APIs and callbacks to access the state of the chart. By using them, you can update the chart even after it's rendered. + + %h3.text-center.sub + C3 enables deeper integration of charts into your application. + %br + + .text-center + %a.button( href="/gettingstarted.html" ) Getting Started + + %hr + + %h3 Change Log + %ul + %li + v0.7.20 - 2020-08-08 + %ul + %li Bug fixes. + %li + v0.7.18 - 2020-06-17 + %ul + %li Bug fixes. + %li + v0.7.17 - 2020-06-15 + %ul + %li Bug fixes. + %li + v0.7.16 - 2020-06-15 + %ul + %li Bug fixes. + %li + v0.7.15 - 2020-02-28 + %ul + %li Bug fixes. + %li + v0.7.14 - 2020-02-24 + %ul + %li Bug fixes. + %li + v0.7.12 - 2019-10-04 + %ul + %li Add rollup support. + %li Improved subchart handling. + %li + v0.7.11 - 2019-10-04 + %ul + %li Bug fixes. + %li + v0.7.10 - 2019-10-02 + %ul + %li Bug fixes. + %li + v0.7.9 - 2019-09-23 + %ul + %li Experimental support for y/y2 log scale. + %li Restore tooltip behavior when grouped. + %li Add Region Labels. + %li + v0.7.8 - 2019-08-25 + %ul + %li Fix scatter appearance. + %li Points in charts can be styled by css. + %li A fix for Firefox. + %li + v0.7.7 - 2019-08-25 + %ul + %li Fix a bug. + %li + v0.7.6 - 2019-08-20 + %ul + %li A bug fix. + %li + v0.7.5 - 2019-08-19 + %ul + %li Add normalized stack chart. + %li Bug fixes. + %li + v0.7.4 - 2019-08-09 + %ul + %li Add padAngle option. + %li A bug fix. + %li + v0.7.3 - 2019-07-29 + %ul + %li Bug fixes. + %li + v0.7.2 - 2019-07-06 + %ul + %li Add stanford.scaleValues option. + %li + v0.7.1 - 2019-05-29 + %ul + %li Add an option for tooltip behavior. + %li + v0.7.0 - 2019-04-10 + %ul + %li Add stanford diagram. + %li + v0.6.14 - 2019-03-27 + %ul + %li Fixed a memory leak. + %li Fixed .selected() API. + %li + v0.6.13 - 2019-03-04 + %ul + %li Reverted resizing change in 0.6.11. + %li + v0.6.12 - 2018-12-28 + %ul + %li Added index to tooltip’s title format callback. + %li + v0.6.11 - 2018-12-08 + %ul + %li Fix a bug of resizing. + %li + v0.6.10 - 2018-12-04 + %ul + %li Fix a bug of arc chart. + %li + v0.6.9 - 2018-11-22 + %ul + %li Fix a bug. + %li + v0.6.8 - 2018-10-01 + %ul + %li Add src/* npm package. + %li + v0.6.7 - 2018-08-08 + %ul + %li Add the zoom type 'drag'. + %li + v0.6.6 - 2018-07-24 + %ul + %li Fix bug of gauge chart. + %li + v0.6.5 - 2018-07-14 + %ul + %li Fix bug of hidden legend option. + %li + v0.6.4 - 2018-07-12 + %ul + %li Fix a bug of mouse events. + %li + v0.6.3 - 2018-07-06 + %ul + %li Fix a bug of gauge. + %li + v0.6.2 - 2018-06-08 + %ul + %li Add step-before and step-after for line.step.type option. + %li + v0.4.23 - 2018-05-18 + %ul + %li Add axis.x.tick.multilineMax option (0.4 branch). + %li + v0.6.1 - 2018-05-17 + %ul + %li Add axis.x.tick.multilineMax option. + %li + v0.6.0 - 2018-05-14 + %ul + %li Update D3 dependency to v5. + %li + v0.5.4 - 2018-04-23 + %ul + %li Bug fixes. + %li + v0.5.3 - 2018-04-12 + %ul + %li Bug fixes. + %li + v0.5.2 - 2018-03-31 + %ul + %li Bug fixes. + %li + v0.5.1 - 2018-03-25 + %ul + %li Bug fixes. + %li + v0.5.0 - 2018-03-24 + %ul + %li Update D3 dependency to version 4. + %li + v0.4.22 - 2018-03-21 + %ul + %li Add axis.x.inner option. + %li + v0.4.21 - 2018-02-15 + %ul + %li Multi arc gauge chart. + %li + v0.4.20 - 2018-02-11 + %ul + %li Fix gauge chart with fullCircle option. + %li + v0.4.19 - 2018-02-10 + %ul + %li Do not call resize functions when chart is hidden. + %li Switched CI environment. + %li Have license in minified bundle. + %li Fixed a memory leak. + %li + v0.4.18 - 2017-09-14 + %ul + %li point.focus.expand.r takes a function. + %li Pie and donuts really handle data.order correctly. + %li + v0.4.17 - 2017-08-19 + %ul + %li Added bar.space option. + %li + v0.4.16 - 2017-08-16 + %ul + %li Bug fix of bar chart. + %li + v0.4.15 - 2017-07-20 + %ul + %li Move some style handling to css. + %li + v0.4.14 - 2017-06-24 + %ul + %li Bug fix. + %li + v0.4.13 - 2017-06-11 + %ul + %li New option and bug fixes. + %li + v0.4.12 - 2017-05-28 + %ul + %li Performance improvement and bug fixes. + %li + v0.4.11 - 2016-05-01 + %ul + %li New features, performance improvement and bug fixes. + %li + v0.4.10 - 2015-03-17 + %ul + %li New features, performance improvement and bug fixes. + %li + v0.4.9 - 2015-01-18 + %ul + %li New features, performance improvement and bug fixes. + %li + v0.4.8 - 2014-12-14 + %ul + %li Bug fixes. + %li + v0.4.7 - 2014-12-02 + %ul + %li Bug fixes. + %li + v0.4.6 - 2014-12-01 + %ul + %li Bug fixes. + %li + v0.4.5 - 2014-11-30 + %ul + %li Bug fixes. + %li Performance improvement. + %li + v0.4.4 - 2014-11-21 + %ul + %li New features (e.g. axis.y/y2.inner, legend.hide options) + %li Bug fixes. + %li Performance improvement. + %li + v0.4.3 - 2014-11-18 + %ul + %li Bug fixes. + %li + v0.4.2 - 2014-11-17 + %ul + %li Bug fixes. + %li + v0.4.1 - 2014-11-16 + %ul + %li Fixed class suffix. + %li + v0.4.0 - 2014-11-15 + %ul + %li A lot of bug fixes and new features + %li Introduce unit test (it's not enough though) + %li and more... + %li + v0.3.0 - 2014-08-22 + %ul + %li Introduced new architecture so that we can extend this library more easily. + %li Modified some options such as data.xFormat and data.xLocaltime. + %li Splitted source file into small ones. + %li + v0.2.5 - 2014-08-09 + %ul + %li Modified to use data.onclick, data.onmouseover and data.onmouseout on pie/donut/gauge instead of its callbacks + %li Modified unload interface + %li Bug fixes + %li and more... + %li + v0.2.4 - 2014-06-16 + %ul + %li Added new options such as pie.sort, donut.sort, bar.zerobased, area.zerobased + %li Added new API such as category, categories + %li Bug fixes + %li + v0.2.3 - 2014-06-04 + %ul + %li Renamed callbacks (onend/onenter/onleave) + %li Added extension for zoom with reduction (by @danelkhen Thank you!) + %li Bug fixes + %li + v0.2.2 - 2014-06-03 + %ul + %li Supported ungrouped tooltip + %li Added zoom.enable API + %li Bug fixes + %li + v0.2.1 - 2014-06-02 + %ul + %li Bug fixes + %li + v0.2.0 - 2014-05-30 + %ul + %li Supported step line/area, stacked line/area, stacked line/area, gauge chart + %li Supported JSON as input + %li Added flow API + %li etc + %li v0.1.42 - 2014-05-18 + + %h3 Browser Support + %p Because of the dependence on D3, C3 supports only modern browsers D3 supports. Please see the description in D3. + %p Note: For IE9 and IE10, polyfill is required because c3 uses MutationObserver, which is not supported in those versions. However, it's not required if charts always will be binded to the DOM specified by bindto because MutationObserver is not called in that case. + + %h3 Dependency + %ul + %li D3.js ^4.12.0 + %p Note: If you need to use D3 v3.x, please use C3 v0.4.22, which is compatible with D3 v3.x. + + %h3 License + %p MIT + + = partial :footer + += partial :script += javascript_include_tag 'index' diff --git a/server/static/server/c3/docs/js/ace/ace.js b/server/static/server/c3/docs/js/ace/ace.js new file mode 100644 index 0000000..2ffacca --- /dev/null +++ b/server/static/server/c3/docs/js/ace/ace.js @@ -0,0 +1,11 @@ +(function(){function s(r){var i=function(e,t){return n("",e,t)},s=e;r&&(e[r]||(e[r]={}),s=e[r]);if(!s.define||!s.define.packaged)t.original=s.define,s.define=t,s.define.packaged=!0;if(!s.require||!s.require.packaged)n.original=s.require,s.require=i,s.require.packaged=!0}var ACE_NAMESPACE = "ace",e=function(){return this}();if(!ACE_NAMESPACE&&typeof requirejs!="undefined")return;var t=function(e,n,r){if(typeof e!="string"){t.original?t.original.apply(window,arguments):(console.error("dropping module because define wasn't a string."),console.trace());return}arguments.length==2&&(r=n),t.modules||(t.modules={},t.payloads={}),t.payloads[e]=r,t.modules[e]=null},n=function(e,t,r){if(Object.prototype.toString.call(t)==="[object Array]"){var s=[];for(var o=0,u=t.length;o1&&u(t,"")>-1&&(a=RegExp(this.source,r.replace.call(o(this),"g","")),r.replace.call(e.slice(t.index),a,function(){for(var e=1;et.index&&this.lastIndex--}return t},s||(RegExp.prototype.test=function(e){var t=r.exec.call(this,e);return t&&this.global&&!t[0].length&&this.lastIndex>t.index&&this.lastIndex--,!!t})}),ace.define("ace/lib/es5-shim",["require","exports","module"],function(e,t,n){function r(){}function w(e){try{return Object.defineProperty(e,"sentinel",{}),"sentinel"in e}catch(t){}}function H(e){return e=+e,e!==e?e=0:e!==0&&e!==1/0&&e!==-1/0&&(e=(e>0||-1)*Math.floor(Math.abs(e))),e}function B(e){var t=typeof e;return e===null||t==="undefined"||t==="boolean"||t==="number"||t==="string"}function j(e){var t,n,r;if(B(e))return e;n=e.valueOf;if(typeof n=="function"){t=n.call(e);if(B(t))return t}r=e.toString;if(typeof r=="function"){t=r.call(e);if(B(t))return t}throw new TypeError}Function.prototype.bind||(Function.prototype.bind=function(t){var n=this;if(typeof n!="function")throw new TypeError("Function.prototype.bind called on incompatible "+n);var i=u.call(arguments,1),s=function(){if(this instanceof s){var e=n.apply(this,i.concat(u.call(arguments)));return Object(e)===e?e:this}return n.apply(t,i.concat(u.call(arguments)))};return n.prototype&&(r.prototype=n.prototype,s.prototype=new r,r.prototype=null),s});var i=Function.prototype.call,s=Array.prototype,o=Object.prototype,u=s.slice,a=i.bind(o.toString),f=i.bind(o.hasOwnProperty),l,c,h,p,d;if(d=f(o,"__defineGetter__"))l=i.bind(o.__defineGetter__),c=i.bind(o.__defineSetter__),h=i.bind(o.__lookupGetter__),p=i.bind(o.__lookupSetter__);if([1,2].splice(0).length!=2)if(!function(){function e(e){var t=new Array(e+2);return t[0]=t[1]=0,t}var t=[],n;t.splice.apply(t,e(20)),t.splice.apply(t,e(26)),n=t.length,t.splice(5,0,"XXX"),n+1==t.length;if(n+1==t.length)return!0}())Array.prototype.splice=function(e,t){var n=this.length;e>0?e>n&&(e=n):e==void 0?e=0:e<0&&(e=Math.max(n+e,0)),e+ta)for(h=l;h--;)this[f+h]=this[a+h];if(s&&e===c)this.length=c,this.push.apply(this,i);else{this.length=c+s;for(h=0;h>>0;if(a(t)!="[object Function]")throw new TypeError;while(++s>>0,s=Array(i),o=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var u=0;u>>0,s=[],o,u=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var f=0;f>>0,s=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var o=0;o>>0,s=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var o=0;o>>0;if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");if(!i&&arguments.length==1)throw new TypeError("reduce of empty array with no initial value");var s=0,o;if(arguments.length>=2)o=arguments[1];else do{if(s in r){o=r[s++];break}if(++s>=i)throw new TypeError("reduce of empty array with no initial value")}while(!0);for(;s>>0;if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");if(!i&&arguments.length==1)throw new TypeError("reduceRight of empty array with no initial value");var s,o=i-1;if(arguments.length>=2)s=arguments[1];else do{if(o in r){s=r[o--];break}if(--o<0)throw new TypeError("reduceRight of empty array with no initial value")}while(!0);do o in this&&(s=t.call(void 0,s,r[o],o,n));while(o--);return s});if(!Array.prototype.indexOf||[0,1].indexOf(1,2)!=-1)Array.prototype.indexOf=function(t){var n=g&&a(this)=="[object String]"?this.split(""):F(this),r=n.length>>>0;if(!r)return-1;var i=0;arguments.length>1&&(i=H(arguments[1])),i=i>=0?i:Math.max(0,r+i);for(;i>>0;if(!r)return-1;var i=r-1;arguments.length>1&&(i=Math.min(i,H(arguments[1]))),i=i>=0?i:r-Math.abs(i);for(;i>=0;i--)if(i in n&&t===n[i])return i;return-1};Object.getPrototypeOf||(Object.getPrototypeOf=function(t){return t.__proto__||(t.constructor?t.constructor.prototype:o)});if(!Object.getOwnPropertyDescriptor){var y="Object.getOwnPropertyDescriptor called on a non-object: ";Object.getOwnPropertyDescriptor=function(t,n){if(typeof t!="object"&&typeof t!="function"||t===null)throw new TypeError(y+t);if(!f(t,n))return;var r,i,s;r={enumerable:!0,configurable:!0};if(d){var u=t.__proto__;t.__proto__=o;var i=h(t,n),s=p(t,n);t.__proto__=u;if(i||s)return i&&(r.get=i),s&&(r.set=s),r}return r.value=t[n],r}}Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(t){return Object.keys(t)});if(!Object.create){var b;Object.prototype.__proto__===null?b=function(){return{__proto__:null}}:b=function(){var e={};for(var t in e)e[t]=null;return e.constructor=e.hasOwnProperty=e.propertyIsEnumerable=e.isPrototypeOf=e.toLocaleString=e.toString=e.valueOf=e.__proto__=null,e},Object.create=function(t,n){var r;if(t===null)r=b();else{if(typeof t!="object")throw new TypeError("typeof prototype["+typeof t+"] != 'object'");var i=function(){};i.prototype=t,r=new i,r.__proto__=t}return n!==void 0&&Object.defineProperties(r,n),r}}if(Object.defineProperty){var E=w({}),S=typeof document=="undefined"||w(document.createElement("div"));if(!E||!S)var x=Object.defineProperty}if(!Object.defineProperty||x){var T="Property description must be an object: ",N="Object.defineProperty called on non-object: ",C="getters & setters can not be defined on this javascript engine";Object.defineProperty=function(t,n,r){if(typeof t!="object"&&typeof t!="function"||t===null)throw new TypeError(N+t);if(typeof r!="object"&&typeof r!="function"||r===null)throw new TypeError(T+r);if(x)try{return x.call(Object,t,n,r)}catch(i){}if(f(r,"value"))if(d&&(h(t,n)||p(t,n))){var s=t.__proto__;t.__proto__=o,delete t[n],t[n]=r.value,t.__proto__=s}else t[n]=r.value;else{if(!d)throw new TypeError(C);f(r,"get")&&l(t,n,r.get),f(r,"set")&&c(t,n,r.set)}return t}}Object.defineProperties||(Object.defineProperties=function(t,n){for(var r in n)f(n,r)&&Object.defineProperty(t,r,n[r]);return t}),Object.seal||(Object.seal=function(t){return t}),Object.freeze||(Object.freeze=function(t){return t});try{Object.freeze(function(){})}catch(k){Object.freeze=function(t){return function(n){return typeof n=="function"?n:t(n)}}(Object.freeze)}Object.preventExtensions||(Object.preventExtensions=function(t){return t}),Object.isSealed||(Object.isSealed=function(t){return!1}),Object.isFrozen||(Object.isFrozen=function(t){return!1}),Object.isExtensible||(Object.isExtensible=function(t){if(Object(t)===t)throw new TypeError;var n="";while(f(t,n))n+="?";t[n]=!0;var r=f(t,n);return delete t[n],r});if(!Object.keys){var L=!0,A=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],O=A.length;for(var M in{toString:null})L=!1;Object.keys=function I(e){if(typeof e!="object"&&typeof e!="function"||e===null)throw new TypeError("Object.keys called on a non-object");var I=[];for(var t in e)f(e,t)&&I.push(t);if(L)for(var n=0,r=O;n=0?parseFloat((i.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]):parseFloat((i.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]),t.isOldIE=t.isIE&&t.isIE<9,t.isGecko=t.isMozilla=(window.Controllers||window.controllers)&&window.navigator.product==="Gecko",t.isOldGecko=t.isGecko&&parseInt((i.match(/rv\:(\d+)/)||[])[1],10)<4,t.isOpera=window.opera&&Object.prototype.toString.call(window.opera)=="[object Opera]",t.isWebKit=parseFloat(i.split("WebKit/")[1])||undefined,t.isChrome=parseFloat(i.split(" Chrome/")[1])||undefined,t.isAIR=i.indexOf("AdobeAIR")>=0,t.isIPad=i.indexOf("iPad")>=0,t.isTouchPad=i.indexOf("TouchPad")>=0,t.isChromeOS=i.indexOf(" CrOS ")>=0}),ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(e,t,n){"use strict";function o(e,t,n){var o=s(t);if(!i.isMac&&u){if(u[91]||u[92])o|=8;if(u.altGr){if((3&o)==3)return;u.altGr=0}if(n===18||n===17){var f="location"in t?t.location:t.keyLocation;if(n===17&&f===1)a=t.timeStamp;else if(n===18&&o===3&&f===2){var l=-a;a=t.timeStamp,l+=a,l<3&&(u.altGr=!0)}}}if(n in r.MODIFIER_KEYS){switch(r.MODIFIER_KEYS[n]){case"Alt":o=2;break;case"Shift":o=4;break;case"Ctrl":o=1;break;default:o=8}n=-1}o&8&&(n===91||n===93)&&(n=-1);if(!o&&n===13){var f="location"in t?t.location:t.keyLocation;if(f===3){e(t,o,-n);if(t.defaultPrevented)return}}if(i.isChromeOS&&o&8){e(t,o,n);if(t.defaultPrevented)return;o&=-9}return!!o||n in r.FUNCTION_KEYS||n in r.PRINTABLE_KEYS?e(t,o,n):!1}var r=e("./keys"),i=e("./useragent");t.addListener=function(e,t,n){if(e.addEventListener)return e.addEventListener(t,n,!1);if(e.attachEvent){var r=function(){n.call(e,window.event)};n._wrapper=r,e.attachEvent("on"+t,r)}},t.removeListener=function(e,t,n){if(e.removeEventListener)return e.removeEventListener(t,n,!1);e.detachEvent&&e.detachEvent("on"+t,n._wrapper||n)},t.stopEvent=function(e){return t.stopPropagation(e),t.preventDefault(e),!1},t.stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},t.preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},t.getButton=function(e){return e.type=="dblclick"?0:e.type=="contextmenu"||i.isMac&&e.ctrlKey&&!e.altKey&&!e.shiftKey?2:e.preventDefault?e.button:{1:0,2:2,4:1}[e.button]},t.capture=function(e,n,r){function i(e){n&&n(e),r&&r(e),t.removeListener(document,"mousemove",n,!0),t.removeListener(document,"mouseup",i,!0),t.removeListener(document,"dragstart",i,!0)}return t.addListener(document,"mousemove",n,!0),t.addListener(document,"mouseup",i,!0),t.addListener(document,"dragstart",i,!0),i},t.addMouseWheelListener=function(e,n){"onmousewheel"in e?t.addListener(e,"mousewheel",function(e){var t=8;e.wheelDeltaX!==undefined?(e.wheelX=-e.wheelDeltaX/t,e.wheelY=-e.wheelDeltaY/t):(e.wheelX=0,e.wheelY=-e.wheelDelta/t),n(e)}):"onwheel"in e?t.addListener(e,"wheel",function(e){var t=.35;switch(e.deltaMode){case e.DOM_DELTA_PIXEL:e.wheelX=e.deltaX*t||0,e.wheelY=e.deltaY*t||0;break;case e.DOM_DELTA_LINE:case e.DOM_DELTA_PAGE:e.wheelX=(e.deltaX||0)*5,e.wheelY=(e.deltaY||0)*5}n(e)}):t.addListener(e,"DOMMouseScroll",function(e){e.axis&&e.axis==e.HORIZONTAL_AXIS?(e.wheelX=(e.detail||0)*5,e.wheelY=0):(e.wheelX=0,e.wheelY=(e.detail||0)*5),n(e)})},t.addMultiMouseDownListener=function(e,n,r,s){var o=0,u,a,f,l={2:"dblclick",3:"tripleclick",4:"quadclick"};t.addListener(e,"mousedown",function(e){t.getButton(e)!==0?o=0:e.detail>1?(o++,o>4&&(o=1)):o=1;if(i.isIE){var c=Math.abs(e.clientX-u)>5||Math.abs(e.clientY-a)>5;if(!f||c)o=1;f&&clearTimeout(f),f=setTimeout(function(){f=null},n[o-1]||600),o==1&&(u=e.clientX,a=e.clientY)}e._clicks=o,r[s]("mousedown",e);if(o>4)o=0;else if(o>1)return r[s](l[o],e)}),i.isOldIE&&t.addListener(e,"dblclick",function(e){o=2,f&&clearTimeout(f),f=setTimeout(function(){f=null},n[o-1]||600),r[s]("mousedown",e),r[s](l[o],e)})};var s=!i.isMac||!i.isOpera||"KeyboardEvent"in window?function(e){return 0|(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0)}:function(e){return 0|(e.metaKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.ctrlKey?8:0)};t.getModifierString=function(e){return r.KEY_MODS[s(e)]};var u=null,a=0;t.addCommandKeyListener=function(e,n){var r=t.addListener;if(i.isOldGecko||i.isOpera&&!("KeyboardEvent"in window)){var s=null;r(e,"keydown",function(e){s=e.keyCode}),r(e,"keypress",function(e){return o(n,e,s)})}else{var a=null;r(e,"keydown",function(e){u[e.keyCode]=!0;var t=o(n,e,e.keyCode);return a=e.defaultPrevented,t}),r(e,"keypress",function(e){a&&(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)&&(t.stopEvent(e),a=null)}),r(e,"keyup",function(e){u[e.keyCode]=null}),u||(u=Object.create(null),r(window,"focus",function(e){u=Object.create(null)}))}};if(window.postMessage&&!i.isOldIE){var f=1;t.nextTick=function(e,n){n=n||window;var r="zero-timeout-message-"+f;t.addListener(n,"message",function i(s){s.data==r&&(t.stopPropagation(s),t.removeListener(n,"message",i),e())}),n.postMessage(r,"*")}}t.nextFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame,t.nextFrame?t.nextFrame=t.nextFrame.bind(window):t.nextFrame=function(e){setTimeout(e,17)}}),ace.define("ace/lib/lang",["require","exports","module"],function(e,t,n){"use strict";t.last=function(e){return e[e.length-1]},t.stringReverse=function(e){return e.split("").reverse().join("")},t.stringRepeat=function(e,t){var n="";while(t>0){t&1&&(n+=e);if(t>>=1)e+=e}return n};var r=/^\s\s*/,i=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(r,"")},t.stringTrimRight=function(e){return e.replace(i,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){var t=[];for(var n=0,r=e.length;n1),e.preventDefault()},this.startSelect=function(e,t){e=e||this.editor.renderer.screenToTextCoordinates(this.x,this.y);var n=this.editor;this.mousedownEvent.getShiftKey()?n.selection.selectToPosition(e):t||n.selection.moveToPosition(e),t||this.select(),n.renderer.scroller.setCapture&&n.renderer.scroller.setCapture(),n.setStyle("ace_selecting"),this.setState("select")},this.select=function(){var e,t=this.editor,n=t.renderer.screenToTextCoordinates(this.x,this.y);if(this.$clickSelection){var r=this.$clickSelection.comparePoint(n);if(r==-1)e=this.$clickSelection.end;else if(r==1)e=this.$clickSelection.start;else{var i=f(this.$clickSelection,n);n=i.cursor,e=i.anchor}t.selection.setSelectionAnchor(e.row,e.column)}t.selection.selectToPosition(n),t.renderer.scrollCursorIntoView()},this.extendSelectionBy=function(e){var t,n=this.editor,r=n.renderer.screenToTextCoordinates(this.x,this.y),i=n.selection[e](r.row,r.column);if(this.$clickSelection){var s=this.$clickSelection.comparePoint(i.start),o=this.$clickSelection.comparePoint(i.end);if(s==-1&&o<=0){t=this.$clickSelection.end;if(i.end.row!=r.row||i.end.column!=r.column)r=i.start}else if(o==1&&s>=0){t=this.$clickSelection.start;if(i.start.row!=r.row||i.start.column!=r.column)r=i.end}else if(s==-1&&o==1)r=i.end,t=i.start;else{var u=f(this.$clickSelection,r);r=u.cursor,t=u.anchor}n.selection.setSelectionAnchor(t.row,t.column)}n.selection.selectToPosition(r),n.renderer.scrollCursorIntoView()},this.selectEnd=this.selectAllEnd=this.selectByWordsEnd=this.selectByLinesEnd=function(){this.$clickSelection=null,this.editor.unsetStyle("ace_selecting"),this.editor.renderer.scroller.releaseCapture&&this.editor.renderer.scroller.releaseCapture()},this.focusWait=function(){var e=a(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y),t=Date.now();(e>o||t-this.mousedownEvent.time>this.$focusTimout)&&this.startSelect(this.mousedownEvent.getDocumentPosition())},this.onDoubleClick=function(e){var t=e.getDocumentPosition(),n=this.editor,r=n.session,i=r.getBracketRange(t);i?(i.isEmpty()&&(i.start.column--,i.end.column++),this.setState("select")):(i=n.selection.getWordRange(t.row,t.column),this.setState("selectByWords")),this.$clickSelection=i,this.select()},this.onTripleClick=function(e){var t=e.getDocumentPosition(),n=this.editor;this.setState("selectByLines");var r=n.getSelectionRange();r.isMultiLine()&&r.contains(t.row,t.column)?(this.$clickSelection=n.selection.getLineRange(r.start.row),this.$clickSelection.end=n.selection.getLineRange(r.end.row).end):this.$clickSelection=n.selection.getLineRange(t.row),this.select()},this.onQuadClick=function(e){var t=this.editor;t.selectAll(),this.$clickSelection=t.getSelectionRange(),this.setState("selectAll")},this.onMouseWheel=function(e){if(e.getAccelKey())return;e.getShiftKey()&&e.wheelY&&!e.wheelX&&(e.wheelX=e.wheelY,e.wheelY=0);var t=e.domEvent.timeStamp,n=t-(this.$lastScrollTime||0),r=this.editor,i=r.renderer.isScrollableBy(e.wheelX*e.speed,e.wheelY*e.speed);if(i||n<200)return this.$lastScrollTime=t,r.renderer.scrollBy(e.wheelX*e.speed,e.wheelY*e.speed),e.stop()}}).call(u.prototype),t.DefaultHandlers=u}),ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"],function(e,t,n){"use strict";function s(e){this.isOpen=!1,this.$element=null,this.$parentNode=e}var r=e("./lib/oop"),i=e("./lib/dom");(function(){this.$init=function(){return this.$element=i.createElement("div"),this.$element.className="ace_tooltip",this.$element.style.display="none",this.$parentNode.appendChild(this.$element),this.$element},this.getElement=function(){return this.$element||this.$init()},this.setText=function(e){i.setInnerText(this.getElement(),e)},this.setHtml=function(e){this.getElement().innerHTML=e},this.setPosition=function(e,t){this.getElement().style.left=e+"px",this.getElement().style.top=t+"px"},this.setClassName=function(e){i.addCssClass(this.getElement(),e)},this.show=function(e,t,n){e!=null&&this.setText(e),t!=null&&n!=null&&this.setPosition(t,n),this.isOpen||(this.getElement().style.display="block",this.isOpen=!0)},this.hide=function(){this.isOpen&&(this.getElement().style.display="none",this.isOpen=!1)},this.getHeight=function(){return this.getElement().offsetHeight},this.getWidth=function(){return this.getElement().offsetWidth}}).call(s.prototype),t.Tooltip=s}),ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"],function(e,t,n){"use strict";function u(e){function l(){var r=u.getDocumentPosition().row,s=n.$annotations[r];if(!s)return c();var o=t.session.getLength();if(r==o){var a=t.renderer.pixelToScreenCoordinates(0,u.y).row,l=u.$pos;if(a>t.session.documentToScreenRow(l.row,l.column))return c()}if(f==s)return;f=s.text.join("
"),i.setHtml(f),i.show(),t.on("mousewheel",c);if(e.$tooltipFollowsMouse)h(u);else{var p=n.$cells[t.session.documentToScreenRow(r,0)].element,d=p.getBoundingClientRect(),v=i.getElement().style;v.left=d.right+"px",v.top=d.bottom+"px"}}function c(){o&&(o=clearTimeout(o)),f&&(i.hide(),f=null,t.removeEventListener("mousewheel",c))}function h(e){i.setPosition(e.x,e.y)}var t=e.editor,n=t.renderer.$gutterLayer,i=new a(t.container);e.editor.setDefaultHandler("guttermousedown",function(r){if(!t.isFocused()||r.getButton()!=0)return;var i=n.getRegion(r);if(i=="foldWidgets")return;var s=r.getDocumentPosition().row,o=t.session.selection;if(r.getShiftKey())o.selectTo(s,0);else{if(r.domEvent.detail==2)return t.selectAll(),r.preventDefault();e.$clickSelection=t.selection.getLineRange(s)}return e.setState("selectByLines"),e.captureMouse(r),r.preventDefault()});var o,u,f;e.editor.setDefaultHandler("guttermousemove",function(t){var n=t.domEvent.target||t.domEvent.srcElement;if(r.hasCssClass(n,"ace_fold-widget"))return c();f&&e.$tooltipFollowsMouse&&h(t),u=t;if(o)return;o=setTimeout(function(){o=null,u&&!e.isMousePressed?l():c()},50)}),s.addListener(t.renderer.$gutter,"mouseout",function(e){u=null;if(!f||o)return;o=setTimeout(function(){o=null,c()},50)}),t.on("changeSession",c)}function a(e){o.call(this,e)}var r=e("../lib/dom"),i=e("../lib/oop"),s=e("../lib/event"),o=e("../tooltip").Tooltip;i.inherits(a,o),function(){this.setPosition=function(e,t){var n=window.innerWidth||document.documentElement.clientWidth,r=window.innerHeight||document.documentElement.clientHeight,i=this.getWidth(),s=this.getHeight();e+=15,t+=15,e+i>n&&(e-=e+i-n),t+s>r&&(t-=20+s),o.prototype.setPosition.call(this,e,t)}}.call(a.prototype),t.GutterHandler=u}),ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=t.MouseEvent=function(e,t){this.domEvent=e,this.editor=t,this.x=this.clientX=e.clientX,this.y=this.clientY=e.clientY,this.$pos=null,this.$inSelection=null,this.propagationStopped=!1,this.defaultPrevented=!1};(function(){this.stopPropagation=function(){r.stopPropagation(this.domEvent),this.propagationStopped=!0},this.preventDefault=function(){r.preventDefault(this.domEvent),this.defaultPrevented=!0},this.stop=function(){this.stopPropagation(),this.preventDefault()},this.getDocumentPosition=function(){return this.$pos?this.$pos:(this.$pos=this.editor.renderer.screenToTextCoordinates(this.clientX,this.clientY),this.$pos)},this.inSelection=function(){if(this.$inSelection!==null)return this.$inSelection;var e=this.editor,t=e.getSelectionRange();if(t.isEmpty())this.$inSelection=!1;else{var n=this.getDocumentPosition();this.$inSelection=t.contains(n.row,n.column)}return this.$inSelection},this.getButton=function(){return r.getButton(this.domEvent)},this.getShiftKey=function(){return this.domEvent.shiftKey},this.getAccelKey=i.isMac?function(){return this.domEvent.metaKey}:function(){return this.domEvent.ctrlKey}}).call(s.prototype)}),ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";function f(e){function T(e,n){var r=Date.now(),i=!n||e.row!=n.row,s=!n||e.column!=n.column;if(!S||i||s)t.$blockScrolling+=1,t.moveCursorToPosition(e),t.$blockScrolling-=1,S=r,x={x:p,y:d};else{var o=l(x.x,x.y,p,d);o>a?S=null:r-S>=u&&(t.renderer.scrollCursorIntoView(),S=null)}}function N(e,n){var r=Date.now(),i=t.renderer.layerConfig.lineHeight,s=t.renderer.layerConfig.characterWidth,u=t.renderer.scroller.getBoundingClientRect(),a={x:{left:p-u.left,right:u.right-p},y:{top:d-u.top,bottom:u.bottom-d}},f=Math.min(a.x.left,a.x.right),l=Math.min(a.y.top,a.y.bottom),c={row:e.row,column:e.column};f/s<=2&&(c.column+=a.x.left=o&&t.renderer.scrollCursorIntoView(c):E=r:E=null}function C(){var e=g;g=t.renderer.screenToTextCoordinates(p,d),T(g,e),N(g,e)}function k(){m=t.selection.toOrientedRange(),h=t.session.addMarker(m,"ace_selection",t.getSelectionStyle()),t.clearSelection(),t.isFocused()&&t.renderer.$cursorLayer.setBlinking(!1),clearInterval(v),C(),v=setInterval(C,20),y=0,i.addListener(document,"mousemove",O)}function L(){clearInterval(v),t.session.removeMarker(h),h=null,t.$blockScrolling+=1,t.selection.fromOrientedRange(m),t.$blockScrolling-=1,t.isFocused()&&!w&&t.renderer.$cursorLayer.setBlinking(!t.getReadOnly()),m=null,g=null,y=0,E=null,S=null,i.removeListener(document,"mousemove",O)}function O(){A==null&&(A=setTimeout(function(){A!=null&&h&&L()},20))}function M(e){var t=e.types;return!t||Array.prototype.some.call(t,function(e){return e=="text/plain"||e=="Text"})}function _(e){var t=["copy","copymove","all","uninitialized"],n=["move","copymove","linkmove","all","uninitialized"],r=s.isMac?e.altKey:e.ctrlKey,i="uninitialized";try{i=e.dataTransfer.effectAllowed.toLowerCase()}catch(e){}var o="none";return r&&t.indexOf(i)>=0?o="copy":n.indexOf(i)>=0?o="move":t.indexOf(i)>=0&&(o="copy"),o}var t=e.editor,n=r.createElement("img");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",s.isOpera&&(n.style.cssText="width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;");var f=["dragWait","dragWaitEnd","startDrag","dragReadyEnd","onMouseDrag"];f.forEach(function(t){e[t]=this[t]},this),t.addEventListener("mousedown",this.onMouseDown.bind(e));var c=t.container,h,p,d,v,m,g,y=0,b,w,E,S,x;this.onDragStart=function(e){if(this.cancelDrag||!c.draggable){var r=this;return setTimeout(function(){r.startSelect(),r.captureMouse(e)},0),e.preventDefault()}m=t.getSelectionRange();var i=e.dataTransfer;i.effectAllowed=t.getReadOnly()?"copy":"copyMove",s.isOpera&&(t.container.appendChild(n),n.scrollTop=0),i.setDragImage&&i.setDragImage(n,0,0),s.isOpera&&t.container.removeChild(n),i.clearData(),i.setData("Text",t.session.getTextRange()),w=!0,this.setState("drag")},this.onDragEnd=function(e){c.draggable=!1,w=!1,this.setState(null);if(!t.getReadOnly()){var n=e.dataTransfer.dropEffect;!b&&n=="move"&&t.session.remove(t.getSelectionRange()),t.renderer.$cursorLayer.setBlinking(!0)}this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle("")},this.onDragEnter=function(e){if(t.getReadOnly()||!M(e.dataTransfer))return;return p=e.clientX,d=e.clientY,h||k(),y++,e.dataTransfer.dropEffect=b=_(e),i.preventDefault(e)},this.onDragOver=function(e){if(t.getReadOnly()||!M(e.dataTransfer))return;return p=e.clientX,d=e.clientY,h||(k(),y++),A!==null&&(A=null),e.dataTransfer.dropEffect=b=_(e),i.preventDefault(e)},this.onDragLeave=function(e){y--;if(y<=0&&h)return L(),b=null,i.preventDefault(e)},this.onDrop=function(e){if(!g)return;var n=e.dataTransfer;if(w)switch(b){case"move":m.contains(g.row,g.column)?m={start:g,end:g}:m=t.moveText(m,g);break;case"copy":m=t.moveText(m,g,!0)}else{var r=n.getData("Text");m={start:g,end:t.session.insert(g,r)},t.focus(),b=null}return L(),i.preventDefault(e)},i.addListener(c,"dragstart",this.onDragStart.bind(e)),i.addListener(c,"dragend",this.onDragEnd.bind(e)),i.addListener(c,"dragenter",this.onDragEnter.bind(e)),i.addListener(c,"dragover",this.onDragOver.bind(e)),i.addListener(c,"dragleave",this.onDragLeave.bind(e)),i.addListener(c,"drop",this.onDrop.bind(e));var A=null}function l(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))}var r=e("../lib/dom"),i=e("../lib/event"),s=e("../lib/useragent"),o=200,u=200,a=5;(function(){this.dragWait=function(){var e=Date.now()-this.mousedownEvent.time;e>this.editor.getDragDelay()&&this.startDrag()},this.dragWaitEnd=function(){var e=this.editor.container;e.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()),this.selectEnd()},this.dragReadyEnd=function(e){this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly()),this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle(""),this.dragWaitEnd()},this.startDrag=function(){this.cancelDrag=!1;var e=this.editor,t=e.container;t.draggable=!0,e.renderer.$cursorLayer.setBlinking(!1),e.setStyle("ace_dragging");var n=s.isWin?"default":"move";e.renderer.setCursorStyle(n),this.setState("dragReady")},this.onMouseDrag=function(e){var t=this.editor.container;if(s.isIE&&this.state=="dragReady"){var n=l(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);n>3&&t.dragDrop()}if(this.state==="dragWait"){var n=l(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);n>0&&(t.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()))}},this.onMouseDown=function(e){if(!this.$dragEnabled)return;this.mousedownEvent=e;var t=this.editor,n=e.inSelection(),r=e.getButton(),i=e.domEvent.detail||1;if(i===1&&r===0&&n){if(e.editor.inMultiSelectMode&&(e.getAccelKey()||e.getShiftKey()))return;this.mousedownEvent.time=Date.now();var o=e.domEvent.target||e.domEvent.srcElement;"unselectable"in o&&(o.unselectable="on");if(t.getDragDelay()){if(s.isWebKit){this.cancelDrag=!0;var u=t.container;u.draggable=!0}this.setState("dragWait")}else this.startDrag();this.captureMouse(e,this.onMouseDrag.bind(this)),e.defaultPrevented=!0}}}).call(f.prototype),t.DragdropHandler=f}),ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("./dom");t.get=function(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.onreadystatechange=function(){n.readyState===4&&t(n.responseText)},n.send(null)},t.loadScript=function(e,t){var n=r.getDocumentHead(),i=document.createElement("script");i.src=e,n.appendChild(i),i.onload=i.onreadystatechange=function(e,n){if(n||!i.readyState||i.readyState=="loaded"||i.readyState=="complete")i=i.onload=i.onreadystatechange=null,n||t()}},t.qualifyURL=function(e){var t=document.createElement("a");return t.href=e,t.href}}),ace.define("ace/lib/event_emitter",["require","exports","module"],function(e,t,n){"use strict";var r={},i=function(){this.propagationStopped=!0},s=function(){this.defaultPrevented=!0};r._emit=r._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],r=this._defaultHandlers[e];if(!n.length&&!r)return;if(typeof t!="object"||!t)t={};t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=i),t.preventDefault||(t.preventDefault=s),n=n.slice();for(var o=0;o1&&(i=n[n.length-2]);var o=a[t+"Path"];return o==null?o=a.basePath:r=="/"&&(t=r=""),o&&o.slice(-1)!="/"&&(o+="/"),o+t+r+i+this.get("suffix")},t.setModuleUrl=function(e,t){return a.$moduleUrls[e]=t},t.$loading={},t.loadModule=function(n,r){var i,o;Array.isArray(n)&&(o=n[0],n=n[1]);try{i=e(n)}catch(u){}if(i&&!t.$loading[n])return r&&r(i);t.$loading[n]||(t.$loading[n]=[]),t.$loading[n].push(r);if(t.$loading[n].length>1)return;var a=function(){e([n],function(e){t._emit("load.module",{name:n,module:e});var r=t.$loading[n];t.$loading[n]=null,r.forEach(function(t){t&&t(e)})})};if(!t.get("packaged"))return a();s.loadScript(t.moduleUrl(n,o),a)},t.init=f;var c={setOptions:function(e){Object.keys(e).forEach(function(t){this.setOption(t,e[t])},this)},getOptions:function(e){var t={};return e?Array.isArray(e)||(t=e,e=Object.keys(t)):e=Object.keys(this.$options),e.forEach(function(e){t[e]=this.getOption(e)},this),t},setOption:function(e,t){if(this["$"+e]===t)return;var n=this.$options[e];if(!n)return typeof console!="undefined"&&console.warn&&console.warn('misspelled option "'+e+'"'),undefined;if(n.forwardTo)return this[n.forwardTo]&&this[n.forwardTo].setOption(e,t);n.handlesSet||(this["$"+e]=t),n&&n.set&&n.set.call(this,t)},getOption:function(e){var t=this.$options[e];return t?t.forwardTo?this[t.forwardTo]&&this[t.forwardTo].getOption(e):t&&t.get?t.get.call(this):this["$"+e]:(typeof console!="undefined"&&console.warn&&console.warn('misspelled option "'+e+'"'),undefined)}},h={};t.defineOptions=function(e,t,n){return e.$options||(h[t]=e.$options={}),Object.keys(n).forEach(function(t){var r=n[t];typeof r=="string"&&(r={forwardTo:r}),r.name||(r.name=t),e.$options[r.name]=r,"initialValue"in r&&(e["$"+r.name]=r.initialValue)}),i.implement(e,c),this},t.resetOptions=function(e){Object.keys(e.$options).forEach(function(t){var n=e.$options[t];"value"in n&&e.setOption(t,n.value)})},t.setDefaultValue=function(e,n,r){var i=h[e]||(h[e]={});i[n]&&(i.forwardTo?t.setDefaultValue(i.forwardTo,n,r):i[n].value=r)},t.setDefaultValues=function(e,n){Object.keys(n).forEach(function(r){t.setDefaultValue(e,r,n[r])})}}),ace.define("ace/mouse/mouse_handler",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/mouse/default_handlers","ace/mouse/default_gutter_handler","ace/mouse/mouse_event","ace/mouse/dragdrop_handler","ace/config"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=e("./default_handlers").DefaultHandlers,o=e("./default_gutter_handler").GutterHandler,u=e("./mouse_event").MouseEvent,a=e("./dragdrop_handler").DragdropHandler,f=e("../config"),l=function(e){var t=this;this.editor=e,new s(this),new o(this),new a(this);var n=function(t){!e.isFocused()&&e.textInput&&e.textInput.moveToMouse(t),e.focus()},u=e.renderer.getMouseEventTarget();r.addListener(u,"click",this.onMouseEvent.bind(this,"click")),r.addListener(u,"mousemove",this.onMouseMove.bind(this,"mousemove")),r.addMultiMouseDownListener(u,[400,300,250],this,"onMouseEvent"),e.renderer.scrollBarV&&(r.addMultiMouseDownListener(e.renderer.scrollBarV.inner,[400,300,250],this,"onMouseEvent"),r.addMultiMouseDownListener(e.renderer.scrollBarH.inner,[400,300,250],this,"onMouseEvent"),i.isIE&&(r.addListener(e.renderer.scrollBarV.element,"mousedown",n),r.addListener(e.renderer.scrollBarH.element,"mousemove",n))),r.addMouseWheelListener(e.container,this.onMouseWheel.bind(this,"mousewheel"));var f=e.renderer.$gutter;r.addListener(f,"mousedown",this.onMouseEvent.bind(this,"guttermousedown")),r.addListener(f,"click",this.onMouseEvent.bind(this,"gutterclick")),r.addListener(f,"dblclick",this.onMouseEvent.bind(this,"gutterdblclick")),r.addListener(f,"mousemove",this.onMouseEvent.bind(this,"guttermousemove")),r.addListener(u,"mousedown",n),r.addListener(f,"mousedown",function(t){return e.focus(),r.preventDefault(t)}),e.on("mousemove",function(n){if(t.state||t.$dragDelay||!t.$dragEnabled)return;var r=e.renderer.screenToTextCoordinates(n.x,n.y),i=e.session.selection.getRange(),s=e.renderer;!i.isEmpty()&&i.insideStart(r.row,r.column)?s.setCursorStyle("default"):s.setCursorStyle("")})};(function(){this.onMouseEvent=function(e,t){this.editor._emit(e,new u(t,this.editor))},this.onMouseMove=function(e,t){var n=this.editor._eventRegistry&&this.editor._eventRegistry.mousemove;if(!n||!n.length)return;this.editor._emit(e,new u(t,this.editor))},this.onMouseWheel=function(e,t){var n=new u(t,this.editor);n.speed=this.$scrollSpeed*2,n.wheelX=t.wheelX,n.wheelY=t.wheelY,this.editor._emit(e,n)},this.setState=function(e){this.state=e},this.captureMouse=function(e,t){this.x=e.x,this.y=e.y,this.isMousePressed=!0;var n=this.editor.renderer;n.$keepTextAreaAtCursor&&(n.$keepTextAreaAtCursor=null);var s=this,o=function(e){if(!e)return;if(i.isWebKit&&!e.which&&s.releaseMouse)return s.releaseMouse();s.x=e.clientX,s.y=e.clientY,t&&t(e),s.mouseEvent=new u(e,s.editor),s.$mouseMoved=!0},a=function(e){clearInterval(l),f(),s[s.state+"End"]&&s[s.state+"End"](e),s.state="",n.$keepTextAreaAtCursor==null&&(n.$keepTextAreaAtCursor=!0,n.$moveTextAreaToCursor()),s.isMousePressed=!1,s.$onCaptureMouseMove=s.releaseMouse=null,e&&s.onMouseEvent("mouseup",e)},f=function(){s[s.state]&&s[s.state](),s.$mouseMoved=!1};if(i.isOldIE&&e.domEvent.type=="dblclick")return setTimeout(function(){a(e)});s.$onCaptureMouseMove=o,s.releaseMouse=r.capture(this.editor.container,o,a);var l=setInterval(f,20)},this.releaseMouse=null,this.cancelContextMenu=function(){var e=function(t){if(t&&t.domEvent&&t.domEvent.type!="contextmenu")return;this.editor.off("nativecontextmenu",e),t&&t.domEvent&&r.stopEvent(t.domEvent)}.bind(this);setTimeout(e,10),this.editor.on("nativecontextmenu",e)}}).call(l.prototype),f.defineOptions(l.prototype,"mouseHandler",{scrollSpeed:{initialValue:2},dragDelay:{initialValue:i.isMac?150:0},dragEnabled:{initialValue:!0},focusTimout:{initialValue:0},tooltipFollowsMouse:{initialValue:!0}}),t.MouseHandler=l}),ace.define("ace/mouse/fold_handler",["require","exports","module"],function(e,t,n){"use strict";function r(e){e.on("click",function(t){var n=t.getDocumentPosition(),r=e.session,i=r.getFoldAt(n.row,n.column,1);i&&(t.getAccelKey()?r.removeFold(i):r.expandFold(i),t.stop())}),e.on("gutterclick",function(t){var n=e.renderer.$gutterLayer.getRegion(t);if(n=="foldWidgets"){var r=t.getDocumentPosition().row,i=e.session;i.foldWidgets&&i.foldWidgets[r]&&e.session.onFoldWidgetClick(r,t),e.isFocused()||e.focus(),t.stop()}}),e.on("gutterdblclick",function(t){var n=e.renderer.$gutterLayer.getRegion(t);if(n=="foldWidgets"){var r=t.getDocumentPosition().row,i=e.session,s=i.getParentFoldRangeData(r,!0),o=s.range||s.firstRange;if(o){r=o.start.row;var u=i.getFoldAt(r,i.getLine(r).length,1);u?i.removeFold(u):(i.addFold("...",o),e.renderer.scrollCursorIntoView({row:o.start.row,column:0}))}t.stop()}})}t.FoldHandler=r}),ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"],function(e,t,n){"use strict";var r=e("../lib/keys"),i=e("../lib/event"),s=function(e){this.$editor=e,this.$data={editor:e},this.$handlers=[],this.setDefaultHandler(e.commands)};(function(){this.setDefaultHandler=function(e){this.removeKeyboardHandler(this.$defaultHandler),this.$defaultHandler=e,this.addKeyboardHandler(e,0)},this.setKeyboardHandler=function(e){var t=this.$handlers;if(t[t.length-1]==e)return;while(t[t.length-1]&&t[t.length-1]!=this.$defaultHandler)this.removeKeyboardHandler(t[t.length-1]);this.addKeyboardHandler(e,1)},this.addKeyboardHandler=function(e,t){if(!e)return;typeof e=="function"&&!e.handleKeyboard&&(e.handleKeyboard=e);var n=this.$handlers.indexOf(e);n!=-1&&this.$handlers.splice(n,1),t==undefined?this.$handlers.push(e):this.$handlers.splice(t,0,e),n==-1&&e.attach&&e.attach(this.$editor)},this.removeKeyboardHandler=function(e){var t=this.$handlers.indexOf(e);return t==-1?!1:(this.$handlers.splice(t,1),e.detach&&e.detach(this.$editor),!0)},this.getKeyboardHandler=function(){return this.$handlers[this.$handlers.length-1]},this.getStatusText=function(){var e=this.$data,t=e.editor;return this.$handlers.map(function(n){return n.getStatusText&&n.getStatusText(t,e)||""}).filter(Boolean).join(" ")},this.$callKeyboardHandlers=function(e,t,n,r){var s,o=!1,u=this.$editor.commands;for(var a=this.$handlers.length;a--;){s=this.$handlers[a].handleKeyboard(this.$data,e,t,n,r);if(!s||!s.command)continue;s.command=="null"?o=!0:o=u.exec(s.command,this.$editor,s.args,r),o&&r&&e!=-1&&s.passEvent!=1&&s.command.passEvent!=1&&i.stopEvent(r);if(o)break}return o},this.onCommandKey=function(e,t,n){var i=r.keyCodeToString(n);this.$callKeyboardHandlers(t,i,n,e)},this.onTextInput=function(e){var t=this.$callKeyboardHandlers(-1,e);t||this.$editor.commands.exec("insertstring",this.$editor,e)}}).call(s.prototype),t.KeyBinding=s}),ace.define("ace/range",["require","exports","module"],function(e,t,n){"use strict";var r=function(e,t){return e.row-t.row||e.column-t.column},i=function(e,t,n,r){this.start={row:e,column:t},this.end={row:n,column:r}};(function(){this.isEqual=function(e){return this.start.row===e.start.row&&this.end.row===e.end.row&&this.start.column===e.start.column&&this.end.column===e.end.column},this.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(e,t){return this.compare(e,t)==0},this.compareRange=function(e){var t,n=e.end,r=e.start;return t=this.compare(n.row,n.column),t==1?(t=this.compare(r.row,r.column),t==1?2:t==0?1:0):t==-1?-2:(t=this.compare(r.row,r.column),t==-1?-1:t==1?42:0)},this.comparePoint=function(e){return this.compare(e.row,e.column)},this.containsRange=function(e){return this.comparePoint(e.start)==0&&this.comparePoint(e.end)==0},this.intersects=function(e){var t=this.compareRange(e);return t==-1||t==0||t==1},this.isEnd=function(e,t){return this.end.row==e&&this.end.column==t},this.isStart=function(e,t){return this.start.row==e&&this.start.column==t},this.setStart=function(e,t){typeof e=="object"?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},this.setEnd=function(e,t){typeof e=="object"?(this.end.column=e.column,this.end.row=e.row):(this.end.row=e,this.end.column=t)},this.inside=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)||this.isStart(e,t)?!1:!0:!1},this.insideStart=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)?!1:!0:!1},this.insideEnd=function(e,t){return this.compare(e,t)==0?this.isStart(e,t)?!1:!0:!1},this.compare=function(e,t){return!this.isMultiLine()&&e===this.start.row?tthis.end.column?1:0:ethis.end.row?1:this.start.row===e?t>=this.start.column?0:-1:this.end.row===e?t<=this.end.column?0:1:0},this.compareStart=function(e,t){return this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.compareEnd=function(e,t){return this.end.row==e&&this.end.column==t?1:this.compare(e,t)},this.compareInside=function(e,t){return this.end.row==e&&this.end.column==t?1:this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.clipRows=function(e,t){if(this.end.row>t)var n={row:t+1,column:0};else if(this.end.rowt)var r={row:t+1,column:0};else if(this.start.rowt.row||e.row==t.row&&e.column>t.column},this.getRange=function(){var e=this.anchor,t=this.lead;return this.isEmpty()?o.fromPoints(t,t):this.isBackwards()?o.fromPoints(t,e):o.fromPoints(e,t)},this.clearSelection=function(){this.$isEmpty||(this.$isEmpty=!0,this._emit("changeSelection"))},this.selectAll=function(){var e=this.doc.getLength()-1;this.setSelectionAnchor(0,0),this.moveCursorTo(e,this.doc.getLine(e).length)},this.setRange=this.setSelectionRange=function(e,t){t?(this.setSelectionAnchor(e.end.row,e.end.column),this.selectTo(e.start.row,e.start.column)):(this.setSelectionAnchor(e.start.row,e.start.column),this.selectTo(e.end.row,e.end.column)),this.getRange().isEmpty()&&(this.$isEmpty=!0),this.$desiredColumn=null},this.$moveSelection=function(e){var t=this.lead;this.$isEmpty&&this.setSelectionAnchor(t.row,t.column),e.call(this)},this.selectTo=function(e,t){this.$moveSelection(function(){this.moveCursorTo(e,t)})},this.selectToPosition=function(e){this.$moveSelection(function(){this.moveCursorToPosition(e)})},this.moveTo=function(e,t){this.clearSelection(),this.moveCursorTo(e,t)},this.moveToPosition=function(e){this.clearSelection(),this.moveCursorToPosition(e)},this.selectUp=function(){this.$moveSelection(this.moveCursorUp)},this.selectDown=function(){this.$moveSelection(this.moveCursorDown)},this.selectRight=function(){this.$moveSelection(this.moveCursorRight)},this.selectLeft=function(){this.$moveSelection(this.moveCursorLeft)},this.selectLineStart=function(){this.$moveSelection(this.moveCursorLineStart)},this.selectLineEnd=function(){this.$moveSelection(this.moveCursorLineEnd)},this.selectFileEnd=function(){this.$moveSelection(this.moveCursorFileEnd)},this.selectFileStart=function(){this.$moveSelection(this.moveCursorFileStart)},this.selectWordRight=function(){this.$moveSelection(this.moveCursorWordRight)},this.selectWordLeft=function(){this.$moveSelection(this.moveCursorWordLeft)},this.getWordRange=function(e,t){if(typeof t=="undefined"){var n=e||this.lead;e=n.row,t=n.column}return this.session.getWordRange(e,t)},this.selectWord=function(){this.setSelectionRange(this.getWordRange())},this.selectAWord=function(){var e=this.getCursor(),t=this.session.getAWordRange(e.row,e.column);this.setSelectionRange(t)},this.getLineRange=function(e,t){var n=typeof e=="number"?e:this.lead.row,r,i=this.session.getFoldLine(n);return i?(n=i.start.row,r=i.end.row):r=n,t===!0?new o(n,0,r,this.session.getLine(r).length):new o(n,0,r+1,0)},this.selectLine=function(){this.setSelectionRange(this.getLineRange())},this.moveCursorUp=function(){this.moveCursorBy(-1,0)},this.moveCursorDown=function(){this.moveCursorBy(1,0)},this.moveCursorLeft=function(){var e=this.lead.getPosition(),t;if(t=this.session.getFoldAt(e.row,e.column,-1))this.moveCursorTo(t.start.row,t.start.column);else if(e.column===0)e.row>0&&this.moveCursorTo(e.row-1,this.doc.getLine(e.row-1).length);else{var n=this.session.getTabSize();this.session.isTabStop(e)&&this.doc.getLine(e.row).slice(e.column-n,e.column).split(" ").length-1==n?this.moveCursorBy(0,-n):this.moveCursorBy(0,-1)}},this.moveCursorRight=function(){var e=this.lead.getPosition(),t;if(t=this.session.getFoldAt(e.row,e.column,1))this.moveCursorTo(t.end.row,t.end.column);else if(this.lead.column==this.doc.getLine(this.lead.row).length)this.lead.row0&&(t.column=r)}}this.moveCursorTo(t.row,t.column)},this.moveCursorFileEnd=function(){var e=this.doc.getLength()-1,t=this.doc.getLine(e).length;this.moveCursorTo(e,t)},this.moveCursorFileStart=function(){this.moveCursorTo(0,0)},this.moveCursorLongWordRight=function(){var e=this.lead.row,t=this.lead.column,n=this.doc.getLine(e),r=n.substring(t),i;this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;var s=this.session.getFoldAt(e,t,1);if(s){this.moveCursorTo(s.end.row,s.end.column);return}if(i=this.session.nonTokenRe.exec(r))t+=this.session.nonTokenRe.lastIndex,this.session.nonTokenRe.lastIndex=0,r=n.substring(t);if(t>=n.length){this.moveCursorTo(e,n.length),this.moveCursorRight(),e0&&this.moveCursorWordLeft();return}if(o=this.session.tokenRe.exec(s))t-=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0;this.moveCursorTo(e,t)},this.$shortWordEndIndex=function(e){var t,n=0,r,i=/\s/,s=this.session.tokenRe;s.lastIndex=0;if(t=this.session.tokenRe.exec(e))n=this.session.tokenRe.lastIndex;else{while((r=e[n])&&i.test(r))n++;if(n<1){s.lastIndex=0;while((r=e[n])&&!s.test(r)){s.lastIndex=0,n++;if(i.test(r)){if(n>2){n--;break}while((r=e[n])&&i.test(r))n++;if(n>2)break}}}}return s.lastIndex=0,n},this.moveCursorShortWordRight=function(){var e=this.lead.row,t=this.lead.column,n=this.doc.getLine(e),r=n.substring(t),i=this.session.getFoldAt(e,t,1);if(i)return this.moveCursorTo(i.end.row,i.end.column);if(t==n.length){var s=this.doc.getLength();do e++,r=this.doc.getLine(e);while(e0&&/^\s*$/.test(r));t=r.length,/\s+$/.test(r)||(r="")}var s=i.stringReverse(r),o=this.$shortWordEndIndex(s);return this.moveCursorTo(e,t-o)},this.moveCursorWordRight=function(){this.session.$selectLongWords?this.moveCursorLongWordRight():this.moveCursorShortWordRight()},this.moveCursorWordLeft=function(){this.session.$selectLongWords?this.moveCursorLongWordLeft():this.moveCursorShortWordLeft()},this.moveCursorBy=function(e,t){var n=this.session.documentToScreenPosition(this.lead.row,this.lead.column);t===0&&(this.$desiredColumn?n.column=this.$desiredColumn:this.$desiredColumn=n.column);var r=this.session.screenToDocumentPosition(n.row+e,n.column);e!==0&&t===0&&r.row===this.lead.row&&r.column===this.lead.column&&this.session.lineWidgets&&this.session.lineWidgets[r.row]&&r.row++,this.moveCursorTo(r.row,r.column+t,t===0)},this.moveCursorToPosition=function(e){this.moveCursorTo(e.row,e.column)},this.moveCursorTo=function(e,t,n){var r=this.session.getFoldAt(e,t,1);r&&(e=r.start.row,t=r.start.column),this.$keepDesiredColumnOnChange=!0,this.lead.setPosition(e,t),this.$keepDesiredColumnOnChange=!1,n||(this.$desiredColumn=null)},this.moveCursorToScreen=function(e,t,n){var r=this.session.screenToDocumentPosition(e,t);this.moveCursorTo(r.row,r.column,n)},this.detach=function(){this.lead.detach(),this.anchor.detach(),this.session=this.doc=null},this.fromOrientedRange=function(e){this.setSelectionRange(e,e.cursor==e.start),this.$desiredColumn=e.desiredColumn||this.$desiredColumn},this.toOrientedRange=function(e){var t=this.getRange();return e?(e.start.column=t.start.column,e.start.row=t.start.row,e.end.column=t.end.column,e.end.row=t.end.row):e=t,e.cursor=this.isBackwards()?e.start:e.end,e.desiredColumn=this.$desiredColumn,e},this.getRangeOfMovements=function(e){var t=this.getCursor();try{e.call(null,this);var n=this.getCursor();return o.fromPoints(t,n)}catch(r){return o.fromPoints(t,t)}finally{this.moveCursorToPosition(t)}},this.toJSON=function(){if(this.rangeCount)var e=this.ranges.map(function(e){var t=e.clone();return t.isBackwards=e.cursor==e.start,t});else{var e=this.getRange();e.isBackwards=this.isBackwards()}return e},this.fromJSON=function(e){if(e.start==undefined){if(this.rangeList){this.toSingleRange(e[0]);for(var t=e.length;t--;){var n=o.fromPoints(e[t].start,e[t].end);e.isBackwards&&(n.cursor=n.start),this.addRange(n,!0)}return}e=e[0]}this.rangeList&&this.toSingleRange(e),this.setSelectionRange(e,e.isBackwards)},this.isEqual=function(e){if((e.length||this.rangeCount)&&e.length!=this.rangeCount)return!1;if(!e.length||!this.ranges)return this.getRange().isEqual(e);for(var t=this.ranges.length;t--;)if(!this.ranges[t].isEqual(e[t]))return!1;return!0}}).call(u.prototype),t.Selection=u}),ace.define("ace/tokenizer",["require","exports","module"],function(e,t,n){"use strict";var r=2e3,i=function(e){this.states=e,this.regExps={},this.matchMappings={};for(var t in this.states){var n=this.states[t],r=[],i=0,s=this.matchMappings[t]={defaultToken:"text"},o="g",u=[];for(var a=0;a1?f.onMatch=this.$applyToken:f.onMatch=f.token),c>1&&(/\\\d/.test(f.regex)?l=f.regex.replace(/\\([0-9]+)/g,function(e,t){return"\\"+(parseInt(t,10)+i+1)}):(c=1,l=this.removeCapturingGroups(f.regex)),!f.splitRegex&&typeof f.token!="string"&&u.push(f)),s[i]=a,i+=c,r.push(l),f.onMatch||(f.onMatch=null)}r.length||(s[0]=0,r.push("$")),u.forEach(function(e){e.splitRegex=this.createSplitterRegexp(e.regex,o)},this),this.regExps[t]=new RegExp("("+r.join(")|(")+")|($)",o)}};(function(){this.$setMaxTokenCount=function(e){r=e|0},this.$applyToken=function(e){var t=this.splitRegex.exec(e).slice(1),n=this.token.apply(this,t);if(typeof n=="string")return[{type:n,value:e}];var r=[];for(var i=0,s=n.length;il){var g=e.substring(l,m-v.length);h.type==p?h.value+=g:(h.type&&f.push(h),h={type:p,value:g})}for(var y=0;yr){c>2*e.length&&this.reportError("infinite loop with in ace tokenizer",{startState:t,line:e});while(l1&&n[0]!==i&&n.unshift("#tmp",i),{tokens:f,state:n.length?n:i}},this.reportError=function(e,t){var n=new Error(e);n.data=t,typeof console=="object"&&console.error&&console.error(n),setTimeout(function(){throw n})}}).call(i.prototype),t.Tokenizer=i}),ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../lib/lang"),i=function(){this.$rules={start:[{token:"empty_line",regex:"^$"},{defaultToken:"text"}]}};(function(){this.addRules=function(e,t){if(!t){for(var n in e)this.$rules[n]=e[n];return}for(var n in e){var r=e[n];for(var i=0;i=this.$rowTokens.length){this.$row+=1,e||(e=this.$session.getLength());if(this.$row>=e)return this.$row=e-1,null;this.$rowTokens=this.$session.getTokens(this.$row),this.$tokenIndex=0}return this.$rowTokens[this.$tokenIndex]},this.getCurrentToken=function(){return this.$rowTokens[this.$tokenIndex]},this.getCurrentTokenRow=function(){return this.$row},this.getCurrentTokenColumn=function(){var e=this.$rowTokens,t=this.$tokenIndex,n=e[t].start;if(n!==undefined)return n;n=0;while(t>0)t-=1,n+=e[t].value.length;return n}}).call(r.prototype),t.TokenIterator=r}),ace.define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"],function(e,t,n){"use strict";var r=e("../tokenizer").Tokenizer,i=e("./text_highlight_rules").TextHighlightRules,s=e("./behaviour").Behaviour,o=e("../unicode"),u=e("../lib/lang"),a=e("../token_iterator").TokenIterator,f=e("../range").Range,l=function(){this.HighlightRules=i,this.$behaviour=new s};(function(){this.tokenRe=new RegExp("^["+o.packages.L+o.packages.Mn+o.packages.Mc+o.packages.Nd+o.packages.Pc+"\\$_]+","g"),this.nonTokenRe=new RegExp("^(?:[^"+o.packages.L+o.packages.Mn+o.packages.Mc+o.packages.Nd+o.packages.Pc+"\\$_]|\\s])+","g"),this.getTokenizer=function(){return this.$tokenizer||(this.$highlightRules=this.$highlightRules||new this.HighlightRules,this.$tokenizer=new r(this.$highlightRules.getRules())),this.$tokenizer},this.lineCommentStart="",this.blockComment="",this.toggleCommentLines=function(e,t,n,r){function w(e){for(var t=n;t<=r;t++)e(i.getLine(t),t)}var i=t.doc,s=!0,o=!0,a=Infinity,f=t.getTabSize(),l=!1;if(!this.lineCommentStart){if(!this.blockComment)return!1;var c=this.blockComment.start,h=this.blockComment.end,p=new RegExp("^(\\s*)(?:"+u.escapeRegExp(c)+")"),d=new RegExp("(?:"+u.escapeRegExp(h)+")\\s*$"),v=function(e,t){if(g(e,t))return;if(!s||/\S/.test(e))i.insertInLine({row:t,column:e.length},h),i.insertInLine({row:t,column:a},c)},m=function(e,t){var n;(n=e.match(d))&&i.removeInLine(t,e.length-n[0].length,e.length),(n=e.match(p))&&i.removeInLine(t,n[1].length,n[0].length)},g=function(e,n){if(p.test(e))return!0;var r=t.getTokens(n);for(var i=0;i2?r%f!=f-1:r%f==0}}var E=Infinity;w(function(e,t){var n=e.search(/\S/);n!==-1?(ne.length&&(E=e.length)}),a==Infinity&&(a=E,s=!1,o=!1),l&&a%f!=0&&(a=Math.floor(a/f)*f),w(o?m:v)},this.toggleBlockComment=function(e,t,n,r){var i=this.blockComment;if(!i)return;!i.start&&i[0]&&(i=i[0]);var s=new a(t,r.row,r.column),o=s.getCurrentToken(),u=t.selection,l=t.selection.toOrientedRange(),c,h;if(o&&/comment/.test(o.type)){var p,d;while(o&&/comment/.test(o.type)){var v=o.value.indexOf(i.start);if(v!=-1){var m=s.getCurrentTokenRow(),g=s.getCurrentTokenColumn()+v;p=new f(m,g,m,g+i.start.length);break}o=s.stepBackward()}var s=new a(t,r.row,r.column),o=s.getCurrentToken();while(o&&/comment/.test(o.type)){var v=o.value.indexOf(i.end);if(v!=-1){var m=s.getCurrentTokenRow(),g=s.getCurrentTokenColumn()+v;d=new f(m,g,m,g+i.end.length);break}o=s.stepForward()}d&&t.remove(d),p&&(t.remove(p),c=p.start.row,h=-i.start.length)}else h=i.start.length,c=n.start.row,t.insert(n.end,i.end),t.insert(n.start,i.start);l.start.row==c&&(l.start.column+=h),l.end.row==c&&(l.end.column+=h),t.selection.fromOrientedRange(l)},this.getNextLineIndent=function(e,t,n){return this.$getIndent(t)},this.checkOutdent=function(e,t,n){return!1},this.autoOutdent=function(e,t,n){},this.$getIndent=function(e){return e.match(/^\s*/)[0]},this.createWorker=function(e){return null},this.createModeDelegates=function(e){this.$embeds=[],this.$modes={};for(var t in e)e[t]&&(this.$embeds.push(t),this.$modes[t]=new e[t]);var n=["toggleBlockComment","toggleCommentLines","getNextLineIndent","checkOutdent","autoOutdent","transformAction","getCompletions"];for(var t=0;tthis.row)return;if(n.start.row==this.row&&n.start.column>this.column)return;var r=this.row,i=this.column,s=n.start,o=n.end;if(t.action==="insertText")if(s.row===r&&s.column<=i){if(s.column!==i||!this.$insertRight)s.row===o.row?i+=o.column-s.column:(i-=s.column,r+=o.row-s.row)}else s.row!==o.row&&s.row=i?i=s.column:i=Math.max(0,i-(o.column-s.column)):s.row!==o.row&&s.row=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n}}).call(s.prototype)}),ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/range","ace/anchor"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=e("./range").Range,o=e("./anchor").Anchor,u=function(e){this.$lines=[],e.length===0?this.$lines=[""]:Array.isArray(e)?this._insertLines(0,e):this.insert({row:0,column:0},e)};(function(){r.implement(this,i),this.setValue=function(e){var t=this.getLength();this.remove(new s(0,0,t,this.getLine(t-1).length)),this.insert({row:0,column:0},e)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(e,t){return new o(this,e,t)},"aaa".split(/a/).length===0?this.$split=function(e){return e.replace(/\r\n|\r/g,"\n").split("\n")}:this.$split=function(e){return e.split(/\r\n|\r|\n/)},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r\n|\r|\n)/m);this.$autoNewLine=t?t[1]:"\n",this._signal("changeNewLineMode")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";default:return this.$autoNewLine||"\n"}},this.$autoNewLine="",this.$newLineMode="auto",this.setNewLineMode=function(e){if(this.$newLineMode===e)return;this.$newLineMode=e,this._signal("changeNewLineMode")},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(e){return e=="\r\n"||e=="\r"||e=="\n"},this.getLine=function(e){return this.$lines[e]||""},this.getLines=function(e,t){return this.$lines.slice(e,t+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(e){if(e.start.row==e.end.row)return this.getLine(e.start.row).substring(e.start.column,e.end.column);var t=this.getLines(e.start.row,e.end.row);t[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;return e.end.row-e.start.row==n&&(t[n]=t[n].substring(0,e.end.column)),t.join(this.getNewLineCharacter())},this.$clipPosition=function(e){var t=this.getLength();return e.row>=t?(e.row=Math.max(0,t-1),e.column=this.getLine(t-1).length):e.row<0&&(e.row=0),e},this.insert=function(e,t){if(!t||t.length===0)return e;e=this.$clipPosition(e),this.getLength()<=1&&this.$detectNewLine(t);var n=this.$split(t),r=n.splice(0,1)[0],i=n.length==0?null:n.splice(n.length-1,1)[0];return e=this.insertInLine(e,r),i!==null&&(e=this.insertNewLine(e),e=this._insertLines(e.row,n),e=this.insertInLine(e,i||"")),e},this.insertLines=function(e,t){return e>=this.getLength()?this.insert({row:e,column:0},"\n"+t.join("\n")):this._insertLines(Math.max(e,0),t)},this._insertLines=function(e,t){if(t.length==0)return{row:e,column:0};while(t.length>61440){var n=this._insertLines(e,t.slice(0,61440));t=t.slice(61440),e=n.row}var r=[e,0];r.push.apply(r,t),this.$lines.splice.apply(this.$lines,r);var i=new s(e,0,e+t.length,0),o={action:"insertLines",range:i,lines:t};return this._signal("change",{data:o}),i.end},this.insertNewLine=function(e){e=this.$clipPosition(e);var t=this.$lines[e.row]||"";this.$lines[e.row]=t.substring(0,e.column),this.$lines.splice(e.row+1,0,t.substring(e.column,t.length));var n={row:e.row+1,column:0},r={action:"insertText",range:s.fromPoints(e,n),text:this.getNewLineCharacter()};return this._signal("change",{data:r}),n},this.insertInLine=function(e,t){if(t.length==0)return e;var n=this.$lines[e.row]||"";this.$lines[e.row]=n.substring(0,e.column)+t+n.substring(e.column);var r={row:e.row,column:e.column+t.length},i={action:"insertText",range:s.fromPoints(e,r),text:t};return this._signal("change",{data:i}),r},this.remove=function(e){e instanceof s||(e=s.fromPoints(e.start,e.end)),e.start=this.$clipPosition(e.start),e.end=this.$clipPosition(e.end);if(e.isEmpty())return e.start;var t=e.start.row,n=e.end.row;if(e.isMultiLine()){var r=e.start.column==0?t:t+1,i=n-1;e.end.column>0&&this.removeInLine(n,0,e.end.column),i>=r&&this._removeLines(r,i),r!=t&&(this.removeInLine(t,e.start.column,this.getLine(t).length),this.removeNewLine(e.start.row))}else this.removeInLine(t,e.start.column,e.end.column);return e.start},this.removeInLine=function(e,t,n){if(t==n)return;var r=new s(e,t,e,n),i=this.getLine(e),o=i.substring(t,n),u=i.substring(0,t)+i.substring(n,i.length);this.$lines.splice(e,1,u);var a={action:"removeText",range:r,text:o};return this._signal("change",{data:a}),r.start},this.removeLines=function(e,t){return e<0||t>=this.getLength()?this.remove(new s(e,0,t+1,0)):this._removeLines(e,t)},this._removeLines=function(e,t){var n=new s(e,0,t+1,0),r=this.$lines.splice(e,t-e+1),i={action:"removeLines",range:n,nl:this.getNewLineCharacter(),lines:r};return this._signal("change",{data:i}),r},this.removeNewLine=function(e){var t=this.getLine(e),n=this.getLine(e+1),r=new s(e,t.length,e+1,0),i=t+n;this.$lines.splice(e,2,i);var o={action:"removeText",range:r,text:this.getNewLineCharacter()};this._signal("change",{data:o})},this.replace=function(e,t){e instanceof s||(e=s.fromPoints(e.start,e.end));if(t.length==0&&e.isEmpty())return e.start;if(t==this.getTextRange(e))return e.end;this.remove(e);if(t)var n=this.insert(e.start,t);else n=e.start;return n},this.applyDeltas=function(e){for(var t=0;t=0;t--){var n=e[t],r=s.fromPoints(n.range.start,n.range.end);n.action=="insertLines"?this._removeLines(r.start.row,r.end.row-1):n.action=="insertText"?this.remove(r):n.action=="removeLines"?this._insertLines(r.start.row,n.lines):n.action=="removeText"&&this.insert(r.start,n.text)}},this.indexToPosition=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length;for(var i=t||0,s=n.length;i20){n.running=setTimeout(n.$worker,20);break}}n.currentLine=t,s<=r&&n.fireUpdateEvent(s,r)}};(function(){r.implement(this,i),this.setTokenizer=function(e){this.tokenizer=e,this.lines=[],this.states=[],this.start(0)},this.setDocument=function(e){this.doc=e,this.lines=[],this.states=[],this.stop()},this.fireUpdateEvent=function(e,t){var n={first:e,last:t};this._signal("update",{data:n})},this.start=function(e){this.currentLine=Math.min(e||0,this.currentLine,this.doc.getLength()),this.lines.splice(this.currentLine,this.lines.length),this.states.splice(this.currentLine,this.states.length),this.stop(),this.running=setTimeout(this.$worker,700)},this.scheduleStart=function(){this.running||(this.running=setTimeout(this.$worker,700))},this.$updateOnChange=function(e){var t=e.range,n=t.start.row,r=t.end.row-n;if(r===0)this.lines[n]=null;else if(e.action=="removeText"||e.action=="removeLines")this.lines.splice(n,r+1,null),this.states.splice(n,r+1,null);else{var i=Array(r+1);i.unshift(n,1),this.lines.splice.apply(this.lines,i),this.states.splice.apply(this.states,i)}this.currentLine=Math.min(n,this.currentLine,this.doc.getLength()),this.stop()},this.stop=function(){this.running&&clearTimeout(this.running),this.running=!1},this.getTokens=function(e){return this.lines[e]||this.$tokenizeRow(e)},this.getState=function(e){return this.currentLine==e&&this.$tokenizeRow(e),this.states[e]||"start"},this.$tokenizeRow=function(e){var t=this.doc.getLine(e),n=this.states[e-1],r=this.tokenizer.getLineTokens(t,n,e);return this.states[e]+""!=r.state+""?(this.states[e]=r.state,this.lines[e+1]=null,this.currentLine>e+1&&(this.currentLine=e+1)):this.currentLine==e&&(this.currentLine=e+1),this.lines[e]=r.tokens}}).call(s.prototype),t.BackgroundTokenizer=s}),ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(e,t,n){"use strict";var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./range").Range,o=function(e,t,n){this.setRegexp(e),this.clazz=t,this.type=n||"text"};(function(){this.MAX_RANGES=500,this.setRegexp=function(e){if(this.regExp+""==e+"")return;this.regExp=e,this.cache=[]},this.update=function(e,t,n,i){if(!this.regExp)return;var o=i.firstRow,u=i.lastRow;for(var a=o;a<=u;a++){var f=this.cache[a];f==null&&(f=r.getMatchOffsets(n.getLine(a),this.regExp),f.length>this.MAX_RANGES&&(f=f.slice(0,this.MAX_RANGES)),f=f.map(function(e){return new s(a,e.offset,a,e.offset+e.length)}),this.cache[a]=f.length?f:"");for(var l=f.length;l--;)t.drawSingleLineMarker(e,f[l].toScreenRange(n),this.clazz,i)}}}).call(o.prototype),t.SearchHighlight=o}),ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"],function(e,t,n){"use strict";function i(e,t){this.foldData=e,Array.isArray(t)?this.folds=t:t=this.folds=[t];var n=t[t.length-1];this.range=new r(t[0].start.row,t[0].start.column,n.end.row,n.end.column),this.start=this.range.start,this.end=this.range.end,this.folds.forEach(function(e){e.setFoldLine(this)},this)}var r=e("../range").Range;(function(){this.shiftRow=function(e){this.start.row+=e,this.end.row+=e,this.folds.forEach(function(t){t.start.row+=e,t.end.row+=e})},this.addFold=function(e){if(e.sameRow){if(e.start.rowthis.endRow)throw new Error("Can't add a fold to this FoldLine as it has no connection");this.folds.push(e),this.folds.sort(function(e,t){return-e.range.compareEnd(t.start.row,t.start.column)}),this.range.compareEnd(e.start.row,e.start.column)>0?(this.end.row=e.end.row,this.end.column=e.end.column):this.range.compareStart(e.end.row,e.end.column)<0&&(this.start.row=e.start.row,this.start.column=e.start.column)}else if(e.start.row==this.end.row)this.folds.push(e),this.end.row=e.end.row,this.end.column=e.end.column;else{if(e.end.row!=this.start.row)throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");this.folds.unshift(e),this.start.row=e.start.row,this.start.column=e.start.column}e.foldLine=this},this.containsRow=function(e){return e>=this.start.row&&e<=this.end.row},this.walk=function(e,t,n){var r=0,i=this.folds,s,o,u,a=!0;t==null&&(t=this.end.row,n=this.end.column);for(var f=0;f0)continue;var a=i(e,o.start);return u===0?t&&a!==0?-s-2:s:a>0||a===0&&!t?s:-s-1}return-s-1},this.add=function(e){var t=!e.isEmpty(),n=this.pointIndex(e.start,t);n<0&&(n=-n-1);var r=this.pointIndex(e.end,t,n);return r<0?r=-r-1:r++,this.ranges.splice(n,r-n,e)},this.addList=function(e){var t=[];for(var n=e.length;n--;)t.push.call(t,this.add(e[n]));return t},this.substractPoint=function(e){var t=this.pointIndex(e);if(t>=0)return this.ranges.splice(t,1)},this.merge=function(){var e=[],t=this.ranges;t=t.sort(function(e,t){return i(e.start,t.start)});var n=t[0],r;for(var s=1;s=0},this.containsPoint=function(e){return this.pointIndex(e)>=0},this.rangeAtPoint=function(e){var t=this.pointIndex(e);if(t>=0)return this.ranges[t]},this.clipRows=function(e,t){var n=this.ranges;if(n[0].start.row>t||n[n.length-1].start.rowi)break;c.start.row==i&&c.start.column>=n.column&&(c.start.column!=n.column||!this.$insertRight)&&(c.start.column+=u,c.start.row+=o);if(c.end.row==i&&c.end.column>=n.column){if(c.end.column==n.column&&this.$insertRight)continue;c.end.column==n.column&&u>0&&fc.start.column&&c.end.column==a[f+1].start.column&&(c.end.column-=u),c.end.column+=u,c.end.row+=o}}if(o!=0&&f=e)return i;if(i.end.row>e)return null}return null},this.getNextFoldLine=function(e,t){var n=this.$foldData,r=0;t&&(r=n.indexOf(t)),r==-1&&(r=0);for(r;r=e)return i}return null},this.getFoldedRowCount=function(e,t){var n=this.$foldData,r=t-e+1;for(var i=0;i=t){u=e?r-=t-u:r=0);break}o>=e&&(u>=e?r-=o-u:r-=o-e+1)}return r},this.$addFoldLine=function(e){return this.$foldData.push(e),this.$foldData.sort(function(e,t){return e.start.row-t.start.row}),e},this.addFold=function(e,t){var n=this.$foldData,r=!1,o;e instanceof s?o=e:(o=new s(t,e),o.collapseChildren=t.collapseChildren),this.$clipRangeToDocument(o.range);var u=o.start.row,a=o.start.column,f=o.end.row,l=o.end.column;if(u0&&(this.removeFolds(p),p.forEach(function(e){o.addSubFold(e)}));for(var d=0;d0&&this.foldAll(e.start.row+1,e.end.row,e.collapseChildren-1),e.subFolds=[]},this.expandFolds=function(e){e.forEach(function(e){this.expandFold(e)},this)},this.unfold=function(e,t){var n,i;e==null?(n=new r(0,0,this.getLength(),0),t=!0):typeof e=="number"?n=new r(e,0,e,this.getLine(e).length):"row"in e?n=r.fromPoints(e,e):n=e,i=this.getFoldsInRangeList(n);if(t)this.removeFolds(i);else{var s=i;while(s.length)this.expandFolds(s),s=this.getFoldsInRangeList(n)}if(i.length)return i},this.isRowFolded=function(e,t){return!!this.getFoldLine(e,t)},this.getRowFoldEnd=function(e,t){var n=this.getFoldLine(e,t);return n?n.end.row:e},this.getRowFoldStart=function(e,t){var n=this.getFoldLine(e,t);return n?n.start.row:e},this.getFoldDisplayLine=function(e,t,n,r,i){r==null&&(r=e.start.row),i==null&&(i=0),t==null&&(t=e.end.row),n==null&&(n=this.getLine(t).length);var s=this.doc,o="";return e.walk(function(e,t,n,u){if(t=e){i=s.end.row;try{var o=this.addFold("...",s);o&&(o.collapseChildren=n)}catch(u){}}}},this.$foldStyles={manual:1,markbegin:1,markbeginend:1},this.$foldStyle="markbegin",this.setFoldStyle=function(e){if(!this.$foldStyles[e])throw new Error("invalid fold style: "+e+"["+Object.keys(this.$foldStyles).join(", ")+"]");if(this.$foldStyle==e)return;this.$foldStyle=e,e=="manual"&&this.unfold();var t=this.$foldMode;this.$setFolding(null),this.$setFolding(t)},this.$setFolding=function(e){if(this.$foldMode==e)return;this.$foldMode=e,this.removeListener("change",this.$updateFoldWidgets),this._emit("changeAnnotation");if(!e||this.$foldStyle=="manual"){this.foldWidgets=null;return}this.foldWidgets=[],this.getFoldWidget=e.getFoldWidget.bind(e,this,this.$foldStyle),this.getFoldWidgetRange=e.getFoldWidgetRange.bind(e,this,this.$foldStyle),this.$updateFoldWidgets=this.updateFoldWidgets.bind(this),this.on("change",this.$updateFoldWidgets)},this.getParentFoldRangeData=function(e,t){var n=this.foldWidgets;if(!n||t&&n[e])return{};var r=e-1,i;while(r>=0){var s=n[r];s==null&&(s=n[r]=this.getFoldWidget(r));if(s=="start"){var o=this.getFoldWidgetRange(r);i||(i=o);if(o&&o.end.row>=e)break}r--}return{range:r!==-1&&o,firstRange:i}},this.onFoldWidgetClick=function(e,t){t=t.domEvent;var n={children:t.shiftKey,all:t.ctrlKey||t.metaKey,siblings:t.altKey},r=this.$toggleFoldWidget(e,n);if(!r){var i=t.target||t.srcElement;i&&/ace_fold-widget/.test(i.className)&&(i.className+=" ace_invalid")}},this.$toggleFoldWidget=function(e,t){if(!this.getFoldWidget)return;var n=this.getFoldWidget(e),r=this.getLine(e),i=n==="end"?-1:1,s=this.getFoldAt(e,i===-1?0:r.length,i);if(s){t.children||t.all?this.removeFold(s):this.expandFold(s);return}var o=this.getFoldWidgetRange(e,!0);if(o&&!o.isMultiLine()){s=this.getFoldAt(o.start.row,o.start.column,1);if(s&&o.isEqual(s.range)){this.removeFold(s);return}}if(t.siblings){var u=this.getParentFoldRangeData(e);if(u.range)var a=u.range.start.row+1,f=u.range.end.row;this.foldAll(a,f,t.all?1e4:0)}else t.children?(f=o?o.end.row:this.getLength(),this.foldAll(e+1,o.end.row,t.all?1e4:0)):o&&(t.all&&(o.collapseChildren=1e4),this.addFold("...",o));return o},this.toggleFoldWidget=function(e){var t=this.selection.getCursor().row;t=this.getRowFoldStart(t);var n=this.$toggleFoldWidget(t,{});if(n)return;var r=this.getParentFoldRangeData(t,!0);n=r.range||r.firstRange;if(n){t=n.start.row;var i=this.getFoldAt(t,this.getLine(t).length,1);i?this.removeFold(i):this.addFold("...",n)}},this.updateFoldWidgets=function(e){var t=e.data,n=t.range,r=n.start.row,i=n.end.row-r;if(i===0)this.foldWidgets[r]=null;else if(t.action=="removeText"||t.action=="removeLines")this.foldWidgets.splice(r,i+1,null);else{var s=Array(i+1);s.unshift(r,1),this.foldWidgets.splice.apply(this.foldWidgets,s)}}}var r=e("../range").Range,i=e("./fold_line").FoldLine,s=e("./fold").Fold,o=e("../token_iterator").TokenIterator;t.Folding=u}),ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"],function(e,t,n){"use strict";function s(){this.findMatchingBracket=function(e,t){if(e.column==0)return null;var n=t||this.getLine(e.row).charAt(e.column-1);if(n=="")return null;var r=n.match(/([\(\[\{])|([\)\]\}])/);return r?r[1]?this.$findClosingBracket(r[1],e):this.$findOpeningBracket(r[2],e):null},this.getBracketRange=function(e){var t=this.getLine(e.row),n=!0,r,s=t.charAt(e.column-1),o=s&&s.match(/([\(\[\{])|([\)\]\}])/);o||(s=t.charAt(e.column),e={row:e.row,column:e.column+1},o=s&&s.match(/([\(\[\{])|([\)\]\}])/),n=!1);if(!o)return null;if(o[1]){var u=this.$findClosingBracket(o[1],e);if(!u)return null;r=i.fromPoints(e,u),n||(r.end.column++,r.start.column--),r.cursor=r.end}else{var u=this.$findOpeningBracket(o[2],e);if(!u)return null;r=i.fromPoints(u,e),n||(r.start.column++,r.end.column--),r.cursor=r.start}return r},this.$brackets={")":"(","(":")","]":"[","[":"]","{":"}","}":"{"},this.$findOpeningBracket=function(e,t,n){var i=this.$brackets[e],s=1,o=new r(this,t.row,t.column),u=o.getCurrentToken();u||(u=o.stepForward());if(!u)return;n||(n=new RegExp("(\\.?"+u.type.replace(".","\\.").replace("rparen",".paren").replace(/\b(?:end|start|begin)\b/,"")+")+"));var a=t.column-o.getCurrentTokenColumn()-2,f=u.value;for(;;){while(a>=0){var l=f.charAt(a);if(l==i){s-=1;if(s==0)return{row:o.getCurrentTokenRow(),column:a+o.getCurrentTokenColumn()}}else l==e&&(s+=1);a-=1}do u=o.stepBackward();while(u&&!n.test(u.type));if(u==null)break;f=u.value,a=f.length-1}return null},this.$findClosingBracket=function(e,t,n){var i=this.$brackets[e],s=1,o=new r(this,t.row,t.column),u=o.getCurrentToken();u||(u=o.stepForward());if(!u)return;n||(n=new RegExp("(\\.?"+u.type.replace(".","\\.").replace("lparen",".paren").replace(/\b(?:end|start|begin)\b/,"")+")+"));var a=t.column-o.getCurrentTokenColumn();for(;;){var f=u.value,l=f.length;while(a=4352&&e<=4447||e>=4515&&e<=4519||e>=4602&&e<=4607||e>=9001&&e<=9002||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12283||e>=12288&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12589||e>=12593&&e<=12686||e>=12688&&e<=12730||e>=12736&&e<=12771||e>=12784&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=13054||e>=13056&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=55216&&e<=55238||e>=55243&&e<=55291||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510}r.implement(this,o),this.setDocument=function(e){this.doc&&this.doc.removeListener("change",this.$onChange),this.doc=e,e.on("change",this.$onChange),this.bgTokenizer&&this.bgTokenizer.setDocument(this.getDocument()),this.resetCaches()},this.getDocument=function(){return this.doc},this.$resetRowCache=function(e){if(!e){this.$docRowCache=[],this.$screenRowCache=[];return}var t=this.$docRowCache.length,n=this.$getRowCacheIndex(this.$docRowCache,e)+1;t>n&&(this.$docRowCache.splice(n,t),this.$screenRowCache.splice(n,t))},this.$getRowCacheIndex=function(e,t){var n=0,r=e.length-1;while(n<=r){var i=n+r>>1,s=e[i];if(t>s)n=i+1;else{if(!(t=t)break}return r=n[s],r?(r.index=s,r.start=i-r.value.length,r):null},this.setUndoManager=function(e){this.$undoManager=e,this.$deltas=[],this.$deltasDoc=[],this.$deltasFold=[],this.$informUndoManager&&this.$informUndoManager.cancel();if(e){var t=this;this.$syncInformUndoManager=function(){t.$informUndoManager.cancel(),t.$deltasFold.length&&(t.$deltas.push({group:"fold",deltas:t.$deltasFold}),t.$deltasFold=[]),t.$deltasDoc.length&&(t.$deltas.push({group:"doc",deltas:t.$deltasDoc}),t.$deltasDoc=[]),t.$deltas.length>0&&e.execute({action:"aceupdate",args:[t.$deltas,t],merge:t.mergeUndoDeltas}),t.mergeUndoDeltas=!1,t.$deltas=[]},this.$informUndoManager=i.delayedCall(this.$syncInformUndoManager)}},this.markUndoGroup=function(){this.$syncInformUndoManager&&this.$syncInformUndoManager()},this.$defaultUndoManager={undo:function(){},redo:function(){},reset:function(){}},this.getUndoManager=function(){return this.$undoManager||this.$defaultUndoManager},this.getTabString=function(){return this.getUseSoftTabs()?i.stringRepeat(" ",this.getTabSize()):" "},this.setUseSoftTabs=function(e){this.setOption("useSoftTabs",e)},this.getUseSoftTabs=function(){return this.$useSoftTabs&&!this.$mode.$indentWithTabs},this.setTabSize=function(e){this.setOption("tabSize",e)},this.getTabSize=function(){return this.$tabSize},this.isTabStop=function(e){return this.$useSoftTabs&&e.column%this.$tabSize===0},this.$overwrite=!1,this.setOverwrite=function(e){this.setOption("overwrite",e)},this.getOverwrite=function(){return this.$overwrite},this.toggleOverwrite=function(){this.setOverwrite(!this.$overwrite)},this.addGutterDecoration=function(e,t){this.$decorations[e]||(this.$decorations[e]=""),this.$decorations[e]+=" "+t,this._signal("changeBreakpoint",{})},this.removeGutterDecoration=function(e,t){this.$decorations[e]=(this.$decorations[e]||"").replace(" "+t,""),this._signal("changeBreakpoint",{})},this.getBreakpoints=function(){return this.$breakpoints},this.setBreakpoints=function(e){this.$breakpoints=[];for(var t=0;t0&&(r=!!n.charAt(t-1).match(this.tokenRe)),r||(r=!!n.charAt(t).match(this.tokenRe));if(r)var i=this.tokenRe;else if(/^\s+$/.test(n.slice(t-1,t+1)))var i=/\s/;else var i=this.nonTokenRe;var s=t;if(s>0){do s--;while(s>=0&&n.charAt(s).match(i));s++}var o=t;while(oe&&(e=t.screenWidth)}),this.lineWidgetWidth=e},this.$computeWidth=function(e){if(this.$modified||e){this.$modified=!1;if(this.$useWrapMode)return this.screenWidth=this.$wrapLimit;var t=this.doc.getAllLines(),n=this.$rowLengthCache,r=0,i=0,s=this.$foldData[i],o=s?s.start.row:Infinity,u=t.length;for(var a=0;ao){a=s.end.row+1;if(a>=u)break;s=this.$foldData[i++],o=s?s.start.row:Infinity}n[a]==null&&(n[a]=this.$getStringScreenWidth(t[a])[0]),n[a]>r&&(r=n[a])}this.screenWidth=r}},this.getLine=function(e){return this.doc.getLine(e)},this.getLines=function(e,t){return this.doc.getLines(e,t)},this.getLength=function(){return this.doc.getLength()},this.getTextRange=function(e){return this.doc.getTextRange(e||this.selection.getRange())},this.insert=function(e,t){return this.doc.insert(e,t)},this.remove=function(e){return this.doc.remove(e)},this.undoChanges=function(e,t){if(!e.length)return;this.$fromUndo=!0;var n=null;for(var r=e.length-1;r!=-1;r--){var i=e[r];i.group=="doc"?(this.doc.revertDeltas(i.deltas),n=this.$getUndoSelection(i.deltas,!0,n)):i.deltas.forEach(function(e){this.addFolds(e.folds)},this)}return this.$fromUndo=!1,n&&this.$undoSelect&&!t&&this.selection.setSelectionRange(n),n},this.redoChanges=function(e,t){if(!e.length)return;this.$fromUndo=!0;var n=null;for(var r=0;re.end.column&&(s.start.column+=u),s.end.row==e.end.row&&s.end.column>e.end.column&&(s.end.column+=u)),o&&s.start.row>=e.end.row&&(s.start.row+=o,s.end.row+=o)}s.end=this.insert(s.start,r);if(i.length){var a=e.start,l=s.start,o=l.row-a.row,u=l.column-a.column;this.addFolds(i.map(function(e){return e=e.clone(),e.start.row==a.row&&(e.start.column+=u),e.end.row==a.row&&(e.end.column+=u),e.start.row+=o,e.end.row+=o,e}))}return s},this.indentRows=function(e,t,n){n=n.replace(/\t/g,this.getTabString());for(var r=e;r<=t;r++)this.insert({row:r,column:0},n)},this.outdentRows=function(e){var t=e.collapseRows(),n=new f(0,0,0,0),r=this.getTabSize();for(var i=t.start.row;i<=t.end.row;++i){var s=this.getLine(i);n.start.row=i,n.end.row=i;for(var o=0;o0){var r=this.getRowFoldEnd(t+n);if(r>this.doc.getLength()-1)return 0;var i=r-t}else{e=this.$clipRowToDocument(e),t=this.$clipRowToDocument(t);var i=t-e+1}var s=new f(e,0,t,Number.MAX_VALUE),o=this.getFoldsInRange(s).map(function(e){return e=e.clone(),e.start.row+=i,e.end.row+=i,e}),u=n==0?this.doc.getLines(e,t):this.doc.removeLines(e,t);return this.doc.insertLines(e+i,u),o.length&&this.addFolds(o),i},this.moveLinesUp=function(e,t){return this.$moveLines(e,t,-1)},this.moveLinesDown=function(e,t){return this.$moveLines(e,t,1)},this.duplicateLines=function(e,t){return this.$moveLines(e,t,0)},this.$clipRowToDocument=function(e){return Math.max(0,Math.min(e,this.doc.getLength()-1))},this.$clipColumnToRow=function(e,t){return t<0?0:Math.min(this.doc.getLine(e).length,t)},this.$clipPositionToDocument=function(e,t){t=Math.max(0,t);if(e<0)e=0,t=0;else{var n=this.doc.getLength();e>=n?(e=n-1,t=this.doc.getLine(n-1).length):t=Math.min(this.doc.getLine(e).length,t)}return{row:e,column:t}},this.$clipRangeToDocument=function(e){e.start.row<0?(e.start.row=0,e.start.column=0):e.start.column=this.$clipColumnToRow(e.start.row,e.start.column);var t=this.doc.getLength()-1;return e.end.row>t?(e.end.row=t,e.end.column=this.doc.getLine(t).length):e.end.column=this.$clipColumnToRow(e.end.row,e.end.column),e},this.$wrapLimit=80,this.$useWrapMode=!1,this.$wrapLimitRange={min:null,max:null},this.setUseWrapMode=function(e){if(e!=this.$useWrapMode){this.$useWrapMode=e,this.$modified=!0,this.$resetRowCache(0);if(e){var t=this.getLength();this.$wrapData=Array(t),this.$updateWrapData(0,t-1)}this._signal("changeWrapMode")}},this.getUseWrapMode=function(){return this.$useWrapMode},this.setWrapLimitRange=function(e,t){if(this.$wrapLimitRange.min!==e||this.$wrapLimitRange.max!==t)this.$wrapLimitRange={min:e,max:t},this.$modified=!0,this._signal("changeWrapMode")},this.adjustWrapLimit=function(e,t){var n=this.$wrapLimitRange;n.max<0&&(n={min:t,max:t});var r=this.$constrainWrapLimit(e,n.min,n.max);return r!=this.$wrapLimit&&r>1?(this.$wrapLimit=r,this.$modified=!0,this.$useWrapMode&&(this.$updateWrapData(0,this.getLength()-1),this.$resetRowCache(0),this._signal("changeWrapLimit")),!0):!1},this.$constrainWrapLimit=function(e,t,n){return t&&(e=Math.max(t,e)),n&&(e=Math.min(n,e)),e},this.getWrapLimit=function(){return this.$wrapLimit},this.setWrapLimit=function(e){this.setWrapLimitRange(e,e)},this.getWrapLimitRange=function(){return{min:this.$wrapLimitRange.min,max:this.$wrapLimitRange.max}},this.$updateInternalDataOnChange=function(e){var t=this.$useWrapMode,n,r=e.data.action,i=e.data.range.start.row,s=e.data.range.end.row,o=e.data.range.start,u=e.data.range.end,a=null;r.indexOf("Lines")!=-1?(r=="insertLines"?s=i+e.data.lines.length:s=i,n=e.data.lines?e.data.lines.length:s-i):n=s-i,this.$updating=!0;if(n!=0)if(r.indexOf("remove")!=-1){this[t?"$wrapData":"$rowLengthCache"].splice(i,n);var f=this.$foldData;a=this.getFoldsInRange(e.data.range),this.removeFolds(a);var l=this.getFoldLine(u.row),c=0;if(l){l.addRemoveChars(u.row,u.column,o.column-u.column),l.shiftRow(-n);var h=this.getFoldLine(i);h&&h!==l&&(h.merge(l),l=h),c=f.indexOf(l)+1}for(c;c=u.row&&l.shiftRow(-n)}s=i}else{var p=Array(n);p.unshift(i,0);var d=t?this.$wrapData:this.$rowLengthCache;d.splice.apply(d,p);var f=this.$foldData,l=this.getFoldLine(i),c=0;if(l){var v=l.range.compareInside(o.row,o.column);v==0?(l=l.split(o.row,o.column),l&&(l.shiftRow(n),l.addRemoveChars(s,0,u.column-o.column))):v==-1&&(l.addRemoveChars(i,0,u.column-o.column),l.shiftRow(n)),c=f.indexOf(l)+1}for(c;c=i&&l.shiftRow(n)}}else{n=Math.abs(e.data.range.start.column-e.data.range.end.column),r.indexOf("remove")!=-1&&(a=this.getFoldsInRange(e.data.range),this.removeFolds(a),n=-n);var l=this.getFoldLine(i);l&&l.addRemoveChars(i,o.column,n)}return t&&this.$wrapData.length!=this.doc.getLength()&&console.error("doc.getLength() and $wrapData.length have to be the same!"),this.$updating=!1,t?this.$updateWrapData(i,s):this.$updateRowLengthCache(i,s),a},this.$updateRowLengthCache=function(e,t,n){this.$rowLengthCache[e]=null,this.$rowLengthCache[t]=null},this.$updateWrapData=function(e,t){var r=this.doc.getAllLines(),i=this.getTabSize(),s=this.$wrapData,o=this.$wrapLimit,a,f,l=e;t=Math.min(t,r.length-1);while(l<=t)f=this.getFoldLine(l,f),f?(a=[],f.walk(function(e,t,i,s){var o;if(e!=null){o=this.$getDisplayTokens(e,a.length),o[0]=n;for(var f=1;fr){var h=o+r;if(e[h-1]>=p&&e[h]>=p){c(h);continue}if(e[h]==n||e[h]==u){for(h;h!=o-1;h--)if(e[h]==n)break;if(h>o){c(h);continue}h=o+r;for(h;h>2)),o-1);while(h>d&&e[h]d&&e[h]d&&e[h]==l)h--}else while(h>d&&e[h]d){c(++h);continue}h=o+r,e[h]==t&&h--,c(h)}return i},this.$getDisplayTokens=function(n,r){var i=[],s;r=r||0;for(var o=0;o39&&u<48||u>57&&u<64?i.push(l):u>=4352&&m(u)?i.push(e,t):i.push(e)}return i},this.$getStringScreenWidth=function(e,t,n){if(t==0)return[0,0];t==null&&(t=Infinity),n=n||0;var r,i;for(i=0;i=4352&&m(r)?n+=2:n+=1;if(n>t)break}return[n,i]},this.lineWidgets=null,this.getRowLength=function(e){if(this.lineWidgets)var t=this.lineWidgets[e]&&this.lineWidgets[e].rowCount||0;else t=0;return!this.$useWrapMode||!this.$wrapData[e]?1+t:this.$wrapData[e].length+1+t},this.getRowLineCount=function(e){return!this.$useWrapMode||!this.$wrapData[e]?1:this.$wrapData[e].length+1},this.getScreenLastRowColumn=function(e){var t=this.screenToDocumentPosition(e,Number.MAX_VALUE);return this.documentToScreenColumn(t.row,t.column)},this.getDocumentLastRowColumn=function(e,t){var n=this.documentToScreenRow(e,t);return this.getScreenLastRowColumn(n)},this.getDocumentLastRowColumnPosition=function(e,t){var n=this.documentToScreenRow(e,t);return this.screenToDocumentPosition(n,Number.MAX_VALUE/10)},this.getRowSplitData=function(e){return this.$useWrapMode?this.$wrapData[e]:undefined},this.getScreenTabSize=function(e){return this.$tabSize-e%this.$tabSize},this.screenToDocumentRow=function(e,t){return this.screenToDocumentPosition(e,t).row},this.screenToDocumentColumn=function(e,t){return this.screenToDocumentPosition(e,t).column},this.screenToDocumentPosition=function(e,t){if(e<0)return{row:0,column:0};var n,r=0,i=0,s,o=0,u=0,a=this.$screenRowCache,f=this.$getRowCacheIndex(a,e),l=a.length;if(l&&f>=0)var o=a[f],r=this.$docRowCache[f],c=e>a[l-1];else var c=!l;var h=this.getLength()-1,p=this.getNextFoldLine(r),d=p?p.start.row:Infinity;while(o<=e){u=this.getRowLength(r);if(o+u>e||r>=h)break;o+=u,r++,r>d&&(r=p.end.row+1,p=this.getNextFoldLine(r,p),d=p?p.start.row:Infinity),c&&(this.$docRowCache.push(r),this.$screenRowCache.push(o))}if(p&&p.start.row<=r)n=this.getFoldDisplayLine(p),r=p.start.row;else{if(o+u<=e||r>h)return{row:h,column:this.getLine(h).length};n=this.getLine(r),p=null}if(this.$useWrapMode){var v=this.$wrapData[r];if(v){var m=Math.floor(e-o);s=v[m],m>0&&v.length&&(i=v[m-1]||v[v.length-1],n=n.substring(i))}}return i+=this.$getStringScreenWidth(n,t)[1],this.$useWrapMode&&i>=s&&(i=s-1),p?p.idxToPosition(i):{row:r,column:i}},this.documentToScreenPosition=function(e,t){if(typeof t=="undefined")var n=this.$clipPositionToDocument(e.row,e.column);else n=this.$clipPositionToDocument(e,t);e=n.row,t=n.column;var r=0,i=null,s=null;s=this.getFoldAt(e,t,1),s&&(e=s.start.row,t=s.start.column);var o,u=0,a=this.$docRowCache,f=this.$getRowCacheIndex(a,e),l=a.length;if(l&&f>=0)var u=a[f],r=this.$screenRowCache[f],c=e>a[l-1];else var c=!l;var h=this.getNextFoldLine(u),p=h?h.start.row:Infinity;while(u=p){o=h.end.row+1;if(o>e)break;h=this.getNextFoldLine(o,h),p=h?h.start.row:Infinity}else o=u+1;r+=this.getRowLength(u),u=o,c&&(this.$docRowCache.push(u),this.$screenRowCache.push(r))}var d="";h&&u>=p?(d=this.getFoldDisplayLine(h,e,t),i=h.start.row):(d=this.getLine(e).substring(0,t),i=e);if(this.$useWrapMode){var v=this.$wrapData[i];if(v){var m=0;while(d.length>=v[m])r++,m++;d=d.substring(v[m-1]||0,d.length)}}return{row:r,column:this.$getStringScreenWidth(d)[0]}},this.documentToScreenColumn=function(e,t){return this.documentToScreenPosition(e,t).column},this.documentToScreenRow=function(e,t){return this.documentToScreenPosition(e,t).row},this.getScreenLength=function(){var e=0,t=null;if(!this.$useWrapMode){e=this.getLength();var n=this.$foldData;for(var r=0;ro&&(s=t.end.row+1,t=this.$foldData[r++],o=t?t.start.row:Infinity)}}return this.lineWidgets&&(e+=this.$getWidgetScreenLength()),e},this.$setFontMetrics=function(e){},this.destroy=function(){this.bgTokenizer&&(this.bgTokenizer.setDocument(null),this.bgTokenizer=null),this.$stopWorker()}}).call(p.prototype),e("./edit_session/folding").Folding.call(p.prototype),e("./edit_session/bracket_match").BracketMatch.call(p.prototype),s.defineOptions(p.prototype,"session",{wrap:{set:function(e){!e||e=="off"?e=!1:e=="free"?e=!0:e=="printMargin"?e=-1:typeof e=="string"&&(e=parseInt(e,10)||!1);if(this.$wrap==e)return;if(!e)this.setUseWrapMode(!1);else{var t=typeof e=="number"?e:null;this.setWrapLimitRange(t,t),this.setUseWrapMode(!0)}this.$wrap=e},get:function(){return this.getUseWrapMode()?this.$wrap==-1?"printMargin":this.getWrapLimitRange().min?this.$wrap:"free":"off"},handlesSet:!0},wrapMethod:{set:function(e){e=e=="auto"?this.$mode.type!="text":e!="text",e!=this.$wrapAsCode&&(this.$wrapAsCode=e,this.$useWrapMode&&(this.$modified=!0,this.$resetRowCache(0),this.$updateWrapData(0,this.getLength()-1)))},initialValue:"auto"},firstLineNumber:{set:function(){this._signal("changeBreakpoint")},initialValue:1},useWorker:{set:function(e){this.$useWorker=e,this.$stopWorker(),e&&this.$startWorker()},initialValue:!0},useSoftTabs:{initialValue:!0},tabSize:{set:function(e){if(isNaN(e)||this.$tabSize===e)return;this.$modified=!0,this.$rowLengthCache=[],this.$tabSize=e,this._signal("changeTabSize")},initialValue:4,handlesSet:!0},overwrite:{set:function(e){this._signal("changeOverwrite")},initialValue:!1},newLineMode:{set:function(e){this.doc.setNewLineMode(e)},get:function(){return this.doc.getNewLineMode()},handlesSet:!0},mode:{set:function(e){this.setMode(e)},get:function(){return this.$modeId}}}),t.EditSession=p}),ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(e,t,n){"use strict";var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./range").Range,o=function(){this.$options={}};(function(){this.set=function(e){return i.mixin(this.$options,e),this},this.getOptions=function(){return r.copyObject(this.$options)},this.setOptions=function(e){this.$options=e},this.find=function(e){var t=this.$matchIterator(e,this.$options);if(!t)return!1;var n=null;return t.forEach(function(e,t,r){if(!e.start){var i=e.offset+(r||0);n=new s(t,i,t,i+e.length)}else n=e;return!0}),n},this.findAll=function(e){var t=this.$options;if(!t.needle)return[];this.$assembleRegExp(t);var n=t.range,i=n?e.getLines(n.start.row,n.end.row):e.doc.getAllLines(),o=[],u=t.re;if(t.$isMultiLine){var a=u.length,f=i.length-a,l;e:for(var c=u.offset||0;c<=f;c++){for(var h=0;hv)continue;o.push(l=new s(c,v,c+a-1,m)),a>2&&(c=c+a-2)}}else for(var g=0;gE&&o[h].end.row==n.end.row)h--;o=o.slice(g,h+1);for(g=0,h=o.length;g=0;u--)if(o(s[u],t,i))return!0};else var f=function(e,t,i){var s=r.getMatchOffsets(e,n);for(var u=0;u=o;r--)if(n(e.getLine(r),r))return;if(t.wrap==0)return;for(r=u,o=s.row;r>=o;r--)if(n(e.getLine(r),r))return}:function(n){var r=s.row,i=e.getLine(r).substr(s.column);if(n(i,r,s.column))return;for(r+=1;r<=u;r++)if(n(e.getLine(r),r))return;if(t.wrap==0)return;for(r=o,u=s.row;r<=u;r++)if(n(e.getLine(r),r))return};return{forEach:a}}}).call(o.prototype),t.Search=o}),ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(e,t,n){"use strict";function o(e,t){this.platform=t||(i.isMac?"mac":"win"),this.commands={},this.commandKeyBinding={},this.addCommands(e),this.$singleCommand=!0}function u(e,t){o.call(this,e,t),this.$singleCommand=!1}var r=e("../lib/keys"),i=e("../lib/useragent"),s=r.KEY_MODS;u.prototype=o.prototype,function(){this.addCommand=function(e){this.commands[e.name]&&this.removeCommand(e),this.commands[e.name]=e,e.bindKey&&this._buildKeyHash(e)},this.removeCommand=function(e,t){var n=e&&(typeof e=="string"?e:e.name);e=this.commands[n],t||delete this.commands[n];var r=this.commandKeyBinding;for(var i in r){var s=r[i];if(s==e)delete r[i];else if(Array.isArray(s)){var o=s.indexOf(e);o!=-1&&(s.splice(o,1),s.length==1&&(r[i]=s[0]))}}},this.bindKey=function(e,t,n){typeof e=="object"&&(e=e[this.platform]);if(!e)return;if(typeof t=="function")return this.addCommand({exec:t,bindKey:e,name:t.name||e});e.split("|").forEach(function(e){var r="";if(e.indexOf(" ")!=-1){var i=e.split(/\s+/);e=i.pop(),i.forEach(function(e){var t=this.parseKeys(e),n=s[t.hashId]+t.key;r+=(r?" ":"")+n,this._addCommandToBinding(r,"chainKeys")},this),r+=" "}var o=this.parseKeys(e),u=s[o.hashId]+o.key;this._addCommandToBinding(r+u,t,n)},this)},this._addCommandToBinding=function(e,t,n){var r=this.commandKeyBinding,i;t?!r[e]||this.$singleCommand?r[e]=t:(Array.isArray(r[e])?(i=r[e].indexOf(t))!=-1&&r[e].splice(i,1):r[e]=[r[e]],n||t.isDefault?r[e].unshift(t):r[e].push(t)):delete r[e]},this.addCommands=function(e){e&&Object.keys(e).forEach(function(t){var n=e[t];if(!n)return;if(typeof n=="string")return this.bindKey(n,t);typeof n=="function"&&(n={exec:n});if(typeof n!="object")return;n.name||(n.name=t),this.addCommand(n)},this)},this.removeCommands=function(e){Object.keys(e).forEach(function(t){this.removeCommand(e[t])},this)},this.bindKeys=function(e){Object.keys(e).forEach(function(t){this.bindKey(t,e[t])},this)},this._buildKeyHash=function(e){this.bindKey(e.bindKey,e)},this.parseKeys=function(e){var t=e.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(e){return e}),n=t.pop(),i=r[n];if(r.FUNCTION_KEYS[i])n=r.FUNCTION_KEYS[i].toLowerCase();else{if(!t.length)return{key:n,hashId:-1};if(t.length==1&&t[0]=="shift")return{key:n.toUpperCase(),hashId:-1}}var s=0;for(var o=t.length;o--;){var u=r.KEY_MODS[t[o]];if(u==null)return typeof console!="undefined"&&console.error("invalid modifier "+t[o]+" in "+e),!1;s|=u}return{key:n,hashId:s}},this.findKeyCommand=function(t,n){var r=s[t]+n;return this.commandKeyBinding[r]},this.handleKeyboard=function(e,t,n,r){var i=s[t]+n,o=this.commandKeyBinding[i];e.$keyChain&&(e.$keyChain+=" "+i,o=this.commandKeyBinding[e.$keyChain]||o);if(o)if(o=="chainKeys"||o[o.length-1]=="chainKeys")return e.$keyChain=e.$keyChain||i,{command:"null"};return e.$keyChain&&r>0&&(e.$keyChain=""),{command:o}}}.call(o.prototype),t.HashHandler=o,t.MultiHashHandler=u}),ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../keyboard/hash_handler").MultiHashHandler,s=e("../lib/event_emitter").EventEmitter,o=function(e,t){i.call(this,t,e),this.byName=this.commands,this.setDefaultHandler("exec",function(e){return e.command.exec(e.editor,e.args||{})})};r.inherits(o,i),function(){r.implement(this,s),this.exec=function(e,t,n){if(Array.isArray(e)){for(var r=e.length;r--;)if(this.exec(e[r],t,n))return!0;return!1}typeof e=="string"&&(e=this.commands[e]);if(!e)return!1;if(t&&t.$readOnly&&!e.readOnly)return!1;var i={editor:t,command:e,args:n};return i.returnValue=this._emit("exec",i),this._signal("afterExec",i),i.returnValue===!1?!1:!0},this.toggleRecording=function(e){if(this.$inReplay)return;return e&&e._emit("changeStatus"),this.recording?(this.macro.pop(),this.removeEventListener("exec",this.$addCommandToMacro),this.macro.length||(this.macro=this.oldMacro),this.recording=!1):(this.$addCommandToMacro||(this.$addCommandToMacro=function(e){this.macro.push([e.command,e.args])}.bind(this)),this.oldMacro=this.macro,this.macro=[],this.on("exec",this.$addCommandToMacro),this.recording=!0)},this.replay=function(e){if(this.$inReplay||!this.macro)return;if(this.recording)return this.toggleRecording(e);try{this.$inReplay=!0,this.macro.forEach(function(t){typeof t=="string"?this.exec(t,e):this.exec(t[0],e,t[1])},this)}finally{this.$inReplay=!1}},this.trimMacro=function(e){return e.map(function(e){return typeof e[0]!="string"&&(e[0]=e[0].name),e[1]||(e=e[0]),e})}}.call(o.prototype),t.CommandManager=o}),ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"],function(e,t,n){"use strict";function o(e,t){return{win:e,mac:t}}var r=e("../lib/lang"),i=e("../config"),s=e("../range").Range;t.commands=[{name:"showSettingsMenu",bindKey:o("Ctrl-,","Command-,"),exec:function(e){i.loadModule("ace/ext/settings_menu",function(t){t.init(e),e.showSettingsMenu()})},readOnly:!0},{name:"goToNextError",bindKey:o("Alt-E","Ctrl-E"),exec:function(e){i.loadModule("ace/ext/error_marker",function(t){t.showErrorMarker(e,1)})},scrollIntoView:"animate",readOnly:!0},{name:"goToPreviousError",bindKey:o("Alt-Shift-E","Ctrl-Shift-E"),exec:function(e){i.loadModule("ace/ext/error_marker",function(t){t.showErrorMarker(e,-1)})},scrollIntoView:"animate",readOnly:!0},{name:"selectall",bindKey:o("Ctrl-A","Command-A"),exec:function(e){e.selectAll()},readOnly:!0},{name:"centerselection",bindKey:o(null,"Ctrl-L"),exec:function(e){e.centerSelection()},readOnly:!0},{name:"gotoline",bindKey:o("Ctrl-L","Command-L"),exec:function(e){var t=parseInt(prompt("Enter line number:"),10);isNaN(t)||e.gotoLine(t)},readOnly:!0},{name:"fold",bindKey:o("Alt-L|Ctrl-F1","Command-Alt-L|Command-F1"),exec:function(e){e.session.toggleFold(!1)},scrollIntoView:"center",readOnly:!0},{name:"unfold",bindKey:o("Alt-Shift-L|Ctrl-Shift-F1","Command-Alt-Shift-L|Command-Shift-F1"),exec:function(e){e.session.toggleFold(!0)},scrollIntoView:"center",readOnly:!0},{name:"toggleFoldWidget",bindKey:o("F2","F2"),exec:function(e){e.session.toggleFoldWidget()},scrollIntoView:"center",readOnly:!0},{name:"toggleParentFoldWidget",bindKey:o("Alt-F2","Alt-F2"),exec:function(e){e.session.toggleFoldWidget(!0)},scrollIntoView:"center",readOnly:!0},{name:"foldall",bindKey:o("Ctrl-Alt-0","Ctrl-Command-Option-0"),exec:function(e){e.session.foldAll()},scrollIntoView:"center",readOnly:!0},{name:"foldOther",bindKey:o("Alt-0","Command-Option-0"),exec:function(e){e.session.foldAll(),e.session.unfold(e.selection.getAllRanges())},scrollIntoView:"center",readOnly:!0},{name:"unfoldall",bindKey:o("Alt-Shift-0","Command-Option-Shift-0"),exec:function(e){e.session.unfold()},scrollIntoView:"center",readOnly:!0},{name:"findnext",bindKey:o("Ctrl-K","Command-G"),exec:function(e){e.findNext()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"findprevious",bindKey:o("Ctrl-Shift-K","Command-Shift-G"),exec:function(e){e.findPrevious()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"selectOrFindNext",bindKey:o("Alt-K","Ctrl-G"),exec:function(e){e.selection.isEmpty()?e.selection.selectWord():e.findNext()},readOnly:!0},{name:"selectOrFindPrevious",bindKey:o("Alt-Shift-K","Ctrl-Shift-G"),exec:function(e){e.selection.isEmpty()?e.selection.selectWord():e.findPrevious()},readOnly:!0},{name:"find",bindKey:o("Ctrl-F","Command-F"),exec:function(e){i.loadModule("ace/ext/searchbox",function(t){t.Search(e)})},readOnly:!0},{name:"overwrite",bindKey:"Insert",exec:function(e){e.toggleOverwrite()},readOnly:!0},{name:"selecttostart",bindKey:o("Ctrl-Shift-Home","Command-Shift-Up"),exec:function(e){e.getSelection().selectFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotostart",bindKey:o("Ctrl-Home","Command-Home|Command-Up"),exec:function(e){e.navigateFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectup",bindKey:o("Shift-Up","Shift-Up"),exec:function(e){e.getSelection().selectUp()},multiSelectAction:"forEach",readOnly:!0},{name:"golineup",bindKey:o("Up","Up|Ctrl-P"),exec:function(e,t){e.navigateUp(t.times)},multiSelectAction:"forEach",readOnly:!0},{name:"selecttoend",bindKey:o("Ctrl-Shift-End","Command-Shift-Down"),exec:function(e){e.getSelection().selectFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotoend",bindKey:o("Ctrl-End","Command-End|Command-Down"),exec:function(e){e.navigateFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectdown",bindKey:o("Shift-Down","Shift-Down"),exec:function(e){e.getSelection().selectDown()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golinedown",bindKey:o("Down","Down|Ctrl-N"),exec:function(e,t){e.navigateDown(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordleft",bindKey:o("Ctrl-Shift-Left","Option-Shift-Left"),exec:function(e){e.getSelection().selectWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordleft",bindKey:o("Ctrl-Left","Option-Left"),exec:function(e){e.navigateWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolinestart",bindKey:o("Alt-Shift-Left","Command-Shift-Left"),exec:function(e){e.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolinestart",bindKey:o("Alt-Left|Home","Command-Left|Home|Ctrl-A"),exec:function(e){e.navigateLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectleft",bindKey:o("Shift-Left","Shift-Left"),exec:function(e){e.getSelection().selectLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoleft",bindKey:o("Left","Left|Ctrl-B"),exec:function(e,t){e.navigateLeft(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordright",bindKey:o("Ctrl-Shift-Right","Option-Shift-Right"),exec:function(e){e.getSelection().selectWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordright",bindKey:o("Ctrl-Right","Option-Right"),exec:function(e){e.navigateWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolineend",bindKey:o("Alt-Shift-Right","Command-Shift-Right"),exec:function(e){e.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolineend",bindKey:o("Alt-Right|End","Command-Right|End|Ctrl-E"),exec:function(e){e.navigateLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectright",bindKey:o("Shift-Right","Shift-Right"),exec:function(e){e.getSelection().selectRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoright",bindKey:o("Right","Right|Ctrl-F"),exec:function(e,t){e.navigateRight(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectpagedown",bindKey:"Shift-PageDown",exec:function(e){e.selectPageDown()},readOnly:!0},{name:"pagedown",bindKey:o(null,"Option-PageDown"),exec:function(e){e.scrollPageDown()},readOnly:!0},{name:"gotopagedown",bindKey:o("PageDown","PageDown|Ctrl-V"),exec:function(e){e.gotoPageDown()},readOnly:!0},{name:"selectpageup",bindKey:"Shift-PageUp",exec:function(e){e.selectPageUp()},readOnly:!0},{name:"pageup",bindKey:o(null,"Option-PageUp"),exec:function(e){e.scrollPageUp()},readOnly:!0},{name:"gotopageup",bindKey:"PageUp",exec:function(e){e.gotoPageUp()},readOnly:!0},{name:"scrollup",bindKey:o("Ctrl-Up",null),exec:function(e){e.renderer.scrollBy(0,-2*e.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"scrolldown",bindKey:o("Ctrl-Down",null),exec:function(e){e.renderer.scrollBy(0,2*e.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"selectlinestart",bindKey:"Shift-Home",exec:function(e){e.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectlineend",bindKey:"Shift-End",exec:function(e){e.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"togglerecording",bindKey:o("Ctrl-Alt-E","Command-Option-E"),exec:function(e){e.commands.toggleRecording(e)},readOnly:!0},{name:"replaymacro",bindKey:o("Ctrl-Shift-E","Command-Shift-E"),exec:function(e){e.commands.replay(e)},readOnly:!0},{name:"jumptomatching",bindKey:o("Ctrl-P","Ctrl-P"),exec:function(e){e.jumpToMatching()},multiSelectAction:"forEach",readOnly:!0},{name:"selecttomatching",bindKey:o("Ctrl-Shift-P","Ctrl-Shift-P"),exec:function(e){e.jumpToMatching(!0)},multiSelectAction:"forEach",readOnly:!0},{name:"passKeysToBrowser",bindKey:o("null","null"),exec:function(){},passEvent:!0,readOnly:!0},{name:"cut",exec:function(e){var t=e.getSelectionRange();e._emit("cut",t),e.selection.isEmpty()||(e.session.remove(t),e.clearSelection())},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"removeline",bindKey:o("Ctrl-D","Command-D"),exec:function(e){e.removeLines()},scrollIntoView:"cursor",multiSelectAction:"forEachLine"},{name:"duplicateSelection",bindKey:o("Ctrl-Shift-D","Command-Shift-D"),exec:function(e){e.duplicateSelection()},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"sortlines",bindKey:o("Ctrl-Alt-S","Command-Alt-S"),exec:function(e){e.sortLines()},scrollIntoView:"selection",multiSelectAction:"forEachLine"},{name:"togglecomment",bindKey:o("Ctrl-/","Command-/"),exec:function(e){e.toggleCommentLines()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"toggleBlockComment",bindKey:o("Ctrl-Shift-/","Command-Shift-/"),exec:function(e){e.toggleBlockComment()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"modifyNumberUp",bindKey:o("Ctrl-Shift-Up","Alt-Shift-Up"),exec:function(e){e.modifyNumber(1)},multiSelectAction:"forEach"},{name:"modifyNumberDown",bindKey:o("Ctrl-Shift-Down","Alt-Shift-Down"),exec:function(e){e.modifyNumber(-1)},multiSelectAction:"forEach"},{name:"replace",bindKey:o("Ctrl-H","Command-Option-F"),exec:function(e){i.loadModule("ace/ext/searchbox",function(t){t.Search(e,!0)})}},{name:"undo",bindKey:o("Ctrl-Z","Command-Z"),exec:function(e){e.undo()}},{name:"redo",bindKey:o("Ctrl-Shift-Z|Ctrl-Y","Command-Shift-Z|Command-Y"),exec:function(e){e.redo()}},{name:"copylinesup",bindKey:o("Alt-Shift-Up","Command-Option-Up"),exec:function(e){e.copyLinesUp()},scrollIntoView:"cursor"},{name:"movelinesup",bindKey:o("Alt-Up","Option-Up"),exec:function(e){e.moveLinesUp()},scrollIntoView:"cursor"},{name:"copylinesdown",bindKey:o("Alt-Shift-Down","Command-Option-Down"),exec:function(e){e.copyLinesDown()},scrollIntoView:"cursor"},{name:"movelinesdown",bindKey:o("Alt-Down","Option-Down"),exec:function(e){e.moveLinesDown()},scrollIntoView:"cursor"},{name:"del",bindKey:o("Delete","Delete|Ctrl-D|Shift-Delete"),exec:function(e){e.remove("right")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"backspace",bindKey:o("Shift-Backspace|Backspace","Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"),exec:function(e){e.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"cut_or_delete",bindKey:o("Shift-Delete",null),exec:function(e){if(!e.selection.isEmpty())return!1;e.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolinestart",bindKey:o("Alt-Backspace","Command-Backspace"),exec:function(e){e.removeToLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolineend",bindKey:o("Alt-Delete","Ctrl-K"),exec:function(e){e.removeToLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordleft",bindKey:o("Ctrl-Backspace","Alt-Backspace|Ctrl-Alt-Backspace"),exec:function(e){e.removeWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordright",bindKey:o("Ctrl-Delete","Alt-Delete"),exec:function(e){e.removeWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"outdent",bindKey:o("Shift-Tab","Shift-Tab"),exec:function(e){e.blockOutdent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"indent",bindKey:o("Tab","Tab"),exec:function(e){e.indent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"blockoutdent",bindKey:o("Ctrl-[","Ctrl-["),exec:function(e){e.blockOutdent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"blockindent",bindKey:o("Ctrl-]","Ctrl-]"),exec:function(e){e.blockIndent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"insertstring",exec:function(e,t){e.insert(t)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"inserttext",exec:function(e,t){e.insert(r.stringRepeat(t.text||"",t.times||1))},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"splitline",bindKey:o(null,"Ctrl-O"),exec:function(e){e.splitLine()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"transposeletters",bindKey:o("Ctrl-T","Ctrl-T"),exec:function(e){e.transposeLetters()},multiSelectAction:function(e){e.transposeSelections(1)},scrollIntoView:"cursor"},{name:"touppercase",bindKey:o("Ctrl-U","Ctrl-U"),exec:function(e){e.toUpperCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"tolowercase",bindKey:o("Ctrl-Shift-U","Ctrl-Shift-U"),exec:function(e){e.toLowerCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"expandtoline",bindKey:o("Ctrl-Shift-L","Command-Shift-L"),exec:function(e){var t=e.selection.getRange();t.start.column=t.end.column=0,t.end.row++,e.selection.setRange(t,!1)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"joinlines",bindKey:o(null,null),exec:function(e){var t=e.selection.isBackwards(),n=t?e.selection.getSelectionLead():e.selection.getSelectionAnchor(),i=t?e.selection.getSelectionAnchor():e.selection.getSelectionLead(),o=e.session.doc.getLine(n.row).length,u=e.session.doc.getTextRange(e.selection.getRange()),a=u.replace(/\n\s*/," ").length,f=e.session.doc.getLine(n.row);for(var l=n.row+1;l<=i.row+1;l++){var c=r.stringTrimLeft(r.stringTrimRight(e.session.doc.getLine(l)));c.length!==0&&(c=" "+c),f+=c}i.row+10?(e.selection.moveCursorTo(n.row,n.column),e.selection.selectTo(n.row,n.column+a)):(o=e.session.doc.getLine(n.row).length>o?o+1:o,e.selection.moveCursorTo(n.row,o))},multiSelectAction:"forEach",readOnly:!0},{name:"invertSelection",bindKey:o(null,null),exec:function(e){var t=e.session.doc.getLength()-1,n=e.session.doc.getLine(t).length,r=e.selection.rangeList.ranges,i=[];r.length<1&&(r=[e.selection.getRange()]);for(var o=0;o=r.lastRow||n.end.row<=r.firstRow)&&this.renderer.scrollSelectionIntoView(this.selection.anchor,this.selection.lead);break;default:}t.scrollIntoView=="animate"&&this.renderer.animateScrolling(this.curOp.scrollTop)}this.prevOp=this.curOp,this.curOp=null}},this.$mergeableCommands=["backspace","del","insertstring"],this.$historyTracker=function(e){if(!this.$mergeUndoDeltas)return;var t=this.prevOp,n=this.$mergeableCommands,r=t.command&&e.command.name==t.command.name;if(e.command.name=="insertstring"){var i=e.args;this.mergeNextCommand===undefined&&(this.mergeNextCommand=!0),r=r&&this.mergeNextCommand&&(!/\s/.test(i)||/\s/.test(t.args)),this.mergeNextCommand=!0}else r=r&&n.indexOf(e.command.name)!==-1;this.$mergeUndoDeltas!="always"&&Date.now()-this.sequenceStartTime>2e3&&(r=!1),r?this.session.mergeUndoDeltas=!0:n.indexOf(e.command.name)!==-1&&(this.sequenceStartTime=Date.now())},this.setKeyboardHandler=function(e,t){if(e&&typeof e=="string"){this.$keybindingId=e;var n=this;g.loadModule(["keybinding",e],function(r){n.$keybindingId==e&&n.keyBinding.setKeyboardHandler(r&&r.handler),t&&t()})}else this.$keybindingId=null,this.keyBinding.setKeyboardHandler(e),t&&t()},this.getKeyboardHandler=function(){return this.keyBinding.getKeyboardHandler()},this.setSession=function(e){if(this.session==e)return;var t=this.session;if(t){this.session.removeEventListener("change",this.$onDocumentChange),this.session.removeEventListener("changeMode",this.$onChangeMode),this.session.removeEventListener("tokenizerUpdate",this.$onTokenizerUpdate),this.session.removeEventListener("changeTabSize",this.$onChangeTabSize),this.session.removeEventListener("changeWrapLimit",this.$onChangeWrapLimit),this.session.removeEventListener("changeWrapMode",this.$onChangeWrapMode),this.session.removeEventListener("onChangeFold",this.$onChangeFold),this.session.removeEventListener("changeFrontMarker",this.$onChangeFrontMarker),this.session.removeEventListener("changeBackMarker",this.$onChangeBackMarker),this.session.removeEventListener("changeBreakpoint",this.$onChangeBreakpoint),this.session.removeEventListener("changeAnnotation",this.$onChangeAnnotation),this.session.removeEventListener("changeOverwrite",this.$onCursorChange),this.session.removeEventListener("changeScrollTop",this.$onScrollTopChange),this.session.removeEventListener("changeScrollLeft",this.$onScrollLeftChange);var n=this.session.getSelection();n.removeEventListener("changeCursor",this.$onCursorChange),n.removeEventListener("changeSelection",this.$onSelectionChange)}this.session=e,e?(this.$onDocumentChange=this.onDocumentChange.bind(this),e.addEventListener("change",this.$onDocumentChange),this.renderer.setSession(e),this.$onChangeMode=this.onChangeMode.bind(this),e.addEventListener("changeMode",this.$onChangeMode),this.$onTokenizerUpdate=this.onTokenizerUpdate.bind(this),e.addEventListener("tokenizerUpdate",this.$onTokenizerUpdate),this.$onChangeTabSize=this.renderer.onChangeTabSize.bind(this.renderer),e.addEventListener("changeTabSize",this.$onChangeTabSize),this.$onChangeWrapLimit=this.onChangeWrapLimit.bind(this),e.addEventListener("changeWrapLimit",this.$onChangeWrapLimit),this.$onChangeWrapMode=this.onChangeWrapMode.bind(this),e.addEventListener("changeWrapMode",this.$onChangeWrapMode),this.$onChangeFold=this.onChangeFold.bind(this),e.addEventListener("changeFold",this.$onChangeFold),this.$onChangeFrontMarker=this.onChangeFrontMarker.bind(this),this.session.addEventListener("changeFrontMarker",this.$onChangeFrontMarker),this.$onChangeBackMarker=this.onChangeBackMarker.bind(this),this.session.addEventListener("changeBackMarker",this.$onChangeBackMarker),this.$onChangeBreakpoint=this.onChangeBreakpoint.bind(this),this.session.addEventListener("changeBreakpoint",this.$onChangeBreakpoint),this.$onChangeAnnotation=this.onChangeAnnotation.bind(this),this.session.addEventListener("changeAnnotation",this.$onChangeAnnotation),this.$onCursorChange=this.onCursorChange.bind(this),this.session.addEventListener("changeOverwrite",this.$onCursorChange),this.$onScrollTopChange=this.onScrollTopChange.bind(this),this.session.addEventListener("changeScrollTop",this.$onScrollTopChange),this.$onScrollLeftChange=this.onScrollLeftChange.bind(this),this.session.addEventListener("changeScrollLeft",this.$onScrollLeftChange),this.selection=e.getSelection(),this.selection.addEventListener("changeCursor",this.$onCursorChange),this.$onSelectionChange=this.onSelectionChange.bind(this),this.selection.addEventListener("changeSelection",this.$onSelectionChange),this.onChangeMode(),this.$blockScrolling+=1,this.onCursorChange(),this.$blockScrolling-=1,this.onScrollTopChange(),this.onScrollLeftChange(),this.onSelectionChange(),this.onChangeFrontMarker(),this.onChangeBackMarker(),this.onChangeBreakpoint(),this.onChangeAnnotation(),this.session.getUseWrapMode()&&this.renderer.adjustWrapLimit(),this.renderer.updateFull()):(this.selection=null,this.renderer.setSession(e)),this._signal("changeSession",{session:e,oldSession:t}),t&&t._signal("changeEditor",{oldEditor:this}),e&&e._signal("changeEditor",{editor:this})},this.getSession=function(){return this.session},this.setValue=function(e,t){return this.session.doc.setValue(e),t?t==1?this.navigateFileEnd():t==-1&&this.navigateFileStart():this.selectAll(),e},this.getValue=function(){return this.session.getValue()},this.getSelection=function(){return this.selection},this.resize=function(e){this.renderer.onResize(e)},this.setTheme=function(e,t){this.renderer.setTheme(e,t)},this.getTheme=function(){return this.renderer.getTheme()},this.setStyle=function(e){this.renderer.setStyle(e)},this.unsetStyle=function(e){this.renderer.unsetStyle(e)},this.getFontSize=function(){return this.getOption("fontSize")||i.computedStyle(this.container,"fontSize")},this.setFontSize=function(e){this.setOption("fontSize",e)},this.$highlightBrackets=function(){this.session.$bracketHighlight&&(this.session.removeMarker(this.session.$bracketHighlight),this.session.$bracketHighlight=null);if(this.$highlightPending)return;var e=this;this.$highlightPending=!0,setTimeout(function(){e.$highlightPending=!1;var t=e.session;if(!t||!t.bgTokenizer)return;var n=t.findMatchingBracket(e.getCursorPosition());if(n)var r=new p(n.row,n.column,n.row,n.column+1);else if(t.$mode.getMatching)var r=t.$mode.getMatching(e.session);r&&(t.$bracketHighlight=t.addMarker(r,"ace_bracket","text"))},50)},this.$highlightTags=function(){if(this.$highlightTagPending)return;var e=this;this.$highlightTagPending=!0,setTimeout(function(){e.$highlightTagPending=!1;var t=e.session;if(!t||!t.bgTokenizer)return;var n=e.getCursorPosition(),r=new y(e.session,n.row,n.column),i=r.getCurrentToken();if(!i||i.type.indexOf("tag-name")===-1){t.removeMarker(t.$tagHighlight),t.$tagHighlight=null;return}var s=i.value,o=0,u=r.stepBackward();if(u.value=="<"){do u=i,i=r.stepForward(),i&&i.value===s&&i.type.indexOf("tag-name")!==-1&&(u.value==="<"?o++:u.value==="=0)}else{do i=u,u=r.stepBackward(),i&&i.value===s&&i.type.indexOf("tag-name")!==-1&&(u.value==="<"?o++:u.value==="1)&&(t=!1)}if(e.$highlightLineMarker&&!t)e.removeMarker(e.$highlightLineMarker.id),e.$highlightLineMarker=null;else if(!e.$highlightLineMarker&&t){var n=new p(t.row,t.column,t.row,Infinity);n.id=e.addMarker(n,"ace_active-line","screenLine"),e.$highlightLineMarker=n}else t&&(e.$highlightLineMarker.start.row=t.row,e.$highlightLineMarker.end.row=t.row,e.$highlightLineMarker.start.column=t.column,e._signal("changeBackMarker"))},this.onSelectionChange=function(e){var t=this.session;t.$selectionMarker&&t.removeMarker(t.$selectionMarker),t.$selectionMarker=null;if(!this.selection.isEmpty()){var n=this.selection.getRange(),r=this.getSelectionStyle();t.$selectionMarker=t.addMarker(n,"ace_selection",r)}else this.$updateHighlightActiveLine();var i=this.$highlightSelectedWord&&this.$getSelectionHighLightRegexp();this.session.highlight(i),this._signal("changeSelection")},this.$getSelectionHighLightRegexp=function(){var e=this.session,t=this.getSelectionRange();if(t.isEmpty()||t.isMultiLine())return;var n=t.start.column-1,r=t.end.column+1,i=e.getLine(t.start.row),s=i.length,o=i.substring(Math.max(n,0),Math.min(r,s));if(n>=0&&/^[\w\d]/.test(o)||r<=s&&/[\w\d]$/.test(o))return;o=i.substring(t.start.column,t.end.column);if(!/^[\w\d]+$/.test(o))return;var u=this.$search.$assembleRegExp({wholeWord:!0,caseSensitive:!0,needle:o});return u},this.onChangeFrontMarker=function(){this.renderer.updateFrontMarkers()},this.onChangeBackMarker=function(){this.renderer.updateBackMarkers()},this.onChangeBreakpoint=function(){this.renderer.updateBreakpoints()},this.onChangeAnnotation=function(){this.renderer.setAnnotations(this.session.getAnnotations())},this.onChangeMode=function(e){this.renderer.updateText(),this._emit("changeMode",e)},this.onChangeWrapLimit=function(){this.renderer.updateFull()},this.onChangeWrapMode=function(){this.renderer.onResize(!0)},this.onChangeFold=function(){this.$updateHighlightActiveLine(),this.renderer.updateFull()},this.getSelectedText=function(){return this.session.getTextRange(this.getSelectionRange())},this.getCopyText=function(){var e=this.getSelectedText();return this._signal("copy",e),e},this.onCopy=function(){this.commands.exec("copy",this)},this.onCut=function(){this.commands.exec("cut",this)},this.onPaste=function(e){if(this.$readOnly)return;var t={text:e};this._signal("paste",t),this.insert(t.text,!0)},this.execCommand=function(e,t){return this.commands.exec(e,this,t)},this.insert=function(e,t){var n=this.session,r=n.getMode(),i=this.getCursorPosition();if(this.getBehavioursEnabled()&&!t){var s=r.transformAction(n.getState(i.row),"insertion",this,n,e);s&&(e!==s.text&&(this.session.mergeUndoDeltas=!1,this.$mergeNextCommand=!1),e=s.text)}e==" "&&(e=this.session.getTabString());if(!this.selection.isEmpty()){var o=this.getSelectionRange();i=this.session.remove(o),this.clearSelection()}else if(this.session.getOverwrite()){var o=new p.fromPoints(i,i);o.end.column+=e.length,this.session.remove(o)}if(e=="\n"||e=="\r\n"){var u=n.getLine(i.row);if(i.column>u.search(/\S|$/)){var a=u.substr(i.column).search(/\S|$/);n.doc.removeInLine(i.row,i.column,i.column+a)}}this.clearSelection();var f=i.column,l=n.getState(i.row),u=n.getLine(i.row),c=r.checkOutdent(l,u,e),h=n.insert(i,e);s&&s.selection&&(s.selection.length==2?this.selection.setSelectionRange(new p(i.row,f+s.selection[0],i.row,f+s.selection[1])):this.selection.setSelectionRange(new p(i.row+s.selection[0],s.selection[1],i.row+s.selection[2],s.selection[3])));if(n.getDocument().isNewLine(e)){var d=r.getNextLineIndent(l,u.slice(0,i.column),n.getTabString());n.insert({row:i.row+1,column:0},d)}c&&r.autoOutdent(l,n,i.row)},this.onTextInput=function(e){this.keyBinding.onTextInput(e)},this.onCommandKey=function(e,t,n){this.keyBinding.onCommandKey(e,t,n)},this.setOverwrite=function(e){this.session.setOverwrite(e)},this.getOverwrite=function(){return this.session.getOverwrite()},this.toggleOverwrite=function(){this.session.toggleOverwrite()},this.setScrollSpeed=function(e){this.setOption("scrollSpeed",e)},this.getScrollSpeed=function(){return this.getOption("scrollSpeed")},this.setDragDelay=function(e){this.setOption("dragDelay",e)},this.getDragDelay=function(){return this.getOption("dragDelay")},this.setSelectionStyle=function(e){this.setOption("selectionStyle",e)},this.getSelectionStyle=function(){return this.getOption("selectionStyle")},this.setHighlightActiveLine=function(e){this.setOption("highlightActiveLine",e)},this.getHighlightActiveLine=function(){return this.getOption("highlightActiveLine")},this.setHighlightGutterLine=function(e){this.setOption("highlightGutterLine",e)},this.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},this.setHighlightSelectedWord=function(e){this.setOption("highlightSelectedWord",e)},this.getHighlightSelectedWord=function(){return this.$highlightSelectedWord},this.setAnimatedScroll=function(e){this.renderer.setAnimatedScroll(e)},this.getAnimatedScroll=function(){return this.renderer.getAnimatedScroll()},this.setShowInvisibles=function(e){this.renderer.setShowInvisibles(e)},this.getShowInvisibles=function(){return this.renderer.getShowInvisibles()},this.setDisplayIndentGuides=function(e){this.renderer.setDisplayIndentGuides(e)},this.getDisplayIndentGuides=function(){return this.renderer.getDisplayIndentGuides()},this.setShowPrintMargin=function(e){this.renderer.setShowPrintMargin(e)},this.getShowPrintMargin=function(){return this.renderer.getShowPrintMargin()},this.setPrintMarginColumn=function(e){this.renderer.setPrintMarginColumn(e)},this.getPrintMarginColumn=function(){return this.renderer.getPrintMarginColumn()},this.setReadOnly=function(e){this.setOption("readOnly",e)},this.getReadOnly=function(){return this.getOption("readOnly")},this.setBehavioursEnabled=function(e){this.setOption("behavioursEnabled",e)},this.getBehavioursEnabled=function(){return this.getOption("behavioursEnabled")},this.setWrapBehavioursEnabled=function(e){this.setOption("wrapBehavioursEnabled",e)},this.getWrapBehavioursEnabled=function(){return this.getOption("wrapBehavioursEnabled")},this.setShowFoldWidgets=function(e){this.setOption("showFoldWidgets",e)},this.getShowFoldWidgets=function(){return this.getOption("showFoldWidgets")},this.setFadeFoldWidgets=function(e){this.setOption("fadeFoldWidgets",e)},this.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},this.remove=function(e){this.selection.isEmpty()&&(e=="left"?this.selection.selectLeft():this.selection.selectRight());var t=this.getSelectionRange();if(this.getBehavioursEnabled()){var n=this.session,r=n.getState(t.start.row),i=n.getMode().transformAction(r,"deletion",this,n,t);if(t.end.column===0){var s=n.getTextRange(t);if(s[s.length-1]=="\n"){var o=n.getLine(t.end.row);/^\s+$/.test(o)&&(t.end.column=o.length)}}i&&(t=i)}this.session.remove(t),this.clearSelection()},this.removeWordRight=function(){this.selection.isEmpty()&&this.selection.selectWordRight(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeWordLeft=function(){this.selection.isEmpty()&&this.selection.selectWordLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineStart=function(){this.selection.isEmpty()&&this.selection.selectLineStart(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineEnd=function(){this.selection.isEmpty()&&this.selection.selectLineEnd();var e=this.getSelectionRange();e.start.column==e.end.column&&e.start.row==e.end.row&&(e.end.column=0,e.end.row++),this.session.remove(e),this.clearSelection()},this.splitLine=function(){this.selection.isEmpty()||(this.session.remove(this.getSelectionRange()),this.clearSelection());var e=this.getCursorPosition();this.insert("\n"),this.moveCursorToPosition(e)},this.transposeLetters=function(){if(!this.selection.isEmpty())return;var e=this.getCursorPosition(),t=e.column;if(t===0)return;var n=this.session.getLine(e.row),r,i;tt.toLowerCase()?1:0});var r=new p(0,0,0,0);for(var i=e.first;i<=e.last;i++){var s=t.getLine(i);r.start.row=i,r.end.row=i,r.end.column=s.length,t.replace(r,n[i-e.first])}},this.toggleCommentLines=function(){var e=this.session.getState(this.getCursorPosition().row),t=this.$getSelectedRows();this.session.getMode().toggleCommentLines(e,this.session,t.first,t.last)},this.toggleBlockComment=function(){var e=this.getCursorPosition(),t=this.session.getState(e.row),n=this.getSelectionRange();this.session.getMode().toggleBlockComment(t,this.session,n,e)},this.getNumberAt=function(e,t){var n=/[\-]?[0-9]+(?:\.[0-9]+)?/g;n.lastIndex=0;var r=this.session.getLine(e);while(n.lastIndex=t){var s={value:i[0],start:i.index,end:i.index+i[0].length};return s}}return null},this.modifyNumber=function(e){var t=this.selection.getCursor().row,n=this.selection.getCursor().column,r=new p(t,n-1,t,n),i=this.session.getTextRange(r);if(!isNaN(parseFloat(i))&&isFinite(i)){var s=this.getNumberAt(t,n);if(s){var o=s.value.indexOf(".")>=0?s.start+s.value.indexOf(".")+1:s.end,u=s.start+s.value.length-o,a=parseFloat(s.value);a*=Math.pow(10,u),o!==s.end&&n=o)s[u].moveBy(i,0),u--}t.fromOrientedRange(t.ranges[0]),t.rangeList.attach(this.session)}},this.$getSelectedRows=function(){var e=this.getSelectionRange().collapseRows();return{first:this.session.getRowFoldStart(e.start.row),last:this.session.getRowFoldEnd(e.end.row)}},this.onCompositionStart=function(e){this.renderer.showComposition(this.getCursorPosition())},this.onCompositionUpdate=function(e){this.renderer.setCompositionText(e)},this.onCompositionEnd=function(){this.renderer.hideComposition()},this.getFirstVisibleRow=function(){return this.renderer.getFirstVisibleRow()},this.getLastVisibleRow=function(){return this.renderer.getLastVisibleRow()},this.isRowVisible=function(e){return e>=this.getFirstVisibleRow()&&e<=this.getLastVisibleRow()},this.isRowFullyVisible=function(e){return e>=this.renderer.getFirstFullyVisibleRow()&&e<=this.renderer.getLastFullyVisibleRow()},this.$getVisibleRowCount=function(){return this.renderer.getScrollBottomRow()-this.renderer.getScrollTopRow()+1},this.$moveByPage=function(e,t){var n=this.renderer,r=this.renderer.layerConfig,i=e*Math.floor(r.height/r.lineHeight);this.$blockScrolling++,t===!0?this.selection.$moveSelection(function(){this.moveCursorBy(i,0)}):t===!1&&(this.selection.moveCursorBy(i,0),this.selection.clearSelection()),this.$blockScrolling--;var s=n.scrollTop;n.scrollBy(0,i*r.lineHeight),t!=null&&n.scrollCursorIntoView(null,.5),n.animateScrolling(s)},this.selectPageDown=function(){this.$moveByPage(1,!0)},this.selectPageUp=function(){this.$moveByPage(-1,!0)},this.gotoPageDown=function(){this.$moveByPage(1,!1)},this.gotoPageUp=function(){this.$moveByPage(-1,!1)},this.scrollPageDown=function(){this.$moveByPage(1)},this.scrollPageUp=function(){this.$moveByPage(-1)},this.scrollToRow=function(e){this.renderer.scrollToRow(e)},this.scrollToLine=function(e,t,n,r){this.renderer.scrollToLine(e,t,n,r)},this.centerSelection=function(){var e=this.getSelectionRange(),t={row:Math.floor(e.start.row+(e.end.row-e.start.row)/2),column:Math.floor(e.start.column+(e.end.column-e.start.column)/2)};this.renderer.alignCursor(t,.5)},this.getCursorPosition=function(){return this.selection.getCursor()},this.getCursorPositionScreen=function(){return this.session.documentToScreenPosition(this.getCursorPosition())},this.getSelectionRange=function(){return this.selection.getRange()},this.selectAll=function(){this.$blockScrolling+=1,this.selection.selectAll(),this.$blockScrolling-=1},this.clearSelection=function(){this.selection.clearSelection()},this.moveCursorTo=function(e,t){this.selection.moveCursorTo(e,t)},this.moveCursorToPosition=function(e){this.selection.moveCursorToPosition(e)},this.jumpToMatching=function(e,t){var n=this.getCursorPosition(),r=new y(this.session,n.row,n.column),i=r.getCurrentToken(),s=i||r.stepForward();if(!s)return;var o,u=!1,a={},f=n.column-s.start,l,c={")":"(","(":"(","]":"[","[":"[","{":"{","}":"{"};do{if(s.value.match(/[{}()\[\]]/g))for(;f=0;--s)this.$tryReplace(n[s],e)&&r++;return this.selection.setSelectionRange(i),this.$blockScrolling-=1,r},this.$tryReplace=function(e,t){var n=this.session.getTextRange(e);return t=this.$search.replace(n,t),t!==null?(e.end=this.session.replace(e,t),e):null},this.getLastSearchOptions=function(){return this.$search.getOptions()},this.find=function(e,t,n){t||(t={}),typeof e=="string"||e instanceof RegExp?t.needle=e:typeof e=="object"&&r.mixin(t,e);var i=this.selection.getRange();t.needle==null&&(e=this.session.getTextRange(i)||this.$search.$options.needle,e||(i=this.session.getWordRange(i.start.row,i.start.column),e=this.session.getTextRange(i)),this.$search.set({needle:e})),this.$search.set(t),t.start||this.$search.set({start:i});var s=this.$search.find(this.session);if(t.preventScroll)return s;if(s)return this.revealRange(s,n),s;t.backwards?i.start=i.end:i.end=i.start,this.selection.setRange(i)},this.findNext=function(e,t){this.find({skipCurrent:!0,backwards:!1},e,t)},this.findPrevious=function(e,t){this.find(e,{skipCurrent:!0,backwards:!0},t)},this.revealRange=function(e,t){this.$blockScrolling+=1,this.session.unfold(e),this.selection.setSelectionRange(e),this.$blockScrolling-=1;var n=this.renderer.scrollTop;this.renderer.scrollSelectionIntoView(e.start,e.end,.5),t!==!1&&this.renderer.animateScrolling(n)},this.undo=function(){this.$blockScrolling++,this.session.getUndoManager().undo(),this.$blockScrolling--,this.renderer.scrollCursorIntoView(null,.5)},this.redo=function(){this.$blockScrolling++,this.session.getUndoManager().redo(),this.$blockScrolling--,this.renderer.scrollCursorIntoView(null,.5)},this.destroy=function(){this.renderer.destroy(),this._signal("destroy",this),this.session&&this.session.destroy()},this.setAutoScrollEditorIntoView=function(e){if(!e)return;var t,n=this,r=!1;this.$scrollAnchor||(this.$scrollAnchor=document.createElement("div"));var i=this.$scrollAnchor;i.style.cssText="position:absolute",this.container.insertBefore(i,this.container.firstChild);var s=this.on("changeSelection",function(){r=!0}),o=this.renderer.on("beforeRender",function(){r&&(t=n.renderer.container.getBoundingClientRect())}),u=this.renderer.on("afterRender",function(){if(r&&t&&(n.isFocused()||n.searchBox&&n.searchBox.isFocused())){var e=n.renderer,s=e.$cursorLayer.$pixelPos,o=e.layerConfig,u=s.top-o.offset;s.top>=0&&u+t.top<0?r=!0:s.topwindow.innerHeight?r=!1:r=null,r!=null&&(i.style.top=u+"px",i.style.left=s.left+"px",i.style.height=o.lineHeight+"px",i.scrollIntoView(r)),r=t=null}});this.setAutoScrollEditorIntoView=function(e){if(e)return;delete this.setAutoScrollEditorIntoView,this.removeEventListener("changeSelection",s),this.renderer.removeEventListener("afterRender",u),this.renderer.removeEventListener("beforeRender",o)}},this.$resetCursorStyle=function(){var e=this.$cursorStyle||"ace",t=this.renderer.$cursorLayer;if(!t)return;t.setSmoothBlinking(/smooth/.test(e)),t.isBlinking=!this.$readOnly&&e!="wide",i.setCssClass(t.element,"ace_slim-cursors",/slim/.test(e))}}).call(b.prototype),g.defineOptions(b.prototype,"editor",{selectionStyle:{set:function(e){this.onSelectionChange(),this._signal("changeSelectionStyle",{data:e})},initialValue:"line"},highlightActiveLine:{set:function(){this.$updateHighlightActiveLine()},initialValue:!0},highlightSelectedWord:{set:function(e){this.$onSelectionChange()},initialValue:!0},readOnly:{set:function(e){this.$resetCursorStyle()},initialValue:!1},cursorStyle:{set:function(e){this.$resetCursorStyle()},values:["ace","slim","smooth","wide"],initialValue:"ace"},mergeUndoDeltas:{values:[!1,!0,"always"],initialValue:!0},behavioursEnabled:{initialValue:!0},wrapBehavioursEnabled:{initialValue:!0},autoScrollEditorIntoView:{set:function(e){this.setAutoScrollEditorIntoView(e)}},hScrollBarAlwaysVisible:"renderer",vScrollBarAlwaysVisible:"renderer",highlightGutterLine:"renderer",animatedScroll:"renderer",showInvisibles:"renderer",showPrintMargin:"renderer",printMarginColumn:"renderer",printMargin:"renderer",fadeFoldWidgets:"renderer",showFoldWidgets:"renderer",showLineNumbers:"renderer",showGutter:"renderer",displayIndentGuides:"renderer",fontSize:"renderer",fontFamily:"renderer",maxLines:"renderer",minLines:"renderer",scrollPastEnd:"renderer",fixedWidthGutter:"renderer",theme:"renderer",scrollSpeed:"$mouseHandler",dragDelay:"$mouseHandler",dragEnabled:"$mouseHandler",focusTimout:"$mouseHandler",tooltipFollowsMouse:"$mouseHandler",firstLineNumber:"session",overwrite:"session",newLineMode:"session",useWorker:"session",useSoftTabs:"session",tabSize:"session",wrap:"session",foldStyle:"session",mode:"session"}),t.Editor=b}),ace.define("ace/undomanager",["require","exports","module"],function(e,t,n){"use strict";var r=function(){this.reset()};(function(){this.execute=function(e){var t=e.args[0];this.$doc=e.args[1],e.merge&&this.hasUndo()&&(this.dirtyCounter--,t=this.$undoStack.pop().concat(t)),this.$undoStack.push(t),this.$redoStack=[],this.dirtyCounter<0&&(this.dirtyCounter=NaN),this.dirtyCounter++},this.undo=function(e){var t=this.$undoStack.pop(),n=null;return t&&(n=this.$doc.undoChanges(t,e),this.$redoStack.push(t),this.dirtyCounter--),n},this.redo=function(e){var t=this.$redoStack.pop(),n=null;return t&&(n=this.$doc.redoChanges(t,e),this.$undoStack.push(t),this.dirtyCounter++),n},this.reset=function(){this.$undoStack=[],this.$redoStack=[],this.dirtyCounter=0},this.hasUndo=function(){return this.$undoStack.length>0},this.hasRedo=function(){return this.$redoStack.length>0},this.markClean=function(){this.dirtyCounter=0},this.isClean=function(){return this.dirtyCounter===0}}).call(r.prototype),t.UndoManager=r}),ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/dom"),i=e("../lib/oop"),s=e("../lib/lang"),o=e("../lib/event_emitter").EventEmitter,u=function(e){this.element=r.createElement("div"),this.element.className="ace_layer ace_gutter-layer",e.appendChild(this.element),this.setShowFoldWidgets(this.$showFoldWidgets),this.gutterWidth=0,this.$annotations=[],this.$updateAnnotations=this.$updateAnnotations.bind(this),this.$cells=[]};(function(){i.implement(this,o),this.setSession=function(e){this.session&&this.session.removeEventListener("change",this.$updateAnnotations),this.session=e,e&&e.on("change",this.$updateAnnotations)},this.addGutterDecoration=function(e,t){window.console&&console.warn&&console.warn("deprecated use session.addGutterDecoration"),this.session.addGutterDecoration(e,t)},this.removeGutterDecoration=function(e,t){window.console&&console.warn&&console.warn("deprecated use session.removeGutterDecoration"),this.session.removeGutterDecoration(e,t)},this.setAnnotations=function(e){this.$annotations=[];for(var t=0;to&&(v=s.end.row+1,s=t.getNextFoldLine(v,s),o=s?s.start.row:Infinity);if(v>i){while(this.$cells.length>d+1)p=this.$cells.pop(),this.element.removeChild(p.element);break}p=this.$cells[++d],p||(p={element:null,textNode:null,foldWidget:null},p.element=r.createElement("div"),p.textNode=document.createTextNode(""),p.element.appendChild(p.textNode),this.element.appendChild(p.element),this.$cells[d]=p);var m="ace_gutter-cell ";a[v]&&(m+=a[v]),f[v]&&(m+=f[v]),this.$annotations[v]&&(m+=this.$annotations[v].className),p.element.className!=m&&(p.element.className=m);var g=t.getRowLength(v)*e.lineHeight+"px";g!=p.element.style.height&&(p.element.style.height=g);if(u){var y=u[v];y==null&&(y=u[v]=t.getFoldWidget(v))}if(y){p.foldWidget||(p.foldWidget=r.createElement("span"),p.element.appendChild(p.foldWidget));var m="ace_fold-widget ace_"+y;y=="start"&&v==o&&vn.right-t.right)return"foldWidgets"}}).call(u.prototype),t.Gutter=u}),ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../range").Range,i=e("../lib/dom"),s=function(e){this.element=i.createElement("div"),this.element.className="ace_layer ace_marker-layer",e.appendChild(this.element)};(function(){this.$padding=0,this.setPadding=function(e){this.$padding=e},this.setSession=function(e){this.session=e},this.setMarkers=function(e){this.markers=e},this.update=function(e){var e=e||this.config;if(!e)return;this.config=e;var t=[];for(var n in this.markers){var r=this.markers[n];if(!r.range){r.update(t,this,this.session,e);continue}var i=r.range.clipRows(e.firstRow,e.lastRow);if(i.isEmpty())continue;i=i.toScreenRange(this.session);if(r.renderer){var s=this.$getTop(i.start.row,e),o=this.$padding+i.start.column*e.characterWidth;r.renderer(t,i,o,s,e)}else r.type=="fullLine"?this.drawFullLineMarker(t,i,r.clazz,e):r.type=="screenLine"?this.drawScreenLineMarker(t,i,r.clazz,e):i.isMultiLine()?r.type=="text"?this.drawTextMarker(t,i,r.clazz,e):this.drawMultiLineMarker(t,i,r.clazz,e):this.drawSingleLineMarker(t,i,r.clazz+" ace_start",e)}this.element.innerHTML=t.join("")},this.$getTop=function(e,t){return(e-t.firstRowScreen)*t.lineHeight},this.drawTextMarker=function(e,t,n,i,s){var o=t.start.row,u=new r(o,t.start.column,o,this.session.getScreenLastRowColumn(o));this.drawSingleLineMarker(e,u,n+" ace_start",i,1,s),o=t.end.row,u=new r(o,0,o,t.end.column),this.drawSingleLineMarker(e,u,n,i,0,s);for(o=t.start.row+1;o"),u=this.$getTop(t.end.row,r);var f=t.end.column*r.characterWidth;e.push("
"),o=(t.end.row-t.start.row-1)*r.lineHeight;if(o<0)return;u=this.$getTop(t.start.row+1,r),e.push("
")},this.drawSingleLineMarker=function(e,t,n,r,i,s){var o=r.lineHeight,u=(t.end.column+(i||0)-t.start.column)*r.characterWidth,a=this.$getTop(t.start.row,r),f=this.$padding+t.start.column*r.characterWidth;e.push("
")},this.drawFullLineMarker=function(e,t,n,r,i){var s=this.$getTop(t.start.row,r),o=r.lineHeight;t.start.row!=t.end.row&&(o+=this.$getTop(t.end.row,r)-s),e.push("
")},this.drawScreenLineMarker=function(e,t,n,r,i){var s=this.$getTop(t.start.row,r),o=r.lineHeight;e.push("
")}}).call(s.prototype),t.Marker=s}),ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/dom"),s=e("../lib/lang"),o=e("../lib/useragent"),u=e("../lib/event_emitter").EventEmitter,a=function(e){this.element=i.createElement("div"),this.element.className="ace_layer ace_text-layer",e.appendChild(this.element),this.$updateEolChar=this.$updateEolChar.bind(this)};(function(){r.implement(this,u),this.EOF_CHAR="\u00b6",this.EOL_CHAR_LF="\u00ac",this.EOL_CHAR_CRLF="\u00a4",this.EOL_CHAR=this.EOL_CHAR_LF,this.TAB_CHAR="\u2192",this.SPACE_CHAR="\u00b7",this.$padding=0,this.$updateEolChar=function(){var e=this.session.doc.getNewLineCharacter()=="\n"?this.EOL_CHAR_LF:this.EOL_CHAR_CRLF;if(this.EOL_CHAR!=e)return this.EOL_CHAR=e,!0},this.setPadding=function(e){this.$padding=e,this.element.style.padding="0 "+e+"px"},this.getLineHeight=function(){return this.$fontMetrics.$characterSize.height||0},this.getCharacterWidth=function(){return this.$fontMetrics.$characterSize.width||0},this.$setFontMetrics=function(e){this.$fontMetrics=e,this.$fontMetrics.on("changeCharacterSize",function(e){this._signal("changeCharacterSize",e)}.bind(this)),this.$pollSizeChanges()},this.checkForSizeChanges=function(){this.$fontMetrics.checkForSizeChanges()},this.$pollSizeChanges=function(){return this.$pollSizeChangesTimer=this.$fontMetrics.$pollSizeChanges()},this.setSession=function(e){this.session=e,e&&this.$computeTabString()},this.showInvisibles=!1,this.setShowInvisibles=function(e){return this.showInvisibles==e?!1:(this.showInvisibles=e,this.$computeTabString(),!0)},this.displayIndentGuides=!0,this.setDisplayIndentGuides=function(e){return this.displayIndentGuides==e?!1:(this.displayIndentGuides=e,this.$computeTabString(),!0)},this.$tabStrings=[],this.onChangeTabSize=this.$computeTabString=function(){var e=this.session.getTabSize();this.tabSize=e;var t=this.$tabStrings=[0];for(var n=1;n"+this.TAB_CHAR+s.stringRepeat("\u00a0",n-1)+""):t.push(s.stringRepeat("\u00a0",n));if(this.displayIndentGuides){this.$indentGuideRe=/\s\S| \t|\t |\s$/;var r="ace_indent-guide",i="",o="";if(this.showInvisibles){r+=" ace_invisible",i=" ace_invisible_space",o=" ace_invisible_tab";var u=s.stringRepeat(this.SPACE_CHAR,this.tabSize),a=this.TAB_CHAR+s.stringRepeat("\u00a0",this.tabSize-1)}else var u=s.stringRepeat("\u00a0",this.tabSize),a=u;this.$tabStrings[" "]=""+u+"",this.$tabStrings[" "]=""+a+""}},this.updateLines=function(e,t,n){(this.config.lastRow!=e.lastRow||this.config.firstRow!=e.firstRow)&&this.scrollLines(e),this.config=e;var r=Math.max(t,e.firstRow),i=Math.min(n,e.lastRow),s=this.element.childNodes,o=0;for(var u=e.firstRow;uf&&(u=a.end.row+1,a=this.session.getNextFoldLine(u,a),f=a?a.start.row:Infinity);if(u>i)break;var l=s[o++];if(l){var c=[];this.$renderLine(c,u,!this.$useLineGroups(),u==f?a:!1),l.style.height=e.lineHeight*this.session.getRowLength(u)+"px",l.innerHTML=c.join("")}u++}},this.scrollLines=function(e){var t=this.config;this.config=e;if(!t||t.lastRow0;r--)n.removeChild(n.firstChild);if(t.lastRow>e.lastRow)for(var r=this.session.getFoldedRowCount(e.lastRow+1,t.lastRow);r>0;r--)n.removeChild(n.lastChild);if(e.firstRowt.lastRow){var i=this.$renderLinesFragment(e,t.lastRow+1,e.lastRow);n.appendChild(i)}},this.$renderLinesFragment=function(e,t,n){var r=this.element.ownerDocument.createDocumentFragment(),s=t,o=this.session.getNextFoldLine(s),u=o?o.start.row:Infinity;for(;;){s>u&&(s=o.end.row+1,o=this.session.getNextFoldLine(s,o),u=o?o.start.row:Infinity);if(s>n)break;var a=i.createElement("div"),f=[];this.$renderLine(f,s,!1,s==u?o:!1),a.innerHTML=f.join("");if(this.$useLineGroups())a.className="ace_line_group",r.appendChild(a),a.style.height=e.lineHeight*this.session.getRowLength(s)+"px";else while(a.firstChild)r.appendChild(a.firstChild);s++}return r},this.update=function(e){this.config=e;var t=[],n=e.firstRow,r=e.lastRow,i=n,s=this.session.getNextFoldLine(i),o=s?s.start.row:Infinity;for(;;){i>o&&(i=s.end.row+1,s=this.session.getNextFoldLine(i,s),o=s?s.start.row:Infinity);if(i>r)break;this.$useLineGroups()&&t.push("
"),this.$renderLine(t,i,!1,i==o?s:!1),this.$useLineGroups()&&t.push("
"),i++}this.element.innerHTML=t.join("")},this.$textToken={text:!0,rparen:!0,lparen:!0},this.$renderToken=function(e,t,n,r){var i=this,o=/\t|&|<|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g,u=function(e,n,r,o,u){if(n)return i.showInvisibles?""+s.stringRepeat(i.SPACE_CHAR,e.length)+"":s.stringRepeat("\u00a0",e.length);if(e=="&")return"&";if(e=="<")return"<";if(e==" "){var a=i.session.getScreenTabSize(t+o);return t+=a-1,i.$tabStrings[a]}if(e=="\u3000"){var f=i.showInvisibles?"ace_cjk ace_invisible ace_invisible_space":"ace_cjk",l=i.showInvisibles?i.SPACE_CHAR:"";return t+=1,""+l+""}return r?""+i.SPACE_CHAR+"":(t+=1,""+e+"")},a=r.replace(o,u);if(!this.$textToken[n.type]){var f="ace_"+n.type.replace(/\./g," ace_"),l="";n.type=="fold"&&(l=" style='width:"+n.value.length*this.config.characterWidth+"px;' "),e.push("",a,"")}else e.push(a);return t+r.length},this.renderIndentGuide=function(e,t,n){var r=t.search(this.$indentGuideRe);return r<=0||r>=n?t:t[0]==" "?(r-=r%this.tabSize,e.push(s.stringRepeat(this.$tabStrings[" "],r/this.tabSize)),t.substr(r)):t[0]==" "?(e.push(s.stringRepeat(this.$tabStrings[" "],r)),t.substr(r)):t},this.$renderWrappedLine=function(e,t,n,r){var i=0,s=0,o=n[0],u=0;for(var a=0;a=o)u=this.$renderToken(e,u,f,l.substring(0,o-i)),l=l.substring(o-i),i=o,r||e.push("","
"),s++,u=0,o=n[s]||Number.MAX_VALUE;l.length!=0&&(i+=l.length,u=this.$renderToken(e,u,f,l))}}},this.$renderSimpleLine=function(e,t){var n=0,r=t[0],i=r.value;this.displayIndentGuides&&(i=this.renderIndentGuide(e,i)),i&&(n=this.$renderToken(e,n,r,i));for(var s=1;s");if(i.length){var s=this.session.getRowSplitData(t);s&&s.length?this.$renderWrappedLine(e,i,s,n):this.$renderSimpleLine(e,i)}this.showInvisibles&&(r&&(t=r.end.row),e.push("",t==this.session.getLength()-1?this.EOF_CHAR:this.EOL_CHAR,"")),n||e.push("
")},this.$getFoldLineTokens=function(e,t){function i(e,t,n){var i=0,s=0;while(s+e[i].value.lengthn-t&&(o=o.substring(0,n-t)),r.push({type:e[i].type,value:o}),s=t+o.length,i+=1}while(sn?r.push({type:e[i].type,value:o.substring(0,n-s)}):r.push(e[i]),s+=o.length,i+=1}}var n=this.session,r=[],s=n.getTokens(e);return t.walk(function(e,t,o,u,a){e!=null?r.push({type:"fold",value:e}):(a&&(s=n.getTokens(t)),s.length&&i(s,u,o))},t.end.row,this.session.getLine(t.end.row).length),r},this.$useLineGroups=function(){return this.session.getUseWrapMode()},this.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.$measureNode&&this.$measureNode.parentNode.removeChild(this.$measureNode),delete this.$measureNode}}).call(a.prototype),t.Text=a}),ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../lib/dom"),i,s=function(e){this.element=r.createElement("div"),this.element.className="ace_layer ace_cursor-layer",e.appendChild(this.element),i===undefined&&(i="opacity"in this.element),this.isVisible=!1,this.isBlinking=!0,this.blinkInterval=1e3,this.smoothBlinking=!1,this.cursors=[],this.cursor=this.addCursor(),r.addCssClass(this.element,"ace_hidden-cursors"),this.$updateCursors=this.$updateVisibility.bind(this)};(function(){this.$updateVisibility=function(e){var t=this.cursors;for(var n=t.length;n--;)t[n].style.visibility=e?"":"hidden"},this.$updateOpacity=function(e){var t=this.cursors;for(var n=t.length;n--;)t[n].style.opacity=e?"":"0"},this.$padding=0,this.setPadding=function(e){this.$padding=e},this.setSession=function(e){this.session=e},this.setBlinking=function(e){e!=this.isBlinking&&(this.isBlinking=e,this.restartTimer())},this.setBlinkInterval=function(e){e!=this.blinkInterval&&(this.blinkInterval=e,this.restartTimer())},this.setSmoothBlinking=function(e){e!=this.smoothBlinking&&!i&&(this.smoothBlinking=e,r.setCssClass(this.element,"ace_smooth-blinking",e),this.$updateCursors(!0),this.$updateCursors=(e?this.$updateOpacity:this.$updateVisibility).bind(this),this.restartTimer())},this.addCursor=function(){var e=r.createElement("div");return e.className="ace_cursor",this.element.appendChild(e),this.cursors.push(e),e},this.removeCursor=function(){if(this.cursors.length>1){var e=this.cursors.pop();return e.parentNode.removeChild(e),e}},this.hideCursor=function(){this.isVisible=!1,r.addCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.showCursor=function(){this.isVisible=!0,r.removeCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.restartTimer=function(){var e=this.$updateCursors;clearInterval(this.intervalId),clearTimeout(this.timeoutId),this.smoothBlinking&&r.removeCssClass(this.element,"ace_smooth-blinking"),e(!0);if(!this.isBlinking||!this.blinkInterval||!this.isVisible)return;this.smoothBlinking&&setTimeout(function(){r.addCssClass(this.element,"ace_smooth-blinking")}.bind(this));var t=function(){this.timeoutId=setTimeout(function(){e(!1)},.6*this.blinkInterval)}.bind(this);this.intervalId=setInterval(function(){e(!0),t()},this.blinkInterval),t()},this.getPixelPosition=function(e,t){if(!this.config||!this.session)return{left:0,top:0};e||(e=this.session.selection.getCursor());var n=this.session.documentToScreenPosition(e),r=this.$padding+n.column*this.config.characterWidth,i=(n.row-(t?this.config.firstRowScreen:0))*this.config.lineHeight;return{left:r,top:i}},this.update=function(e){this.config=e;var t=this.session.$selectionMarkers,n=0,r=0;if(t===undefined||t.length===0)t=[{cursor:null}];for(var n=0,i=t.length;ne.height+e.offset||s.top<0)&&n>1)continue;var o=(this.cursors[r++]||this.addCursor()).style;o.left=s.left+"px",o.top=s.top+"px",o.width=e.characterWidth+"px",o.height=e.lineHeight+"px"}while(this.cursors.length>r)this.removeCursor();var u=this.session.getOverwrite();this.$setOverwrite(u),this.$pixelPos=s,this.restartTimer()},this.$setOverwrite=function(e){e!=this.overwrite&&(this.overwrite=e,e?r.addCssClass(this.element,"ace_overwrite-cursors"):r.removeCssClass(this.element,"ace_overwrite-cursors"))},this.destroy=function(){clearInterval(this.intervalId),clearTimeout(this.timeoutId)}}).call(s.prototype),t.Cursor=s}),ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./lib/event"),o=e("./lib/event_emitter").EventEmitter,u=function(e){this.element=i.createElement("div"),this.element.className="ace_scrollbar ace_scrollbar"+this.classSuffix,this.inner=i.createElement("div"),this.inner.className="ace_scrollbar-inner",this.element.appendChild(this.inner),e.appendChild(this.element),this.setVisible(!1),this.skipEvent=!1,s.addListener(this.element,"scroll",this.onScroll.bind(this)),s.addListener(this.element,"mousedown",s.preventDefault)};(function(){r.implement(this,o),this.setVisible=function(e){this.element.style.display=e?"":"none",this.isVisible=e}}).call(u.prototype);var a=function(e,t){u.call(this,e),this.scrollTop=0,t.$scrollbarWidth=this.width=i.scrollbarWidth(e.ownerDocument),this.inner.style.width=this.element.style.width=(this.width||15)+5+"px"};r.inherits(a,u),function(){this.classSuffix="-v",this.onScroll=function(){this.skipEvent||(this.scrollTop=this.element.scrollTop,this._emit("scroll",{data:this.scrollTop})),this.skipEvent=!1},this.getWidth=function(){return this.isVisible?this.width:0},this.setHeight=function(e){this.element.style.height=e+"px"},this.setInnerHeight=function(e){this.inner.style.height=e+"px"},this.setScrollHeight=function(e){this.inner.style.height=e+"px"},this.setScrollTop=function(e){this.scrollTop!=e&&(this.skipEvent=!0,this.scrollTop=this.element.scrollTop=e)}}.call(a.prototype);var f=function(e,t){u.call(this,e),this.scrollLeft=0,this.height=t.$scrollbarWidth,this.inner.style.height=this.element.style.height=(this.height||15)+5+"px"};r.inherits(f,u),function(){this.classSuffix="-h",this.onScroll=function(){this.skipEvent||(this.scrollLeft=this.element.scrollLeft,this._emit("scroll",{data:this.scrollLeft})),this.skipEvent=!1},this.getHeight=function(){return this.isVisible?this.height:0},this.setWidth=function(e){this.element.style.width=e+"px"},this.setInnerWidth=function(e){this.inner.style.width=e+"px"},this.setScrollWidth=function(e){this.inner.style.width=e+"px"},this.setScrollLeft=function(e){this.scrollLeft!=e&&(this.skipEvent=!0,this.scrollLeft=this.element.scrollLeft=e)}}.call(f.prototype),t.ScrollBar=a,t.ScrollBarV=a,t.ScrollBarH=f,t.VScrollBar=a,t.HScrollBar=f}),ace.define("ace/renderloop",["require","exports","module","ace/lib/event"],function(e,t,n){"use strict";var r=e("./lib/event"),i=function(e,t){this.onRender=e,this.pending=!1,this.changes=0,this.window=t||window};(function(){this.schedule=function(e){this.changes=this.changes|e;if(!this.pending&&this.changes){this.pending=!0;var t=this;r.nextFrame(function(){t.pending=!1;var e;while(e=t.changes)t.changes=0,t.onRender(e)},this.window)}}}).call(i.prototype),t.RenderLoop=i}),ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"],function(e,t,n){var r=e("../lib/oop"),i=e("../lib/dom"),s=e("../lib/lang"),o=e("../lib/useragent"),u=e("../lib/event_emitter").EventEmitter,a=0,f=t.FontMetrics=function(e,t){this.el=i.createElement("div"),this.$setMeasureNodeStyles(this.el.style,!0),this.$main=i.createElement("div"),this.$setMeasureNodeStyles(this.$main.style),this.$measureNode=i.createElement("div"),this.$setMeasureNodeStyles(this.$measureNode.style),this.el.appendChild(this.$main),this.el.appendChild(this.$measureNode),e.appendChild(this.el),a||this.$testFractionalRect(),this.$measureNode.innerHTML=s.stringRepeat("X",a),this.$characterSize={width:0,height:0},this.checkForSizeChanges()};(function(){r.implement(this,u),this.$characterSize={width:0,height:0},this.$testFractionalRect=function(){var e=i.createElement("div");this.$setMeasureNodeStyles(e.style),e.style.width="0.2px",document.documentElement.appendChild(e);var t=e.getBoundingClientRect().width;t>0&&t<1?a=50:a=100,e.parentNode.removeChild(e)},this.$setMeasureNodeStyles=function(e,t){e.width=e.height="auto",e.left=e.top="-100px",e.visibility="hidden",e.position="fixed",e.whiteSpace="pre",o.isIE<8?e["font-family"]="inherit":e.font="inherit",e.overflow=t?"hidden":"visible"},this.checkForSizeChanges=function(){var e=this.$measureSizes();if(e&&(this.$characterSize.width!==e.width||this.$characterSize.height!==e.height)){this.$measureNode.style.fontWeight="bold";var t=this.$measureSizes();this.$measureNode.style.fontWeight="",this.$characterSize=e,this.charSizes=Object.create(null),this.allowBoldFonts=t&&t.width===e.width&&t.height===e.height,this._emit("changeCharacterSize",{data:e})}},this.$pollSizeChanges=function(){if(this.$pollSizeChangesTimer)return this.$pollSizeChangesTimer;var e=this;return this.$pollSizeChangesTimer=setInterval(function(){e.checkForSizeChanges()},500)},this.setPolling=function(e){e?this.$pollSizeChanges():this.$pollSizeChangesTimer&&this.$pollSizeChangesTimer},this.$measureSizes=function(){if(a===50){var e=null;try{e=this.$measureNode.getBoundingClientRect()}catch(t){e={width:0,height:0}}var n={height:e.height,width:e.width/a}}else var n={height:this.$measureNode.clientHeight,width:this.$measureNode.clientWidth/a};return n.width===0||n.height===0?null:n},this.$measureCharWidth=function(e){this.$main.innerHTML=s.stringRepeat(e,a);var t=this.$main.getBoundingClientRect();return t.width/a},this.getCharacterWidth=function(e){var t=this.charSizes[e];return t===undefined&&(this.charSizes[e]=this.$measureCharWidth(e)/this.$characterSize.width),t},this.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)}}).call(f.prototype)}),ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/config","ace/lib/useragent","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./config"),o=e("./lib/useragent"),u=e("./layer/gutter").Gutter,a=e("./layer/marker").Marker,f=e("./layer/text").Text,l=e("./layer/cursor").Cursor,c=e("./scrollbar").HScrollBar,h=e("./scrollbar").VScrollBar,p=e("./renderloop").RenderLoop,d=e("./layer/font_metrics").FontMetrics,v=e("./lib/event_emitter").EventEmitter,m='.ace_editor {position: relative;overflow: hidden;font: 12px/normal \'Monaco\', \'Menlo\', \'Ubuntu Mono\', \'Consolas\', \'source-code-pro\', monospace;direction: ltr;}.ace_scroller {position: absolute;overflow: hidden;top: 0;bottom: 0;background-color: inherit;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;cursor: text;}.ace_content {position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;min-width: 100%;}.ace_dragging .ace_scroller:before{position: absolute;top: 0;left: 0;right: 0;bottom: 0;content: \'\';background: rgba(250, 250, 250, 0.01);z-index: 1000;}.ace_dragging.ace_dark .ace_scroller:before{background: rgba(0, 0, 0, 0.01);}.ace_selecting, .ace_selecting * {cursor: text !important;}.ace_gutter {position: absolute;overflow : hidden;width: auto;top: 0;bottom: 0;left: 0;cursor: default;z-index: 4;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;}.ace_gutter-active-line {position: absolute;left: 0;right: 0;}.ace_scroller.ace_scroll-left {box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;}.ace_gutter-cell {padding-left: 19px;padding-right: 6px;background-repeat: no-repeat;}.ace_gutter-cell.ace_error {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: 2px center;}.ace_gutter-cell.ace_warning {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==");background-position: 2px center;}.ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=");background-position: 2px center;}.ace_dark .ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC");}.ace_scrollbar {position: absolute;right: 0;bottom: 0;z-index: 6;}.ace_scrollbar-inner {position: absolute;cursor: text;left: 0;top: 0;}.ace_scrollbar-v{overflow-x: hidden;overflow-y: scroll;top: 0;}.ace_scrollbar-h {overflow-x: scroll;overflow-y: hidden;left: 0;}.ace_print-margin {position: absolute;height: 100%;}.ace_text-input {position: absolute;z-index: 0;width: 0.5em;height: 1em;opacity: 0;background: transparent;-moz-appearance: none;appearance: none;border: none;resize: none;outline: none;overflow: hidden;font: inherit;padding: 0 1px;margin: 0 -1px;text-indent: -1em;-ms-user-select: text;-moz-user-select: text;-webkit-user-select: text;user-select: text;}.ace_text-input.ace_composition {background: inherit;color: inherit;z-index: 1000;opacity: 1;text-indent: 0;}.ace_layer {z-index: 1;position: absolute;overflow: hidden;white-space: pre;height: 100%;width: 100%;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;pointer-events: none;}.ace_gutter-layer {position: relative;width: auto;text-align: right;pointer-events: auto;}.ace_text-layer {font: inherit !important;}.ace_cjk {display: inline-block;text-align: center;}.ace_cursor-layer {z-index: 4;}.ace_cursor {z-index: 4;position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;border-left: 2px solid}.ace_slim-cursors .ace_cursor {border-left-width: 1px;}.ace_overwrite-cursors .ace_cursor {border-left-width: 0;border-bottom: 1px solid;}.ace_hidden-cursors .ace_cursor {opacity: 0.2;}.ace_smooth-blinking .ace_cursor {-webkit-transition: opacity 0.18s;transition: opacity 0.18s;}.ace_editor.ace_multiselect .ace_cursor {border-left-width: 1px;}.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {position: absolute;z-index: 3;}.ace_marker-layer .ace_selection {position: absolute;z-index: 5;}.ace_marker-layer .ace_bracket {position: absolute;z-index: 6;}.ace_marker-layer .ace_active-line {position: absolute;z-index: 2;}.ace_marker-layer .ace_selected-word {position: absolute;z-index: 4;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;}.ace_line .ace_fold {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;display: inline-block;height: 11px;margin-top: -2px;vertical-align: middle;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=");background-repeat: no-repeat, repeat-x;background-position: center center, top left;color: transparent;border: 1px solid black;border-radius: 2px;cursor: pointer;pointer-events: auto;}.ace_dark .ace_fold {}.ace_fold:hover{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC");}.ace_tooltip {background-color: #FFF;background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));border: 1px solid gray;border-radius: 1px;box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);color: black;max-width: 100%;padding: 3px 4px;position: fixed;z-index: 999999;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;cursor: default;white-space: pre;word-wrap: break-word;line-height: normal;font-style: normal;font-weight: normal;letter-spacing: normal;pointer-events: none;}.ace_folding-enabled > .ace_gutter-cell {padding-right: 13px;}.ace_fold-widget {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0 -12px 0 1px;display: none;width: 11px;vertical-align: top;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: center;border-radius: 3px;border: 1px solid transparent;cursor: pointer;}.ace_folding-enabled .ace_fold-widget {display: inline-block; }.ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==");}.ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==");}.ace_fold-widget:hover {border: 1px solid rgba(0, 0, 0, 0.3);background-color: rgba(255, 255, 255, 0.2);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);}.ace_fold-widget:active {border: 1px solid rgba(0, 0, 0, 0.4);background-color: rgba(0, 0, 0, 0.05);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);}.ace_dark .ace_fold-widget {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC");}.ace_dark .ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget:hover {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);background-color: rgba(255, 255, 255, 0.1);}.ace_dark .ace_fold-widget:active {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);}.ace_fold-widget.ace_invalid {background-color: #FFB4B4;border-color: #DE5555;}.ace_fade-fold-widgets .ace_fold-widget {-webkit-transition: opacity 0.4s ease 0.05s;transition: opacity 0.4s ease 0.05s;opacity: 0;}.ace_fade-fold-widgets:hover .ace_fold-widget {-webkit-transition: opacity 0.05s ease 0.05s;transition: opacity 0.05s ease 0.05s;opacity:1;}.ace_underline {text-decoration: underline;}.ace_bold {font-weight: bold;}.ace_nobold .ace_bold {font-weight: normal;}.ace_italic {font-style: italic;}.ace_error-marker {background-color: rgba(255, 0, 0,0.2);position: absolute;z-index: 9;}.ace_highlight-marker {background-color: rgba(255, 255, 0,0.2);position: absolute;z-index: 8;}';i.importCssString(m,"ace_editor");var g=function(e,t){var n=this;this.container=e||i.createElement("div"),this.$keepTextAreaAtCursor=!o.isOldIE,i.addCssClass(this.container,"ace_editor"),this.setTheme(t),this.$gutter=i.createElement("div"),this.$gutter.className="ace_gutter",this.container.appendChild(this.$gutter),this.scroller=i.createElement("div"),this.scroller.className="ace_scroller",this.container.appendChild(this.scroller),this.content=i.createElement("div"),this.content.className="ace_content",this.scroller.appendChild(this.content),this.$gutterLayer=new u(this.$gutter),this.$gutterLayer.on("changeGutterWidth",this.onGutterResize.bind(this)),this.$markerBack=new a(this.content);var r=this.$textLayer=new f(this.content);this.canvas=r.element,this.$markerFront=new a(this.content),this.$cursorLayer=new l(this.content),this.$horizScroll=!1,this.$vScroll=!1,this.scrollBar=this.scrollBarV=new h(this.container,this),this.scrollBarH=new c(this.container,this),this.scrollBarV.addEventListener("scroll",function(e){n.$scrollAnimation||n.session.setScrollTop(e.data-n.scrollMargin.top)}),this.scrollBarH.addEventListener("scroll",function(e){n.$scrollAnimation||n.session.setScrollLeft(e.data-n.scrollMargin.left)}),this.scrollTop=0,this.scrollLeft=0,this.cursorPos={row:0,column:0},this.$fontMetrics=new d(this.container,500),this.$textLayer.$setFontMetrics(this.$fontMetrics),this.$textLayer.addEventListener("changeCharacterSize",function(e){n.updateCharacterSize(),n.onResize(!0,n.gutterWidth,n.$size.width,n.$size.height),n._signal("changeCharacterSize",e)}),this.$size={width:0,height:0,scrollerHeight:0,scrollerWidth:0,$dirty:!0},this.layerConfig={width:1,padding:0,firstRow:0,firstRowScreen:0,lastRow:0,lineHeight:0,characterWidth:0,minHeight:1,maxHeight:1,offset:0,height:1,gutterOffset:1},this.scrollMargin={left:0,right:0,top:0,bottom:0,v:0,h:0},this.$loop=new p(this.$renderChanges.bind(this),this.container.ownerDocument.defaultView),this.$loop.schedule(this.CHANGE_FULL),this.updateCharacterSize(),this.setPadding(4),s.resetOptions(this),s._emit("renderer",this)};(function(){this.CHANGE_CURSOR=1,this.CHANGE_MARKER=2,this.CHANGE_GUTTER=4,this.CHANGE_SCROLL=8,this.CHANGE_LINES=16,this.CHANGE_TEXT=32,this.CHANGE_SIZE=64,this.CHANGE_MARKER_BACK=128,this.CHANGE_MARKER_FRONT=256,this.CHANGE_FULL=512,this.CHANGE_H_SCROLL=1024,r.implement(this,v),this.updateCharacterSize=function(){this.$textLayer.allowBoldFonts!=this.$allowBoldFonts&&(this.$allowBoldFonts=this.$textLayer.allowBoldFonts,this.setStyle("ace_nobold",!this.$allowBoldFonts)),this.layerConfig.characterWidth=this.characterWidth=this.$textLayer.getCharacterWidth(),this.layerConfig.lineHeight=this.lineHeight=this.$textLayer.getLineHeight(),this.$updatePrintMargin()},this.setSession=function(e){this.session&&this.session.doc.off("changeNewLineMode",this.onChangeNewLineMode),this.session=e,e&&this.scrollMargin.top&&e.getScrollTop()<=0&&e.setScrollTop(-this.scrollMargin.top),this.$cursorLayer.setSession(e),this.$markerBack.setSession(e),this.$markerFront.setSession(e),this.$gutterLayer.setSession(e),this.$textLayer.setSession(e);if(!e)return;this.$loop.schedule(this.CHANGE_FULL),this.session.$setFontMetrics(this.$fontMetrics),this.onChangeNewLineMode=this.onChangeNewLineMode.bind(this),this.onChangeNewLineMode(),this.session.doc.on("changeNewLineMode",this.onChangeNewLineMode)},this.updateLines=function(e,t,n){t===undefined&&(t=Infinity),this.$changedLines?(this.$changedLines.firstRow>e&&(this.$changedLines.firstRow=e),this.$changedLines.lastRowthis.layerConfig.lastRow)return;this.$loop.schedule(this.CHANGE_LINES)},this.onChangeNewLineMode=function(){this.$loop.schedule(this.CHANGE_TEXT),this.$textLayer.$updateEolChar()},this.onChangeTabSize=function(){this.$loop.schedule(this.CHANGE_TEXT|this.CHANGE_MARKER),this.$textLayer.onChangeTabSize()},this.updateText=function(){this.$loop.schedule(this.CHANGE_TEXT)},this.updateFull=function(e){e?this.$renderChanges(this.CHANGE_FULL,!0):this.$loop.schedule(this.CHANGE_FULL)},this.updateFontSize=function(){this.$textLayer.checkForSizeChanges()},this.$changes=0,this.$updateSizeAsync=function(){this.$loop.pending?this.$size.$dirty=!0:this.onResize()},this.onResize=function(e,t,n,r){if(this.resizing>2)return;this.resizing>0?this.resizing++:this.resizing=e?1:0;var i=this.container;r||(r=i.clientHeight||i.scrollHeight),n||(n=i.clientWidth||i.scrollWidth);var s=this.$updateCachedSize(e,t,n,r);if(!this.$size.scrollerHeight||!n&&!r)return this.resizing=0;e&&(this.$gutterLayer.$padding=null),e?this.$renderChanges(s|this.$changes,!0):this.$loop.schedule(s|this.$changes),this.resizing&&(this.resizing=0)},this.$updateCachedSize=function(e,t,n,r){r-=this.$extraHeight||0;var i=0,s=this.$size,o={width:s.width,height:s.height,scrollerHeight:s.scrollerHeight,scrollerWidth:s.scrollerWidth};r&&(e||s.height!=r)&&(s.height=r,i|=this.CHANGE_SIZE,s.scrollerHeight=s.height,this.$horizScroll&&(s.scrollerHeight-=this.scrollBarH.getHeight()),this.scrollBarV.element.style.bottom=this.scrollBarH.getHeight()+"px",i|=this.CHANGE_SCROLL);if(n&&(e||s.width!=n)){i|=this.CHANGE_SIZE,s.width=n,t==null&&(t=this.$showGutter?this.$gutter.offsetWidth:0),this.gutterWidth=t,this.scrollBarH.element.style.left=this.scroller.style.left=t+"px",s.scrollerWidth=Math.max(0,n-t-this.scrollBarV.getWidth()),this.scrollBarH.element.style.right=this.scroller.style.right=this.scrollBarV.getWidth()+"px",this.scroller.style.bottom=this.scrollBarH.getHeight()+"px";if(this.session&&this.session.getUseWrapMode()&&this.adjustWrapLimit()||e)i|=this.CHANGE_FULL}return s.$dirty=!n||!r,i&&this._signal("resize",o),i},this.onGutterResize=function(){var e=this.$showGutter?this.$gutter.offsetWidth:0;e!=this.gutterWidth&&(this.$changes|=this.$updateCachedSize(!0,e,this.$size.width,this.$size.height)),this.session.getUseWrapMode()&&this.adjustWrapLimit()?this.$loop.schedule(this.CHANGE_FULL):this.$size.$dirty?this.$loop.schedule(this.CHANGE_FULL):(this.$computeLayerConfig(),this.$loop.schedule(this.CHANGE_MARKER))},this.adjustWrapLimit=function(){var e=this.$size.scrollerWidth-this.$padding*2,t=Math.floor(e/this.characterWidth);return this.session.adjustWrapLimit(t,this.$showPrintMargin&&this.$printMarginColumn)},this.setAnimatedScroll=function(e){this.setOption("animatedScroll",e)},this.getAnimatedScroll=function(){return this.$animatedScroll},this.setShowInvisibles=function(e){this.setOption("showInvisibles",e)},this.getShowInvisibles=function(){return this.getOption("showInvisibles")},this.getDisplayIndentGuides=function(){return this.getOption("displayIndentGuides")},this.setDisplayIndentGuides=function(e){this.setOption("displayIndentGuides",e)},this.setShowPrintMargin=function(e){this.setOption("showPrintMargin",e)},this.getShowPrintMargin=function(){return this.getOption("showPrintMargin")},this.setPrintMarginColumn=function(e){this.setOption("printMarginColumn",e)},this.getPrintMarginColumn=function(){return this.getOption("printMarginColumn")},this.getShowGutter=function(){return this.getOption("showGutter")},this.setShowGutter=function(e){return this.setOption("showGutter",e)},this.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},this.setFadeFoldWidgets=function(e){this.setOption("fadeFoldWidgets",e)},this.setHighlightGutterLine=function(e){this.setOption("highlightGutterLine",e)},this.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},this.$updateGutterLineHighlight=function(){var e=this.$cursorLayer.$pixelPos,t=this.layerConfig.lineHeight;if(this.session.getUseWrapMode()){var n=this.session.selection.getCursor();n.column=0,e=this.$cursorLayer.getPixelPosition(n,!0),t*=this.session.getRowLength(n.row)}this.$gutterLineHighlight.style.top=e.top-this.layerConfig.offset+"px",this.$gutterLineHighlight.style.height=t+"px"},this.$updatePrintMargin=function(){if(!this.$showPrintMargin&&!this.$printMarginEl)return;if(!this.$printMarginEl){var e=i.createElement("div");e.className="ace_layer ace_print-margin-layer",this.$printMarginEl=i.createElement("div"),this.$printMarginEl.className="ace_print-margin",e.appendChild(this.$printMarginEl),this.content.insertBefore(e,this.content.firstChild)}var t=this.$printMarginEl.style;t.left=this.characterWidth*this.$printMarginColumn+this.$padding+"px",t.visibility=this.$showPrintMargin?"visible":"hidden",this.session&&this.session.$wrap==-1&&this.adjustWrapLimit()},this.getContainerElement=function(){return this.container},this.getMouseEventTarget=function(){return this.content},this.getTextAreaContainer=function(){return this.container},this.$moveTextAreaToCursor=function(){if(!this.$keepTextAreaAtCursor)return;var e=this.layerConfig,t=this.$cursorLayer.$pixelPos.top,n=this.$cursorLayer.$pixelPos.left;t-=e.offset;var r=this.lineHeight;if(t<0||t>e.height-r)return;var i=this.characterWidth;if(this.$composition){var s=this.textarea.value.replace(/^\x01+/,"");i*=this.session.$getStringScreenWidth(s)[0]+2,r+=2}n-=this.scrollLeft,n>this.$size.scrollerWidth-i&&(n=this.$size.scrollerWidth-i),n+=this.gutterWidth,this.textarea.style.height=r+"px",this.textarea.style.width=i+"px",this.textarea.style.left=Math.min(n,this.$size.scrollerWidth-i)+"px",this.textarea.style.top=Math.min(t,this.$size.height-r)+"px"},this.getFirstVisibleRow=function(){return this.layerConfig.firstRow},this.getFirstFullyVisibleRow=function(){return this.layerConfig.firstRow+(this.layerConfig.offset===0?0:1)},this.getLastFullyVisibleRow=function(){var e=Math.floor((this.layerConfig.height+this.layerConfig.offset)/this.layerConfig.lineHeight);return this.layerConfig.firstRow-1+e},this.getLastVisibleRow=function(){return this.layerConfig.lastRow},this.$padding=null,this.setPadding=function(e){this.$padding=e,this.$textLayer.setPadding(e),this.$cursorLayer.setPadding(e),this.$markerFront.setPadding(e),this.$markerBack.setPadding(e),this.$loop.schedule(this.CHANGE_FULL),this.$updatePrintMargin()},this.setScrollMargin=function(e,t,n,r){var i=this.scrollMargin;i.top=e|0,i.bottom=t|0,i.right=r|0,i.left=n|0,i.v=i.top+i.bottom,i.h=i.left+i.right,i.top&&this.scrollTop<=0&&this.session&&this.session.setScrollTop(-i.top),this.updateFull()},this.getHScrollBarAlwaysVisible=function(){return this.$hScrollBarAlwaysVisible},this.setHScrollBarAlwaysVisible=function(e){this.setOption("hScrollBarAlwaysVisible",e)},this.getVScrollBarAlwaysVisible=function(){return this.$hScrollBarAlwaysVisible},this.setVScrollBarAlwaysVisible=function(e){this.setOption("vScrollBarAlwaysVisible",e)},this.$updateScrollBarV=function(){var e=this.layerConfig.maxHeight,t=this.$size.scrollerHeight;!this.$maxLines&&this.$scrollPastEnd&&(e-=(t-this.lineHeight)*this.$scrollPastEnd,this.scrollTop>e-t&&(e=this.scrollTop+t,this.scrollBarV.scrollTop=null)),this.scrollBarV.setScrollHeight(e+this.scrollMargin.v),this.scrollBarV.setScrollTop(this.scrollTop+this.scrollMargin.top)},this.$updateScrollBarH=function(){this.scrollBarH.setScrollWidth(this.layerConfig.width+2*this.$padding+this.scrollMargin.h),this.scrollBarH.setScrollLeft(this.scrollLeft+this.scrollMargin.left)},this.$frozen=!1,this.freeze=function(){this.$frozen=!0},this.unfreeze=function(){this.$frozen=!1},this.$renderChanges=function(e,t){this.$changes&&(e|=this.$changes,this.$changes=0);if(!this.session||!this.container.offsetWidth||this.$frozen||!e&&!t){this.$changes|=e;return}if(this.$size.$dirty)return this.$changes|=e,this.onResize(!0);this.lineHeight||this.$textLayer.checkForSizeChanges(),this._signal("beforeRender");var n=this.layerConfig;if(e&this.CHANGE_FULL||e&this.CHANGE_SIZE||e&this.CHANGE_TEXT||e&this.CHANGE_LINES||e&this.CHANGE_SCROLL||e&this.CHANGE_H_SCROLL){e|=this.$computeLayerConfig();if(n.firstRow!=this.layerConfig.firstRow&&n.firstRowScreen==this.layerConfig.firstRowScreen){var r=this.scrollTop+(n.firstRow-this.layerConfig.firstRow)*this.lineHeight;r>0&&(this.scrollTop=r,e|=this.CHANGE_SCROLL,e|=this.$computeLayerConfig())}n=this.layerConfig,this.$updateScrollBarV(),e&this.CHANGE_H_SCROLL&&this.$updateScrollBarH(),this.$gutterLayer.element.style.marginTop=-n.offset+"px",this.content.style.marginTop=-n.offset+"px",this.content.style.width=n.width+2*this.$padding+"px",this.content.style.height=n.minHeight+"px"}e&this.CHANGE_H_SCROLL&&(this.content.style.marginLeft=-this.scrollLeft+"px",this.scroller.className=this.scrollLeft<=0?"ace_scroller":"ace_scroller ace_scroll-left");if(e&this.CHANGE_FULL){this.$textLayer.update(n),this.$showGutter&&this.$gutterLayer.update(n),this.$markerBack.update(n),this.$markerFront.update(n),this.$cursorLayer.update(n),this.$moveTextAreaToCursor(),this.$highlightGutterLine&&this.$updateGutterLineHighlight(),this._signal("afterRender");return}if(e&this.CHANGE_SCROLL){e&this.CHANGE_TEXT||e&this.CHANGE_LINES?this.$textLayer.update(n):this.$textLayer.scrollLines(n),this.$showGutter&&this.$gutterLayer.update(n),this.$markerBack.update(n),this.$markerFront.update(n),this.$cursorLayer.update(n),this.$highlightGutterLine&&this.$updateGutterLineHighlight(),this.$moveTextAreaToCursor(),this._signal("afterRender");return}e&this.CHANGE_TEXT?(this.$textLayer.update(n),this.$showGutter&&this.$gutterLayer.update(n)):e&this.CHANGE_LINES?(this.$updateLines()||e&this.CHANGE_GUTTER&&this.$showGutter)&&this.$gutterLayer.update(n):(e&this.CHANGE_TEXT||e&this.CHANGE_GUTTER)&&this.$showGutter&&this.$gutterLayer.update(n),e&this.CHANGE_CURSOR&&(this.$cursorLayer.update(n),this.$moveTextAreaToCursor(),this.$highlightGutterLine&&this.$updateGutterLineHighlight()),e&(this.CHANGE_MARKER|this.CHANGE_MARKER_FRONT)&&this.$markerFront.update(n),e&(this.CHANGE_MARKER|this.CHANGE_MARKER_BACK)&&this.$markerBack.update(n),this._signal("afterRender")},this.$autosize=function(){var e=this.session.getScreenLength()*this.lineHeight,t=this.$maxLines*this.lineHeight,n=Math.max((this.$minLines||1)*this.lineHeight,Math.min(t,e))+this.scrollMargin.v+(this.$extraHeight||0),r=e>t;if(n!=this.desiredHeight||this.$size.height!=this.desiredHeight||r!=this.$vScroll){r!=this.$vScroll&&(this.$vScroll=r,this.scrollBarV.setVisible(r));var i=this.container.clientWidth;this.container.style.height=n+"px",this.$updateCachedSize(!0,this.$gutterWidth,i,n),this.desiredHeight=n,this._signal("autosize")}},this.$computeLayerConfig=function(){this.$maxLines&&this.lineHeight>1&&this.$autosize();var e=this.session,t=this.$size,n=t.height<=2*this.lineHeight,r=this.session.getScreenLength(),i=r*this.lineHeight,s=this.scrollTop%this.lineHeight,o=t.scrollerHeight+this.lineHeight,u=this.$getLongestLine(),a=!n&&(this.$hScrollBarAlwaysVisible||t.scrollerWidth-u-2*this.$padding<0),f=this.$horizScroll!==a;f&&(this.$horizScroll=a,this.scrollBarH.setVisible(a));var l=!this.$maxLines&&this.$scrollPastEnd?(t.scrollerHeight-this.lineHeight)*this.$scrollPastEnd:0;i+=l,this.session.setScrollTop(Math.max(-this.scrollMargin.top,Math.min(this.scrollTop,i-t.scrollerHeight+this.scrollMargin.bottom))),this.session.setScrollLeft(Math.max(-this.scrollMargin.left,Math.min(this.scrollLeft,u+2*this.$padding-t.scrollerWidth+this.scrollMargin.right)));var c=!n&&(this.$vScrollBarAlwaysVisible||t.scrollerHeight-i+l<0||this.scrollTop),h=this.$vScroll!==c;h&&(this.$vScroll=c,this.scrollBarV.setVisible(c));var p=Math.ceil(o/this.lineHeight)-1,d=Math.max(0,Math.round((this.scrollTop-s)/this.lineHeight)),v=d+p,m,g,y=this.lineHeight;d=e.screenToDocumentRow(d,0);var b=e.getFoldLine(d);b&&(d=b.start.row),m=e.documentToScreenRow(d,0),g=e.getRowLength(d)*y,v=Math.min(e.screenToDocumentRow(v,0),e.getLength()-1),o=t.scrollerHeight+e.getRowLength(v)*y+g,s=this.scrollTop-m*y;var w=0;this.layerConfig.width!=u&&(w=this.CHANGE_H_SCROLL);if(f||h)w=this.$updateCachedSize(!0,this.gutterWidth,t.width,t.height),this._signal("scrollbarVisibilityChanged"),h&&(u=this.$getLongestLine());return this.layerConfig={width:u,padding:this.$padding,firstRow:d,firstRowScreen:m,lastRow:v,lineHeight:y,characterWidth:this.characterWidth,minHeight:o,maxHeight:i,offset:s,gutterOffset:Math.max(0,Math.ceil((s+t.height-t.scrollerHeight)/y)),height:this.$size.scrollerHeight},w},this.$updateLines=function(){var e=this.$changedLines.firstRow,t=this.$changedLines.lastRow;this.$changedLines=null;var n=this.layerConfig;if(e>n.lastRow+1)return;if(ts?(t&&(s-=t*this.$size.scrollerHeight),s===0&&(s=-this.scrollMargin.top),this.session.setScrollTop(s)):a+this.$size.scrollerHeight-ui?(i=1-this.scrollMargin.top)return!0;if(t>0&&this.session.getScrollTop()+this.$size.scrollerHeight-this.layerConfig.maxHeight<-1+this.scrollMargin.bottom)return!0;if(e<0&&this.session.getScrollLeft()>=1-this.scrollMargin.left)return!0;if(e>0&&this.session.getScrollLeft()+this.$size.scrollerWidth-this.layerConfig.width<-1+this.scrollMargin.right)return!0},this.pixelToScreenCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=(e+this.scrollLeft-n.left-this.$padding)/this.characterWidth,i=Math.floor((t+this.scrollTop-n.top)/this.lineHeight),s=Math.round(r);return{row:i,column:s,side:r-s>0?1:-1}},this.screenToTextCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=Math.round((e+this.scrollLeft-n.left-this.$padding)/this.characterWidth),i=(t+this.scrollTop-n.top)/this.lineHeight;return this.session.screenToDocumentPosition(i,Math.max(r,0))},this.textToScreenCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=this.session.documentToScreenPosition(e,t),i=this.$padding+Math.round(r.column*this.characterWidth),s=r.row*this.lineHeight;return{pageX:n.left+i-this.scrollLeft,pageY:n.top+s-this.scrollTop}},this.visualizeFocus=function(){i.addCssClass(this.container,"ace_focus")},this.visualizeBlur=function(){i.removeCssClass(this.container,"ace_focus")},this.showComposition=function(e){this.$composition||(this.$composition={keepTextAreaAtCursor:this.$keepTextAreaAtCursor,cssText:this.textarea.style.cssText}),this.$keepTextAreaAtCursor=!0,i.addCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText="",this.$moveTextAreaToCursor()},this.setCompositionText=function(e){this.$moveTextAreaToCursor()},this.hideComposition=function(){if(!this.$composition)return;i.removeCssClass(this.textarea,"ace_composition"),this.$keepTextAreaAtCursor=this.$composition.keepTextAreaAtCursor,this.textarea.style.cssText=this.$composition.cssText,this.$composition=null},this.setTheme=function(e,t){function o(r){if(n.$themeId!=e)return t&&t();if(!r.cssClass)return;i.importCssString(r.cssText,r.cssClass,n.container.ownerDocument),n.theme&&i.removeCssClass(n.container,n.theme.cssClass);var s="padding"in r?r.padding:"padding"in(n.theme||{})?4:n.$padding;n.$padding&&s!=n.$padding&&n.setPadding(s),n.$theme=r.cssClass,n.theme=r,i.addCssClass(n.container,r.cssClass),i.setCssClass(n.container,"ace_dark",r.isDark),n.$size&&(n.$size.width=0,n.$updateSizeAsync()),n._dispatchEvent("themeLoaded",{theme:r}),t&&t()}var n=this;this.$themeId=e,n._dispatchEvent("themeChange",{theme:e});if(!e||typeof e=="string"){var r=e||this.$options.theme.initialValue;s.loadModule(["theme",r],o)}else o(e)},this.getTheme=function(){return this.$themeId},this.setStyle=function(e,t){i.setCssClass(this.container,e,t!==!1)},this.unsetStyle=function(e){i.removeCssClass(this.container,e)},this.setCursorStyle=function(e){this.scroller.style.cursor!=e&&(this.scroller.style.cursor=e)},this.setMouseCursor=function(e){this.scroller.style.cursor=e},this.destroy=function(){this.$textLayer.destroy(),this.$cursorLayer.destroy()}}).call(g.prototype),s.defineOptions(g.prototype,"renderer",{animatedScroll:{initialValue:!1},showInvisibles:{set:function(e){this.$textLayer.setShowInvisibles(e)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!1},showPrintMargin:{set:function(){this.$updatePrintMargin()},initialValue:!0},printMarginColumn:{set:function(){this.$updatePrintMargin()},initialValue:80},printMargin:{set:function(e){typeof e=="number"&&(this.$printMarginColumn=e),this.$showPrintMargin=!!e,this.$updatePrintMargin()},get:function(){return this.$showPrintMargin&&this.$printMarginColumn}},showGutter:{set:function(e){this.$gutter.style.display=e?"block":"none",this.$loop.schedule(this.CHANGE_FULL),this.onGutterResize()},initialValue:!0},fadeFoldWidgets:{set:function(e){i.setCssClass(this.$gutter,"ace_fade-fold-widgets",e)},initialValue:!1},showFoldWidgets:{set:function(e){this.$gutterLayer.setShowFoldWidgets(e)},initialValue:!0},showLineNumbers:{set:function(e){this.$gutterLayer.setShowLineNumbers(e),this.$loop.schedule(this.CHANGE_GUTTER)},initialValue:!0},displayIndentGuides:{set:function(e){this.$textLayer.setDisplayIndentGuides(e)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!0},highlightGutterLine:{set:function(e){if(!this.$gutterLineHighlight){this.$gutterLineHighlight=i.createElement("div"),this.$gutterLineHighlight.className="ace_gutter-active-line",this.$gutter.appendChild(this.$gutterLineHighlight);return}this.$gutterLineHighlight.style.display=e?"":"none",this.$cursorLayer.$pixelPos&&this.$updateGutterLineHighlight()},initialValue:!1,value:!0},hScrollBarAlwaysVisible:{set:function(e){(!this.$hScrollBarAlwaysVisible||!this.$horizScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},vScrollBarAlwaysVisible:{set:function(e){(!this.$vScrollBarAlwaysVisible||!this.$vScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},fontSize:{set:function(e){typeof e=="number"&&(e+="px"),this.container.style.fontSize=e,this.updateFontSize()},initialValue:12},fontFamily:{set:function(e){this.container.style.fontFamily=e,this.updateFontSize()}},maxLines:{set:function(e){this.updateFull()}},minLines:{set:function(e){this.updateFull()}},scrollPastEnd:{set:function(e){e=+e||0;if(this.$scrollPastEnd==e)return;this.$scrollPastEnd=e,this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:0,handlesSet:!0},fixedWidthGutter:{set:function(e){this.$gutterLayer.$fixedWidth=!!e,this.$loop.schedule(this.CHANGE_GUTTER)}},theme:{set:function(e){this.setTheme(e)},get:function(){return this.$themeId||this.theme},initialValue:"./theme/textmate",handlesSet:!0}}),t.VirtualRenderer=g}),ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/net"),s=e("../lib/event_emitter").EventEmitter,o=e("../config"),u=function(t,n,r,i){this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.onMessage=this.onMessage.bind(this),e.nameToUrl&&!e.toUrl&&(e.toUrl=e.nameToUrl);if(o.get("packaged")||!e.toUrl)i=i||o.moduleUrl(n,"worker");else{var s=this.$normalizePath;i=i||s(e.toUrl("ace/worker/worker.js",null,"_"));var u={};t.forEach(function(t){u[t]=s(e.toUrl(t,null,"_").replace(/(\.js)?(\?.*)?$/,""))})}try{this.$worker=new Worker(i)}catch(a){if(!(a instanceof window.DOMException))throw a;var f=this.$workerBlob(i),l=window.URL||window.webkitURL,c=l.createObjectURL(f);this.$worker=new Worker(c),l.revokeObjectURL(c)}this.$worker.postMessage({init:!0,tlns:u,module:n,classname:r}),this.callbackId=1,this.callbacks={},this.$worker.onmessage=this.onMessage};(function(){r.implement(this,s),this.onMessage=function(e){var t=e.data;switch(t.type){case"event":this._signal(t.name,{data:t.data});break;case"call":var n=this.callbacks[t.id];n&&(n(t.data),delete this.callbacks[t.id]);break;case"error":this.reportError(t.data);break;case"log":window.console&&console.log&&console.log.apply(console,t.data)}},this.reportError=function(e){window.console&&console.error&&console.error(e)},this.$normalizePath=function(e){return i.qualifyURL(e)},this.terminate=function(){this._signal("terminate",{}),this.deltaQueue=null,this.$worker.terminate(),this.$worker=null,this.$doc&&this.$doc.off("change",this.changeListener),this.$doc=null},this.send=function(e,t){this.$worker.postMessage({command:e,args:t})},this.call=function(e,t,n){if(n){var r=this.callbackId++;this.callbacks[r]=n,t.push(r)}this.send(e,t)},this.emit=function(e,t){try{this.$worker.postMessage({event:e,data:{data:t.data}})}catch(n){console.error(n.stack)}},this.attachToDocument=function(e){this.$doc&&this.terminate(),this.$doc=e,this.call("setValue",[e.getValue()]),e.on("change",this.changeListener)},this.changeListener=function(e){this.deltaQueue?this.deltaQueue.push(e.data):(this.deltaQueue=[e.data],setTimeout(this.$sendDeltaQueue,0))},this.$sendDeltaQueue=function(){var e=this.deltaQueue;if(!e)return;this.deltaQueue=null,e.length>20&&e.length>this.$doc.getLength()>>1?this.call("setValue",[this.$doc.getValue()]):this.emit("change",{data:e})},this.$workerBlob=function(e){var t="importScripts('"+i.qualifyURL(e)+"');";try{return new Blob([t],{type:"application/javascript"})}catch(n){var r=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,s=new r;return s.append(t),s.getBlob("application/javascript")}}}).call(u.prototype);var a=function(e,t,n){this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.callbackId=1,this.callbacks={},this.messageBuffer=[];var r=null,i=!1,u=Object.create(s),a=this;this.$worker={},this.$worker.terminate=function(){},this.$worker.postMessage=function(e){a.messageBuffer.push(e),r&&(i?setTimeout(f):f())},this.setEmitSync=function(e){i=e};var f=function(){var e=a.messageBuffer.shift();e.command?r[e.command].apply(r,e.args):e.event&&u._signal(e.event,e.data)};u.postMessage=function(e){a.onMessage({data:e})},u.callback=function(e,t){this.postMessage({type:"call",id:t,data:e})},u.emit=function(e,t){this.postMessage({type:"event",name:e,data:t})},o.loadModule(["worker",t],function(e){r=new e[n](u);while(a.messageBuffer.length)f()})};a.prototype=u.prototype,t.UIWorkerClient=a,t.WorkerClient=u}),ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"],function(e,t,n){"use strict";var r=e("./range").Range,i=e("./lib/event_emitter").EventEmitter,s=e("./lib/oop"),o=function(e,t,n,r,i,s){var o=this;this.length=t,this.session=e,this.doc=e.getDocument(),this.mainClass=i,this.othersClass=s,this.$onUpdate=this.onUpdate.bind(this),this.doc.on("change",this.$onUpdate),this.$others=r,this.$onCursorChange=function(){setTimeout(function(){o.onCursorChange()})},this.$pos=n;var u=e.getUndoManager().$undoStack||e.getUndoManager().$undostack||{length:-1};this.$undoStackDepth=u.length,this.setup(),e.selection.on("changeCursor",this.$onCursorChange)};(function(){s.implement(this,i),this.setup=function(){var e=this,t=this.doc,n=this.session,i=this.$pos;this.selectionBefore=n.selection.toJSON(),n.selection.inMultiSelectMode&&n.selection.toSingleRange(),this.pos=t.createAnchor(i.row,i.column),this.markerId=n.addMarker(new r(i.row,i.column,i.row,i.column+this.length),this.mainClass,null,!1),this.pos.on("change",function(t){n.removeMarker(e.markerId),e.markerId=n.addMarker(new r(t.value.row,t.value.column,t.value.row,t.value.column+e.length),e.mainClass,null,!1)}),this.others=[],this.$others.forEach(function(n){var r=t.createAnchor(n.row,n.column);e.others.push(r)}),n.setUndoSelect(!1)},this.showOtherMarkers=function(){if(this.othersActive)return;var e=this.session,t=this;this.othersActive=!0,this.others.forEach(function(n){n.markerId=e.addMarker(new r(n.row,n.column,n.row,n.column+t.length),t.othersClass,null,!1),n.on("change",function(i){e.removeMarker(n.markerId),n.markerId=e.addMarker(new r(i.value.row,i.value.column,i.value.row,i.value.column+t.length),t.othersClass,null,!1)})})},this.hideOtherMarkers=function(){if(!this.othersActive)return;this.othersActive=!1;for(var e=0;e=this.pos.column&&n.start.column<=this.pos.column+this.length+1){var s=n.start.column-this.pos.column;this.length+=i;if(!this.session.$fromUndo){if(t.action==="insertText")for(var o=this.others.length-1;o>=0;o--){var u=this.others[o],a={row:u.row,column:u.column+s};u.row===n.start.row&&n.start.column=0;o--){var u=this.others[o],a={row:u.row,column:u.column+s};u.row===n.start.row&&n.start.column=this.pos.column&&t.column<=this.pos.column+this.length?(this.showOtherMarkers(),this._emit("cursorEnter",e)):(this.hideOtherMarkers(),this._emit("cursorLeave",e))},this.detach=function(){this.session.removeMarker(this.markerId),this.hideOtherMarkers(),this.doc.removeEventListener("change",this.$onUpdate),this.session.selection.removeEventListener("changeCursor",this.$onCursorChange),this.pos.detach();for(var e=0;e1&&!this.inMultiSelectMode&&(this._signal("multiSelect"),this.inMultiSelectMode=!0,this.session.$undoSelect=!1,this.rangeList.attach(this.session)),t||this.fromOrientedRange(e)},this.toSingleRange=function(e){e=e||this.ranges[0];var t=this.rangeList.removeAll();t.length&&this.$onRemoveRange(t),e&&this.fromOrientedRange(e)},this.substractPoint=function(e){var t=this.rangeList.substractPoint(e);if(t)return this.$onRemoveRange(t),t[0]},this.mergeOverlappingRanges=function(){var e=this.rangeList.merge();e.length?this.$onRemoveRange(e):this.ranges[0]&&this.fromOrientedRange(this.ranges[0])},this.$onAddRange=function(e){this.rangeCount=this.rangeList.ranges.length,this.ranges.unshift(e),this._signal("addRange",{range:e})},this.$onRemoveRange=function(e){this.rangeCount=this.rangeList.ranges.length;if(this.rangeCount==1&&this.inMultiSelectMode){var t=this.rangeList.ranges.pop();e.push(t),this.rangeCount=0}for(var n=e.length;n--;){var r=this.ranges.indexOf(e[n]);this.ranges.splice(r,1)}this._signal("removeRange",{ranges:e}),this.rangeCount===0&&this.inMultiSelectMode&&(this.inMultiSelectMode=!1,this._signal("singleSelect"),this.session.$undoSelect=!0,this.rangeList.detach(this.session)),t=t||this.ranges[0],t&&!t.isEqual(this.getRange())&&this.fromOrientedRange(t)},this.$initRangeList=function(){if(this.rangeList)return;this.rangeList=new r,this.ranges=[],this.rangeCount=0},this.getAllRanges=function(){return this.rangeCount?this.rangeList.ranges.concat():[this.getRange()]},this.splitIntoLines=function(){if(this.rangeCount>1){var e=this.rangeList.ranges,t=e[e.length-1],n=i.fromPoints(e[0].start,t.end);this.toSingleRange(),this.setSelectionRange(n,t.cursor==t.start)}else{var n=this.getRange(),r=this.isBackwards(),s=n.start.row,o=n.end.row;if(s==o){if(r)var u=n.end,a=n.start;else var u=n.start,a=n.end;this.addRange(i.fromPoints(a,a)),this.addRange(i.fromPoints(u,u));return}var f=[],l=this.getLineRange(s,!0);l.start.column=n.start.column,f.push(l);for(var c=s+1;c1){var e=this.rangeList.ranges,t=e[e.length-1],n=i.fromPoints(e[0].start,t.end);this.toSingleRange(),this.setSelectionRange(n,t.cursor==t.start)}else{var r=this.session.documentToScreenPosition(this.selectionLead),s=this.session.documentToScreenPosition(this.selectionAnchor),o=this.rectangularRangeBlock(r,s);o.forEach(this.addRange,this)}},this.rectangularRangeBlock=function(e,t,n){var r=[],s=e.column0)d--;if(d>0){var m=0;while(r[m].isEmpty())m++}for(var g=d;g>=m;g--)r[g].isEmpty()&&r.splice(g,1)}return r}}.call(s.prototype);var d=e("./editor").Editor;(function(){this.updateSelectionMarkers=function(){this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.addSelectionMarker=function(e){e.cursor||(e.cursor=e.end);var t=this.getSelectionStyle();return e.marker=this.session.addMarker(e,"ace_selection",t),this.session.$selectionMarkers.push(e),this.session.selectionMarkerCount=this.session.$selectionMarkers.length,e},this.removeSelectionMarker=function(e){if(!e.marker)return;this.session.removeMarker(e.marker);var t=this.session.$selectionMarkers.indexOf(e);t!=-1&&this.session.$selectionMarkers.splice(t,1),this.session.selectionMarkerCount=this.session.$selectionMarkers.length},this.removeSelectionMarkers=function(e){var t=this.session.$selectionMarkers;for(var n=e.length;n--;){var r=e[n];if(!r.marker)continue;this.session.removeMarker(r.marker);var i=t.indexOf(r);i!=-1&&t.splice(i,1)}this.session.selectionMarkerCount=t.length},this.$onAddRange=function(e){this.addSelectionMarker(e.range),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onRemoveRange=function(e){this.removeSelectionMarkers(e.ranges),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onMultiSelect=function(e){if(this.inMultiSelectMode)return;this.inMultiSelectMode=!0,this.setStyle("ace_multiselect"),this.keyBinding.addKeyboardHandler(f.keyboardHandler),this.commands.setDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onSingleSelect=function(e){if(this.session.multiSelect.inVirtualMode)return;this.inMultiSelectMode=!1,this.unsetStyle("ace_multiselect"),this.keyBinding.removeKeyboardHandler(f.keyboardHandler),this.commands.removeDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers(),this._emit("changeSelection")},this.$onMultiSelectExec=function(e){var t=e.command,n=e.editor;if(!n.multiSelect)return;if(!t.multiSelectAction){var r=t.exec(n,e.args||{});n.multiSelect.addRange(n.multiSelect.toOrientedRange()),n.multiSelect.mergeOverlappingRanges()}else t.multiSelectAction=="forEach"?r=n.forEachSelection(t,e.args):t.multiSelectAction=="forEachLine"?r=n.forEachSelection(t,e.args,!0):t.multiSelectAction=="single"?(n.exitMultiSelectMode(),r=t.exec(n,e.args||{})):r=t.multiSelectAction(n,e.args||{});return r},this.forEachSelection=function(e,t,n){if(this.inVirtualSelectionMode)return;var r=n&&n.keepOrder,i=n==1||n&&n.$byLines,o=this.session,u=this.selection,a=u.rangeList,f=(r?u:a).ranges,l;if(!f.length)return e.exec?e.exec(this,t||{}):e(this,t||{});var c=u._eventRegistry;u._eventRegistry={};var h=new s(o);this.inVirtualSelectionMode=!0;for(var p=f.length;p--;){if(i)while(p>0&&f[p].start.row==f[p-1].end.row)p--;h.fromOrientedRange(f[p]),h.index=p,this.selection=o.selection=h;var d=e.exec?e.exec(this,t||{}):e(this,t||{});!l&&d!==undefined&&(l=d),h.toOrientedRange(f[p])}h.detach(),this.selection=o.selection=u,this.inVirtualSelectionMode=!1,u._eventRegistry=c,u.mergeOverlappingRanges();var v=this.renderer.$scrollAnimation;return this.onCursorChange(),this.onSelectionChange(),v&&v.from==v.to&&this.renderer.animateScrolling(v.from),l},this.exitMultiSelectMode=function(){if(!this.inMultiSelectMode||this.inVirtualSelectionMode)return;this.multiSelect.toSingleRange()},this.getSelectedText=function(){var e="";if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){var t=this.multiSelect.rangeList.ranges,n=[];for(var r=0;rr.length||n.length<2||!n[1])return this.commands.exec("insertstring",this,e);for(var i=r.length;i--;){var s=r[i];s.isEmpty()||this.session.remove(s),this.session.insert(s.start,n[i])}},this.findAll=function(e,t,n){t=t||{},t.needle=e||t.needle;if(t.needle==undefined){var r=this.selection.isEmpty()?this.selection.getWordRange():this.selection.getRange();t.needle=this.session.getTextRange(r)}this.$search.set(t);var i=this.$search.findAll(this.session);if(!i.length)return 0;this.$blockScrolling+=1;var s=this.multiSelect;n||s.toSingleRange(i[0]);for(var o=i.length;o--;)s.addRange(i[o],!0);return r&&s.rangeList.rangeAtPoint(r.start)&&s.addRange(r,!0),this.$blockScrolling-=1,i.length},this.selectMoreLines=function(e,t){var n=this.selection.toOrientedRange(),r=n.cursor==n.end,s=this.session.documentToScreenPosition(n.cursor);this.selection.$desiredColumn&&(s.column=this.selection.$desiredColumn);var o=this.session.screenToDocumentPosition(s.row+e,s.column);if(!n.isEmpty())var u=this.session.documentToScreenPosition(r?n.end:n.start),a=this.session.screenToDocumentPosition(u.row+e,u.column);else var a=o;if(r){var f=i.fromPoints(o,a);f.cursor=f.start}else{var f=i.fromPoints(a,o);f.cursor=f.end}f.desiredColumn=s.column;if(!this.selection.inMultiSelectMode)this.selection.addRange(n);else if(t)var l=n.cursor;this.selection.addRange(f),l&&this.selection.substractPoint(l)},this.transposeSelections=function(e){var t=this.session,n=t.multiSelect,r=n.ranges;for(var i=r.length;i--;){var s=r[i];if(s.isEmpty()){var o=t.getWordRange(s.start.row,s.start.column);s.start.row=o.start.row,s.start.column=o.start.column,s.end.row=o.end.row,s.end.column=o.end.column}}n.mergeOverlappingRanges();var u=[];for(var i=r.length;i--;){var s=r[i];u.unshift(t.getTextRange(s))}e<0?u.unshift(u.pop()):u.push(u.shift());for(var i=r.length;i--;){var s=r[i],o=s.clone();t.replace(s,u[i]),s.start.row=o.start.row,s.start.column=o.start.column}},this.selectMore=function(e,t,n){var r=this.session,i=r.multiSelect,s=i.toOrientedRange();if(s.isEmpty()){s=r.getWordRange(s.start.row,s.start.column),s.cursor=e==-1?s.start:s.end,this.multiSelect.addRange(s);if(n)return}var o=r.getTextRange(s),u=h(r,o,e);u&&(u.cursor=e==-1?u.start:u.end,this.$blockScrolling+=1,this.session.unfold(u),this.multiSelect.addRange(u),this.$blockScrolling-=1,this.renderer.scrollCursorIntoView(null,.5)),t&&this.multiSelect.substractPoint(s.cursor)},this.alignCursors=function(){var e=this.session,t=e.multiSelect,n=t.ranges,r=-1,s=n.filter(function(e){if(e.cursor.row==r)return!0;r=e.cursor.row});if(!n.length||s.length==n.length-1){var o=this.selection.getRange(),u=o.start.row,f=o.end.row,l=u==f;if(l){var c=this.session.getLength(),h;do h=this.session.getLine(f);while(/[=:]/.test(h)&&++f0);u<0&&(u=0),f>=c&&(f=c-1)}var p=this.session.doc.removeLines(u,f);p=this.$reAlignText(p,l),this.session.doc.insert({row:u,column:0},p.join("\n")+"\n"),l||(o.start.column=0,o.end.column=p[p.length-1].length),this.selection.setRange(o)}else{s.forEach(function(e){t.substractPoint(e.cursor)});var d=0,v=Infinity,m=n.map(function(t){var n=t.cursor,r=e.getLine(n.row),i=r.substr(n.column).search(/\S/g);return i==-1&&(i=0),n.column>d&&(d=n.column),io?e.insert(r,a.stringRepeat(" ",s-o)):e.remove(new i(r.row,r.column,r.row,r.column-s+o)),t.start.column=t.end.column=d,t.start.row=t.end.row=r.row,t.cursor=t.end}),t.fromOrientedRange(n[0]),this.renderer.updateCursor(),this.renderer.updateBackMarkers()}},this.$reAlignText=function(e,t){function u(e){return a.stringRepeat(" ",e)}function f(e){return e[2]?u(i)+e[2]+u(s-e[2].length+o)+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}function l(e){return e[2]?u(i+s-e[2].length)+e[2]+u(o," ")+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}function c(e){return e[2]?u(i)+e[2]+u(o)+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}var n=!0,r=!0,i,s,o;return e.map(function(e){var t=e.match(/(\s*)(.*?)(\s*)([=:].*)/);return t?i==null?(i=t[1].length,s=t[2].length,o=t[3].length,t):(i+s+o!=t[1].length+t[2].length+t[3].length&&(r=!1),i!=t[1].length&&(n=!1),i>t[1].length&&(i=t[1].length),st[3].length&&(o=t[3].length),t):[e]}).map(t?f:n?r?l:f:c)}}).call(d.prototype),t.onSessionChange=function(e){var t=e.session;t&&!t.multiSelect&&(t.$selectionMarkers=[],t.selection.$initRangeList(),t.multiSelect=t.selection),this.multiSelect=t&&t.multiSelect;var n=e.oldSession;n&&(n.multiSelect.off("addRange",this.$onAddRange),n.multiSelect.off("removeRange",this.$onRemoveRange),n.multiSelect.off("multiSelect",this.$onMultiSelect),n.multiSelect.off("singleSelect",this.$onSingleSelect),n.multiSelect.lead.off("change",this.$checkMultiselectChange),n.multiSelect.anchor.off("change",this.$checkMultiselectChange)),t&&(t.multiSelect.on("addRange",this.$onAddRange),t.multiSelect.on("removeRange",this.$onRemoveRange),t.multiSelect.on("multiSelect",this.$onMultiSelect),t.multiSelect.on("singleSelect",this.$onSingleSelect),t.multiSelect.lead.on("change",this.$checkMultiselectChange),t.multiSelect.anchor.on("change",this.$checkMultiselectChange)),t&&this.inMultiSelectMode!=t.selection.inMultiSelectMode&&(t.selection.inMultiSelectMode?this.$onMultiSelect():this.$onSingleSelect())},t.MultiSelect=m,e("./config").defineOptions(d.prototype,"editor",{enableMultiselect:{set:function(e){m(this),e?(this.on("changeSession",this.$multiselectOnSessionChange),this.on("mousedown",o)):(this.off("changeSession",this.$multiselectOnSessionChange),this.off("mousedown",o))},value:!0}})}),ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../../range").Range,i=t.FoldMode=function(){};(function(){this.foldingStartMarker=null,this.foldingStopMarker=null,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);return this.foldingStartMarker.test(r)?"start":t=="markbeginend"&&this.foldingStopMarker&&this.foldingStopMarker.test(r)?"end":""},this.getFoldWidgetRange=function(e,t,n){return null},this.indentationBlock=function(e,t,n){var i=/\S/,s=e.getLine(t),o=s.search(i);if(o==-1)return;var u=n||s.length,a=e.getLength(),f=t,l=t;while(++tf){var h=e.getLine(l).length;return new r(f,u,l,h)}},this.openingBracketBlock=function(e,t,n,i,s){var o={row:n,column:i+1},u=e.$findClosingBracket(t,o,s);if(!u)return;var a=e.foldWidgets[u.row];return a==null&&(a=e.getFoldWidget(u.row)),a=="start"&&u.row>o.row&&(u.row--,u.column=e.getLine(u.row).length),r.fromPoints(o,u)},this.closingBracketBlock=function(e,t,n,i,s){var o={row:n,column:i},u=e.$findOpeningBracket(t,o);if(!u)return;return u.column++,o.column--,r.fromPoints(u,o)}}).call(i.prototype)}),ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";t.isDark=!1,t.cssClass="ace-tm",t.cssText='.ace-tm .ace_gutter {background: #f0f0f0;color: #333;}.ace-tm .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-tm .ace_fold {background-color: #6B72E6;}.ace-tm {background-color: #FFFFFF;color: black;}.ace-tm .ace_cursor {color: black;}.ace-tm .ace_invisible {color: rgb(191, 191, 191);}.ace-tm .ace_storage,.ace-tm .ace_keyword {color: blue;}.ace-tm .ace_constant {color: rgb(197, 6, 11);}.ace-tm .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-tm .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-tm .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-tm .ace_invalid {background-color: rgba(255, 0, 0, 0.1);color: red;}.ace-tm .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-tm .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-tm .ace_support.ace_type,.ace-tm .ace_support.ace_class {color: rgb(109, 121, 222);}.ace-tm .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-tm .ace_string {color: rgb(3, 106, 7);}.ace-tm .ace_comment {color: rgb(76, 136, 107);}.ace-tm .ace_comment.ace_doc {color: rgb(0, 102, 255);}.ace-tm .ace_comment.ace_doc.ace_tag {color: rgb(128, 159, 191);}.ace-tm .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-tm .ace_variable {color: rgb(49, 132, 149);}.ace-tm .ace_xml-pe {color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-tm .ace_heading {color: rgb(12, 7, 255);}.ace-tm .ace_list {color:rgb(185, 6, 144);}.ace-tm .ace_meta.ace_tag {color:rgb(0, 22, 142);}.ace-tm .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-tm .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-tm.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;border-radius: 2px;}.ace-tm .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_gutter-active-line {background-color : #dcdcdc;}.ace-tm .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}';var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}),ace.define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"],function(e,t,n){"use strict";function o(e){this.session=e,this.session.widgetManager=this,this.session.getRowLength=this.getRowLength,this.session.$getWidgetScreenLength=this.$getWidgetScreenLength,this.updateOnChange=this.updateOnChange.bind(this),this.renderWidgets=this.renderWidgets.bind(this),this.measureWidgets=this.measureWidgets.bind(this),this.session._changedWidgets=[],this.$onChangeEditor=this.$onChangeEditor.bind(this),this.session.on("change",this.updateOnChange),this.session.on("changeEditor",this.$onChangeEditor)}var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./range").Range;(function(){this.getRowLength=function(e){var t;return this.lineWidgets?t=this.lineWidgets[e]&&this.lineWidgets[e].rowCount||0:t=0,!this.$useWrapMode||!this.$wrapData[e]?1+t:this.$wrapData[e].length+1+t},this.$getWidgetScreenLength=function(){var e=0;return this.lineWidgets.forEach(function(t){t&&t.rowCount&&(e+=t.rowCount)}),e},this.$onChangeEditor=function(e){this.attach(e.editor)},this.attach=function(e){e&&e.widgetManager&&e.widgetManager!=this&&e.widgetManager.detach();if(this.editor==e)return;this.detach(),this.editor=e,e&&(e.widgetManager=this,e.renderer.on("beforeRender",this.measureWidgets),e.renderer.on("afterRender",this.renderWidgets))},this.detach=function(e){var t=this.editor;if(!t)return;this.editor=null,t.widgetManager=null,t.renderer.off("beforeRender",this.measureWidgets),t.renderer.off("afterRender",this.renderWidgets);var n=this.session.lineWidgets;n&&n.forEach(function(e){e&&e.el&&e.el.parentNode&&(e._inDocument=!1,e.el.parentNode.removeChild(e.el))})},this.updateOnChange=function(e){var t=this.session.lineWidgets;if(!t)return;var n=e.data,r=n.range,i=r.start.row,s=r.end.row-i;if(s!==0)if(n.action=="removeText"||n.action=="removeLines"){var o=t.splice(i+1,s);o.forEach(function(e){e&&this.removeLineWidget(e)},this),this.$updateRows()}else{var u=new Array(s);u.unshift(i,0),t.splice.apply(t,u),this.$updateRows()}},this.$updateRows=function(){var e=this.session.lineWidgets;if(!e)return;var t=!0;e.forEach(function(e,n){e&&(t=!1,e.row=n)}),t&&(this.session.lineWidgets=null)},this.addLineWidget=function(e){this.session.lineWidgets||(this.session.lineWidgets=new Array(this.session.getLength())),this.session.lineWidgets[e.row]=e;var t=this.editor.renderer;return e.html&&!e.el&&(e.el=i.createElement("div"),e.el.innerHTML=e.html),e.el&&(i.addCssClass(e.el,"ace_lineWidgetContainer"),e.el.style.position="absolute",e.el.style.zIndex=5,t.container.appendChild(e.el),e._inDocument=!0),e.coverGutter||(e.el.style.zIndex=3),e.pixelHeight||(e.pixelHeight=e.el.offsetHeight),e.rowCount==null&&(e.rowCount=e.pixelHeight/t.layerConfig.lineHeight),this.session._emit("changeFold",{data:{start:{row:e.row}}}),this.$updateRows(),this.renderWidgets(null,t),e},this.removeLineWidget=function(e){e._inDocument=!1,e.el&&e.el.parentNode&&e.el.parentNode.removeChild(e.el);if(e.editor&&e.editor.destroy)try{e.editor.destroy()}catch(t){}this.session.lineWidgets&&(this.session.lineWidgets[e.row]=undefined),this.session._emit("changeFold",{data:{start:{row:e.row}}}),this.$updateRows()},this.onWidgetChanged=function(e){this.session._changedWidgets.push(e),this.editor&&this.editor.renderer.updateFull()},this.measureWidgets=function(e,t){var n=this.session._changedWidgets,r=t.layerConfig;if(!n||!n.length)return;var i=Infinity;for(var s=0;s0&&!r[i])i--;this.firstRow=n.firstRow,this.lastRow=n.lastRow,t.$cursorLayer.config=n;for(var o=i;o<=s;o++){var u=r[o];if(!u||!u.el)continue;u._inDocument||(u._inDocument=!0,t.container.appendChild(u.el));var a=t.$cursorLayer.getPixelPosition({row:o,column:0},!0).top;u.coverLine||(a+=n.lineHeight*this.session.getRowLineCount(u.row)),u.el.style.top=a-n.offset+"px";var f=u.coverGutter?0:t.gutterWidth;u.fixedWidth||(f-=t.scrollLeft),u.el.style.left=f+"px",u.fixedWidth?u.el.style.right=t.scrollBar.getWidth()+"px":u.el.style.right=""}}}).call(o.prototype),t.LineWidgets=o}),ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"],function(e,t,n){"use strict";function o(e,t,n){var r=0,i=e.length-1;while(r<=i){var s=r+i>>1,o=n(t,e[s]);if(o>0)r=s+1;else{if(!(o<0))return s;i=s-1}}return-(r+1)}function u(e,t,n){var r=e.getAnnotations().sort(s.comparePoints);if(!r.length)return;var i=o(r,{row:t,column:-1},s.comparePoints);i<0&&(i=-i-1),i>=r.length-1?i=n>0?0:r.length-1:i===0&&n<0&&(i=r.length-1);var u=r[i];if(!u||!n)return;if(u.row===t){do u=r[i+=n];while(u&&u.row===t);if(!u)return r.slice()}var a=[];t=u.row;do a[n<0?"unshift":"push"](u),u=r[i+=n];while(u&&u.row==t);return a.length&&a}var r=e("../line_widgets").LineWidgets,i=e("../lib/dom"),s=e("../range").Range;t.showErrorMarker=function(e,t){var n=e.session;n.widgetManager||(n.widgetManager=new r(n),n.widgetManager.attach(e));var s=e.getCursorPosition(),o=s.row,a=n.lineWidgets&&n.lineWidgets[o];a?a.destroy():o-=t;var f=u(n,o,t),l;if(f){var c=f[0];s.column=(c.pos&&typeof c.column!="number"?c.pos.sc:c.column)||0,s.row=c.row,l=e.renderer.$gutterLayer.$annotations[s.row]}else{if(a)return;l={text:["Looks good!"],className:"ace_ok"}}e.session.unfold(s.row),e.selection.moveToPosition(s);var h={row:s.row,fixedWidth:!0,coverGutter:!0,el:i.createElement("div")},p=h.el.appendChild(i.createElement("div")),d=h.el.appendChild(i.createElement("div"));d.className="error_widget_arrow "+l.className;var v=e.renderer.$cursorLayer.getPixelPosition(s).left;d.style.left=v+e.renderer.gutterWidth-5+"px",h.el.className="error_widget_wrapper",p.className="error_widget "+l.className,p.innerHTML=l.text.join("
"),p.appendChild(i.createElement("div"));var m=function(e,t,n){if(t===0&&(n==="esc"||n==="return"))return h.destroy(),{command:"null"}};h.destroy=function(){if(e.$mouseHandler.isMousePressed)return;e.keyBinding.removeKeyboardHandler(m),n.widgetManager.removeLineWidget(h),e.off("changeSelection",h.destroy),e.off("changeSession",h.destroy),e.off("mouseup",h.destroy),e.off("change",h.destroy)},e.keyBinding.addKeyboardHandler(m),e.on("changeSelection",h.destroy),e.on("changeSession",h.destroy),e.on("mouseup",h.destroy),e.on("change",h.destroy),e.session.widgetManager.addLineWidget(h),h.el.onmousedown=e.focus.bind(e),e.renderer.scrollCursorIntoView(null,.5,{bottom:h.el.offsetHeight})},i.importCssString(" .error_widget_wrapper { background: inherit; color: inherit; border:none } .error_widget { border-top: solid 2px; border-bottom: solid 2px; margin: 5px 0; padding: 10px 40px; white-space: pre-wrap; } .error_widget.ace_error, .error_widget_arrow.ace_error{ border-color: #ff5a5a } .error_widget.ace_warning, .error_widget_arrow.ace_warning{ border-color: #F1D817 } .error_widget.ace_info, .error_widget_arrow.ace_info{ border-color: #5a5a5a } .error_widget.ace_ok, .error_widget_arrow.ace_ok{ border-color: #5aaa5a } .error_widget_arrow { position: absolute; border: solid 5px; border-top-color: transparent!important; border-right-color: transparent!important; border-left-color: transparent!important; top: -5px; }","")}),ace.define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config"],function(e,t,n){"use strict";e("./lib/fixoldbrowsers");var r=e("./lib/dom"),i=e("./lib/event"),s=e("./editor").Editor,o=e("./edit_session").EditSession,u=e("./undomanager").UndoManager,a=e("./virtual_renderer").VirtualRenderer;e("./worker/worker_client"),e("./keyboard/hash_handler"),e("./placeholder"),e("./multi_select"),e("./mode/folding/fold_mode"),e("./theme/textmate"),e("./ext/error_marker"),t.config=e("./config"),t.require=e,t.edit=function(e){if(typeof e=="string"){var n=e;e=document.getElementById(n);if(!e)throw new Error("ace.edit can't find div #"+n)}if(e&&e.env&&e.env.editor instanceof s)return e.env.editor;var o="";if(e&&/input|textarea/i.test(e.tagName)){var u=e;o=u.value,e=r.createElement("pre"),u.parentNode.replaceChild(e,u)}else o=r.getInnerText(e),e.innerHTML="";var f=t.createEditSession(o),l=new s(new a(e));l.setSession(f);var c={document:f,editor:l,onResize:l.resize.bind(l,null)};return u&&(c.textarea=u),i.addListener(window,"resize",c.onResize),l.on("destroy",function(){i.removeListener(window,"resize",c.onResize),c.editor.container.env=null}),l.container.env=l.env=c,l},t.createEditSession=function(e,t){var n=new o(e,t);return n.setUndoManager(new u),n},t.EditSession=o,t.UndoManager=u}); + (function() { + ace.require(["ace/ace"], function(a) { + a && a.config.init(true); + if (!window.ace) + window.ace = a; + for (var key in a) if (a.hasOwnProperty(key)) + window.ace[key] = a[key]; + }); + })(); + diff --git a/server/static/server/c3/docs/js/ace/mode-javascript.js b/server/static/server/c3/docs/js/ace/mode-javascript.js new file mode 100644 index 0000000..c96597b --- /dev/null +++ b/server/static/server/c3/docs/js/ace/mode-javascript.js @@ -0,0 +1 @@ +ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},s.getTagRule(),{defaultToken:"comment.doc",caseInsensitive:!0}]}};r.inherits(s,i),s.getTagRule=function(e){return{token:"comment.doc.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},s.getStartRule=function(e){return{token:"comment.doc",regex:"\\/\\*(?=\\*)",next:e}},s.getEndRule=function(e){return{token:"comment.doc",regex:"\\*\\/",next:e}},t.DocCommentHighlightRules=s}),ace.define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./doc_comment_highlight_rules").DocCommentHighlightRules,s=e("./text_highlight_rules").TextHighlightRules,o=function(e){var t=this.createKeywordMapper({"variable.language":"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|Namespace|QName|XML|XMLList|ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|SyntaxError|TypeError|URIError|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|JSON|Math|this|arguments|prototype|window|document",keyword:"const|yield|import|get|set|break|case|catch|continue|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|__parent__|__count__|escape|unescape|with|__proto__|class|enum|extends|super|export|implements|private|public|interface|package|protected|static","storage.type":"const|let|var|function","constant.language":"null|Infinity|NaN|undefined","support.function":"alert","constant.language.boolean":"true|false"},"identifier"),n="case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void",r="[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b",s="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)";this.$rules={no_regex:[{token:"comment",regex:"\\/\\/",next:"line_comment"},i.getStartRule("doc-start"),{token:"comment",regex:/\/\*/,next:"comment"},{token:"string",regex:"'(?=.)",next:"qstring"},{token:"string",regex:'"(?=.)',next:"qqstring"},{token:"constant.numeric",regex:/0[xX][0-9a-fA-F]+\b/},{token:"constant.numeric",regex:/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["storage.type","punctuation.operator","support.function","punctuation.operator","entity.name.function","text","keyword.operator"],regex:"("+r+")(\\.)(prototype)(\\.)("+r+")(\\s*)(=)",next:"function_arguments"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","paren.lparen"],regex:"("+r+")(\\.)("+r+")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["entity.name.function","text","keyword.operator","text","storage.type","text","paren.lparen"],regex:"("+r+")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","entity.name.function","text","paren.lparen"],regex:"("+r+")(\\.)("+r+")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",next:"function_arguments"},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+r+")(\\s*)(\\()",next:"function_arguments"},{token:["entity.name.function","text","punctuation.operator","text","storage.type","text","paren.lparen"],regex:"("+r+")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["text","text","storage.type","text","paren.lparen"],regex:"(:)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:"keyword",regex:"(?:"+n+")\\b",next:"start"},{token:["punctuation.operator","support.function"],regex:/(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/},{token:["punctuation.operator","support.function.dom"],regex:/(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/},{token:["punctuation.operator","support.constant"],regex:/(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/},{token:["support.constant"],regex:/that\b/},{token:["storage.type","punctuation.operator","support.function.firebug"],regex:/(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/},{token:t,regex:r},{token:"keyword.operator",regex:/--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,next:"start"},{token:"punctuation.operator",regex:/[?:,;.]/,next:"start"},{token:"paren.lparen",regex:/[\[({]/,next:"start"},{token:"paren.rparen",regex:/[\])}]/},{token:"comment",regex:/^#!.*$/}],start:[i.getStartRule("doc-start"),{token:"comment",regex:"\\/\\*",next:"comment_regex_allowed"},{token:"comment",regex:"\\/\\/",next:"line_comment_regex_allowed"},{token:"string.regexp",regex:"\\/",next:"regex"},{token:"text",regex:"\\s+|^$",next:"start"},{token:"empty",regex:"",next:"no_regex"}],regex:[{token:"regexp.keyword.operator",regex:"\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"},{token:"string.regexp",regex:"/[sxngimy]*",next:"no_regex"},{token:"invalid",regex:/\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/},{token:"constant.language.escape",regex:/\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/},{token:"constant.language.delimiter",regex:/\|/},{token:"constant.language.escape",regex:/\[\^?/,next:"regex_character_class"},{token:"empty",regex:"$",next:"no_regex"},{defaultToken:"string.regexp"}],regex_character_class:[{token:"regexp.charclass.keyword.operator",regex:"\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"},{token:"constant.language.escape",regex:"]",next:"regex"},{token:"constant.language.escape",regex:"-"},{token:"empty",regex:"$",next:"no_regex"},{defaultToken:"string.regexp.charachterclass"}],function_arguments:[{token:"variable.parameter",regex:r},{token:"punctuation.operator",regex:"[, ]+"},{token:"punctuation.operator",regex:"$"},{token:"empty",regex:"",next:"no_regex"}],comment_regex_allowed:[i.getTagRule(),{token:"comment",regex:"\\*\\/",next:"start"},{defaultToken:"comment",caseInsensitive:!0}],comment:[i.getTagRule(),{token:"comment",regex:"\\*\\/",next:"no_regex"},{defaultToken:"comment",caseInsensitive:!0}],line_comment_regex_allowed:[i.getTagRule(),{token:"comment",regex:"$|^",next:"start"},{defaultToken:"comment",caseInsensitive:!0}],line_comment:[i.getTagRule(),{token:"comment",regex:"$|^",next:"no_regex"},{defaultToken:"comment",caseInsensitive:!0}],qqstring:[{token:"constant.language.escape",regex:s},{token:"string",regex:"\\\\$",next:"qqstring"},{token:"string",regex:'"|$',next:"no_regex"},{defaultToken:"string"}],qstring:[{token:"constant.language.escape",regex:s},{token:"string",regex:"\\\\$",next:"qstring"},{token:"string",regex:"'|$",next:"no_regex"},{defaultToken:"string"}]},(!e||!e.noES6)&&this.$rules.no_regex.unshift({regex:"[{}]",onMatch:function(e,t,n){this.next=e=="{"?this.nextState:"";if(e=="{"&&n.length)return n.unshift("start",t),"paren";if(e=="}"&&n.length){n.shift(),this.next=n.shift();if(this.next.indexOf("string")!=-1)return"paren.quasi.end"}return e=="{"?"paren.lparen":"paren.rparen"},nextState:"start"},{token:"string.quasi.start",regex:/`/,push:[{token:"constant.language.escape",regex:s},{token:"paren.quasi.start",regex:/\${/,push:"start"},{token:"string.quasi.end",regex:/`/,next:"pop"},{defaultToken:"string.quasi"}]}),this.embedRules(i,"doc-",[i.getEndRule("no_regex")]),this.normalizeRules()};r.inherits(o,s),t.JavaScriptHighlightRules=o}),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../behaviour").Behaviour,s=e("../../token_iterator").TokenIterator,o=e("../../lib/lang"),u=["text","paren.rparen","punctuation.operator"],a=["text","paren.rparen","punctuation.operator","comment"],f,l={},c=function(e){var t=-1;e.multiSelect&&(t=e.selection.index,l.rangeCount!=e.multiSelect.rangeCount&&(l={rangeCount:e.multiSelect.rangeCount}));if(l[t])return f=l[t];f=l[t]={autoInsertedBrackets:0,autoInsertedRow:-1,autoInsertedLineEnd:"",maybeInsertedBrackets:0,maybeInsertedRow:-1,maybeInsertedLineStart:"",maybeInsertedLineEnd:""}},h=function(){this.add("braces","insertion",function(e,t,n,r,i){var s=n.getCursorPosition(),u=r.doc.getLine(s.row);if(i=="{"){c(n);var a=n.getSelectionRange(),l=r.doc.getTextRange(a);if(l!==""&&l!=="{"&&n.getWrapBehavioursEnabled())return{text:"{"+l+"}",selection:!1};if(h.isSaneInsertion(n,r))return/[\]\}\)]/.test(u[s.column])||n.inMultiSelectMode?(h.recordAutoInsert(n,r,"}"),{text:"{}",selection:[1,1]}):(h.recordMaybeInsert(n,r,"{"),{text:"{",selection:[1,1]})}else if(i=="}"){c(n);var p=u.substring(s.column,s.column+1);if(p=="}"){var d=r.$findOpeningBracket("}",{column:s.column+1,row:s.row});if(d!==null&&h.isAutoInsertedClosing(s,u,i))return h.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}else{if(i=="\n"||i=="\r\n"){c(n);var v="";h.isMaybeInsertedClosing(s,u)&&(v=o.stringRepeat("}",f.maybeInsertedBrackets),h.clearMaybeInsertedClosing());var p=u.substring(s.column,s.column+1);if(p==="}"){var m=r.findMatchingBracket({row:s.row,column:s.column+1},"}");if(!m)return null;var g=this.$getIndent(r.getLine(m.row))}else{if(!v){h.clearMaybeInsertedClosing();return}var g=this.$getIndent(u)}var y=g+r.getTabString();return{text:"\n"+y+"\n"+g+v,selection:[1,y.length,1,y.length]}}h.clearMaybeInsertedClosing()}}),this.add("braces","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="{"){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.end.column,i.end.column+1);if(u=="}")return i.end.column++,i;f.maybeInsertedBrackets--}}),this.add("parens","insertion",function(e,t,n,r,i){if(i=="("){c(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return{text:"("+o+")",selection:!1};if(h.isSaneInsertion(n,r))return h.recordAutoInsert(n,r,")"),{text:"()",selection:[1,1]}}else if(i==")"){c(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f==")"){var l=r.$findOpeningBracket(")",{column:u.column+1,row:u.row});if(l!==null&&h.isAutoInsertedClosing(u,a,i))return h.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="("){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==")")return i.end.column++,i}}),this.add("brackets","insertion",function(e,t,n,r,i){if(i=="["){c(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return{text:"["+o+"]",selection:!1};if(h.isSaneInsertion(n,r))return h.recordAutoInsert(n,r,"]"),{text:"[]",selection:[1,1]}}else if(i=="]"){c(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f=="]"){var l=r.$findOpeningBracket("]",{column:u.column+1,row:u.row});if(l!==null&&h.isAutoInsertedClosing(u,a,i))return h.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("brackets","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="["){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u=="]")return i.end.column++,i}}),this.add("string_dquotes","insertion",function(e,t,n,r,i){if(i=='"'||i=="'"){c(n);var s=i,o=n.getSelectionRange(),u=r.doc.getTextRange(o);if(u!==""&&u!=="'"&&u!='"'&&n.getWrapBehavioursEnabled())return{text:s+u+s,selection:!1};var a=n.getCursorPosition(),f=r.doc.getLine(a.row),l=f.substring(a.column-1,a.column);if(l=="\\")return null;var p=r.getTokens(o.start.row),d=0,v,m=-1;for(var g=0;go.start.column)break;d+=p[g].value.length}if(!v||m<0&&v.type!=="comment"&&(v.type!=="string"||o.start.column!==v.value.length+d-1&&v.value.lastIndexOf(s)===v.value.length-1)){if(!h.isSaneInsertion(n,r))return;return{text:s+s,selection:[1,1]}}if(v&&v.type==="string"){var y=f.substring(a.column,a.column+1);if(y==s)return{text:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&(s=='"'||s=="'")){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==s)return i.end.column++,i}})};h.isSaneInsertion=function(e,t){var n=e.getCursorPosition(),r=new s(t,n.row,n.column);if(!this.$matchTokenType(r.getCurrentToken()||"text",u)){var i=new s(t,n.row,n.column+1);if(!this.$matchTokenType(i.getCurrentToken()||"text",u))return!1}return r.stepForward(),r.getCurrentTokenRow()!==n.row||this.$matchTokenType(r.getCurrentToken()||"text",a)},h.$matchTokenType=function(e,t){return t.indexOf(e.type||e)>-1},h.recordAutoInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isAutoInsertedClosing(r,i,f.autoInsertedLineEnd[0])||(f.autoInsertedBrackets=0),f.autoInsertedRow=r.row,f.autoInsertedLineEnd=n+i.substr(r.column),f.autoInsertedBrackets++},h.recordMaybeInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isMaybeInsertedClosing(r,i)||(f.maybeInsertedBrackets=0),f.maybeInsertedRow=r.row,f.maybeInsertedLineStart=i.substr(0,r.column)+n,f.maybeInsertedLineEnd=i.substr(r.column),f.maybeInsertedBrackets++},h.isAutoInsertedClosing=function(e,t,n){return f.autoInsertedBrackets>0&&e.row===f.autoInsertedRow&&n===f.autoInsertedLineEnd[0]&&t.substr(e.column)===f.autoInsertedLineEnd},h.isMaybeInsertedClosing=function(e,t){return f.maybeInsertedBrackets>0&&e.row===f.maybeInsertedRow&&t.substr(e.column)===f.maybeInsertedLineEnd&&t.substr(0,e.column)==f.maybeInsertedLineStart},h.popAutoInsertedClosing=function(){f.autoInsertedLineEnd=f.autoInsertedLineEnd.substr(1),f.autoInsertedBrackets--},h.clearMaybeInsertedClosing=function(){f&&(f.maybeInsertedBrackets=0,f.maybeInsertedRow=-1)},r.inherits(h,i),t.CstyleBehaviour=h}),ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n),s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++tf)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)}}.call(o.prototype)}),ace.define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./javascript_highlight_rules").JavaScriptHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"||e=="no_regex"){var u=t.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc-start"){if(o=="start"||o=="no_regex")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.createWorker=function(e){var t=new a(["ace"],"ace/mode/javascript_worker","JavaScriptWorker");return t.attachToDocument(e.getDocument()),t.on("jslint",function(t){e.setAnnotations(t.data)}),t.on("terminate",function(){e.clearAnnotations()}),t},this.$id="ace/mode/javascript"}.call(c.prototype),t.Mode=c}) diff --git a/server/static/server/c3/docs/js/ace/theme-tomorrow.js b/server/static/server/c3/docs/js/ace/theme-tomorrow.js new file mode 100644 index 0000000..facd3be --- /dev/null +++ b/server/static/server/c3/docs/js/ace/theme-tomorrow.js @@ -0,0 +1 @@ +ace.define("ace/theme/tomorrow",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!1,t.cssClass="ace-tomorrow",t.cssText=".ace-tomorrow .ace_gutter {background: #f6f6f6;color: #4D4D4C}.ace-tomorrow .ace_print-margin {width: 1px;background: #f6f6f6}.ace-tomorrow {background-color: #FFFFFF;color: #4D4D4C}.ace-tomorrow .ace_cursor {color: #AEAFAD}.ace-tomorrow .ace_marker-layer .ace_selection {background: #D6D6D6}.ace-tomorrow.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #FFFFFF;border-radius: 2px}.ace-tomorrow .ace_marker-layer .ace_step {background: rgb(255, 255, 0)}.ace-tomorrow .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid #D1D1D1}.ace-tomorrow .ace_marker-layer .ace_active-line {background: #EFEFEF}.ace-tomorrow .ace_gutter-active-line {background-color : #dcdcdc}.ace-tomorrow .ace_marker-layer .ace_selected-word {border: 1px solid #D6D6D6}.ace-tomorrow .ace_invisible {color: #D1D1D1}.ace-tomorrow .ace_keyword,.ace-tomorrow .ace_meta,.ace-tomorrow .ace_storage,.ace-tomorrow .ace_storage.ace_type,.ace-tomorrow .ace_support.ace_type {color: #8959A8}.ace-tomorrow .ace_keyword.ace_operator {color: #3E999F}.ace-tomorrow .ace_constant.ace_character,.ace-tomorrow .ace_constant.ace_language,.ace-tomorrow .ace_constant.ace_numeric,.ace-tomorrow .ace_keyword.ace_other.ace_unit,.ace-tomorrow .ace_support.ace_constant,.ace-tomorrow .ace_variable.ace_parameter {color: #F5871F}.ace-tomorrow .ace_constant.ace_other {color: #666969}.ace-tomorrow .ace_invalid {color: #FFFFFF;background-color: #C82829}.ace-tomorrow .ace_invalid.ace_deprecated {color: #FFFFFF;background-color: #8959A8}.ace-tomorrow .ace_fold {background-color: #4271AE;border-color: #4D4D4C}.ace-tomorrow .ace_entity.ace_name.ace_function,.ace-tomorrow .ace_support.ace_function,.ace-tomorrow .ace_variable {color: #4271AE}.ace-tomorrow .ace_support.ace_class,.ace-tomorrow .ace_support.ace_type {color: #C99E00}.ace-tomorrow .ace_heading,.ace-tomorrow .ace_markup.ace_heading,.ace-tomorrow .ace_string {color: #718C00}.ace-tomorrow .ace_entity.ace_name.ace_tag,.ace-tomorrow .ace_entity.ace_other.ace_attribute-name,.ace-tomorrow .ace_meta.ace_tag,.ace-tomorrow .ace_string.ace_regexp,.ace-tomorrow .ace_variable {color: #C82829}.ace-tomorrow .ace_comment {color: #8E908C}.ace-tomorrow .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bdu3f/BwAlfgctduB85QAAAABJRU5ErkJggg==) right repeat-y}";var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}) diff --git a/server/static/server/c3/docs/js/ace/worker-javascript.js b/server/static/server/c3/docs/js/ace/worker-javascript.js new file mode 100644 index 0000000..088c10c --- /dev/null +++ b/server/static/server/c3/docs/js/ace/worker-javascript.js @@ -0,0 +1 @@ +"no use strict";(function(e){if(typeof e.window!="undefined"&&e.document)return;e.console=function(){var e=Array.prototype.slice.call(arguments,0);postMessage({type:"log",data:e})},e.console.error=e.console.warn=e.console.log=e.console.trace=e.console,e.window=e,e.ace=e,e.onerror=function(e,t,n,r,i){postMessage({type:"error",data:{message:e,file:t,line:n,col:r,stack:i.stack}})},e.normalizeModule=function(t,n){if(n.indexOf("!")!==-1){var r=n.split("!");return e.normalizeModule(t,r[0])+"!"+e.normalizeModule(t,r[1])}if(n.charAt(0)=="."){var i=t.split("/").slice(0,-1).join("/");n=(i?i+"/":"")+n;while(n.indexOf(".")!==-1&&s!=n){var s=n;n=n.replace(/^\.\//,"").replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return n},e.require=function(t,n){n||(n=t,t=null);if(!n.charAt)throw new Error("worker.js require() accepts only (parentId, id) as arguments");n=e.normalizeModule(t,n);var r=e.require.modules[n];if(r)return r.initialized||(r.initialized=!0,r.exports=r.factory().exports),r.exports;var i=n.split("/");if(!e.require.tlns)return console.log("unable to load "+n);i[0]=e.require.tlns[i[0]]||i[0];var s=i.join("/")+".js";return e.require.id=n,importScripts(s),e.require(t,n)},e.require.modules={},e.require.tlns={},e.define=function(t,n,r){arguments.length==2?(r=n,typeof t!="string"&&(n=t,t=e.require.id)):arguments.length==1&&(r=t,n=[],t=e.require.id);if(typeof r!="function"){e.require.modules[t]={exports:r,initialized:!0};return}n.length||(n=["require","exports","module"]);var i=function(n){return e.require(t,n)};e.require.modules[t]={exports:{},factory:function(){var e=this,t=r.apply(this,n.map(function(t){switch(t){case"require":return i;case"exports":return e.exports;case"module":return e;default:return i(t)}}));return t&&(e.exports=t),e}}},e.define.amd={},e.initBaseUrls=function(t){require.tlns=t},e.initSender=function(){var n=e.require("ace/lib/event_emitter").EventEmitter,r=e.require("ace/lib/oop"),i=function(){};return function(){r.implement(this,n),this.callback=function(e,t){postMessage({type:"call",id:t,data:e})},this.emit=function(e,t){postMessage({type:"event",name:e,data:t})}}.call(i.prototype),new i};var t=e.main=null,n=e.sender=null;e.onmessage=function(r){var i=r.data;if(i.command){if(!t[i.command])throw new Error("Unknown command:"+i.command);t[i.command].apply(t,i.args)}else if(i.init){initBaseUrls(i.tlns),require("ace/lib/es5-shim"),n=e.sender=initSender();var s=require(i.module)[i.classname];t=e.main=new s(n)}else i.event&&n&&n._signal(i.event,i.data)}})(this),ace.define("ace/lib/oop",["require","exports","module"],function(e,t,n){"use strict";t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t.mixin=function(e,t){for(var n in t)e[n]=t[n];return e},t.implement=function(e,n){t.mixin(e,n)}}),ace.define("ace/lib/event_emitter",["require","exports","module"],function(e,t,n){"use strict";var r={},i=function(){this.propagationStopped=!0},s=function(){this.defaultPrevented=!0};r._emit=r._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],r=this._defaultHandlers[e];if(!n.length&&!r)return;if(typeof t!="object"||!t)t={};t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=i),t.preventDefault||(t.preventDefault=s),n=n.slice();for(var o=0;o ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(e,t){return this.compare(e,t)==0},this.compareRange=function(e){var t,n=e.end,r=e.start;return t=this.compare(n.row,n.column),t==1?(t=this.compare(r.row,r.column),t==1?2:t==0?1:0):t==-1?-2:(t=this.compare(r.row,r.column),t==-1?-1:t==1?42:0)},this.comparePoint=function(e){return this.compare(e.row,e.column)},this.containsRange=function(e){return this.comparePoint(e.start)==0&&this.comparePoint(e.end)==0},this.intersects=function(e){var t=this.compareRange(e);return t==-1||t==0||t==1},this.isEnd=function(e,t){return this.end.row==e&&this.end.column==t},this.isStart=function(e,t){return this.start.row==e&&this.start.column==t},this.setStart=function(e,t){typeof e=="object"?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},this.setEnd=function(e,t){typeof e=="object"?(this.end.column=e.column,this.end.row=e.row):(this.end.row=e,this.end.column=t)},this.inside=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)||this.isStart(e,t)?!1:!0:!1},this.insideStart=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)?!1:!0:!1},this.insideEnd=function(e,t){return this.compare(e,t)==0?this.isStart(e,t)?!1:!0:!1},this.compare=function(e,t){return!this.isMultiLine()&&e===this.start.row?tthis.end.column?1:0:ethis.end.row?1:this.start.row===e?t>=this.start.column?0:-1:this.end.row===e?t<=this.end.column?0:1:0},this.compareStart=function(e,t){return this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.compareEnd=function(e,t){return this.end.row==e&&this.end.column==t?1:this.compare(e,t)},this.compareInside=function(e,t){return this.end.row==e&&this.end.column==t?1:this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.clipRows=function(e,t){if(this.end.row>t)var n={row:t+1,column:0};else if(this.end.rowt)var r={row:t+1,column:0};else if(this.start.rowthis.row)return;if(n.start.row==this.row&&n.start.column>this.column)return;var r=this.row,i=this.column,s=n.start,o=n.end;if(t.action==="insertText")if(s.row===r&&s.column<=i){if(s.column!==i||!this.$insertRight)s.row===o.row?i+=o.column-s.column:(i-=s.column,r+=o.row-s.row)}else s.row!==o.row&&s.row=i?i=s.column:i=Math.max(0,i-(o.column-s.column)):s.row!==o.row&&s.row=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n}}).call(s.prototype)}),ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/range","ace/anchor"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=e("./range").Range,o=e("./anchor").Anchor,u=function(e){this.$lines=[],e.length===0?this.$lines=[""]:Array.isArray(e)?this._insertLines(0,e):this.insert({row:0,column:0},e)};(function(){r.implement(this,i),this.setValue=function(e){var t=this.getLength();this.remove(new s(0,0,t,this.getLine(t-1).length)),this.insert({row:0,column:0},e)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(e,t){return new o(this,e,t)},"aaa".split(/a/).length===0?this.$split=function(e){return e.replace(/\r\n|\r/g,"\n").split("\n")}:this.$split=function(e){return e.split(/\r\n|\r|\n/)},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r\n|\r|\n)/m);this.$autoNewLine=t?t[1]:"\n",this._signal("changeNewLineMode")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";default:return this.$autoNewLine||"\n"}},this.$autoNewLine="",this.$newLineMode="auto",this.setNewLineMode=function(e){if(this.$newLineMode===e)return;this.$newLineMode=e,this._signal("changeNewLineMode")},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(e){return e=="\r\n"||e=="\r"||e=="\n"},this.getLine=function(e){return this.$lines[e]||""},this.getLines=function(e,t){return this.$lines.slice(e,t+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(e){if(e.start.row==e.end.row)return this.getLine(e.start.row).substring(e.start.column,e.end.column);var t=this.getLines(e.start.row,e.end.row);t[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;return e.end.row-e.start.row==n&&(t[n]=t[n].substring(0,e.end.column)),t.join(this.getNewLineCharacter())},this.$clipPosition=function(e){var t=this.getLength();return e.row>=t?(e.row=Math.max(0,t-1),e.column=this.getLine(t-1).length):e.row<0&&(e.row=0),e},this.insert=function(e,t){if(!t||t.length===0)return e;e=this.$clipPosition(e),this.getLength()<=1&&this.$detectNewLine(t);var n=this.$split(t),r=n.splice(0,1)[0],i=n.length==0?null:n.splice(n.length-1,1)[0];return e=this.insertInLine(e,r),i!==null&&(e=this.insertNewLine(e),e=this._insertLines(e.row,n),e=this.insertInLine(e,i||"")),e},this.insertLines=function(e,t){return e>=this.getLength()?this.insert({row:e,column:0},"\n"+t.join("\n")):this._insertLines(Math.max(e,0),t)},this._insertLines=function(e,t){if(t.length==0)return{row:e,column:0};while(t.length>61440){var n=this._insertLines(e,t.slice(0,61440));t=t.slice(61440),e=n.row}var r=[e,0];r.push.apply(r,t),this.$lines.splice.apply(this.$lines,r);var i=new s(e,0,e+t.length,0),o={action:"insertLines",range:i,lines:t};return this._signal("change",{data:o}),i.end},this.insertNewLine=function(e){e=this.$clipPosition(e);var t=this.$lines[e.row]||"";this.$lines[e.row]=t.substring(0,e.column),this.$lines.splice(e.row+1,0,t.substring(e.column,t.length));var n={row:e.row+1,column:0},r={action:"insertText",range:s.fromPoints(e,n),text:this.getNewLineCharacter()};return this._signal("change",{data:r}),n},this.insertInLine=function(e,t){if(t.length==0)return e;var n=this.$lines[e.row]||"";this.$lines[e.row]=n.substring(0,e.column)+t+n.substring(e.column);var r={row:e.row,column:e.column+t.length},i={action:"insertText",range:s.fromPoints(e,r),text:t};return this._signal("change",{data:i}),r},this.remove=function(e){e instanceof s||(e=s.fromPoints(e.start,e.end)),e.start=this.$clipPosition(e.start),e.end=this.$clipPosition(e.end);if(e.isEmpty())return e.start;var t=e.start.row,n=e.end.row;if(e.isMultiLine()){var r=e.start.column==0?t:t+1,i=n-1;e.end.column>0&&this.removeInLine(n,0,e.end.column),i>=r&&this._removeLines(r,i),r!=t&&(this.removeInLine(t,e.start.column,this.getLine(t).length),this.removeNewLine(e.start.row))}else this.removeInLine(t,e.start.column,e.end.column);return e.start},this.removeInLine=function(e,t,n){if(t==n)return;var r=new s(e,t,e,n),i=this.getLine(e),o=i.substring(t,n),u=i.substring(0,t)+i.substring(n,i.length);this.$lines.splice(e,1,u);var a={action:"removeText",range:r,text:o};return this._signal("change",{data:a}),r.start},this.removeLines=function(e,t){return e<0||t>=this.getLength()?this.remove(new s(e,0,t+1,0)):this._removeLines(e,t)},this._removeLines=function(e,t){var n=new s(e,0,t+1,0),r=this.$lines.splice(e,t-e+1),i={action:"removeLines",range:n,nl:this.getNewLineCharacter(),lines:r};return this._signal("change",{data:i}),r},this.removeNewLine=function(e){var t=this.getLine(e),n=this.getLine(e+1),r=new s(e,t.length,e+1,0),i=t+n;this.$lines.splice(e,2,i);var o={action:"removeText",range:r,text:this.getNewLineCharacter()};this._signal("change",{data:o})},this.replace=function(e,t){e instanceof s||(e=s.fromPoints(e.start,e.end));if(t.length==0&&e.isEmpty())return e.start;if(t==this.getTextRange(e))return e.end;this.remove(e);if(t)var n=this.insert(e.start,t);else n=e.start;return n},this.applyDeltas=function(e){for(var t=0;t=0;t--){var n=e[t],r=s.fromPoints(n.range.start,n.range.end);n.action=="insertLines"?this._removeLines(r.start.row,r.end.row-1):n.action=="insertText"?this.remove(r):n.action=="removeLines"?this._insertLines(r.start.row,n.lines):n.action=="removeText"&&this.insert(r.start,n.text)}},this.indexToPosition=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length;for(var i=t||0,s=n.length;i0){t&1&&(n+=e);if(t>>=1)e+=e}return n};var r=/^\s\s*/,i=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(r,"")},t.stringTrimRight=function(e){return e.replace(i,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){var t=[];for(var n=0,r=e.length;n=65&&i<=90||i===95||i>=97&&i<=122;var s=[];for(var i=0;i<128;i++)s[i]=r[i]||i>=48&&i<=57;t.exports={asciiIdentifierStartTable:r,asciiIdentifierPartTable:s}},{}],2:[function(e,t,n){(function(){var e=this,r=e._,i={},s=Array.prototype,o=Object.prototype,u=Function.prototype,a=s.push,f=s.slice,l=s.concat,c=o.toString,h=o.hasOwnProperty,p=s.forEach,d=s.map,v=s.reduce,m=s.reduceRight,g=s.filter,y=s.every,b=s.some,w=s.indexOf,E=s.lastIndexOf,S=Array.isArray,x=Object.keys,T=u.bind,N=function(e){if(e instanceof N)return e;if(!(this instanceof N))return new N(e);this._wrapped=e};typeof n!="undefined"?(typeof t!="undefined"&&t.exports&&(n=t.exports=N),n._=N):e._=N,N.VERSION="1.6.0";var C=N.each=N.forEach=function(e,t,n){if(e==null)return e;if(p&&e.forEach===p)e.forEach(t,n);else if(e.length===+e.length){for(var r=0,s=e.length;r2;e==null&&(e=[]);if(v&&e.reduce===v)return r&&(t=N.bind(t,r)),i?e.reduce(t,n):e.reduce(t);C(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError(k);return n},N.reduceRight=N.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(m&&e.reduceRight===m)return r&&(t=N.bind(t,r)),i?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=N.keys(e);s=o.length}C(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError(k);return n},N.find=N.detect=function(e,t,n){var r;return L(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},N.filter=N.select=function(e,t,n){var r=[];return e==null?r:g&&e.filter===g?e.filter(t,n):(C(e,function(e,i,s){t.call(n,e,i,s)&&r.push(e)}),r)},N.reject=function(e,t,n){return N.filter(e,function(e,r,i){return!t.call(n,e,r,i)},n)},N.every=N.all=function(e,t,n){t||(t=N.identity);var r=!0;return e==null?r:y&&e.every===y?e.every(t,n):(C(e,function(e,s,o){if(!(r=r&&t.call(n,e,s,o)))return i}),!!r)};var L=N.some=N.any=function(e,t,n){t||(t=N.identity);var r=!1;return e==null?r:b&&e.some===b?e.some(t,n):(C(e,function(e,s,o){if(r||(r=t.call(n,e,s,o)))return i}),!!r)};N.contains=N.include=function(e,t){return e==null?!1:w&&e.indexOf===w?e.indexOf(t)!=-1:L(e,function(e){return e===t})},N.invoke=function(e,t){var n=f.call(arguments,2),r=N.isFunction(t);return N.map(e,function(e){return(r?t:e[t]).apply(e,n)})},N.pluck=function(e,t){return N.map(e,N.property(t))},N.where=function(e,t){return N.filter(e,N.matches(t))},N.findWhere=function(e,t){return N.find(e,N.matches(t))},N.max=function(e,t,n){if(!t&&N.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);var r=-Infinity,i=-Infinity;return C(e,function(e,s,o){var u=t?t.call(n,e,s,o):e;u>i&&(r=e,i=u)}),r},N.min=function(e,t,n){if(!t&&N.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);var r=Infinity,i=Infinity;return C(e,function(e,s,o){var u=t?t.call(n,e,s,o):e;ur||n===void 0)return 1;if(n>>1;n.call(r,e[u])=0;n--)t=[e[n].apply(this,t)];return t[0]}},N.after=function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},N.keys=function(e){if(!N.isObject(e))return[];if(x)return x(e);var t=[];for(var n in e)N.has(e,n)&&t.push(n);return t},N.values=function(e){var t=N.keys(e),n=t.length,r=new Array(n);for(var i=0;i":">",'"':""","'":"'"}};P.unescape=N.invert(P.escape);var H={escape:new RegExp("["+N.keys(P.escape).join("")+"]","g"),unescape:new RegExp("("+N.keys(P.unescape).join("|")+")","g")};N.each(["escape","unescape"],function(e){N[e]=function(t){return t==null?"":(""+t).replace(H[e],function(t){return P[e][t]})}}),N.result=function(e,t){if(e==null)return void 0;var n=e[t];return N.isFunction(n)?n.call(e):n},N.mixin=function(e){C(N.functions(e),function(t){var n=N[t]=e[t];N.prototype[t]=function(){var e=[this._wrapped];return a.apply(e,arguments),q.call(this,n.apply(N,e))}})};var B=0;N.uniqueId=function(e){var t=++B+"";return e?e+t:t},N.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var j=/(.)^/,F={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},I=/\\|'|\r|\n|\t|\u2028|\u2029/g;N.template=function(e,t,n){var r;n=N.defaults({},n,N.templateSettings);var i=new RegExp([(n.escape||j).source,(n.interpolate||j).source,(n.evaluate||j).source].join("|")+"|$","g"),s=0,o="__p+='";e.replace(i,function(t,n,r,i,u){return o+=e.slice(s,u).replace(I,function(e){return"\\"+F[e]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),s=u+t.length,t}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=new Function(n.variable||"obj","_",o)}catch(u){throw u.source=o,u}if(t)return r(t,N);var a=function(e){return r.call(this,e,N)};return a.source="function("+(n.variable||"obj")+"){\n"+o+"}",a},N.chain=function(e){return N(e).chain()};var q=function(e){return this._chain?N(e).chain():e};N.mixin(N),C(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=s[e];N.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],q.call(this,n)}}),C(["concat","join","slice"],function(e){var t=s[e];N.prototype[e]=function(){return q.call(this,t.apply(this._wrapped,arguments))}}),N.extend(N.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),typeof define=="function"&&define.amd&&ace.define("underscore",[],function(){return N})}).call(this)},{}],3:[function(e,t,n){var r=e("underscore"),i=e("events"),s=e("./vars.js"),o=e("./messages.js"),u=e("./lex.js").Lexer,a=e("./reg.js"),f=e("./state.js").state,l=e("./style.js"),c=function(){"use strict";function I(e,t){return e=e.trim(),/^[+-]W\d{3}$/g.test(e)?!0:p[e]===undefined&&h[e]===undefined&&t.type!=="jslint"&&!m[e]?(G("E001",t,e),!1):!0}function q(e){return Object.prototype.toString.call(e)==="[object String]"}function R(e,t){return e?!e.identifier||e.value!==t?!1:!0:!1}function U(e){if(!e.reserved)return!1;var t=e.meta;if(t&&t.isFutureReservedWord&&f.option.inES5()){if(!t.es5)return!1;if(t.strictOnly&&!f.option.strict&&!f.directive["use strict"])return!1;if(e.isProperty)return!1}return!0}function z(e,t){return e.replace(/\{([^{}]*)\}/g,function(e,n){var r=t[n];return typeof r=="string"||typeof r=="number"?r:e})}function W(e,t){Object.keys(t).forEach(function(n){if(r.has(c.blacklist,n))return;e[n]=t[n]})}function X(){f.option.esnext&&W(M,s.newEcmaIdentifiers),f.option.couch&&W(M,s.couch),f.option.qunit&&W(M,s.qunit),f.option.rhino&&W(M,s.rhino),f.option.shelljs&&(W(M,s.shelljs),W(M,s.node)),f.option.typed&&W(M,s.typed),f.option.phantom&&W(M,s.phantom),f.option.prototypejs&&W(M,s.prototypejs),f.option.node&&(W(M,s.node),W(M,s.typed)),f.option.devel&&W(M,s.devel),f.option.dojo&&W(M,s.dojo),f.option.browser&&(W(M,s.browser),W(M,s.typed)),f.option.nonstandard&&W(M,s.nonstandard),f.option.jasmine&&W(M,s.jasmine),f.option.jquery&&W(M,s.jquery),f.option.mootools&&W(M,s.mootools),f.option.worker&&W(M,s.worker),f.option.wsh&&W(M,s.wsh),f.option.globalstrict&&f.option.strict!==!1&&(f.option.strict=!0),f.option.yui&&W(M,s.yui),f.option.mocha&&W(M,s.mocha),f.option.inMoz=function(e){return f.option.moz},f.option.inESNext=function(e){return f.option.moz||f.option.esnext},f.option.inES5=function(){return!f.option.es3},f.option.inES3=function(e){return e?!f.option.moz&&!f.option.esnext&&f.option.es3:f.option.es3}}function V(e,t,n){var r=Math.floor(t/f.lines.length*100),i=o.errors[e].desc;throw{name:"JSHintError",line:t,character:n,message:i+" ("+r+"% scanned).",raw:i,code:e}}function $(e,t,n,r){return c.undefs.push([e,t,n,r])}function J(){var e=f.ignoredLines;if(r.isEmpty(e))return;c.errors=r.reject(c.errors,function(t){return e[t.line]})}function K(e,t,n,r,i,s){var u,a,l,h;if(/^W\d{3}$/.test(e)){if(f.ignored[e])return;h=o.warnings[e]}else/E\d{3}/.test(e)?h=o.errors[e]:/I\d{3}/.test(e)&&(h=o.info[e]);return t=t||f.tokens.next,t.id==="(end)"&&(t=f.tokens.curr),a=t.line||0,u=t.from||0,l={id:"(error)",raw:h.desc,code:h.code,evidence:f.lines[a-1]||"",line:a,character:u,scope:c.scope,a:n,b:r,c:i,d:s},l.reason=z(h.desc,l),c.errors.push(l),J(),c.errors.length>=f.option.maxerr&&V("E043",a,u),l}function Q(e,t,n,r,i,s,o){return K(e,{line:t,from:n},r,i,s,o)}function G(e,t,n,r,i,s){K(e,t,n,r,i,s)}function Y(e,t,n,r,i,s,o){return G(e,{line:t,from:n},r,i,s,o)}function Z(e,t){var n;return n={id:"(internal)",elem:e,value:t},c.internals.push(n),n}function et(e,t){t=t||{};var n=t.type,i=t.token,s=t.islet;n==="exception"&&r.has(w["(context)"],e)&&w[e]!==!0&&!f.option.node&&K("W002",f.tokens.next,e),r.has(w,e)&&!w["(global)"]&&(w[e]===!0?f.option.latedef&&(f.option.latedef===!0&&r.contains([w[e],n],"unction")||!r.contains([w[e],n],"unction"))&&K("W003",f.tokens.next,e):((!f.option.shadow||r.contains(["inner","outer"],f.option.shadow))&&n!=="exception"||w["(blockscope)"].getlabel(e))&&K("W004",f.tokens.next,e)),w["(context)"]&&r.has(w["(context)"],e)&&n!=="function"&&f.option.shadow==="outer"&&K("W123",f.tokens.next,e),s?w["(blockscope)"].current.add(e,n,f.tokens.curr):(w["(blockscope)"].shadow(e),w[e]=n,i&&(w["(tokens)"][e]=i),Xt(w,e,{unused:t.unused||!1}),w["(global)"]?(S[e]=w,r.has(x,e)&&(f.option.latedef&&(f.option.latedef===!0&&r.contains([w[e],n],"unction")||!r.contains([w[e],n],"unction"))&&K("W003",f.tokens.next,e),delete x[e])):D[e]=w)}function tt(){var e=f.tokens.next,t=e.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g)||[],n={};if(e.type==="globals"){t.forEach(function(e){e=e.split(":");var t=(e[0]||"").trim(),r=(e[1]||"").trim();t.charAt(0)==="-"?(t=t.slice(1),r=!1,c.blacklist[t]=t,delete M[t]):n[t]=r==="true"}),W(M,n);for(var i in n)r.has(n,i)&&(g[i]=e)}e.type==="exported"&&t.forEach(function(e){y[e]=!0}),e.type==="members"&&(A=A||{},t.forEach(function(e){var t=e.charAt(0),n=e.charAt(e.length-1);t===n&&(t==='"'||t==="'")&&(e=e.substr(1,e.length-2).replace('\\"','"')),A[e]=!1}));var s=["maxstatements","maxparams","maxdepth","maxcomplexity","maxerr","maxlen","indent"];if(e.type==="jshint"||e.type==="jslint")t.forEach(function(t){t=t.split(":");var n=(t[0]||"").trim(),r=(t[1]||"").trim();if(!I(n,e))return;if(s.indexOf(n)>=0){if(r!=="false"){r=+r;if(typeof r!="number"||!isFinite(r)||r<=0||Math.floor(r)!==r){G("E032",e,t[1].trim());return}f.option[n]=r}else f.option[n]=n==="indent"?4:!1;return}if(n==="validthis"){if(w["(global)"])return void G("E009");if(r!=="true"&&r!=="false")return void G("E002",e);f.option.validthis=r==="true";return}if(n==="quotmark"){switch(r){case"true":case"false":f.option.quotmark=r==="true";break;case"double":case"single":f.option.quotmark=r;break;default:G("E002",e)}return}if(n==="shadow"){switch(r){case"true":f.option.shadow=!0;break;case"outer":f.option.shadow="outer";break;case"false":case"inner":f.option.shadow="inner";break;default:G("E002",e)}return}if(n==="unused"){switch(r){case"true":f.option.unused=!0;break;case"false":f.option.unused=!1;break;case"vars":case"strict":f.option.unused=r;break;default:G("E002",e)}return}if(n==="latedef"){switch(r){case"true":f.option.latedef=!0;break;case"false":f.option.latedef=!1;break;case"nofunc":f.option.latedef="nofunc";break;default:G("E002",e)}return}if(n==="ignore"){switch(r){case"start":f.ignoreLinterErrors=!0;break;case"end":f.ignoreLinterErrors=!1;break;case"line":f.ignoredLines[e.line]=!0,J();break;default:G("E002",e)}return}var i=/^([+-])(W\d{3})$/g.exec(n);if(i){f.ignored[i[2]]=i[1]==="-";return}var o;if(r==="true"||r==="false"){e.type==="jslint"?(o=v[n]||n,f.option[o]=r==="true",d[o]!==undefined&&(f.option[o]=!f.option[o])):f.option[n]=r==="true",n==="newcap"&&(f.option["(explicitNewcap)"]=!0);return}G("E002",e)}),X()}function nt(e){var t=e||0,n=0,r;while(n<=t)r=C[n],r||(r=C[n]=k.token()),n+=1;return r}function rt(t,n){switch(f.tokens.curr.id){case"(number)":f.tokens.next.id==="."&&K("W005",f.tokens.curr);break;case"-":(f.tokens.next.id==="-"||f.tokens.next.id==="--")&&K("W006");break;case"+":(f.tokens.next.id==="+"||f.tokens.next.id==="++")&&K("W007")}if(f.tokens.curr.type==="(string)"||f.tokens.curr.identifier)e=f.tokens.curr.value;t&&f.tokens.next.id!==t&&(n?f.tokens.next.id==="(end)"?G("E019",n,n.id):G("E020",f.tokens.next,t,n.id,n.line,f.tokens.next.value):(f.tokens.next.type!=="(identifier)"||f.tokens.next.value!==t)&&K("W116",f.tokens.next,t,f.tokens.next.value)),f.tokens.prev=f.tokens.curr,f.tokens.curr=f.tokens.next;for(;;){f.tokens.next=C.shift()||k.token(),f.tokens.next||V("E041",f.tokens.curr.line);if(f.tokens.next.id==="(end)"||f.tokens.next.id==="(error)")return;f.tokens.next.check&&f.tokens.next.check();if(f.tokens.next.isSpecial)tt();else if(f.tokens.next.id!=="(endline)")break}}function it(e){return e.infix||!e.identifier&&!!e.led}function st(){var e=f.tokens.curr,t=f.tokens.next;return t.id===";"||t.id==="}"||t.id===":"?!0:it(t)===it(e)||e.id==="yield"&&f.option.inMoz(!0)?e.line!==t.line:!1}function ot(t,n){var i,s=!1,o=!1,u=!1;!n&&f.tokens.next.value==="let"&&nt(0).value==="("&&(f.option.inMoz(!0)||K("W118",f.tokens.next,"let expressions"),u=!0,w["(blockscope)"].stack(),rt("let"),rt("("),f.syntax.let.fud.call(f.syntax.let.fud,!1),rt(")")),f.tokens.next.id==="(end)"&&G("E006",f.tokens.curr);var a=f.option.asi&&f.tokens.prev.line="a"&&t<="z"||t>="A"&&t<="Z")e.identifier=e.reserved=!0;return e}function mt(e,t){var n=ct(e,150);return vt(n),n.nud=typeof t=="function"?t:function(){this.right=ot(150),this.arity="unary";if(this.id==="++"||this.id==="--")f.option.plusplus?K("W016",this,this.id):this.right&&(!this.right.identifier||U(this.right))&&this.right.id!=="."&&this.right.id!=="["&&K("W017",this);return this},n}function gt(e,t){var n=ht(e);return n.type=e,n.nud=t,n}function yt(e,t){var n=gt(e,t);return n.identifier=!0,n.reserved=!0,n}function bt(e,t){var n=gt(e,t&&t.nud||function(){return this});return t=t||{},t.isFutureReservedWord=!0,n.value=e,n.identifier=!0,n.reserved=!0,n.meta=t,n}function wt(e,t){return yt(e,function(){return typeof t=="function"&&t(this),this})}function Et(e,t,n,r){var i=ct(e,n);return vt(i),i.infix=!0,i.led=function(i){return r||ut(f.tokens.prev,f.tokens.curr),e==="in"&&i.id==="!"&&K("W018",i,"!"),typeof t=="function"?t(i,this):(this.left=i,this.right=ot(n),this)},i}function St(e){var t=ct(e,42);return t.led=function(e){return f.option.inESNext()||K("W104",f.tokens.curr,"arrow function syntax (=>)"),ut(f.tokens.prev,f.tokens.curr),this.left=e,this.right=Jt(undefined,undefined,!1,e),this},t}function xt(e,t){var n=ct(e,100);return n.led=function(e){ut(f.tokens.prev,f.tokens.curr);var n=ot(100);return R(e,"NaN")||R(n,"NaN")?K("W019",this):t&&t.apply(this,[e,n]),(!e||!n)&&V("E041",f.tokens.curr.line),e.id==="!"&&K("W018",e,"!"),n.id==="!"&&K("W018",n,"!"),this.left=e,this.right=n,this},n}function Tt(e){return e&&(e.type==="(number)"&&+e.value===0||e.type==="(string)"&&e.value===""||e.type==="null"&&!f.option.eqnull||e.type==="true"||e.type==="false"||e.type==="undefined")}function Nt(e,t){if(f.option.notypeof)return!1;if(!e||!t)return!1;var n=["undefined","object","boolean","number","string","function","xml","object","unknown"];return t.type==="(identifier)"&&t.value==="typeof"&&e.type==="(string)"?!r.contains(n,e.value):!1}function Ct(e){function n(e){if(typeof e!="object")return;return e.right==="prototype"?e:n(e.left)}function r(e){while(!e.identifier&&typeof e.left=="object")e=e.left;if(e.identifier&&t.indexOf(e.value)>=0)return e.value}var t=["Array","ArrayBuffer","Boolean","Collator","DataView","Date","DateTimeFormat","Error","EvalError","Float32Array","Float64Array","Function","Infinity","Intl","Int16Array","Int32Array","Int8Array","Iterator","Number","NumberFormat","Object","RangeError","ReferenceError","RegExp","StopIteration","String","SyntaxError","TypeError","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","URIError"],i=n(e);if(i)return r(i)}function kt(e,t,n){var r=Et(e,typeof t=="function"?t:function(e,t){t.left=e;if(e){if(f.option.freeze){var n=Ct(e);n&&K("W121",e,n)}M[e.value]===!1&&D[e.value]["(global)"]===!0?K("W020",e):e["function"]&&K("W021",e,e.value),w[e.value]==="const"&&G("E013",e,e.value);if(e.id===".")return e.left?e.left.value==="arguments"&&!f.directive["use strict"]&&K("E031",t):K("E031",t),t.right=ot(10),t;if(e.id==="[")return f.tokens.curr.left.first?f.tokens.curr.left.first.forEach(function(e){e&&w[e.value]==="const"&&G("E013",e,e.value)}):e.left?e.left.value==="arguments"&&!f.directive["use strict"]&&K("E031",t):K("E031",t),t.right=ot(10),t;if(e.identifier&&!U(e))return w[e.value]==="exception"&&K("W022",e),t.right=ot(10),t;e===f.syntax["function"]&&K("W023",f.tokens.curr)}G("E031",t)},n);return r.exps=!0,r.assign=!0,r}function Lt(e,t,n){var r=ct(e,n);return vt(r),r.led=typeof t=="function"?t:function(e){return f.option.bitwise&&K("W016",this,this.id),this.left=e,this.right=ot(n),this},r}function At(e){return kt(e,function(e,t){f.option.bitwise&&K("W016",t,t.id);if(e)return e.id==="."||e.id==="["||e.identifier&&!U(e)?(ot(10),t):(e===f.syntax["function"]&&K("W023",f.tokens.curr),t);G("E031",t)},20)}function Ot(e){var t=ct(e,150);return t.led=function(e){return f.option.plusplus?K("W016",this,this.id):(!e.identifier||U(e))&&e.id!=="."&&e.id!=="["&&K("W017",this),this.left=e,this},t}function Mt(e,t){if(!f.tokens.next.identifier)return;rt();var n=f.tokens.curr,r=f.tokens.curr.value;return U(n)?t&&f.option.inES5()?r:e&&r==="undefined"?r:(K("W024",f.tokens.curr,f.tokens.curr.id),r):r}function _t(e,t){var n=Mt(e,t);if(n)return n;f.tokens.curr.id==="function"&&f.tokens.next.id==="("?K("W025"):G("E030",f.tokens.next,f.tokens.next.value)}function Dt(e){var t=0,n;if(f.tokens.next.id!==";"||O)return;for(;;){do n=nt(t),t+=1;while(n.id!="(end)"&&n.id==="(comment)");if(n.reach)return;if(n.id!=="(endline)"){if(n.id==="function"){f.option.latedef===!0&&K("W026",n);break}K("W027",n,n.value,e);break}}}function Pt(){f.tokens.next.id!==";"?f.option.asi||(!f.option.lastsemic||f.tokens.next.id!=="}"||f.tokens.next.line!==f.tokens.curr.line)&&Q("W033",f.tokens.curr.line,f.tokens.curr.character):rt(";")}function Ht(){var e,t=N,n,i=D,s=f.tokens.next;if(s.id===";"){rt(";");return}var o=U(s);o&&s.meta&&s.meta.isFutureReservedWord&&nt().id===":"&&(K("W024",s,s.id),o=!1);if(s.value==="module"&&s.type==="(identifier)"&&nt().type==="(identifier)"){f.option.inESNext()||K("W119",f.tokens.curr,"module"),rt("module");var u=_t();et(u,{type:"unused",token:f.tokens.curr}),rt("from"),rt("(string)"),Pt();return}if(r.has(["[","{"],s.value)&&on().isDestAssign){f.option.inESNext()||K("W104",f.tokens.curr,"destructuring expression"),e=Yt(),e.forEach(function(e){$(w,"W117",e.token,e.id)}),rt("="),Zt(e,ot(10,!0)),rt(";");return}s.identifier&&!o&&nt().id===":"&&(rt(),rt(":"),D=Object.create(i),et(s.value,{type:"label"}),!f.tokens.next.labelled&&f.tokens.next.value!=="{"&&K("W028",f.tokens.next,s.value,f.tokens.next.value),f.tokens.next.label=s.value,s=f.tokens.next);if(s.id==="{"){var a=w["(verb)"]==="case"&&f.tokens.curr.value===":";Ft(!0,!0,!1,!1,a);return}return n=ot(0,!0),n&&(!n.identifier||n.value!=="function")&&n.type!=="(punctuator)"&&!f.directive["use strict"]&&f.option.globalstrict&&f.option.strict&&K("E007"),s.block||(!f.option.expr&&(!n||!n.exps)?K("W030",f.tokens.curr):f.option.nonew&&n&&n.left&&n.id==="("&&n.left.id==="new"&&K("W031",s),Pt()),N=t,D=i,n}function Bt(e){var t=[],n;while(!f.tokens.next.reach&&f.tokens.next.id!=="(end)")f.tokens.next.id===";"?(n=nt(),(!n||n.id!=="("&&n.id!=="[")&&K("W032"),rt(";")):t.push(Ht(e===f.tokens.next.line));return t}function jt(){var e,t,n;for(;;){if(f.tokens.next.id==="(string)"){t=nt(0);if(t.id==="(endline)"){e=1;do n=nt(e),e+=1;while(n.id==="(endline)");if(n.id!==";"){if(n.id!=="(string)"&&n.id!=="(number)"&&n.id!=="(regexp)"&&n.identifier!==!0&&n.id!=="}")break;K("W033",f.tokens.next)}else t=n}else if(t.id==="}")K("W033",t);else if(t.id!==";")break;rt(),f.directive[f.tokens.curr.value]&&K("W034",f.tokens.curr,f.tokens.curr.value),f.tokens.curr.value==="use strict"&&(f.option["(explicitNewcap)"]||(f.option.newcap=!0),f.option.undef=!0),f.directive[f.tokens.curr.value]=!0,t.id===";"&&rt(";");continue}break}}function Ft(e,t,n,i,s){var o,u=T,a=N,l,c=D,h,p,d;T=e;if(!e||!f.option.funcscope)D=Object.create(D);h=f.tokens.next;var v=w["(metrics)"];v.nestedBlockDepth+=1,v.verifyMaxNestedBlockDepthPerFunction();if(f.tokens.next.id==="{"){rt("{"),w["(blockscope)"].stack(),p=f.tokens.curr.line;if(f.tokens.next.id!=="}"){N+=f.option.indent;while(!e&&f.tokens.next.from>N)N+=f.option.indent;if(n){l={};for(d in f.directive)r.has(f.directive,d)&&(l[d]=f.directive[d]);jt(),f.option.strict&&w["(context)"]["(global)"]&&!l["use strict"]&&!f.directive["use strict"]&&K("E007")}o=Bt(p),v.statementCount+=o.length,n&&(f.directive=l),N-=f.option.indent}rt("}",h),w["(blockscope)"].unstack(),N=a}else if(!e)if(n){l={},t&&!i&&!f.option.inMoz(!0)&&G("W118",f.tokens.curr,"function closure expressions");if(!t)for(d in f.directive)r.has(f.directive,d)&&(l[d]=f.directive[d]);ot(10),f.option.strict&&w["(context)"]["(global)"]&&!l["use strict"]&&!f.directive["use strict"]&&K("E007")}else G("E021",f.tokens.next,"{",f.tokens.next.value);else w["(nolet)"]=!0,(!t||f.option.curly)&&K("W116",f.tokens.next,"{",f.tokens.next.value),O=!0,N+=f.option.indent,o=[Ht()],N-=f.option.indent,O=!1,delete w["(nolet)"];switch(w["(verb)"]){case"break":case"continue":case"return":case"throw":if(s)break;default:w["(verb)"]=null}if(!e||!f.option.funcscope)D=c;return T=u,e&&f.option.noempty&&(!o||o.length===0)&&K("W035"),v.nestedBlockDepth-=1,o}function It(e){A&&typeof A[e]!="boolean"&&K("W036",f.tokens.curr,e),typeof L[e]=="number"?L[e]+=1:L[e]=1}function qt(e){var t=e.value,n=Object.getOwnPropertyDescriptor(x,t);n?n.value.push(e.line):x[t]=[e.line]}function Ut(){var e={};e.exps=!0,w["(comparray)"].stack();var t=!1;return f.tokens.next.value!=="for"&&(t=!0,f.option.inMoz(!0)||K("W116",f.tokens.next,"for",f.tokens.next.value),w["(comparray)"].setState("use"),e.right=ot(10)),rt("for"),f.tokens.next.value==="each"&&(rt("each"),f.option.inMoz(!0)||K("W118",f.tokens.curr,"for each")),rt("("),w["(comparray)"].setState("define"),e.left=ot(130),r.contains(["in","of"],f.tokens.next.value)?rt():G("E045",f.tokens.curr),w["(comparray)"].setState("generate"),ot(10),rt(")"),f.tokens.next.value==="if"&&(rt("if"),rt("("),w["(comparray)"].setState("filter"),e.filter=ot(10),rt(")")),t||(w["(comparray)"].setState("use"),e.right=ot(10)),rt("]"),w["(comparray)"].unstack(),e}function zt(){var e=Mt(!1,!0);return e||(f.tokens.next.id==="(string)"?(e=f.tokens.next.value,rt()):f.tokens.next.id==="(number)"&&(e=f.tokens.next.value.toString(),rt())),e==="hasOwnProperty"&&K("W001"),e}function Wt(e){var t,n,i=[],s,o=[],u,a=!1;if(e){if(Array.isArray(e)){for(var l in e){t=e[l];if(t.value==="..."){f.option.inESNext()||K("W104",t,"spread/rest operator");continue}t.value!==","&&(i.push(t.value),et(t.value,{type:"unused",token:t}))}return i}if(e.identifier===!0)return et(e.value,{type:"unused",token:e}),[e]}n=f.tokens.next,rt("(");if(f.tokens.next.id===")"){rt(")");return}for(;;){if(r.contains(["{","["],f.tokens.next.id)){o=Yt();for(u in o)u=o[u],u.id&&(i.push(u.id),et(u.id,{type:"unused",token:u.token}))}else f.tokens.next.value==="..."?(f.option.inESNext()||K("W104",f.tokens.next,"spread/rest operator"),rt("..."),s=_t(!0),i.push(s),et(s,{type:"unused",token:f.tokens.curr})):(s=_t(!0),i.push(s),et(s,{type:"unused",token:f.tokens.curr}));a&&f.tokens.next.id!=="="&&G("E051",f.tokens.current),f.tokens.next.id==="="&&(f.option.inESNext()||K("W119",f.tokens.next,"default parameters"),rt("="),a=!0,ot(10));if(f.tokens.next.id!==",")return rt(")",n),i;lt()}}function Xt(e,t,n){e["(properties)"][t]||(e["(properties)"][t]={unused:!1}),r.extend(e["(properties)"][t],n)}function Vt(e,t,n){return e["(properties)"][t]?e["(properties)"][t][n]||null:null}function $t(e,t,n,i){var s={"(name)":e,"(breakage)":0,"(loopage)":0,"(scope)":n,"(tokens)":{},"(properties)":{},"(catch)":!1,"(global)":!1,"(line)":null,"(character)":null,"(metrics)":null,"(statement)":null,"(context)":null,"(blockscope)":null,"(comparray)":null,"(generator)":null,"(params)":null};return t&&r.extend(s,{"(line)":t.line,"(character)":t.character,"(metrics)":Kt(t)}),r.extend(s,i),s["(context)"]&&(s["(blockscope)"]=s["(context)"]["(blockscope)"],s["(comparray)"]=s["(context)"]["(comparray)"]),s}function Jt(t,n,i,s){var o,u=f.option,a=f.ignored,l=D;return f.option=Object.create(f.option),f.ignored=Object.create(f.ignored),D=Object.create(D),w=$t(t||'"'+e+'"',f.tokens.next,D,{"(statement)":n,"(context)":w,"(generator)":i?!0:null}),o=w,f.tokens.curr.funct=w,E.push(w),t&&et(t,{type:"function"}),w["(params)"]=Wt(s),w["(metrics)"].verifyMaxParametersPerFunction(w["(params)"]),c.undefs=r.filter(c.undefs,function(e){return!r.contains(r.union(s),e[2])}),Ft(!1,!0,!0,s?!0:!1),!f.option.noyield&&i&&w["(generator)"]!=="yielded"&&K("W124",f.tokens.curr),w["(metrics)"].verifyMaxStatementsPerFunction(),w["(metrics)"].verifyMaxComplexityPerFunction(),w["(unusedOption)"]=f.option.unused,D=l,f.option=u,f.ignored=a,w["(last)"]=f.tokens.curr.line,w["(lastcharacter)"]=f.tokens.curr.character,r.map(Object.keys(w),function(e){if(e[0]==="(")return;w["(blockscope)"].unshadow(e)}),w=w["(context)"],o}function Kt(e){return{statementCount:0,nestedBlockDepth:-1,ComplexityCount:1,verifyMaxStatementsPerFunction:function(){f.option.maxstatements&&this.statementCount>f.option.maxstatements&&K("W071",e,this.statementCount)},verifyMaxParametersPerFunction:function(t){t=t||[],f.option.maxparams&&t.length>f.option.maxparams&&K("W072",e,t.length)},verifyMaxNestedBlockDepthPerFunction:function(){f.option.maxdepth&&this.nestedBlockDepth>0&&this.nestedBlockDepth===f.option.maxdepth+1&&K("W073",null,this.nestedBlockDepth)},verifyMaxComplexityPerFunction:function(){var t=f.option.maxcomplexity,n=this.ComplexityCount;t&&n>t&&K("W074",e,n)}}}function Qt(){w["(metrics)"].ComplexityCount+=1}function Gt(e){var t,n;e&&(t=e.id,n=e.paren,t===","&&(e=e.exprs[e.exprs.length-1])&&(t=e.id,n=n||e.paren));switch(t){case"=":case"+=":case"-=":case"*=":case"%=":case"&=":case"|=":case"^=":case"/=":!n&&!f.option.boss&&K("W084")}}function Yt(){var e,t,n=[];f.option.inESNext()||K("W104",f.tokens.curr,"destructuring expression");var i=function(){var e;if(r.contains(["[","{"],f.tokens.next.value)){t=Yt();for(var s in t)s=t[s],n.push({id:s.id,token:s.token})}else f.tokens.next.value===","?n.push({id:null,token:f.tokens.curr}):f.tokens.next.value==="("?(rt("("),i(),rt(")")):(e=_t(),e&&n.push({id:e,token:f.tokens.curr}))};if(f.tokens.next.value==="["){rt("["),i();while(f.tokens.next.value!=="]")rt(","),i();rt("]")}else if(f.tokens.next.value==="{"){rt("{"),e=_t(),f.tokens.next.value===":"?(rt(":"),i()):n.push({id:e,token:f.tokens.curr});while(f.tokens.next.value!=="}")rt(","),e=_t(),f.tokens.next.value===":"?(rt(":"),i()):n.push({id:e,token:f.tokens.curr});rt("}")}return n}function Zt(e,t){var n=t.first;if(!n)return;r.zip(e,Array.isArray(n)?n:[n]).forEach(function(e){var t=e[0],n=e[1];t&&n?t.first=n:t&&t.first&&!n&&K("W080",t.first,t.first.value)})}function rn(e){return f.option.inESNext()||K("W104",f.tokens.curr,"class"),e?(this.name=_t(),et(this.name,{type:"unused",token:f.tokens.curr})):f.tokens.next.identifier&&f.tokens.next.value!=="extends"&&(this.name=_t()),sn(this),this}function sn(e){var t=f.directive["use strict"];f.tokens.next.value==="extends"&&(rt("extends"),e.heritage=ot(10)),f.directive["use strict"]=!0,rt("{"),e.body=f.syntax["{"].nud(!0),f.directive["use strict"]=t}function un(){var e=on();e.notJson?(!f.option.inESNext()&&e.isDestAssign&&K("W104",f.tokens.curr,"destructuring assignment"),Bt()):(f.option.laxbreak=!0,f.jsonMode=!0,fn())}function fn(){function e(){var e={},t=f.tokens.next;rt("{");if(f.tokens.next.id!=="}")for(;;){if(f.tokens.next.id==="(end)")G("E026",f.tokens.next,t.line);else{if(f.tokens.next.id==="}"){K("W094",f.tokens.curr);break}f.tokens.next.id===","?G("E028",f.tokens.next):f.tokens.next.id!=="(string)"&&K("W095",f.tokens.next,f.tokens.next.value)}e[f.tokens.next.value]===!0?K("W075",f.tokens.next,f.tokens.next.value):f.tokens.next.value==="__proto__"&&!f.option.proto||f.tokens.next.value==="__iterator__"&&!f.option.iterator?K("W096",f.tokens.next,f.tokens.next.value):e[f.tokens.next.value]=!0,rt(),rt(":"),fn();if(f.tokens.next.id!==",")break;rt(",")}rt("}")}function t(){var e=f.tokens.next;rt("[");if(f.tokens.next.id!=="]")for(;;){if(f.tokens.next.id==="(end)")G("E027",f.tokens.next,e.line);else{if(f.tokens.next.id==="]"){K("W094",f.tokens.curr);break}f.tokens.next.id===","&&G("E028",f.tokens.next)}fn();if(f.tokens.next.id!==",")break;rt(",")}rt("]")}switch(f.tokens.next.id){case"{":e();break;case"[":t();break;case"true":case"false":case"null":case"(number)":case"(string)":rt();break;case"-":rt("-"),rt("(number)");break;default:G("E003",f.tokens.next)}}var e,t,n={"<":!0,"<=":!0,"==":!0,"===":!0,"!==":!0,"!=":!0,">":!0,">=":!0,"+":!0,"-":!0,"*":!0,"/":!0,"%":!0},h={asi:!0,bitwise:!0,boss:!0,browser:!0,camelcase:!0,couch:!0,curly:!0,debug:!0,devel:!0,dojo:!0,eqeqeq:!0,eqnull:!0,notypeof:!0,es3:!0,es5:!0,esnext:!0,moz:!0,evil:!0,expr:!0,forin:!0,funcscope:!0,globalstrict:!0,immed:!0,iterator:!0,jasmine:!0,jquery:!0,lastsemic:!0,laxbreak:!0,laxcomma:!0,loopfunc:!0,mootools:!0,multistr:!0,freeze:!0,newcap:!0,noarg:!0,node:!0,noempty:!0,nonbsp:!0,nonew:!0,nonstandard:!0,phantom:!0,plusplus:!0,proto:!0,prototypejs:!0,qunit:!0,rhino:!0,shelljs:!0,typed:!0,undef:!0,scripturl:!0,strict:!0,sub:!0,supernew:!0,validthis:!0,withstmt:!0,worker:!0,wsh:!0,yui:!0,mocha:!0,noyield:!0,onecase:!0,regexp:!0,regexdash:!0},p={maxlen:!1,indent:!1,maxerr:!1,predef:!1,globals:!1,quotmark:!1,scope:!1,maxstatements:!1,maxdepth:!1,maxparams:!1,maxcomplexity:!1,shadow:!1,unused:!0,latedef:!1,ignore:!1},d={bitwise:!0,forin:!0,newcap:!0,plusplus:!0,regexp:!0,undef:!0,eqeqeq:!0,strict:!0},v={eqeq:"eqeqeq",windows:"wsh",sloppy:"strict"},m={nomen:!0,onevar:!0,passfail:!0,white:!0,gcl:!0,smarttabs:!0,trailing:!0},g,y,b=["closure","exception","global","label","outer","unused","var"],w,E,S,x,T,N,C,k,L,A,O,M,D,P,H,B,j=[],F=new i.EventEmitter;gt("(number)",function(){return this}),gt("(string)",function(){return this}),gt("(template)",function(){return this}),f.syntax["(identifier)"]={type:"(identifier)",lbp:0,identifier:!0,nud:function(){var t=this.value,n=D[t],r,i;typeof n=="function"?n=undefined:!w["(blockscope)"].current.has(t)&&typeof n=="boolean"&&(r=w,w=E[0],et(t,{type:"var"}),n=w,w=r),i=w["(blockscope)"].getlabel(t);if(w===n||i)switch(i?i[t]["(type)"]:w[t]){case"unused":i?i[t]["(type)"]="var":w[t]="var";break;case"unction":i?i[t]["(type)"]="function":w[t]="function",this["function"]=!0;break;case"const":Xt(w,t,{unused:!1});break;case"function":this["function"]=!0;break;case"label":K("W037",f.tokens.curr,t)}else if(w["(global)"])typeof M[t]!="boolean"&&(e!=="typeof"&&e!=="delete"||f.tokens.next&&(f.tokens.next.value==="."||f.tokens.next.value==="["))&&(w["(comparray)"].check(t)||$(w,"W117",f.tokens.curr,t)),qt(f.tokens.curr);else switch(w[t]){case"closure":case"function":case"var":case"unused":K("W038",f.tokens.curr,t);break;case"label":K("W037",f.tokens.curr,t);break;case"outer":case"global":break;default:if(n===!0)w[t]=!0;else if(n===null)K("W039",f.tokens.curr,t),qt(f.tokens.curr);else if(typeof n!="object")(e!=="typeof"&&e!=="delete"||f.tokens.next&&(f.tokens.next.value==="."||f.tokens.next.value==="["))&&$(w,"W117",f.tokens.curr,t),w[t]=!0,qt(f.tokens.curr);else switch(n[t]){case"function":case"unction":this["function"]=!0,n[t]="closure",w[t]=n["(global)"]?"global":"outer";break;case"var":case"unused":n[t]="closure",w[t]=n["(global)"]?"global":"outer";break;case"const":Xt(n,t,{unused:!1});break;case"closure":w[t]=n["(global)"]?"global":"outer";break;case"label":K("W037",f.tokens.curr,t)}}return this},led:function(){G("E033",f.tokens.next,f.tokens.next.value)}},gt("(regexp)",function(){return this}),ht("(endline)"),ht("(begin)"),ht("(end)").reach=!0,ht("(error)").reach=!0,ht("}").reach=!0,ht(")"),ht("]"),ht('"').reach=!0,ht("'").reach=!0,ht(";"),ht(":").reach=!0,ht("#"),yt("else"),yt("case").reach=!0,yt("catch"),yt("default").reach=!0,yt("finally"),wt("arguments",function(e){f.directive["use strict"]&&w["(global)"]&&K("E008",e)}),wt("eval"),wt("false"),wt("Infinity"),wt("null"),wt("this",function(e){f.directive["use strict"]&&!f.option.validthis&&(w["(statement)"]&&w["(name)"].charAt(0)>"Z"||w["(global)"])&&K("W040",e)}),wt("true"),wt("undefined"),kt("=","assign",20),kt("+=","assignadd",20),kt("-=","assignsub",20),kt("*=","assignmult",20),kt("/=","assigndiv",20).nud=function(){G("E014")},kt("%=","assignmod",20),At("&=","assignbitand",20),At("|=","assignbitor",20),At("^=","assignbitxor",20),At("<<=","assignshiftleft",20),At(">>=","assignshiftright",20),At(">>>=","assignshiftrightunsigned",20),Et(",",function(e,t){var n;t.exprs=[e];if(!lt({peek:!0}))return t;for(;;){if(!(n=ot(10)))break;t.exprs.push(n);if(f.tokens.next.value!==","||!lt())break}return t},10,!0),Et("?",function(e,t){return Qt(),t.left=e,t.right=ot(10),rt(":"),t["else"]=ot(10),t},30);var Rt=40;Et("||",function(e,t){return Qt(),t.left=e,t.right=ot(Rt),t},Rt),Et("&&","and",50),Lt("|","bitor",70),Lt("^","bitxor",80),Lt("&","bitand",90),xt("==",function(e,t){var n=f.option.eqnull&&(e.value==="null"||t.value==="null");switch(!0){case!n&&f.option.eqeqeq:this.from=this.character,K("W116",this,"===","==");break;case Tt(e):K("W041",this,"===",e.value);break;case Tt(t):K("W041",this,"===",t.value);break;case Nt(t,e):K("W122",this,t.value);break;case Nt(e,t):K("W122",this,e.value)}return this}),xt("===",function(e,t){return Nt(t,e)?K("W122",this,t.value):Nt(e,t)&&K("W122",this,e.value),this}),xt("!=",function(e,t){var n=f.option.eqnull&&(e.value==="null"||t.value==="null");return!n&&f.option.eqeqeq?(this.from=this.character,K("W116",this,"!==","!=")):Tt(e)?K("W041",this,"!==",e.value):Tt(t)?K("W041",this,"!==",t.value):Nt(t,e)?K("W122",this,t.value):Nt(e,t)&&K("W122",this,e.value),this}),xt("!==",function(e,t){return Nt(t,e)?K("W122",this,t.value):Nt(e,t)&&K("W122",this,e.value),this}),xt("<"),xt(">"),xt("<="),xt(">="),Lt("<<","shiftleft",120),Lt(">>","shiftright",120),Lt(">>>","shiftrightunsigned",120),Et("in","in",120),Et("instanceof","instanceof",120),Et("+",function(e,t){var n=ot(130);return e&&n&&e.id==="(string)"&&n.id==="(string)"?(e.value+=n.value,e.character=n.character,!f.option.scripturl&&a.javascriptURL.test(e.value)&&K("W050",e),e):(t.left=e,t.right=n,t)},130),mt("+","num"),mt("+++",function(){return K("W007"),this.right=ot(150),this.arity="unary",this}),Et("+++",function(e){return K("W007"),this.left=e,this.right=ot(130),this},130),Et("-","sub",130),mt("-","neg"),mt("---",function(){return K("W006"),this.right=ot(150),this.arity="unary",this}),Et("---",function(e){return K("W006"),this.left=e,this.right=ot(130),this},130),Et("*","mult",140),Et("/","div",140),Et("%","mod",140),Ot("++","postinc"),mt("++","preinc"),f.syntax["++"].exps=!0,Ot("--","postdec"),mt("--","predec"),f.syntax["--"].exps=!0,mt("delete",function(){var e=ot(10);return(!e||e.id!=="."&&e.id!=="[")&&K("W051"),this.first=e,this}).exps=!0,mt("~",function(){return f.option.bitwise&&K("W052",this,"~"),ot(150),this}),mt("...",function(){return f.option.inESNext()||K("W104",this,"spread/rest operator"),f.tokens.next.identifier||G("E030",f.tokens.next,f.tokens.next.value),ot(150),this}),mt("!",function(){return this.right=ot(150),this.arity="unary",this.right||V("E041",this.line||0),n[this.right.id]===!0&&K("W018",this,"!"),this}),mt("typeof","typeof"),mt("new",function(){var e=ot(155),t;if(e&&e.id!=="function")if(e.identifier){e["new"]=!0;switch(e.value){case"Number":case"String":case"Boolean":case"Math":case"JSON":K("W053",f.tokens.prev,e.value);break;case"Function":f.option.evil||K("W054");break;case"Date":case"RegExp":case"this":break;default:e.id!=="function"&&(t=e.value.substr(0,1),f.option.newcap&&(t<"A"||t>"Z")&&!r.has(S,e.value)&&K("W055",f.tokens.curr))}}else e.id!=="."&&e.id!=="["&&e.id!=="("&&K("W056",f.tokens.curr);else f.option.supernew||K("W057",this);return f.tokens.next.id!=="("&&!f.option.supernew&&K("W058",f.tokens.curr,f.tokens.curr.value),this.first=e,this}),f.syntax["new"].exps=!0,mt("void").exps=!0,Et(".",function(e,t){var n=_t(!1,!0);return typeof n=="string"&&It(n),t.left=e,t.right=n,n&&n==="hasOwnProperty"&&f.tokens.next.value==="="&&K("W001"),!e||e.value!=="arguments"||n!=="callee"&&n!=="caller"?!f.option.evil&&e&&e.value==="document"&&(n==="write"||n==="writeln")&&K("W060",e):f.option.noarg?K("W059",e,n):f.directive["use strict"]&&G("E008"),!f.option.evil&&(n==="eval"||n==="execScript")&&K("W061"),t},160,!0),Et("(",function(e,t){f.option.immed&&e&&!e.immed&&e.id==="function"&&K("W062");var n=0,r=[];e&&e.type==="(identifier)"&&e.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)&&"Number String Boolean Date Object Error".indexOf(e.value)===-1&&(e.value==="Math"?K("W063",e):f.option.newcap&&K("W064",e));if(f.tokens.next.id!==")")for(;;){r[r.length]=ot(10),n+=1;if(f.tokens.next.id!==",")break;lt()}return rt(")"),typeof e=="object"&&(f.option.inES3()&&e.value==="parseInt"&&n===1&&K("W065",f.tokens.curr),f.option.evil||(e.value==="eval"||e.value==="Function"||e.value==="execScript"?(K("W061",e),r[0]&&[0].id==="(string)"&&Z(e,r[0].value)):!r[0]||r[0].id!=="(string)"||e.value!=="setTimeout"&&e.value!=="setInterval"?r[0]&&r[0].id==="(string)"&&e.value==="."&&e.left.value==="window"&&(e.right==="setTimeout"||e.right==="setInterval")&&(K("W066",e),Z(e,r[0].value)):(K("W066",e),Z(e,r[0].value))),!e.identifier&&e.id!=="."&&e.id!=="["&&e.id!=="("&&e.id!=="&&"&&e.id!=="||"&&e.id!=="?"&&K("W067",e)),t.left=e,t},155,!0).exps=!0,mt("(",function(){var e,t=[],n,i,s=0,o,u=1;do n=nt(s),n.value==="("?u+=1:n.value===")"&&(u-=1),s+=1,i=nt(s);while((u!==0||n.value!==")")&&i.value!=="=>"&&i.value!==";"&&i.type!=="(end)");f.tokens.next.id==="function"&&(f.tokens.next.immed=!0);var a=[];if(f.tokens.next.id!==")")for(;;){if(i.value==="=>"&&r.contains(["{","["],f.tokens.next.value)){e=f.tokens.next,e.left=Yt(),t.push(e);for(var l in e.left)a.push(e.left[l].token)}else a.push(ot(10));if(f.tokens.next.id!==",")break;lt()}rt(")",this),f.option.immed&&a[0]&&a[0].id==="function"&&f.tokens.next.id!=="("&&(f.tokens.next.id!=="."||nt().value!=="call"&&nt().value!=="apply")&&K("W068",this);if(f.tokens.next.value==="=>")return a;if(!a.length)return;return a.length>1?(o=Object.create(f.syntax[","]),o.exprs=a):o=a[0],o&&(o.paren=!0),o}),St("=>"),Et("[",function(e,t){var n=ot(10),r;return n&&n.type==="(string)"&&(!f.option.evil&&(n.value==="eval"||n.value==="execScript")&&K("W061",t),It(n.value),!f.option.sub&&a.identifier.test(n.value)&&(r=f.syntax[n.value],(!r||!U(r))&&K("W069",f.tokens.prev,n.value))),rt("]",t),n&&n.value==="hasOwnProperty"&&f.tokens.next.value==="="&&K("W001"),t.left=e,t.right=n,t},160,!0),mt("[",function(){var e=on(!0);if(e.isCompArray)return f.option.inESNext()||K("W119",f.tokens.curr,"array comprehension"),Ut();e.isDestAssign&&!f.option.inESNext()&&K("W104",f.tokens.curr,"destructuring assignment");var t=f.tokens.curr.line!==f.tokens.next.line;this.first=[],t&&(N+=f.option.indent,f.tokens.next.from===N+f.option.indent&&(N+=f.option.indent));while(f.tokens.next.id!=="(end)"){while(f.tokens.next.id===",")f.option.inES5()||K("W070"),rt(",");if(f.tokens.next.id==="]")break;this.first.push(ot(10));if(f.tokens.next.id!==",")break;lt({allowTrailing:!0});if(f.tokens.next.id==="]"&&!f.option.inES5(!0)){K("W070",f.tokens.curr);break}}return t&&(N-=f.option.indent),rt("]",this),this},160),function(e){e.nud=function(e){function c(e,t){a[e]&&r.has(a,e)?K("W075",f.tokens.next,i):a[e]={},a[e].basic=!0,a[e].basictkn=t}function h(e,t){a[e]&&r.has(a,e)?(a[e].basic||a[e].setter)&&K("W075",f.tokens.next,i):a[e]={},a[e].setter=!0,a[e].setterToken=t}function p(e){a[e]&&r.has(a,e)?(a[e].basic||a[e].getter)&&K("W075",f.tokens.next,i):a[e]={},a[e].getter=!0,a[e].getterToken=f.tokens.curr}var t,n,i,s,o,u,a={},l="";t=f.tokens.curr.line!==f.tokens.next.line,t&&(N+=f.option.indent,f.tokens.next.from===N+f.option.indent&&(N+=f.option.indent));for(;;){if(f.tokens.next.id==="}")break;e&&f.tokens.next.value==="static"&&(rt("static"),l="static ");if(f.tokens.next.value==="get"&&nt().id!==":")rt("get"),f.option.inES5(!e)||G("E034"),i=zt(),!i&&!f.option.inESNext()&&G("E035"),e&&i==="constructor"&&G("E049",f.tokens.next,"class getter method",i),i&&p(l+i),o=f.tokens.next,n=Jt(),s=n["(params)"],i&&s&&K("W076",o,s[0],i);else if(f.tokens.next.value==="set"&&nt().id!==":")rt("set"),f.option.inES5(!e)||G("E034"),i=zt(),!i&&!f.option.inESNext()&&G("E035"),e&&i==="constructor"&&G("E049",f.tokens.next,"class setter method",i),i&&h(l+i,f.tokens.next),o=f.tokens.next,n=Jt(),s=n["(params)"],i&&(!s||s.length!==1)&&K("W077",o,i);else{u=!1,f.tokens.next.value==="*"&&f.tokens.next.type==="(punctuator)"&&(f.option.inESNext()||K("W104",f.tokens.next,"generator functions"),rt("*"),u=!0),i=zt(),c(l+i,f.tokens.next);if(typeof i!="string")break;f.tokens.next.value==="("?(f.option.inESNext()||K("W104",f.tokens.curr,"concise methods"),Jt(i,undefined,u)):e||(rt(":"),ot(10))}e&&i==="prototype"&&G("E049",f.tokens.next,"class method",i),It(i);if(e){l="";continue}if(f.tokens.next.id!==",")break;lt({allowTrailing:!0,property:!0}),f.tokens.next.id===","?K("W070",f.tokens.curr):f.tokens.next.id==="}"&&!f.option.inES5(!0)&&K("W070",f.tokens.curr)}t&&(N-=f.option.indent),rt("}",this);if(f.option.inES5())for(var d in a)r.has(a,d)&&a[d].setter&&!a[d].getter&&K("W078",a[d].setterToken);return this},e.fud=function(){G("E036",f.tokens.curr)}}(ht("{"));var en=pt("const",function(e){var t,n,i;f.option.inESNext()||K("W104",f.tokens.curr,"const"),this.first=[];for(;;){var s=[];r.contains(["{","["],f.tokens.next.value)?(t=Yt(),i=!1):(t=[{id:_t(),token:f.tokens.curr}],i=!0);for(var o in t)t.hasOwnProperty(o)&&(o=t[o],w[o.id]==="const"&&K("E011",null,o.id),w["(global)"]&&M[o.id]===!1&&K("W079",o.token,o.id),o.id&&(et(o.id,{token:o.token,type:"const",unused:!0}),s.push(o.token)));if(e)break;this.first=this.first.concat(s),f.tokens.next.id!=="="&&K("E012",f.tokens.curr,f.tokens.curr.value),f.tokens.next.id==="="&&(rt("="),f.tokens.next.id==="undefined"&&K("W080",f.tokens.prev,f.tokens.prev.value),nt(0).id==="="&&f.tokens.next.identifier&&K("W120",f.tokens.next,f.tokens.next.value),n=ot(10),i?t[0].first=n:Zt(s,n));if(f.tokens.next.id!==",")break;lt()}return this});en.exps=!0;var tn=pt("var",function(e){var t,n,i;this.first=[];for(;;){var s=[];r.contains(["{","["],f.tokens.next.value)?(t=Yt(),n=!1):(t=[{id:_t(),token:f.tokens.curr}],n=!0);for(var o in t)t.hasOwnProperty(o)&&(o=t[o],f.option.inESNext()&&w[o.id]==="const"&&K("E011",null,o.id),w["(global)"]&&M[o.id]===!1&&K("W079",o.token,o.id),o.id&&(et(o.id,{type:"unused",token:o.token}),s.push(o.token)));if(e)break;this.first=this.first.concat(s),f.tokens.next.id==="="&&(rt("="),f.tokens.next.id==="undefined"&&K("W080",f.tokens.prev,f.tokens.prev.value),nt(0).id==="="&&f.tokens.next.identifier&&K("W120",f.tokens.next,f.tokens.next.value),i=ot(10),n?t[0].first=i:Zt(s,i));if(f.tokens.next.id!==",")break;lt()}return this});tn.exps=!0;var nn=pt("let",function(e){var t,n,i,s;f.option.inESNext()||K("W104",f.tokens.curr,"let"),f.tokens.next.value==="("?(f.option.inMoz(!0)||K("W118",f.tokens.next,"let block"),rt("("),w["(blockscope)"].stack(),s=!0):w["(nolet)"]&&G("E048",f.tokens.curr),this.first=[];for(;;){var o=[];r.contains(["{","["],f.tokens.next.value)?(t=Yt(),n=!1):(t=[{id:_t(),token:f.tokens.curr.value}],n=!0);for(var u in t)t.hasOwnProperty(u)&&(u=t[u],f.option.inESNext()&&w[u.id]==="const"&&K("E011",null,u.id),w["(global)"]&&M[u.id]===!1&&K("W079",u.token,u.id),u.id&&!w["(nolet)"]&&(et(u.id,{type:"unused",token:u.token,islet:!0}),o.push(u.token)));if(e)break;this.first=this.first.concat(o),f.tokens.next.id==="="&&(rt("="),f.tokens.next.id==="undefined"&&K("W080",f.tokens.prev,f.tokens.prev.value),nt(0).id==="="&&f.tokens.next.identifier&&K("W120",f.tokens.next,f.tokens.next.value),i=ot(10),n?t[0].first=i:Zt(o,i));if(f.tokens.next.id!==",")break;lt()}return s&&(rt(")"),Ft(!0,!0),this.block=!0,w["(blockscope)"].unstack()),this});nn.exps=!0,dt("class",function(){return rn.call(this,!0)}),dt("function",function(){var e=!1;f.tokens.next.value==="*"&&(rt("*"),f.option.inESNext(!0)?e=!0:K("W119",f.tokens.curr,"function*")),T&&K("W082",f.tokens.curr);var t=_t();return w[t]==="const"&&K("E011",null,t),et(t,{type:"unction",token:f.tokens.curr}),Jt(t,{statement:!0},e),f.tokens.next.id==="("&&f.tokens.next.line===f.tokens.curr.line&&G("E039"),this}),mt("function",function(){var e=!1;f.tokens.next.value==="*"&&(f.option.inESNext()||K("W119",f.tokens.curr,"function*"),rt("*"),e=!0);var t=Mt();return Jt(t,undefined,e),!f.option.loopfunc&&w["(loopage)"]&&K("W083"),this}),dt("if",function(){var e=f.tokens.next;return Qt(),f.condition=!0,rt("("),Gt(ot(0)),rt(")",e),f.condition=!1,Ft(!0,!0),f.tokens.next.id==="else"&&(rt("else"),f.tokens.next.id==="if"||f.tokens.next.id==="switch"?Ht(!0):Ft(!0,!0)),this}),dt("try",function(){function t(){var e=D,t;rt("catch"),rt("("),D=Object.create(e),t=f.tokens.next.value,f.tokens.next.type!=="(identifier)"&&(t=null,K("E030",f.tokens.next,t)),rt(),w=$t("(catch)",f.tokens.next,D,{"(context)":w,"(breakage)":w["(breakage)"],"(loopage)":w["(loopage)"],"(statement)":!1,"(catch)":!0}),t&&et(t,{type:"exception"}),f.tokens.next.value==="if"&&(f.option.inMoz(!0)||K("W118",f.tokens.curr,"catch filter"),rt("if"),ot(0)),rt(")"),f.tokens.curr.funct=w,E.push(w),Ft(!1),D=e,w["(last)"]=f.tokens.curr.line,w["(lastcharacter)"]=f.tokens.curr.character,w=w["(context)"]}var e;Ft(!0);while(f.tokens.next.id==="catch")Qt(),e&&!f.option.inMoz(!0)&&K("W118",f.tokens.next,"multiple catch blocks"),t(),e=!0;if(f.tokens.next.id==="finally"){rt("finally"),Ft(!0);return}return e||G("E021",f.tokens.next,"catch",f.tokens.next.value),this}),dt("while",function(){var e=f.tokens.next;return w["(breakage)"]+=1,w["(loopage)"]+=1,Qt(),rt("("),Gt(ot(0)),rt(")",e),Ft(!0,!0),w["(breakage)"]-=1,w["(loopage)"]-=1,this}).labelled=!0,dt("with",function(){var e=f.tokens.next;return f.directive["use strict"]?G("E010",f.tokens.curr):f.option.withstmt||K("W085",f.tokens.curr),rt("("),ot(0),rt(")",e),Ft(!0,!0),this}),dt("switch",function(){var e=f.tokens.next,t=!1,n=!1;w["(breakage)"]+=1,rt("("),Gt(ot(0)),rt(")",e),e=f.tokens.next,rt("{"),f.tokens.next.from===N&&(n=!0),n||(N+=f.option.indent),this.cases=[];for(;;)switch(f.tokens.next.id){case"case":switch(w["(verb)"]){case"yield":case"break":case"case":case"continue":case"return":case"switch":case"throw":break;default:a.fallsThrough.test(f.lines[f.tokens.next.line-2])||K("W086",f.tokens.curr,"case")}rt("case"),this.cases.push(ot(0)),Qt(),t=!0,rt(":"),w["(verb)"]="case";break;case"default":switch(w["(verb)"]){case"yield":case"break":case"continue":case"return":case"throw":break;default:this.cases.length&&(a.fallsThrough.test(f.lines[f.tokens.next.line-2])||K("W086",f.tokens.curr,"default"))}rt("default"),t=!0,rt(":");break;case"}":n||(N-=f.option.indent),rt("}",e),w["(breakage)"]-=1,w["(verb)"]=undefined;return;case"(end)":G("E023",f.tokens.next,"}");return;default:N+=f.option.indent;if(t)switch(f.tokens.curr.id){case",":G("E040");return;case":":t=!1,Bt();break;default:G("E025",f.tokens.curr);return}else{if(f.tokens.curr.id!==":"){G("E021",f.tokens.next,"case",f.tokens.next.value);return}rt(":"),G("E024",f.tokens.curr,":"),Bt()}N-=f.option.indent}}).labelled=!0,pt("debugger",function(){return f.option.debug||K("W087",this),this}).exps=!0,function(){var e=pt("do",function(){w["(breakage)"]+=1,w["(loopage)"]+=1,Qt(),this.first=Ft(!0,!0),rt("while");var e=f.tokens.next;return rt("("),Gt(ot(0)),rt(")",e),w["(breakage)"]-=1,w["(loopage)"]-=1,this});e.labelled=!0,e.exps=!0}(),dt("for",function(){var e,t=f.tokens.next,n=!1,i=null;t.value==="each"&&(i=t,rt("each"),f.option.inMoz(!0)||K("W118",f.tokens.curr,"for each")),w["(breakage)"]+=1,w["(loopage)"]+=1,Qt(),rt("(");var s,o=0,u=["in","of"];do s=nt(o),++o;while(!r.contains(u,s.value)&&s.value!==";"&&s.type!=="(end)");if(r.contains(u,s.value)){!f.option.inESNext()&&s.value==="of"&&G("W104",s,"for of");if(f.tokens.next.id==="var")rt("var"),f.syntax["var"].fud.call(f.syntax["var"].fud,!0);else if(f.tokens.next.id==="let")rt("let"),n=!0,w["(blockscope)"].stack(),f.syntax.let.fud.call(f.syntax.let.fud,!0);else if(!f.tokens.next.identifier)G("E030",f.tokens.next,f.tokens.next.type),rt();else{switch(w[f.tokens.next.value]){case"unused":w[f.tokens.next.value]="var";break;case"var":break;default:w["(blockscope)"].getlabel(f.tokens.next.value)||K("W088",f.tokens.next,f.tokens.next.value)}rt()}rt(s.value),ot(20),rt(")",t),e=Ft(!0,!0),f.option.forin&&e&&(e.length>1||typeof e[0]!="object"||e[0].value!=="if")&&K("W089",this),w["(breakage)"]-=1,w["(loopage)"]-=1}else{i&&G("E045",i);if(f.tokens.next.id!==";")if(f.tokens.next.id==="var")rt("var"),f.syntax["var"].fud.call(f.syntax["var"].fud);else if(f.tokens.next.id==="let")rt("let"),n=!0,w["(blockscope)"].stack(),f.syntax.let.fud.call(f.syntax.let.fud);else for(;;){ot(0,"for");if(f.tokens.next.id!==",")break;lt()}at(f.tokens.curr),rt(";"),f.tokens.next.id!==";"&&Gt(ot(0)),at(f.tokens.curr),rt(";"),f.tokens.next.id===";"&&G("E021",f.tokens.next,")",";");if(f.tokens.next.id!==")")for(;;){ot(0,"for");if(f.tokens.next.id!==",")break;lt()}rt(")",t),Ft(!0,!0),w["(breakage)"]-=1,w["(loopage)"]-=1}return n&&w["(blockscope)"].unstack(),this}).labelled=!0,pt("break",function(){var e=f.tokens.next.value;return w["(breakage)"]===0&&K("W052",f.tokens.next,this.value),f.option.asi||at(this),f.tokens.next.id!==";"&&!f.tokens.next.reach&&f.tokens.curr.line===f.tokens.next.line&&(w[e]!=="label"?K("W090",f.tokens.next,e):D[e]!==w&&K("W091",f.tokens.next,e),this.first=f.tokens.next,rt()),Dt("break"),this}).exps=!0,pt("continue",function(){var e=f.tokens.next.value;return w["(breakage)"]===0&&K("W052",f.tokens.next,this.value),f.option.asi||at(this),f.tokens.next.id!==";"&&!f.tokens.next.reach?f.tokens.curr.line===f.tokens.next.line&&(w[e]!=="label"?K("W090",f.tokens.next,e):D[e]!==w&&K("W091",f.tokens.next,e),this.first=f.tokens.next,rt()):w["(loopage)"]||K("W052",f.tokens.next,this.value),Dt("continue"),this}).exps=!0,pt("return",function(){return this.line===f.tokens.next.line?f.tokens.next.id!==";"&&!f.tokens.next.reach&&(this.first=ot(0),this.first&&this.first.type==="(punctuator)"&&this.first.value==="="&&!this.first.paren&&!f.option.boss&&Q("W093",this.first.line,this.first.character)):f.tokens.next.type==="(punctuator)"&&["[","{","+","-"].indexOf(f.tokens.next.value)>-1&&at(this),Dt("return"),this}).exps=!0,function(e){e.exps=!0,e.lbp=25}(mt("yield",function(){var e=f.tokens.prev;return f.option.inESNext(!0)&&!w["(generator)"]?("(catch)"!==w["(name)"]||!w["(context)"]["(generator)"])&&G("E046",f.tokens.curr,"yield"):f.option.inESNext()||K("W104",f.tokens.curr,"yield"),w["(generator)"]="yielded",this.line===f.tokens.next.line||!f.option.inMoz(!0)?(f.tokens.next.id!==";"&&!f.tokens.next.reach&&f.tokens.next.nud&&(ut(f.tokens.curr,f.tokens.next),this.first=ot(10),this.first.type==="(punctuator)"&&this.first.value==="="&&!this.first.paren&&!f.option.boss&&Q("W093",this.first.line,this.first.character)),f.option.inMoz(!0)&&f.tokens.next.id!==")"&&(e.lbp>30||!e.assign&&!st()||e.id==="yield")&&G("E050",this)):f.option.asi||at(this),this})),pt("throw",function(){return at(this),this.first=ot(20),Dt("throw"),this}).exps=!0,pt("import",function(){f.option.inESNext()||K("W119",f.tokens.curr,"import");if(f.tokens.next.type==="(string)")return rt("(string)"),this;if(f.tokens.next.identifier)this.name=_t(),et(this.name,{type:"unused",token:f.tokens.curr});else{rt("{");for(;;){if(f.tokens.next.value==="}"){rt("}");break}var e;f.tokens.next.type==="default"?(e="default",rt("default")):e=_t(),f.tokens.next.value==="as"&&(rt("as"),e=_t()),et(e,{type:"unused",token:f.tokens.curr});if(f.tokens.next.value!==","){if(f.tokens.next.value==="}"){rt("}");break}G("E024",f.tokens.next,f.tokens.next.value);break}rt(",")}}return rt("from"),rt("(string)"),this}).exps=!0,pt("export",function(){f.option.inESNext()||K("W119",f.tokens.curr,"export");if(f.tokens.next.type==="default"){rt("default");if(f.tokens.next.id==="function"||f.tokens.next.id==="class")this.block=!0;return this.exportee=ot(10),this}if(f.tokens.next.value==="{"){rt("{");for(;;){y[_t()]=!0;if(f.tokens.next.value!==","){if(f.tokens.next.value==="}"){rt("}");break}G("E024",f.tokens.next,f.tokens.next.value);break}rt(",")}return this}return f.tokens.next.id==="var"?(rt("var"),y[f.tokens.next.value]=!0,f.syntax["var"].fud.call(f.syntax["var"].fud)):f.tokens.next.id==="let"?(rt("let"),y[f.tokens.next.value]=!0,f.syntax.let.fud.call(f.syntax.let.fud)):f.tokens.next.id==="const"?(rt("const"),y[f.tokens.next.value]=!0,f.syntax["const"].fud.call(f.syntax["const"].fud)):f.tokens.next.id==="function"?(this.block=!0,rt("function"),y[f.tokens.next.value]=!0,f.syntax["function"].fud()):f.tokens.next.id==="class"?(this.block=!0,rt("class"),y[f.tokens.next.value]=!0,f.syntax["class"].fud()):G("E024",f.tokens.next,f.tokens.next.value),this}).exps=!0,bt("abstract"),bt("boolean"),bt("byte"),bt("char"),bt("class",{es5:!0,nud:rn}),bt("double"),bt("enum",{es5:!0}),bt("export",{es5:!0}),bt("extends",{es5:!0}),bt("final"),bt("float"),bt("goto"),bt("implements",{es5:!0,strictOnly:!0}),bt("import",{es5:!0}),bt("int"),bt("interface",{es5:!0,strictOnly:!0}),bt("long"),bt("native"),bt("package",{es5:!0,strictOnly:!0}),bt("private",{es5:!0,strictOnly:!0}),bt("protected",{es5:!0,strictOnly:!0}),bt("public",{es5:!0,strictOnly:!0}),bt("short"),bt("static",{es5:!0,strictOnly:!0}),bt("super",{es5:!0}),bt("synchronized"),bt("transient"),bt("volatile");var on=function(){var e,t,n=-1,i=0,s={};r.contains(["[","{"],f.tokens.curr.value)&&(i+=1);do{e=n===-1?f.tokens.next:nt(n),t=nt(n+1),n+=1,r.contains(["[","{"],e.value)?i+=1:r.contains(["]","}"],e.value)&&(i-=1);if(e.identifier&&e.value==="for"&&i===1){s.isCompArray=!0,s.notJson=!0;break}if(r.contains(["}","]"],e.value)&&t.value==="="&&i===0){s.isDestAssign=!0,s.notJson=!0;break}e.value===";"&&(s.isBlock=!0,s.notJson=!0)}while(i>0&&e.id!=="(end)"&&n<15);return s},an=function(){function i(e){var t=n.variables.filter(function(t){if(t.value===e)return t.undef=!1,e}).length;return t!==0}function s(e){var t=n.variables.filter(function(t){if(t.value===e&&!t.undef)return t.unused===!0&&(t.unused=!1),e}).length;return t===0}var e=function(){this.mode="use",this.variables=[]},t=[],n;return{stack:function(){n=new e,t.push(n)},unstack:function(){n.variables.filter(function(e){e.unused&&K("W098",e.token,e.value),e.undef&&$(e.funct,"W117",e.token,e.value)}),t.splice(-1,1),n=t[t.length-1]},setState:function(e){r.contains(["use","define","generate","filter"],e)&&(n.mode=e)},check:function(e){if(!n)return;return n&&n.mode==="use"?(s(e)&&n.variables.push({funct:w,token:f.tokens.curr,value:e,undef:!0,unused:!1}),!0):n&&n.mode==="define"?(i(e)||n.variables.push({funct:w,token:f.tokens.curr,value:e,undef:!1,unused:!0}),!0):n&&n.mode==="generate"?($(w,"W117",f.tokens.curr,e),!0):n&&n.mode==="filter"?(s(e)&&$(w,"W117",f.tokens.curr,e),!0):!1}}},ln=function(){function n(){for(var t in e)if(e[t]["(type)"]==="unused"&&f.option.unused){var n=e[t]["(token)"],r=n.line,i=n.character;Q("W098",r,i,t)}}var e={},t=[e];return{stack:function(){e={},t.push(e)},unstack:function(){n(),t.splice(t.length-1,1),e=r.last(t)},getlabel:function(e){for(var n=t.length-1;n>=0;--n)if(r.has(t[n],e)&&!t[n][e]["(shadowed)"])return t[n]},shadow:function(e){for(var n=t.length-1;n>=0;n--)r.has(t[n],e)&&(t[n][e]["(shadowed)"]=!0)},unshadow:function(e){for(var n=t.length-1;n>=0;n--)r.has(t[n],e)&&(t[n][e]["(shadowed)"]=!1)},current:{has:function(t){return r.has(e,t)},add:function(t,n,r){e[t]={"(type)":n,"(token)":r,"(shadowed)":!1}}}}},cn=function(e,n,i){function v(e,t){if(!e)return;!Array.isArray(e)&&typeof e=="object"&&(e=Object.keys(e)),e.forEach(t)}var o,a,l,h,p={},d={};n=r.clone(n),f.reset(),n&&n.scope?c.scope=n.scope:(c.errors=[],c.undefs=[],c.internals=[],c.blacklist={},c.scope="(main)"),M=Object.create(null),W(M,s.ecmaIdentifiers),W(M,s.reservedVars),W(M,i||{}),g=Object.create(null),y=Object.create(null);if(n){v(n.predef||null,function(e){var t,r;e[0]==="-"?(t=e.slice(1),c.blacklist[t]=t):(r=Object.getOwnPropertyDescriptor(n.predef,e),M[e]=r?r.value:!1)}),v(n.exported||null,function(e){y[e]=!0}),delete n.predef,delete n.exported,h=Object.keys(n);for(l=0;l0&&(e.implieds=t),B.length>0&&(e.urls=B),l=Object.keys(D),l.length>0&&(e.globals=l);for(o=1;o0&&(e.unused=H),n=[];for(a in L)if(typeof L[a]=="number"){e.member=L;break}return e},cn.jshint=cn,cn}();typeof n=="object"&&n&&(n.JSHINT=c)},{"./lex.js":4,"./messages.js":5,"./reg.js":6,"./state.js":7,"./style.js":8,"./vars.js":9,events:10,underscore:2}],4:[function(e,t,n){"use strict";function c(){var e=[];return{push:function(t){e.push(t)},check:function(){for(var t=0;t"&&t===">"&&n===">"&&r==="="?{type:l.Punctuator,value:">>>="}:e==="="&&t==="="&&n==="="?{type:l.Punctuator,value:"==="}:e==="!"&&t==="="&&n==="="?{type:l.Punctuator,value:"!=="}:e===">"&&t===">"&&n===">"?{type:l.Punctuator,value:">>>"}:e==="<"&&t==="<"&&n==="="?{type:l.Punctuator,value:"<<="}:e===">"&&t===">"&&n==="="?{type:l.Punctuator,value:">>="}:e==="="&&t===">"?{type:l.Punctuator,value:e+t}:e===t&&"+-<>&|".indexOf(e)>=0?{type:l.Punctuator,value:e+t}:"<>=!+-*%&|^".indexOf(e)>=0?t==="="?{type:l.Punctuator,value:e+t}:{type:l.Punctuator,value:e}:e==="/"?t==="="&&/\/=(?!(\S*\/[gim]?))/.test(this.input)?{type:l.Punctuator,value:"/="}:{type:l.Punctuator,value:"/"}:null},scanComments:function(){function s(e,t,n){var r=["jshint","jslint","members","member","globals","global","exported"],i=!1,s=e+t,o="plain";return n=n||{},n.isMultiline&&(s+="*/"),r.forEach(function(n){if(i)return;if(e==="//"&&n!=="jshint")return;t.substr(0,n.length)===n&&(i=!0,e+=n,t=t.substr(n.length)),!i&&t.charAt(0)===" "&&t.substr(1,n.length)===n&&(i=!0,e=e+" "+n,t=t.substr(n.length+1));if(!i)return;switch(n){case"member":o="members";break;case"global":o="globals";break;default:o=n}}),{type:l.Comment,commentType:o,value:s,body:t,isSpecial:i,isMultiline:n.isMultiline||!1,isMalformed:n.isMalformed||!1}}var e=this.peek(),t=this.peek(1),n=this.input.substr(2),r=this.line,i=this.char;if(e==="*"&&t==="/")return this.trigger("error",{code:"E018",line:r,character:i}),this.skip(2),null;if(e!=="/"||t!=="*"&&t!=="/")return null;if(t==="/")return this.skip(this.input.length),s("//",n);var o="";if(t==="*"){this.inComment=!0,this.skip(2);while(this.peek()!=="*"||this.peek(1)!=="/")if(this.peek()===""){o+="\n";if(!this.nextLine())return this.trigger("error",{code:"E017",line:r,character:i}),this.inComment=!1,s("/*",o,{isMultiline:!0,isMalformed:!0})}else o+=this.peek(),this.skip();return this.skip(2),this.inComment=!1,s("/*",o,{isMultiline:!0})}},scanKeyword:function(){var e=/^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input),t=["if","in","do","var","for","new","try","let","this","else","case","void","with","enum","while","break","catch","throw","const","yield","class","super","return","typeof","delete","switch","export","import","default","finally","extends","function","continue","debugger","instanceof"];return e&&t.indexOf(e[0])>=0?{type:l.Keyword,value:e[0]}:null},scanIdentifier:function(){function i(e){return e>256}function s(e){return e>256}function o(e){return/^[0-9a-fA-F]$/.test(e)}var e="",t=0,n,r,u=function(){t+=1;if(this.peek(t)!=="u")return null;var e=this.peek(t+1),n=this.peek(t+2),r=this.peek(t+3),i=this.peek(t+4),u;return o(e)&&o(n)&&o(r)&&o(i)?(u=parseInt(e+n+r+i,16),f[u]||s(u)?(t+=5,"\\u"+e+n+r+i):null):null}.bind(this),c=function(){var e=this.peek(t),n=e.charCodeAt(0);return n===92?u():n<128?a[n]?(t+=1,e):null:i(n)?(t+=1,e):null}.bind(this),h=function(){var e=this.peek(t),n=e.charCodeAt(0);return n===92?u():n<128?f[n]?(t+=1,e):null:s(n)?(t+=1,e):null}.bind(this);r=c();if(r===null)return null;e=r;for(;;){r=h();if(r===null)break;e+=r}switch(e){case"true":case"false":n=l.BooleanLiteral;break;case"null":n=l.NullLiteral;break;default:n=l.Identifier}return{type:n,value:e}},scanNumericLiteral:function(){function s(e){return/^[0-9]$/.test(e)}function o(e){return/^[0-7]$/.test(e)}function u(e){return/^[0-9a-fA-F]$/.test(e)}function a(e){return e==="$"||e==="_"||e==="\\"||e>="a"&&e<="z"||e>="A"&&e<="Z"}var e=0,t="",n=this.input.length,r=this.peek(e),i;if(r!=="."&&!s(r))return null;if(r!=="."){t=this.peek(e),e+=1,r=this.peek(e);if(t==="0"){if(r==="x"||r==="X"){e+=1,t+=r;while(e"]});if(u==="\\"){this.skip(),u=this.peek();switch(u){case"'":this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\'"]},e,function(){return o.jsonMode});break;case"b":u="\\b";break;case"f":u="\\f";break;case"n":u="\\n";break;case"r":u="\\r";break;case"t":u="\\t";break;case"0":u="\\0";var f=parseInt(this.peek(1),10);this.triggerAsync("warning",{code:"W115",line:this.line,character:this.char},e,function(){return f>=0&&f<=7&&o.directive["use strict"]});break;case"u":u=String.fromCharCode(parseInt(this.input.substr(1,4),16)),a=5;break;case"v":this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\v"]},e,function(){return o.jsonMode}),u=" ";break;case"x":var c=parseInt(this.input.substr(1,2),16);this.triggerAsync("warning",{code:"W114",line:this.line,character:this.char,data:["\\x-"]},e,function(){return o.jsonMode}),u=String.fromCharCode(c),a=3;break;case"\\":u="\\\\";break;case'"':u='\\"';break;case"/":break;case"":s=!0,u="";break;case"!":if(n.slice(n.length-2)==="<")break;default:this.trigger("warning",{code:"W044",line:this.line,character:this.char})}}n+=u,this.skip(a)}return this.skip(),{type:l.StringLiteral,value:n,isUnclosed:!1,quote:t}},scanRegExp:function(){var e=0,t=this.input.length,n=this.peek(),r=n,i="",s=[],o=!1,u=!1,a,f=function(){n<" "&&(o=!0,this.trigger("warning",{code:"W048",line:this.line,character:this.char})),n==="<"&&(o=!0,this.trigger("warning",{code:"W049",line:this.line,character:this.char,data:[n]}))}.bind(this);if(!this.prereg||n!=="/")return null;e+=1,a=!1;while(e=this.getLines().length)return!1;this.input=this.getLines()[this.line],this.line+=1,this.char=1,this.from=1;var t=this.input.trim(),n=function(){return r.some(arguments,function(e){return t.indexOf(e)===0})},i=function(){return r.some(arguments,function(e){return t.indexOf(e,t.length-e.length)!==-1})};o.ignoreLinterErrors===!0&&!n("/*","//")&&!i("*/")&&(this.input=""),e=this.scanNonBreakingSpaces(),e>=0&&this.trigger("warning",{code:"W125",line:this.line,character:e+1}),this.input=this.input.replace(/\t/g,o.tab),e=this.scanUnsafeChars(),e>=0&&this.trigger("warning",{code:"W100",line:this.line,character:e});if(o.option.maxlen&&o.option.maxlen-1&&!n.name.match(/^[A-Z0-9_]*$/)&&e.warn("W106",{line:n.line,"char":n.from,data:[n.name]})}),e.on("String",function(n){var r=e.getOption("quotmark"),i;if(!r)return;r==="single"&&n.quote!=="'"&&(i="W109"),r==="double"&&n.quote!=='"'&&(i="W108"),r===!0&&(e.getCache("quotmark")||e.setCache("quotmark",n.quote),e.getCache("quotmark")!==n.quote&&(i="W110")),i&&e.warn(i,{line:n.line,"char":n.char})}),e.on("Number",function(n){n.value.charAt(0)==="."&&e.warn("W008",{line:n.line,"char":n.char,data:[n.value]}),n.value.substr(n.value.length-1)==="."&&e.warn("W047",{line:n.line,"char":n.char,data:[n.value]}),/^00+/.test(n.value)&&e.warn("W046",{line:n.line,"char":n.char,data:[n.value]})}),e.on("String",function(n){var r=/^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;if(e.getOption("scripturl"))return;r.test(n.value)&&e.warn("W107",{line:n.line,"char":n.char})})}},{}],9:[function(e,t,n){"use strict";n.reservedVars={arguments:!1,NaN:!1},n.ecmaIdentifiers={Array:!1,Boolean:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,eval:!1,EvalError:!1,Function:!1,hasOwnProperty:!1,isFinite:!1,isNaN:!1,JSON:!1,Math:!1,Number:!1,Object:!1,parseInt:!1,parseFloat:!1,RangeError:!1,ReferenceError:!1,RegExp:!1,String:!1,SyntaxError:!1,TypeError:!1,URIError:!1},n.newEcmaIdentifiers={Set:!1,Map:!1,WeakMap:!1,WeakSet:!1,Proxy:!1,Promise:!1},n.browser={Audio:!1,Blob:!1,addEventListener:!1,applicationCache:!1,atob:!1,blur:!1,btoa:!1,CanvasGradient:!1,CanvasPattern:!1,CanvasRenderingContext2D:!1,clearInterval:!1,clearTimeout:!1,close:!1,closed:!1,CustomEvent:!1,DOMParser:!1,defaultStatus:!1,document:!1,Element:!1,ElementTimeControl:!1,event:!1,FileReader:!1,FormData:!1,focus:!1,frames:!1,getComputedStyle:!1,HTMLElement:!1,HTMLAnchorElement:!1,HTMLBaseElement:!1,HTMLBlockquoteElement:!1,HTMLBodyElement:!1,HTMLBRElement:!1,HTMLButtonElement:!1,HTMLCanvasElement:!1,HTMLDirectoryElement:!1,HTMLDivElement:!1,HTMLDListElement:!1,HTMLFieldSetElement:!1,HTMLFontElement:!1,HTMLFormElement:!1,HTMLFrameElement:!1,HTMLFrameSetElement:!1,HTMLHeadElement:!1,HTMLHeadingElement:!1,HTMLHRElement:!1,HTMLHtmlElement:!1,HTMLIFrameElement:!1,HTMLImageElement:!1,HTMLInputElement:!1,HTMLIsIndexElement:!1,HTMLLabelElement:!1,HTMLLayerElement:!1,HTMLLegendElement:!1,HTMLLIElement:!1,HTMLLinkElement:!1,HTMLMapElement:!1,HTMLMenuElement:!1,HTMLMetaElement:!1,HTMLModElement:!1,HTMLObjectElement:!1,HTMLOListElement:!1,HTMLOptGroupElement:!1,HTMLOptionElement:!1,HTMLParagraphElement:!1,HTMLParamElement:!1,HTMLPreElement:!1,HTMLQuoteElement:!1,HTMLScriptElement:!1,HTMLSelectElement:!1,HTMLStyleElement:!1,HTMLTableCaptionElement:!1,HTMLTableCellElement:!1,HTMLTableColElement:!1,HTMLTableElement:!1,HTMLTableRowElement:!1,HTMLTableSectionElement:!1,HTMLTextAreaElement:!1,HTMLTitleElement:!1,HTMLUListElement:!1,HTMLVideoElement:!1,history:!1,Image:!1,length:!1,localStorage:!1,location:!1,matchMedia:!1,MessageChannel:!1,MessageEvent:!1,MessagePort:!1,MouseEvent:!1,moveBy:!1,moveTo:!1,MutationObserver:!1,name:!1,Node:!1,NodeFilter:!1,NodeList:!1,navigator:!1,onbeforeunload:!0,onblur:!0,onerror:!0,onfocus:!0,onload:!0,onresize:!0,onunload:!0,open:!1,openDatabase:!1,opener:!1,Option:!1,parent:!1,print:!1,removeEventListener:!1,resizeBy:!1,resizeTo:!1,screen:!1,scroll:!1,scrollBy:!1,scrollTo:!1,sessionStorage:!1,setInterval:!1,setTimeout:!1,SharedWorker:!1,status:!1,SVGAElement:!1,SVGAltGlyphDefElement:!1,SVGAltGlyphElement:!1,SVGAltGlyphItemElement:!1,SVGAngle:!1,SVGAnimateColorElement:!1,SVGAnimateElement:!1,SVGAnimateMotionElement:!1,SVGAnimateTransformElement:!1,SVGAnimatedAngle:!1,SVGAnimatedBoolean:!1,SVGAnimatedEnumeration:!1,SVGAnimatedInteger:!1,SVGAnimatedLength:!1,SVGAnimatedLengthList:!1,SVGAnimatedNumber:!1,SVGAnimatedNumberList:!1,SVGAnimatedPathData:!1,SVGAnimatedPoints:!1,SVGAnimatedPreserveAspectRatio:!1,SVGAnimatedRect:!1,SVGAnimatedString:!1,SVGAnimatedTransformList:!1,SVGAnimationElement:!1,SVGCSSRule:!1,SVGCircleElement:!1,SVGClipPathElement:!1,SVGColor:!1,SVGColorProfileElement:!1,SVGColorProfileRule:!1,SVGComponentTransferFunctionElement:!1,SVGCursorElement:!1,SVGDefsElement:!1,SVGDescElement:!1,SVGDocument:!1,SVGElement:!1,SVGElementInstance:!1,SVGElementInstanceList:!1,SVGEllipseElement:!1,SVGExternalResourcesRequired:!1,SVGFEBlendElement:!1,SVGFEColorMatrixElement:!1,SVGFEComponentTransferElement:!1,SVGFECompositeElement:!1,SVGFEConvolveMatrixElement:!1,SVGFEDiffuseLightingElement:!1,SVGFEDisplacementMapElement:!1,SVGFEDistantLightElement:!1,SVGFEFloodElement:!1,SVGFEFuncAElement:!1,SVGFEFuncBElement:!1,SVGFEFuncGElement:!1,SVGFEFuncRElement:!1,SVGFEGaussianBlurElement:!1,SVGFEImageElement:!1,SVGFEMergeElement:!1,SVGFEMergeNodeElement:!1,SVGFEMorphologyElement:!1,SVGFEOffsetElement:!1,SVGFEPointLightElement:!1,SVGFESpecularLightingElement:!1,SVGFESpotLightElement:!1,SVGFETileElement:!1,SVGFETurbulenceElement:!1,SVGFilterElement:!1,SVGFilterPrimitiveStandardAttributes:!1,SVGFitToViewBox:!1,SVGFontElement:!1,SVGFontFaceElement:!1,SVGFontFaceFormatElement:!1,SVGFontFaceNameElement:!1,SVGFontFaceSrcElement:!1,SVGFontFaceUriElement:!1,SVGForeignObjectElement:!1,SVGGElement:!1,SVGGlyphElement:!1,SVGGlyphRefElement:!1,SVGGradientElement:!1,SVGHKernElement:!1,SVGICCColor:!1,SVGImageElement:!1,SVGLangSpace:!1,SVGLength:!1,SVGLengthList:!1,SVGLineElement:!1,SVGLinearGradientElement:!1,SVGLocatable:!1,SVGMPathElement:!1,SVGMarkerElement:!1,SVGMaskElement:!1,SVGMatrix:!1,SVGMetadataElement:!1,SVGMissingGlyphElement:!1,SVGNumber:!1,SVGNumberList:!1,SVGPaint:!1,SVGPathElement:!1,SVGPathSeg:!1,SVGPathSegArcAbs:!1,SVGPathSegArcRel:!1,SVGPathSegClosePath:!1,SVGPathSegCurvetoCubicAbs:!1,SVGPathSegCurvetoCubicRel:!1,SVGPathSegCurvetoCubicSmoothAbs:!1,SVGPathSegCurvetoCubicSmoothRel:!1,SVGPathSegCurvetoQuadraticAbs:!1,SVGPathSegCurvetoQuadraticRel:!1,SVGPathSegCurvetoQuadraticSmoothAbs:!1,SVGPathSegCurvetoQuadraticSmoothRel:!1,SVGPathSegLinetoAbs:!1,SVGPathSegLinetoHorizontalAbs:!1,SVGPathSegLinetoHorizontalRel:!1,SVGPathSegLinetoRel:!1,SVGPathSegLinetoVerticalAbs:!1,SVGPathSegLinetoVerticalRel:!1,SVGPathSegList:!1,SVGPathSegMovetoAbs:!1,SVGPathSegMovetoRel:!1,SVGPatternElement:!1,SVGPoint:!1,SVGPointList:!1,SVGPolygonElement:!1,SVGPolylineElement:!1,SVGPreserveAspectRatio:!1,SVGRadialGradientElement:!1,SVGRect:!1,SVGRectElement:!1,SVGRenderingIntent:!1,SVGSVGElement:!1,SVGScriptElement:!1,SVGSetElement:!1,SVGStopElement:!1,SVGStringList:!1,SVGStylable:!1,SVGStyleElement:!1,SVGSwitchElement:!1,SVGSymbolElement:!1,SVGTRefElement:!1,SVGTSpanElement:!1,SVGTests:!1,SVGTextContentElement:!1,SVGTextElement:!1,SVGTextPathElement:!1,SVGTextPositioningElement:!1,SVGTitleElement:!1,SVGTransform:!1,SVGTransformList:!1,SVGTransformable:!1,SVGURIReference:!1,SVGUnitTypes:!1,SVGUseElement:!1,SVGVKernElement:!1,SVGViewElement:!1,SVGViewSpec:!1,SVGZoomAndPan:!1,TimeEvent:!1,top:!1,URL:!1,WebSocket:!1,window:!1,Worker:!1,XMLHttpRequest:!1,XMLSerializer:!1,XPathEvaluator:!1,XPathException:!1,XPathExpression:!1,XPathNamespace:!1,XPathNSResolver:!1,XPathResult:!1},n.devel={alert:!1,confirm:!1,console:!1,Debug:!1,opera:!1,prompt:!1},n.worker={importScripts:!0,postMessage:!0,self:!0},n.nonstandard={escape:!1,unescape:!1},n.couch={require:!1,respond:!1,getRow:!1,emit:!1,send:!1,start:!1,sum:!1,log:!1,exports:!1,module:!1,provides:!1},n.node={__filename:!1,__dirname:!1,GLOBAL:!1,global:!1,module:!1,require:!1,Buffer:!0,console:!0,exports:!0,process:!0,setTimeout:!0,clearTimeout:!0,setInterval:!0,clearInterval:!0,setImmediate:!0,clearImmediate:!0},n.phantom={phantom:!0,require:!0,WebPage:!0,console:!0,exports:!0},n.qunit={asyncTest:!1,deepEqual:!1,equal:!1,expect:!1,module:!1,notDeepEqual:!1,notEqual:!1,notPropEqual:!1,notStrictEqual:!1,ok:!1,propEqual:!1,QUnit:!1,raises:!1,start:!1,stop:!1,strictEqual:!1,test:!1,"throws":!1},n.rhino={defineClass:!1,deserialize:!1,gc:!1,help:!1,importClass:!1,importPackage:!1,java:!1,load:!1,loadClass:!1,Packages:!1,print:!1,quit:!1,readFile:!1,readUrl:!1,runCommand:!1,seal:!1,serialize:!1,spawn:!1,sync:!1,toint32:!1,version:!1},n.shelljs={target:!1,echo:!1,exit:!1,cd:!1,pwd:!1,ls:!1,find:!1,cp:!1,rm:!1,mv:!1,mkdir:!1,test:!1,cat:!1,sed:!1,grep:!1,which:!1,dirs:!1,pushd:!1,popd:!1,env:!1,exec:!1,chmod:!1,config:!1,error:!1,tempdir:!1},n.typed={ArrayBuffer:!1,ArrayBufferView:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int16Array:!1,Int32Array:!1,Int8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8Array:!1,Uint8ClampedArray:!1},n.wsh={ActiveXObject:!0,Enumerator:!0,GetObject:!0,ScriptEngine:!0,ScriptEngineBuildVersion:!0,ScriptEngineMajorVersion:!0,ScriptEngineMinorVersion:!0,VBArray:!0,WSH:!0,WScript:!0,XDomainRequest:!0},n.dojo={dojo:!1,dijit:!1,dojox:!1,define:!1,require:!1},n.jquery={$:!1,jQuery:!1},n.mootools={$:!1,$$:!1,Asset:!1,Browser:!1,Chain:!1,Class:!1,Color:!1,Cookie:!1,Core:!1,Document:!1,DomReady:!1,DOMEvent:!1,DOMReady:!1,Drag:!1,Element:!1,Elements:!1,Event:!1,Events:!1,Fx:!1,Group:!1,Hash:!1,HtmlTable:!1,IFrame:!1,IframeShim:!1,InputValidator:!1,instanceOf:!1,Keyboard:!1,Locale:!1,Mask:!1,MooTools:!1,Native:!1,Options:!1,OverText:!1,Request:!1,Scroller:!1,Slick:!1,Slider:!1,Sortables:!1,Spinner:!1,Swiff:!1,Tips:!1,Type:!1,typeOf:!1,URI:!1,Window:!1},n.prototypejs={$:!1,$$:!1,$A:!1,$F:!1,$H:!1,$R:!1,$break:!1,$continue:!1,$w:!1,Abstract:!1,Ajax:!1,Class:!1,Enumerable:!1,Element:!1,Event:!1,Field:!1,Form:!1,Hash:!1,Insertion:!1,ObjectRange:!1,PeriodicalExecuter:!1,Position:!1,Prototype:!1,Selector:!1,Template:!1,Toggle:!1,Try:!1,Autocompleter:!1,Builder:!1,Control:!1,Draggable:!1,Draggables:!1,Droppables:!1,Effect:!1,Sortable:!1,SortableObserver:!1,Sound:!1,Scriptaculous:!1},n.yui={YUI:!1,Y:!1,YUI_config:!1},n.mocha={describe:!1,it:!1,before:!1,after:!1,beforeEach:!1,afterEach:!1,suite:!1,test:!1,setup:!1,teardown:!1},n.jasmine={jasmine:!1,describe:!1,it:!1,xit:!1,beforeEach:!1,afterEach:!1,setFixtures:!1,loadFixtures:!1,spyOn:!1,expect:!1,runs:!1,waitsFor:!1,waits:!1}},{}],10:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||undefined}function i(e){return typeof e=="function"}function s(e){return typeof e=="number"}function o(e){return typeof e=="object"&&e!==null}function u(e){return e===void 0}t.exports=r,r.EventEmitter=r,r.prototype._events=undefined,r.prototype._maxListeners=undefined,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!s(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,s,a,f;this._events||(this._events={});if(e==="error")if(!this._events.error||o(this._events.error)&&!this._events.error.length)throw t=arguments[1],t instanceof Error?t:TypeError('Uncaught, unspecified "error" event.');n=this._events[e];if(u(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:r=arguments.length,s=new Array(r-1);for(a=1;a0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var n=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,s,u;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;n=this._events[e],s=n.length,r=-1;if(n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(u=s;u-->0;)if(n[u]===t||n[u].listener&&n[u].listener===t){r=u;break}if(r<0)return this;n.length===1?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[e]&&delete this._events[e],this;if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}return this.removeAllListeners("removeListener"),this._events={},this}n=this._events[e];if(i(n))this.removeListener(e,n);else while(n.length)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return!this._events||!this._events[e]?t=[]:i(this._events[e])?t=[this._events[e]]:t=this._events[e].slice(),t},r.listenerCount=function(e,t){var n;return!e._events||!e._events[t]?n=0:i(e._events[t])?n=1:n=e._events[t].length,n}},{}]},{},[3])(3)}),ace.define("ace/mode/javascript_worker",["require","exports","module","ace/lib/oop","ace/worker/mirror","ace/mode/javascript/jshint"],function(require,exports,module){"use strict";function startRegex(e){return RegExp("^("+e.join("|")+")")}var oop=require("../lib/oop"),Mirror=require("../worker/mirror").Mirror,lint=require("./javascript/jshint").JSHINT,disabledWarningsRe=startRegex(["Bad for in variable '(.+)'.",'Missing "use strict"']),errorsRe=startRegex(["Unexpected","Expected ","Confusing (plus|minus)","\\{a\\} unterminated regular expression","Unclosed ","Unmatched ","Unbegun comment","Bad invocation","Missing space after","Missing operator at"]),infoRe=startRegex(["Expected an assignment","Bad escapement of EOL","Unexpected comma","Unexpected space","Missing radix parameter.","A leading decimal point can","\\['{a}'\\] is better written in dot notation.","'{a}' used out of scope"]),JavaScriptWorker=exports.JavaScriptWorker=function(e){Mirror.call(this,e),this.setTimeout(500),this.setOptions()};oop.inherits(JavaScriptWorker,Mirror),function(){this.setOptions=function(e){this.options=e||{esnext:!0,moz:!0,devel:!0,browser:!0,node:!0,laxcomma:!0,laxbreak:!0,lastsemic:!0,onevar:!1,passfail:!1,maxerr:100,expr:!0,multistr:!0,globalstrict:!0},this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.changeOptions=function(e){oop.mixin(this.options,e),this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.isValidJS=function(str){try{eval("throw 0;"+str)}catch(e){if(e===0)return!0}return!1},this.onUpdate=function(){var e=this.doc.getValue();e=e.replace(/^#!.*\n/,"\n");if(!e){this.sender.emit("jslint",[]);return}var t=[],n=this.isValidJS(e)?"warning":"error";lint(e,this.options);var r=lint.errors,i=!1;for(var s=0;s0||-1)*Math.floor(Math.abs(e))),e}function B(e){var t=typeof e;return e===null||t==="undefined"||t==="boolean"||t==="number"||t==="string"}function j(e){var t,n,r;if(B(e))return e;n=e.valueOf;if(typeof n=="function"){t=n.call(e);if(B(t))return t}r=e.toString;if(typeof r=="function"){t=r.call(e);if(B(t))return t}throw new TypeError}Function.prototype.bind||(Function.prototype.bind=function(t){var n=this;if(typeof n!="function")throw new TypeError("Function.prototype.bind called on incompatible "+n);var i=u.call(arguments,1),s=function(){if(this instanceof s){var e=n.apply(this,i.concat(u.call(arguments)));return Object(e)===e?e:this}return n.apply(t,i.concat(u.call(arguments)))};return n.prototype&&(r.prototype=n.prototype,s.prototype=new r,r.prototype=null),s});var i=Function.prototype.call,s=Array.prototype,o=Object.prototype,u=s.slice,a=i.bind(o.toString),f=i.bind(o.hasOwnProperty),l,c,h,p,d;if(d=f(o,"__defineGetter__"))l=i.bind(o.__defineGetter__),c=i.bind(o.__defineSetter__),h=i.bind(o.__lookupGetter__),p=i.bind(o.__lookupSetter__);if([1,2].splice(0).length!=2)if(!function(){function e(e){var t=new Array(e+2);return t[0]=t[1]=0,t}var t=[],n;t.splice.apply(t,e(20)),t.splice.apply(t,e(26)),n=t.length,t.splice(5,0,"XXX"),n+1==t.length;if(n+1==t.length)return!0}())Array.prototype.splice=function(e,t){var n=this.length;e>0?e>n&&(e=n):e==void 0?e=0:e<0&&(e=Math.max(n+e,0)),e+ta)for(h=l;h--;)this[f+h]=this[a+h];if(s&&e===c)this.length=c,this.push.apply(this,i);else{this.length=c+s;for(h=0;h>>0;if(a(t)!="[object Function]")throw new TypeError;while(++s>>0,s=Array(i),o=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var u=0;u>>0,s=[],o,u=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var f=0;f>>0,s=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var o=0;o>>0,s=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var o=0;o>>0;if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");if(!i&&arguments.length==1)throw new TypeError("reduce of empty array with no initial value");var s=0,o;if(arguments.length>=2)o=arguments[1];else do{if(s in r){o=r[s++];break}if(++s>=i)throw new TypeError("reduce of empty array with no initial value")}while(!0);for(;s>>0;if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");if(!i&&arguments.length==1)throw new TypeError("reduceRight of empty array with no initial value");var s,o=i-1;if(arguments.length>=2)s=arguments[1];else do{if(o in r){s=r[o--];break}if(--o<0)throw new TypeError("reduceRight of empty array with no initial value")}while(!0);do o in this&&(s=t.call(void 0,s,r[o],o,n));while(o--);return s});if(!Array.prototype.indexOf||[0,1].indexOf(1,2)!=-1)Array.prototype.indexOf=function(t){var n=g&&a(this)=="[object String]"?this.split(""):F(this),r=n.length>>>0;if(!r)return-1;var i=0;arguments.length>1&&(i=H(arguments[1])),i=i>=0?i:Math.max(0,r+i);for(;i>>0;if(!r)return-1;var i=r-1;arguments.length>1&&(i=Math.min(i,H(arguments[1]))),i=i>=0?i:r-Math.abs(i);for(;i>=0;i--)if(i in n&&t===n[i])return i;return-1};Object.getPrototypeOf||(Object.getPrototypeOf=function(t){return t.__proto__||(t.constructor?t.constructor.prototype:o)});if(!Object.getOwnPropertyDescriptor){var y="Object.getOwnPropertyDescriptor called on a non-object: ";Object.getOwnPropertyDescriptor=function(t,n){if(typeof t!="object"&&typeof t!="function"||t===null)throw new TypeError(y+t);if(!f(t,n))return;var r,i,s;r={enumerable:!0,configurable:!0};if(d){var u=t.__proto__;t.__proto__=o;var i=h(t,n),s=p(t,n);t.__proto__=u;if(i||s)return i&&(r.get=i),s&&(r.set=s),r}return r.value=t[n],r}}Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(t){return Object.keys(t)});if(!Object.create){var b;Object.prototype.__proto__===null?b=function(){return{__proto__:null}}:b=function(){var e={};for(var t in e)e[t]=null;return e.constructor=e.hasOwnProperty=e.propertyIsEnumerable=e.isPrototypeOf=e.toLocaleString=e.toString=e.valueOf=e.__proto__=null,e},Object.create=function(t,n){var r;if(t===null)r=b();else{if(typeof t!="object")throw new TypeError("typeof prototype["+typeof t+"] != 'object'");var i=function(){};i.prototype=t,r=new i,r.__proto__=t}return n!==void 0&&Object.defineProperties(r,n),r}}if(Object.defineProperty){var E=w({}),S=typeof document=="undefined"||w(document.createElement("div"));if(!E||!S)var x=Object.defineProperty}if(!Object.defineProperty||x){var T="Property description must be an object: ",N="Object.defineProperty called on non-object: ",C="getters & setters can not be defined on this javascript engine";Object.defineProperty=function(t,n,r){if(typeof t!="object"&&typeof t!="function"||t===null)throw new TypeError(N+t);if(typeof r!="object"&&typeof r!="function"||r===null)throw new TypeError(T+r);if(x)try{return x.call(Object,t,n,r)}catch(i){}if(f(r,"value"))if(d&&(h(t,n)||p(t,n))){var s=t.__proto__;t.__proto__=o,delete t[n],t[n]=r.value,t.__proto__=s}else t[n]=r.value;else{if(!d)throw new TypeError(C);f(r,"get")&&l(t,n,r.get),f(r,"set")&&c(t,n,r.set)}return t}}Object.defineProperties||(Object.defineProperties=function(t,n){for(var r in n)f(n,r)&&Object.defineProperty(t,r,n[r]);return t}),Object.seal||(Object.seal=function(t){return t}),Object.freeze||(Object.freeze=function(t){return t});try{Object.freeze(function(){})}catch(k){Object.freeze=function(t){return function(n){return typeof n=="function"?n:t(n)}}(Object.freeze)}Object.preventExtensions||(Object.preventExtensions=function(t){return t}),Object.isSealed||(Object.isSealed=function(t){return!1}),Object.isFrozen||(Object.isFrozen=function(t){return!1}),Object.isExtensible||(Object.isExtensible=function(t){if(Object(t)===t)throw new TypeError;var n="";while(f(t,n))n+="?";t[n]=!0;var r=f(t,n);return delete t[n],r});if(!Object.keys){var L=!0,A=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],O=A.length;for(var M in{toString:null})L=!1;Object.keys=function I(e){if(typeof e!="object"&&typeof e!="function"||e===null)throw new TypeError("Object.keys called on a non-object");var I=[];for(var t in e)f(e,t)&&I.push(t);if(L)for(var n=0,r=O;n 0) { + bindThis(fn[key], target[key], argThis); + } + }); + })(Chart.prototype, this, this); +} + +var asHalfPixel = function(n) { + return Math.ceil(n) + 0.5 +}; +var ceil10 = function(v) { + return Math.ceil(v / 10) * 10 +}; +var diffDomain = function(d) { + return d[1] - d[0] +}; +var getOption = function(options, key, defaultValue) { + return isDefined(options[key]) ? options[key] : defaultValue +}; +var getPathBox = function(path) { + var box = getBBox(path), + items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)], + minX = items[0].x, + minY = Math.min(items[0].y, items[1].y); + return { x: minX, y: minY, width: box.width, height: box.height } +}; +var getBBox = function(element) { + try { + return element.getBBox() + } catch (ignore) { + // Firefox will throw an exception if getBBox() is called whereas the + // element is rendered with display:none + // See https://github.com/c3js/c3/issues/2692 + + // The previous code was using `getBoundingClientRect` which was returning + // everything at 0 in this case so let's reproduce this behavior here. + + return { x: 0, y: 0, width: 0, height: 0 } + } +}; +var hasValue = function(dict, value) { + var found = false; + Object.keys(dict).forEach(function(key) { + if (dict[key] === value) { + found = true; + } + }); + return found +}; +var isArray = function(o) { + return Array.isArray(o) +}; +var isDefined = function(v) { + return typeof v !== 'undefined' +}; +var isEmpty = function(o) { + return ( + typeof o === 'undefined' || + o === null || + (isString(o) && o.length === 0) || + (typeof o === 'object' && Object.keys(o).length === 0) + ) +}; +var isFunction = function(o) { + return typeof o === 'function' +}; +var isNumber = function(o) { + return typeof o === 'number' +}; +var isString = function(o) { + return typeof o === 'string' +}; +var isUndefined = function(v) { + return typeof v === 'undefined' +}; +var isValue = function(v) { + return v || v === 0 +}; +var notEmpty = function(o) { + return !isEmpty(o) +}; +var sanitise = function(str) { + return typeof str === 'string' + ? str.replace(//g, '>') + : str +}; +var flattenArray = function(arr) { + return Array.isArray(arr) ? [].concat(...arr) : [] +}; +/** + * Returns whether the point is within the given box. + * + * @param {Array} point An [x,y] coordinate + * @param {Object} box An object with {x, y, width, height} keys + * @param {Number} sensitivity An offset to ease check on very small boxes + */ +var isWithinBox = function(point, box, sensitivity = 0) { + const xStart = box.x - sensitivity; + const xEnd = box.x + box.width + sensitivity; + const yStart = box.y + box.height + sensitivity; + const yEnd = box.y - sensitivity; + + return ( + xStart < point[0] && point[0] < xEnd && yEnd < point[1] && point[1] < yStart + ) +}; + +/** + * Returns Internet Explorer version number (or false if no Internet Explorer used). + * + * @param string agent Optional parameter to specify user agent + */ +var getIEVersion = function(agent) { + // https://stackoverflow.com/questions/19999388/check-if-user-is-using-ie + if (typeof agent === 'undefined') { + agent = window.navigator.userAgent; + } + + let pos = agent.indexOf('MSIE '); // up to IE10 + if (pos > 0) { + return parseInt(agent.substring(pos + 5, agent.indexOf('.', pos)), 10) + } + + pos = agent.indexOf('Trident/'); // IE11 + if (pos > 0) { + pos = agent.indexOf('rv:'); + return parseInt(agent.substring(pos + 3, agent.indexOf('.', pos)), 10) + } + + return false +}; + +/** + * Returns whether the used browser is Internet Explorer. + * + * @param {Number} version Optional parameter to specify IE version + */ +var isIE = function(version) { + const ver = getIEVersion(); + + if (typeof version === 'undefined') { + return !!ver + } + + return version === ver +}; + +function AxisInternal(component, params) { + var internal = this; + internal.component = component; + internal.params = params || {}; + + internal.d3 = component.d3; + internal.scale = internal.d3.scaleLinear(); + internal.range; + internal.orient = 'bottom'; + internal.innerTickSize = 6; + internal.outerTickSize = this.params.withOuterTick ? 6 : 0; + internal.tickPadding = 3; + internal.tickValues = null; + internal.tickFormat; + internal.tickArguments; + + internal.tickOffset = 0; + internal.tickCulling = true; + internal.tickCentered; + internal.tickTextCharSize; + internal.tickTextRotate = internal.params.tickTextRotate; + internal.tickLength; + + internal.axis = internal.generateAxis(); +} + +AxisInternal.prototype.axisX = function(selection, x, tickOffset) { + selection.attr('transform', function(d) { + return 'translate(' + Math.ceil(x(d) + tickOffset) + ', 0)' + }); +}; +AxisInternal.prototype.axisY = function(selection, y) { + selection.attr('transform', function(d) { + return 'translate(0,' + Math.ceil(y(d)) + ')' + }); +}; +AxisInternal.prototype.scaleExtent = function(domain) { + var start = domain[0], + stop = domain[domain.length - 1]; + return start < stop ? [start, stop] : [stop, start] +}; +AxisInternal.prototype.generateTicks = function(scale) { + var internal = this; + var i, + domain, + ticks = []; + if (scale.ticks) { + return scale.ticks.apply(scale, internal.tickArguments) + } + domain = scale.domain(); + for (i = Math.ceil(domain[0]); i < domain[1]; i++) { + ticks.push(i); + } + if (ticks.length > 0 && ticks[0] > 0) { + ticks.unshift(ticks[0] - (ticks[1] - ticks[0])); + } + return ticks +}; +AxisInternal.prototype.copyScale = function() { + var internal = this; + var newScale = internal.scale.copy(), + domain; + if (internal.params.isCategory) { + domain = internal.scale.domain(); + newScale.domain([domain[0], domain[1] - 1]); + } + return newScale +}; +AxisInternal.prototype.textFormatted = function(v) { + var internal = this, + formatted = internal.tickFormat ? internal.tickFormat(v) : v; + return typeof formatted !== 'undefined' ? formatted : '' +}; +AxisInternal.prototype.updateRange = function() { + var internal = this; + internal.range = internal.scale.rangeExtent + ? internal.scale.rangeExtent() + : internal.scaleExtent(internal.scale.range()); + return internal.range +}; +AxisInternal.prototype.updateTickTextCharSize = function(tick) { + var internal = this; + if (internal.tickTextCharSize) { + return internal.tickTextCharSize + } + var size = { + h: 11.5, + w: 5.5 + }; + tick + .select('text') + .text(function(d) { + return internal.textFormatted(d) + }) + .each(function(d) { + var box = getBBox(this), + text = internal.textFormatted(d), + h = box.height, + w = text ? box.width / text.length : undefined; + if (h && w) { + size.h = h; + size.w = w; + } + }) + .text(''); + internal.tickTextCharSize = size; + return size +}; +AxisInternal.prototype.isVertical = function() { + return this.orient === 'left' || this.orient === 'right' +}; +AxisInternal.prototype.tspanData = function(d, i, scale) { + var internal = this; + var splitted = internal.params.tickMultiline + ? internal.splitTickText(d, scale) + : [].concat(internal.textFormatted(d)); + + if (internal.params.tickMultiline && internal.params.tickMultilineMax > 0) { + splitted = internal.ellipsify(splitted, internal.params.tickMultilineMax); + } + + return splitted.map(function(s) { + return { index: i, splitted: s, length: splitted.length } + }) +}; +AxisInternal.prototype.splitTickText = function(d, scale) { + var internal = this, + tickText = internal.textFormatted(d), + maxWidth = internal.params.tickWidth, + subtext, + spaceIndex, + textWidth, + splitted = []; + + if (Object.prototype.toString.call(tickText) === '[object Array]') { + return tickText + } + + if (!maxWidth || maxWidth <= 0) { + maxWidth = internal.isVertical() + ? 95 + : internal.params.isCategory + ? Math.ceil(scale(1) - scale(0)) - 12 + : 110; + } + + function split(splitted, text) { + spaceIndex = undefined; + for (var i = 1; i < text.length; i++) { + if (text.charAt(i) === ' ') { + spaceIndex = i; + } + subtext = text.substr(0, i + 1); + textWidth = internal.tickTextCharSize.w * subtext.length; + // if text width gets over tick width, split by space index or crrent index + if (maxWidth < textWidth) { + return split( + splitted.concat(text.substr(0, spaceIndex ? spaceIndex : i)), + text.slice(spaceIndex ? spaceIndex + 1 : i) + ) + } + } + return splitted.concat(text) + } + + return split(splitted, tickText + '') +}; +AxisInternal.prototype.ellipsify = function(splitted, max) { + if (splitted.length <= max) { + return splitted + } + + var ellipsified = splitted.slice(0, max); + var remaining = 3; + for (var i = max - 1; i >= 0; i--) { + var available = ellipsified[i].length; + + ellipsified[i] = ellipsified[i] + .substr(0, available - remaining) + .padEnd(available, '.'); + + remaining -= available; + + if (remaining <= 0) { + break + } + } + + return ellipsified +}; +AxisInternal.prototype.updateTickLength = function() { + var internal = this; + internal.tickLength = + Math.max(internal.innerTickSize, 0) + internal.tickPadding; +}; +AxisInternal.prototype.lineY2 = function(d) { + var internal = this, + tickPosition = + internal.scale(d) + (internal.tickCentered ? 0 : internal.tickOffset); + return internal.range[0] < tickPosition && tickPosition < internal.range[1] + ? internal.innerTickSize + : 0 +}; +AxisInternal.prototype.textY = function() { + var internal = this, + rotate = internal.tickTextRotate; + return rotate + ? 11.5 - 2.5 * (rotate / 15) * (rotate > 0 ? 1 : -1) + : internal.tickLength +}; +AxisInternal.prototype.textTransform = function() { + var internal = this, + rotate = internal.tickTextRotate; + return rotate ? 'rotate(' + rotate + ')' : '' +}; +AxisInternal.prototype.textTextAnchor = function() { + var internal = this, + rotate = internal.tickTextRotate; + return rotate ? (rotate > 0 ? 'start' : 'end') : 'middle' +}; +AxisInternal.prototype.tspanDx = function() { + var internal = this, + rotate = internal.tickTextRotate; + return rotate ? 8 * Math.sin(Math.PI * (rotate / 180)) : 0 +}; +AxisInternal.prototype.tspanDy = function(d, i) { + var internal = this, + dy = internal.tickTextCharSize.h; + if (i === 0) { + if (internal.isVertical()) { + dy = -((d.length - 1) * (internal.tickTextCharSize.h / 2) - 3); + } else { + dy = '.71em'; + } + } + return dy +}; + +AxisInternal.prototype.generateAxis = function() { + var internal = this, + d3 = internal.d3, + params = internal.params; + function axis(g, transition) { + var self; + g.each(function() { + var g = (axis.g = d3.select(this)); + + var scale0 = this.__chart__ || internal.scale, + scale1 = (this.__chart__ = internal.copyScale()); + + var ticksValues = internal.tickValues + ? internal.tickValues + : internal.generateTicks(scale1), + ticks = g.selectAll('.tick').data(ticksValues, scale1), + tickEnter = ticks + .enter() + .insert('g', '.domain') + .attr('class', 'tick') + .style('opacity', 1e-6), + // MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks. + tickExit = ticks.exit().remove(), + tickUpdate = ticks.merge(tickEnter), + tickTransform, + tickX, + tickY; + + if (params.isCategory) { + internal.tickOffset = Math.ceil((scale1(1) - scale1(0)) / 2); + tickX = internal.tickCentered ? 0 : internal.tickOffset; + tickY = internal.tickCentered ? internal.tickOffset : 0; + } else { + internal.tickOffset = tickX = 0; + } + + internal.updateRange(); + internal.updateTickLength(); + internal.updateTickTextCharSize(g.select('.tick')); + + var lineUpdate = tickUpdate + .select('line') + .merge(tickEnter.append('line')), + textUpdate = tickUpdate.select('text').merge(tickEnter.append('text')); + + var tspans = tickUpdate + .selectAll('text') + .selectAll('tspan') + .data(function(d, i) { + return internal.tspanData(d, i, scale1) + }), + tspanEnter = tspans.enter().append('tspan'), + tspanUpdate = tspanEnter.merge(tspans).text(function(d) { + return d.splitted + }); + tspans.exit().remove(); + + var path = g.selectAll('.domain').data([0]), + pathUpdate = path + .enter() + .append('path') + .merge(path) + .attr('class', 'domain'); + + // TODO: each attr should be one function and change its behavior by internal.orient, probably + switch (internal.orient) { + case 'bottom': { + tickTransform = internal.axisX; + lineUpdate + .attr('x1', tickX) + .attr('x2', tickX) + .attr('y2', function(d, i) { + return internal.lineY2(d, i) + }); + textUpdate + .attr('x', 0) + .attr('y', function(d, i) { + return internal.textY(d, i) + }) + .attr('transform', function(d, i) { + return internal.textTransform(d, i) + }) + .style('text-anchor', function(d, i) { + return internal.textTextAnchor(d, i) + }); + tspanUpdate + .attr('x', 0) + .attr('dy', function(d, i) { + return internal.tspanDy(d, i) + }) + .attr('dx', function(d, i) { + return internal.tspanDx(d, i) + }); + pathUpdate.attr( + 'd', + 'M' + + internal.range[0] + + ',' + + internal.outerTickSize + + 'V0H' + + internal.range[1] + + 'V' + + internal.outerTickSize + ); + break + } + case 'top': { + // TODO: rotated tick text + tickTransform = internal.axisX; + lineUpdate + .attr('x1', tickX) + .attr('x2', tickX) + .attr('y2', function(d, i) { + return -1 * internal.lineY2(d, i) + }); + textUpdate + .attr('x', 0) + .attr('y', function(d, i) { + return ( + -1 * internal.textY(d, i) - + (params.isCategory ? 2 : internal.tickLength - 2) + ) + }) + .attr('transform', function(d, i) { + return internal.textTransform(d, i) + }) + .style('text-anchor', function(d, i) { + return internal.textTextAnchor(d, i) + }); + tspanUpdate + .attr('x', 0) + .attr('dy', function(d, i) { + return internal.tspanDy(d, i) + }) + .attr('dx', function(d, i) { + return internal.tspanDx(d, i) + }); + pathUpdate.attr( + 'd', + 'M' + + internal.range[0] + + ',' + + -internal.outerTickSize + + 'V0H' + + internal.range[1] + + 'V' + + -internal.outerTickSize + ); + break + } + case 'left': { + tickTransform = internal.axisY; + lineUpdate + .attr('x2', -internal.innerTickSize) + .attr('y1', tickY) + .attr('y2', tickY); + textUpdate + .attr('x', -internal.tickLength) + .attr('y', internal.tickOffset) + .style('text-anchor', 'end'); + tspanUpdate + .attr('x', -internal.tickLength) + .attr('dy', function(d, i) { + return internal.tspanDy(d, i) + }); + pathUpdate.attr( + 'd', + 'M' + + -internal.outerTickSize + + ',' + + internal.range[0] + + 'H0V' + + internal.range[1] + + 'H' + + -internal.outerTickSize + ); + break + } + case 'right': { + tickTransform = internal.axisY; + lineUpdate + .attr('x2', internal.innerTickSize) + .attr('y1', tickY) + .attr('y2', tickY); + textUpdate + .attr('x', internal.tickLength) + .attr('y', internal.tickOffset) + .style('text-anchor', 'start'); + tspanUpdate.attr('x', internal.tickLength).attr('dy', function(d, i) { + return internal.tspanDy(d, i) + }); + pathUpdate.attr( + 'd', + 'M' + + internal.outerTickSize + + ',' + + internal.range[0] + + 'H0V' + + internal.range[1] + + 'H' + + internal.outerTickSize + ); + break + } + } + if (scale1.rangeBand) { + var x = scale1, + dx = x.rangeBand() / 2; + scale0 = scale1 = function(d) { + return x(d) + dx + }; + } else if (scale0.rangeBand) { + scale0 = scale1; + } else { + tickExit.call(tickTransform, scale1, internal.tickOffset); + } + tickEnter.call(tickTransform, scale0, internal.tickOffset); + self = (transition ? tickUpdate.transition(transition) : tickUpdate) + .style('opacity', 1) + .call(tickTransform, scale1, internal.tickOffset); + }); + return self + } + axis.scale = function(x) { + if (!arguments.length) { + return internal.scale + } + internal.scale = x; + return axis + }; + axis.orient = function(x) { + if (!arguments.length) { + return internal.orient + } + internal.orient = + x in { top: 1, right: 1, bottom: 1, left: 1 } ? x + '' : 'bottom'; + return axis + }; + axis.tickFormat = function(format) { + if (!arguments.length) { + return internal.tickFormat + } + internal.tickFormat = format; + return axis + }; + axis.tickCentered = function(isCentered) { + if (!arguments.length) { + return internal.tickCentered + } + internal.tickCentered = isCentered; + return axis + }; + axis.tickOffset = function() { + return internal.tickOffset + }; + axis.tickInterval = function() { + var interval, length; + if (params.isCategory) { + interval = internal.tickOffset * 2; + } else { + length = + axis.g + .select('path.domain') + .node() + .getTotalLength() - + internal.outerTickSize * 2; + interval = length / axis.g.selectAll('line').size(); + } + return interval === Infinity ? 0 : interval + }; + axis.ticks = function() { + if (!arguments.length) { + return internal.tickArguments + } + internal.tickArguments = arguments; + return axis + }; + axis.tickCulling = function(culling) { + if (!arguments.length) { + return internal.tickCulling + } + internal.tickCulling = culling; + return axis + }; + axis.tickValues = function(x) { + if (typeof x === 'function') { + internal.tickValues = function() { + return x(internal.scale.domain()) + }; + } else { + if (!arguments.length) { + return internal.tickValues + } + internal.tickValues = x; + } + return axis + }; + return axis +}; + +var CLASS = { + target: 'c3-target', + chart: 'c3-chart', + chartLine: 'c3-chart-line', + chartLines: 'c3-chart-lines', + chartBar: 'c3-chart-bar', + chartBars: 'c3-chart-bars', + chartText: 'c3-chart-text', + chartTexts: 'c3-chart-texts', + chartArc: 'c3-chart-arc', + chartArcs: 'c3-chart-arcs', + chartArcsTitle: 'c3-chart-arcs-title', + chartArcsBackground: 'c3-chart-arcs-background', + chartArcsGaugeUnit: 'c3-chart-arcs-gauge-unit', + chartArcsGaugeMax: 'c3-chart-arcs-gauge-max', + chartArcsGaugeMin: 'c3-chart-arcs-gauge-min', + selectedCircle: 'c3-selected-circle', + selectedCircles: 'c3-selected-circles', + eventRect: 'c3-event-rect', + eventRects: 'c3-event-rects', + eventRectsSingle: 'c3-event-rects-single', + eventRectsMultiple: 'c3-event-rects-multiple', + zoomRect: 'c3-zoom-rect', + brush: 'c3-brush', + dragZoom: 'c3-drag-zoom', + focused: 'c3-focused', + defocused: 'c3-defocused', + region: 'c3-region', + regions: 'c3-regions', + title: 'c3-title', + tooltipContainer: 'c3-tooltip-container', + tooltip: 'c3-tooltip', + tooltipName: 'c3-tooltip-name', + shape: 'c3-shape', + shapes: 'c3-shapes', + line: 'c3-line', + lines: 'c3-lines', + bar: 'c3-bar', + bars: 'c3-bars', + circle: 'c3-circle', + circles: 'c3-circles', + arc: 'c3-arc', + arcLabelLine: 'c3-arc-label-line', + arcs: 'c3-arcs', + area: 'c3-area', + areas: 'c3-areas', + empty: 'c3-empty', + text: 'c3-text', + texts: 'c3-texts', + gaugeValue: 'c3-gauge-value', + grid: 'c3-grid', + gridLines: 'c3-grid-lines', + xgrid: 'c3-xgrid', + xgrids: 'c3-xgrids', + xgridLine: 'c3-xgrid-line', + xgridLines: 'c3-xgrid-lines', + xgridFocus: 'c3-xgrid-focus', + ygrid: 'c3-ygrid', + ygrids: 'c3-ygrids', + ygridLine: 'c3-ygrid-line', + ygridLines: 'c3-ygrid-lines', + colorScale: 'c3-colorscale', + stanfordElements: 'c3-stanford-elements', + stanfordLine: 'c3-stanford-line', + stanfordLines: 'c3-stanford-lines', + stanfordRegion: 'c3-stanford-region', + stanfordRegions: 'c3-stanford-regions', + stanfordText: 'c3-stanford-text', + stanfordTexts: 'c3-stanford-texts', + axis: 'c3-axis', + axisX: 'c3-axis-x', + axisXLabel: 'c3-axis-x-label', + axisY: 'c3-axis-y', + axisYLabel: 'c3-axis-y-label', + axisY2: 'c3-axis-y2', + axisY2Label: 'c3-axis-y2-label', + legendBackground: 'c3-legend-background', + legendItem: 'c3-legend-item', + legendItemEvent: 'c3-legend-item-event', + legendItemTile: 'c3-legend-item-tile', + legendItemHidden: 'c3-legend-item-hidden', + legendItemFocused: 'c3-legend-item-focused', + dragarea: 'c3-dragarea', + EXPANDED: '_expanded_', + SELECTED: '_selected_', + INCLUDED: '_included_' +}; + +class Axis { + constructor(owner) { + this.owner = owner; + this.d3 = owner.d3; + this.internal = AxisInternal; + } +} +Axis.prototype.init = function init() { + var $$ = this.owner, + config = $$.config, + main = $$.main; + $$.axes.x = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisX) + .attr('clip-path', config.axis_x_inner ? '' : $$.clipPathForXAxis) + .attr('transform', $$.getTranslate('x')) + .style('visibility', config.axis_x_show ? 'visible' : 'hidden'); + $$.axes.x + .append('text') + .attr('class', CLASS.axisXLabel) + .attr('transform', config.axis_rotated ? 'rotate(-90)' : '') + .style('text-anchor', this.textAnchorForXAxisLabel.bind(this)); + $$.axes.y = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisY) + .attr('clip-path', config.axis_y_inner ? '' : $$.clipPathForYAxis) + .attr('transform', $$.getTranslate('y')) + .style('visibility', config.axis_y_show ? 'visible' : 'hidden'); + $$.axes.y + .append('text') + .attr('class', CLASS.axisYLabel) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .style('text-anchor', this.textAnchorForYAxisLabel.bind(this)); + + $$.axes.y2 = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisY2) + // clip-path? + .attr('transform', $$.getTranslate('y2')) + .style('visibility', config.axis_y2_show ? 'visible' : 'hidden'); + $$.axes.y2 + .append('text') + .attr('class', CLASS.axisY2Label) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .style('text-anchor', this.textAnchorForY2AxisLabel.bind(this)); +}; +Axis.prototype.getXAxis = function getXAxis( + scale, + orient, + tickFormat, + tickValues, + withOuterTick, + withoutTransition, + withoutRotateTickText +) { + var $$ = this.owner, + config = $$.config, + axisParams = { + isCategory: $$.isCategorized(), + withOuterTick: withOuterTick, + tickMultiline: config.axis_x_tick_multiline, + tickMultilineMax: config.axis_x_tick_multiline + ? Number(config.axis_x_tick_multilineMax) + : 0, + tickWidth: config.axis_x_tick_width, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_x_tick_rotate, + withoutTransition: withoutTransition + }, + axis = new this.internal(this, axisParams).axis.scale(scale).orient(orient); + + if ($$.isTimeSeries() && tickValues && typeof tickValues !== 'function') { + tickValues = tickValues.map(function(v) { + return $$.parseDate(v) + }); + } + + // Set tick + axis.tickFormat(tickFormat).tickValues(tickValues); + if ($$.isCategorized()) { + axis.tickCentered(config.axis_x_tick_centered); + if (isEmpty(config.axis_x_tick_culling)) { + config.axis_x_tick_culling = false; + } + } + + return axis +}; +Axis.prototype.updateXAxisTickValues = function updateXAxisTickValues( + targets, + axis +) { + var $$ = this.owner, + config = $$.config, + tickValues; + if (config.axis_x_tick_fit || config.axis_x_tick_count) { + tickValues = this.generateTickValues( + $$.mapTargetsToUniqueXs(targets), + config.axis_x_tick_count, + $$.isTimeSeries() + ); + } + if (axis) { + axis.tickValues(tickValues); + } else { + $$.xAxis.tickValues(tickValues); + $$.subXAxis.tickValues(tickValues); + } + return tickValues +}; +Axis.prototype.getYAxis = function getYAxis( + axisId, + scale, + orient, + tickValues, + withOuterTick, + withoutTransition, + withoutRotateTickText +) { + const $$ = this.owner; + const config = $$.config; + + let tickFormat = config[`axis_${axisId}_tick_format`]; + if (!tickFormat && $$.isAxisNormalized(axisId)) { + tickFormat = x => `${x}%`; + } + + const axis = new this.internal(this, { + withOuterTick: withOuterTick, + withoutTransition: withoutTransition, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate + }).axis + .scale(scale) + .orient(orient); + + if (tickFormat) { + axis.tickFormat(tickFormat); + } + + if ($$.isTimeSeriesY()) { + axis.ticks(config.axis_y_tick_time_type, config.axis_y_tick_time_interval); + } else { + axis.tickValues(tickValues); + } + return axis +}; +Axis.prototype.getId = function getId(id) { + var config = this.owner.config; + return id in config.data_axes ? config.data_axes[id] : 'y' +}; +Axis.prototype.getXAxisTickFormat = function getXAxisTickFormat() { + // #2251 previously set any negative values to a whole number, + // however both should be truncated according to the users format specification + var $$ = this.owner, + config = $$.config; + let format = $$.isTimeSeries() + ? $$.defaultAxisTimeFormat + : $$.isCategorized() + ? $$.categoryName + : function(v) { + return v + }; + + if (config.axis_x_tick_format) { + if (isFunction(config.axis_x_tick_format)) { + format = config.axis_x_tick_format; + } else if ($$.isTimeSeries()) { + format = function(date) { + return date ? $$.axisTimeFormat(config.axis_x_tick_format)(date) : '' + }; + } + } + return isFunction(format) + ? function(v) { + return format.call($$, v) + } + : format +}; +Axis.prototype.getTickValues = function getTickValues(tickValues, axis) { + return tickValues ? tickValues : axis ? axis.tickValues() : undefined +}; +Axis.prototype.getXAxisTickValues = function getXAxisTickValues() { + return this.getTickValues( + this.owner.config.axis_x_tick_values, + this.owner.xAxis + ) +}; +Axis.prototype.getYAxisTickValues = function getYAxisTickValues() { + return this.getTickValues( + this.owner.config.axis_y_tick_values, + this.owner.yAxis + ) +}; +Axis.prototype.getY2AxisTickValues = function getY2AxisTickValues() { + return this.getTickValues( + this.owner.config.axis_y2_tick_values, + this.owner.y2Axis + ) +}; +Axis.prototype.getLabelOptionByAxisId = function getLabelOptionByAxisId( + axisId +) { + var $$ = this.owner, + config = $$.config, + option; + if (axisId === 'y') { + option = config.axis_y_label; + } else if (axisId === 'y2') { + option = config.axis_y2_label; + } else if (axisId === 'x') { + option = config.axis_x_label; + } + return option +}; +Axis.prototype.getLabelText = function getLabelText(axisId) { + var option = this.getLabelOptionByAxisId(axisId); + return isString(option) ? option : option ? option.text : null +}; +Axis.prototype.setLabelText = function setLabelText(axisId, text) { + var $$ = this.owner, + config = $$.config, + option = this.getLabelOptionByAxisId(axisId); + if (isString(option)) { + if (axisId === 'y') { + config.axis_y_label = text; + } else if (axisId === 'y2') { + config.axis_y2_label = text; + } else if (axisId === 'x') { + config.axis_x_label = text; + } + } else if (option) { + option.text = text; + } +}; +Axis.prototype.getLabelPosition = function getLabelPosition( + axisId, + defaultPosition +) { + var option = this.getLabelOptionByAxisId(axisId), + position = + option && typeof option === 'object' && option.position + ? option.position + : defaultPosition; + return { + isInner: position.indexOf('inner') >= 0, + isOuter: position.indexOf('outer') >= 0, + isLeft: position.indexOf('left') >= 0, + isCenter: position.indexOf('center') >= 0, + isRight: position.indexOf('right') >= 0, + isTop: position.indexOf('top') >= 0, + isMiddle: position.indexOf('middle') >= 0, + isBottom: position.indexOf('bottom') >= 0 + } +}; +Axis.prototype.getXAxisLabelPosition = function getXAxisLabelPosition() { + return this.getLabelPosition( + 'x', + this.owner.config.axis_rotated ? 'inner-top' : 'inner-right' + ) +}; +Axis.prototype.getYAxisLabelPosition = function getYAxisLabelPosition() { + return this.getLabelPosition( + 'y', + this.owner.config.axis_rotated ? 'inner-right' : 'inner-top' + ) +}; +Axis.prototype.getY2AxisLabelPosition = function getY2AxisLabelPosition() { + return this.getLabelPosition( + 'y2', + this.owner.config.axis_rotated ? 'inner-right' : 'inner-top' + ) +}; +Axis.prototype.getLabelPositionById = function getLabelPositionById(id) { + return id === 'y2' + ? this.getY2AxisLabelPosition() + : id === 'y' + ? this.getYAxisLabelPosition() + : this.getXAxisLabelPosition() +}; +Axis.prototype.textForXAxisLabel = function textForXAxisLabel() { + return this.getLabelText('x') +}; +Axis.prototype.textForYAxisLabel = function textForYAxisLabel() { + return this.getLabelText('y') +}; +Axis.prototype.textForY2AxisLabel = function textForY2AxisLabel() { + return this.getLabelText('y2') +}; +Axis.prototype.xForAxisLabel = function xForAxisLabel(forHorizontal, position) { + var $$ = this.owner; + if (forHorizontal) { + return position.isLeft ? 0 : position.isCenter ? $$.width / 2 : $$.width + } else { + return position.isBottom + ? -$$.height + : position.isMiddle + ? -$$.height / 2 + : 0 + } +}; +Axis.prototype.dxForAxisLabel = function dxForAxisLabel( + forHorizontal, + position +) { + if (forHorizontal) { + return position.isLeft ? '0.5em' : position.isRight ? '-0.5em' : '0' + } else { + return position.isTop ? '-0.5em' : position.isBottom ? '0.5em' : '0' + } +}; +Axis.prototype.textAnchorForAxisLabel = function textAnchorForAxisLabel( + forHorizontal, + position +) { + if (forHorizontal) { + return position.isLeft ? 'start' : position.isCenter ? 'middle' : 'end' + } else { + return position.isBottom ? 'start' : position.isMiddle ? 'middle' : 'end' + } +}; +Axis.prototype.xForXAxisLabel = function xForXAxisLabel() { + return this.xForAxisLabel( + !this.owner.config.axis_rotated, + this.getXAxisLabelPosition() + ) +}; +Axis.prototype.xForYAxisLabel = function xForYAxisLabel() { + return this.xForAxisLabel( + this.owner.config.axis_rotated, + this.getYAxisLabelPosition() + ) +}; +Axis.prototype.xForY2AxisLabel = function xForY2AxisLabel() { + return this.xForAxisLabel( + this.owner.config.axis_rotated, + this.getY2AxisLabelPosition() + ) +}; +Axis.prototype.dxForXAxisLabel = function dxForXAxisLabel() { + return this.dxForAxisLabel( + !this.owner.config.axis_rotated, + this.getXAxisLabelPosition() + ) +}; +Axis.prototype.dxForYAxisLabel = function dxForYAxisLabel() { + return this.dxForAxisLabel( + this.owner.config.axis_rotated, + this.getYAxisLabelPosition() + ) +}; +Axis.prototype.dxForY2AxisLabel = function dxForY2AxisLabel() { + return this.dxForAxisLabel( + this.owner.config.axis_rotated, + this.getY2AxisLabelPosition() + ) +}; +Axis.prototype.dyForXAxisLabel = function dyForXAxisLabel() { + var $$ = this.owner, + config = $$.config, + position = this.getXAxisLabelPosition(); + if (config.axis_rotated) { + return position.isInner + ? '1.2em' + : -25 - ($$.config.axis_x_inner ? 0 : this.getMaxTickWidth('x')) + } else { + return position.isInner ? '-0.5em' : $$.getHorizontalAxisHeight('x') - 10 + } +}; +Axis.prototype.dyForYAxisLabel = function dyForYAxisLabel() { + var $$ = this.owner, + position = this.getYAxisLabelPosition(); + if ($$.config.axis_rotated) { + return position.isInner ? '-0.5em' : '3em' + } else { + return position.isInner + ? '1.2em' + : -10 - ($$.config.axis_y_inner ? 0 : this.getMaxTickWidth('y') + 10) + } +}; +Axis.prototype.dyForY2AxisLabel = function dyForY2AxisLabel() { + var $$ = this.owner, + position = this.getY2AxisLabelPosition(); + if ($$.config.axis_rotated) { + return position.isInner ? '1.2em' : '-2.2em' + } else { + return position.isInner + ? '-0.5em' + : 15 + ($$.config.axis_y2_inner ? 0 : this.getMaxTickWidth('y2') + 15) + } +}; +Axis.prototype.textAnchorForXAxisLabel = function textAnchorForXAxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel( + !$$.config.axis_rotated, + this.getXAxisLabelPosition() + ) +}; +Axis.prototype.textAnchorForYAxisLabel = function textAnchorForYAxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel( + $$.config.axis_rotated, + this.getYAxisLabelPosition() + ) +}; +Axis.prototype.textAnchorForY2AxisLabel = function textAnchorForY2AxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel( + $$.config.axis_rotated, + this.getY2AxisLabelPosition() + ) +}; +Axis.prototype.getMaxTickWidth = function getMaxTickWidth( + id, + withoutRecompute +) { + var $$ = this.owner, + maxWidth = 0, + targetsToShow, + scale, + axis, + dummy, + svg; + if (withoutRecompute && $$.currentMaxTickWidths[id]) { + return $$.currentMaxTickWidths[id] + } + if ($$.svg) { + targetsToShow = $$.filterTargetsToShow($$.data.targets); + if (id === 'y') { + scale = $$.y.copy().domain($$.getYDomain(targetsToShow, 'y')); + axis = this.getYAxis( + id, + scale, + $$.yOrient, + $$.yAxisTickValues, + false, + true, + true + ); + } else if (id === 'y2') { + scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); + axis = this.getYAxis( + id, + scale, + $$.y2Orient, + $$.y2AxisTickValues, + false, + true, + true + ); + } else { + scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); + axis = this.getXAxis( + scale, + $$.xOrient, + $$.xAxisTickFormat, + $$.xAxisTickValues, + false, + true, + true + ); + this.updateXAxisTickValues(targetsToShow, axis); + } + dummy = $$.d3 + .select('body') + .append('div') + .classed('c3', true) + ;(svg = dummy + .append('svg') + .style('visibility', 'hidden') + .style('position', 'fixed') + .style('top', 0) + .style('left', 0)), + svg + .append('g') + .call(axis) + .each(function() { + $$.d3 + .select(this) + .selectAll('text') + .each(function() { + var box = getBBox(this); + if (maxWidth < box.width) { + maxWidth = box.width; + } + }); + dummy.remove(); + }); + } + $$.currentMaxTickWidths[id] = + maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; + return $$.currentMaxTickWidths[id] +}; + +Axis.prototype.updateLabels = function updateLabels(withTransition) { + var $$ = this.owner; + var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), + axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel), + axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label) + ;(withTransition ? axisXLabel.transition() : axisXLabel) + .attr('x', this.xForXAxisLabel.bind(this)) + .attr('dx', this.dxForXAxisLabel.bind(this)) + .attr('dy', this.dyForXAxisLabel.bind(this)) + .text(this.textForXAxisLabel.bind(this)) + ;(withTransition ? axisYLabel.transition() : axisYLabel) + .attr('x', this.xForYAxisLabel.bind(this)) + .attr('dx', this.dxForYAxisLabel.bind(this)) + .attr('dy', this.dyForYAxisLabel.bind(this)) + .text(this.textForYAxisLabel.bind(this)) + ;(withTransition ? axisY2Label.transition() : axisY2Label) + .attr('x', this.xForY2AxisLabel.bind(this)) + .attr('dx', this.dxForY2AxisLabel.bind(this)) + .attr('dy', this.dyForY2AxisLabel.bind(this)) + .text(this.textForY2AxisLabel.bind(this)); +}; +Axis.prototype.getPadding = function getPadding( + padding, + key, + defaultValue, + domainLength +) { + var p = typeof padding === 'number' ? padding : padding[key]; + if (!isValue(p)) { + return defaultValue + } + if (padding.unit === 'ratio') { + return padding[key] * domainLength + } + // assume padding is pixels if unit is not specified + return this.convertPixelsToAxisPadding(p, domainLength) +}; +Axis.prototype.convertPixelsToAxisPadding = function convertPixelsToAxisPadding( + pixels, + domainLength +) { + var $$ = this.owner, + length = $$.config.axis_rotated ? $$.width : $$.height; + return domainLength * (pixels / length) +}; +Axis.prototype.generateTickValues = function generateTickValues( + values, + tickCount, + forTimeSeries +) { + var tickValues = values, + targetCount, + start, + end, + count, + interval, + i, + tickValue; + if (tickCount) { + targetCount = isFunction(tickCount) ? tickCount() : tickCount; + // compute ticks according to tickCount + if (targetCount === 1) { + tickValues = [values[0]]; + } else if (targetCount === 2) { + tickValues = [values[0], values[values.length - 1]]; + } else if (targetCount > 2) { + count = targetCount - 2; + start = values[0]; + end = values[values.length - 1]; + interval = (end - start) / (count + 1); + // re-construct unique values + tickValues = [start]; + for (i = 0; i < count; i++) { + tickValue = +start + interval * (i + 1); + tickValues.push(forTimeSeries ? new Date(tickValue) : tickValue); + } + tickValues.push(end); + } + } + if (!forTimeSeries) { + tickValues = tickValues.sort(function(a, b) { + return a - b + }); + } + return tickValues +}; +Axis.prototype.generateTransitions = function generateTransitions(duration) { + var $$ = this.owner, + axes = $$.axes; + return { + axisX: duration ? axes.x.transition().duration(duration) : axes.x, + axisY: duration ? axes.y.transition().duration(duration) : axes.y, + axisY2: duration ? axes.y2.transition().duration(duration) : axes.y2, + axisSubX: duration ? axes.subx.transition().duration(duration) : axes.subx + } +}; +Axis.prototype.redraw = function redraw(duration, isHidden) { + var $$ = this.owner, + transition = duration ? $$.d3.transition().duration(duration) : null; + $$.axes.x.style('opacity', isHidden ? 0 : 1).call($$.xAxis, transition); + $$.axes.y.style('opacity', isHidden ? 0 : 1).call($$.yAxis, transition); + $$.axes.y2.style('opacity', isHidden ? 0 : 1).call($$.y2Axis, transition); + $$.axes.subx.style('opacity', isHidden ? 0 : 1).call($$.subXAxis, transition); +}; + +var c3 = { + version: '0.7.18', + chart: { + fn: Chart.prototype, + internal: { + fn: ChartInternal.prototype, + axis: { + fn: Axis.prototype, + internal: { + fn: AxisInternal.prototype + } + } + } + }, + generate: function(config) { + return new Chart(config) + } +}; + +ChartInternal.prototype.beforeInit = function() { + // can do something +}; +ChartInternal.prototype.afterInit = function() { + // can do something +}; +ChartInternal.prototype.init = function() { + var $$ = this, + config = $$.config; + + $$.initParams(); + + if (config.data_url) { + $$.convertUrlToData( + config.data_url, + config.data_mimeType, + config.data_headers, + config.data_keys, + $$.initWithData + ); + } else if (config.data_json) { + $$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); + } else if (config.data_rows) { + $$.initWithData($$.convertRowsToData(config.data_rows)); + } else if (config.data_columns) { + $$.initWithData($$.convertColumnsToData(config.data_columns)); + } else { + throw Error('url or json or rows or columns is required.') + } +}; + +ChartInternal.prototype.initParams = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config; + + // MEMO: clipId needs to be unique because it conflicts when multiple charts exist + $$.clipId = 'c3-' + new Date().valueOf() + '-clip'; + $$.clipIdForXAxis = $$.clipId + '-xaxis'; + $$.clipIdForYAxis = $$.clipId + '-yaxis'; + $$.clipIdForGrid = $$.clipId + '-grid'; + $$.clipIdForSubchart = $$.clipId + '-subchart'; + $$.clipPath = $$.getClipPath($$.clipId); + $$.clipPathForXAxis = $$.getClipPath($$.clipIdForXAxis); + $$.clipPathForYAxis = $$.getClipPath($$.clipIdForYAxis); + $$.clipPathForGrid = $$.getClipPath($$.clipIdForGrid); + $$.clipPathForSubchart = $$.getClipPath($$.clipIdForSubchart); + + $$.dragStart = null; + $$.dragging = false; + $$.flowing = false; + $$.cancelClick = false; + $$.mouseover = undefined; + $$.transiting = false; + + $$.color = $$.generateColor(); + $$.levelColor = $$.generateLevelColor(); + + $$.dataTimeParse = (config.data_xLocaltime ? d3.timeParse : d3.utcParse)( + $$.config.data_xFormat + ); + $$.axisTimeFormat = config.axis_x_localtime ? d3.timeFormat : d3.utcFormat; + $$.defaultAxisTimeFormat = function(date) { + if (date.getMilliseconds()) { + return d3.timeFormat('.%L')(date) + } + if (date.getSeconds()) { + return d3.timeFormat(':%S')(date) + } + if (date.getMinutes()) { + return d3.timeFormat('%I:%M')(date) + } + if (date.getHours()) { + return d3.timeFormat('%I %p')(date) + } + if (date.getDay() && date.getDate() !== 1) { + return d3.timeFormat('%-m/%-d')(date) + } + if (date.getDate() !== 1) { + return d3.timeFormat('%-m/%-d')(date) + } + if (date.getMonth()) { + return d3.timeFormat('%-m/%-d')(date) + } + return d3.timeFormat('%Y/%-m/%-d')(date) + }; + $$.hiddenTargetIds = []; + $$.hiddenLegendIds = []; + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; + + $$.xOrient = config.axis_rotated + ? config.axis_x_inner + ? 'right' + : 'left' + : config.axis_x_inner + ? 'top' + : 'bottom'; + $$.yOrient = config.axis_rotated + ? config.axis_y_inner + ? 'top' + : 'bottom' + : config.axis_y_inner + ? 'right' + : 'left'; + $$.y2Orient = config.axis_rotated + ? config.axis_y2_inner + ? 'bottom' + : 'top' + : config.axis_y2_inner + ? 'left' + : 'right'; + $$.subXOrient = config.axis_rotated ? 'left' : 'bottom'; + + $$.isLegendRight = config.legend_position === 'right'; + $$.isLegendInset = config.legend_position === 'inset'; + $$.isLegendTop = + config.legend_inset_anchor === 'top-left' || + config.legend_inset_anchor === 'top-right'; + $$.isLegendLeft = + config.legend_inset_anchor === 'top-left' || + config.legend_inset_anchor === 'bottom-left'; + $$.legendStep = 0; + $$.legendItemWidth = 0; + $$.legendItemHeight = 0; + + $$.currentMaxTickWidths = { + x: 0, + y: 0, + y2: 0 + }; + + $$.rotated_padding_left = 30; + $$.rotated_padding_right = config.axis_rotated && !config.axis_x_show ? 0 : 30; + $$.rotated_padding_top = 5; + + $$.withoutFadeIn = {}; + + $$.intervalForObserveInserted = undefined; + + $$.axes.subx = d3.selectAll([]); // needs when excluding subchart.js +}; + +ChartInternal.prototype.initChartElements = function() { + if (this.initBar) { + this.initBar(); + } + if (this.initLine) { + this.initLine(); + } + if (this.initArc) { + this.initArc(); + } + if (this.initGauge) { + this.initGauge(); + } + if (this.initText) { + this.initText(); + } +}; + +ChartInternal.prototype.initWithData = function(data) { + var $$ = this, + d3 = $$.d3, + config = $$.config; + var defs, + main, + binding = true; + + $$.axis = new Axis($$); + + if (!config.bindto) { + $$.selectChart = d3.selectAll([]); + } else if (typeof config.bindto.node === 'function') { + $$.selectChart = config.bindto; + } else { + $$.selectChart = d3.select(config.bindto); + } + if ($$.selectChart.empty()) { + $$.selectChart = d3 + .select(document.createElement('div')) + .style('opacity', 0); + $$.observeInserted($$.selectChart); + binding = false; + } + $$.selectChart.html('').classed('c3', true); + + // Init data as targets + $$.data.xs = {}; + $$.data.targets = $$.convertDataToTargets(data); + + if (config.data_filter) { + $$.data.targets = $$.data.targets.filter(config.data_filter); + } + + // Set targets to hide if needed + if (config.data_hide) { + $$.addHiddenTargetIds( + config.data_hide === true + ? $$.mapToIds($$.data.targets) + : config.data_hide + ); + } + if (config.legend_hide) { + $$.addHiddenLegendIds( + config.legend_hide === true + ? $$.mapToIds($$.data.targets) + : config.legend_hide + ); + } + + if ($$.isStanfordGraphType()) { + $$.initStanfordData(); + } + + // Init sizes and scales + $$.updateSizes(); + $$.updateScales(); + + // Set domains for each scale + $$.x.domain(d3.extent($$.getXDomain($$.data.targets))); + $$.y.domain($$.getYDomain($$.data.targets, 'y')); + $$.y2.domain($$.getYDomain($$.data.targets, 'y2')); + $$.subX.domain($$.x.domain()); + $$.subY.domain($$.y.domain()); + $$.subY2.domain($$.y2.domain()); + + // Save original x domain for zoom update + $$.orgXDomain = $$.x.domain(); + + /*-- Basic Elements --*/ + + // Define svgs + $$.svg = $$.selectChart + .append('svg') + .style('overflow', 'hidden') + .on('mouseenter', function() { + return config.onmouseover.call($$) + }) + .on('mouseleave', function() { + return config.onmouseout.call($$) + }); + + if ($$.config.svg_classname) { + $$.svg.attr('class', $$.config.svg_classname); + } + + // Define defs + defs = $$.svg.append('defs'); + $$.clipChart = $$.appendClip(defs, $$.clipId); + $$.clipXAxis = $$.appendClip(defs, $$.clipIdForXAxis); + $$.clipYAxis = $$.appendClip(defs, $$.clipIdForYAxis); + $$.clipGrid = $$.appendClip(defs, $$.clipIdForGrid); + $$.clipSubchart = $$.appendClip(defs, $$.clipIdForSubchart); + $$.updateSvgSize(); + + // Define regions + main = $$.main = $$.svg.append('g').attr('transform', $$.getTranslate('main')); + + if ($$.initPie) { + $$.initPie(); + } + if ($$.initDragZoom) { + $$.initDragZoom(); + } + if (config.subchart_show && $$.initSubchart) { + $$.initSubchart(); + } + if ($$.initTooltip) { + $$.initTooltip(); + } + if ($$.initLegend) { + $$.initLegend(); + } + if ($$.initTitle) { + $$.initTitle(); + } + if ($$.initZoom) { + $$.initZoom(); + } + if ($$.isStanfordGraphType()) { + $$.drawColorScale(); + } + + // Update selection based on size and scale + // TODO: currently this must be called after initLegend because of update of sizes, but it should be done in initSubchart. + if (config.subchart_show && $$.initSubchartBrush) { + $$.initSubchartBrush(); + } + + /*-- Main Region --*/ + + // text when empty + main + .append('text') + .attr('class', CLASS.text + ' ' + CLASS.empty) + .attr('text-anchor', 'middle') // horizontal centering of text at x position in all browsers. + .attr('dominant-baseline', 'middle'); // vertical centering of text at y position in all browsers, except IE. + + // Regions + $$.initRegion(); + + // Grids + $$.initGrid(); + + // Define g for chart area + main + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.chart); + + // Grid lines + if (config.grid_lines_front) { + $$.initGridLines(); + } + + $$.initStanfordElements(); + + // Cover whole with rects for events + $$.initEventRect(); + + // Define g for chart + $$.initChartElements(); + + // Add Axis + $$.axis.init(); + + // Set targets + $$.updateTargets($$.data.targets); + + // Set default extent if defined + if (config.axis_x_selection) { + $$.brush.selectionAsValue($$.getDefaultSelection()); + } + + // Draw with targets + if (binding) { + $$.updateDimension(); + $$.config.oninit.call($$); + $$.redraw({ + withTransition: false, + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransitionForAxis: false + }); + } + + // Bind to resize event + $$.bindResize(); + + // Bind to window focus event + $$.bindWindowFocus(); + + // export element of the chart + $$.api.element = $$.selectChart.node(); +}; + +ChartInternal.prototype.smoothLines = function(el, type) { + var $$ = this; + if (type === 'grid') { + el.each(function() { + var g = $$.d3.select(this), + x1 = g.attr('x1'), + x2 = g.attr('x2'), + y1 = g.attr('y1'), + y2 = g.attr('y2'); + g.attr({ + x1: Math.ceil(x1), + x2: Math.ceil(x2), + y1: Math.ceil(y1), + y2: Math.ceil(y2) + }); + }); + } +}; + +ChartInternal.prototype.updateSizes = function() { + var $$ = this, + config = $$.config; + var legendHeight = $$.legend ? $$.getLegendHeight() : 0, + legendWidth = $$.legend ? $$.getLegendWidth() : 0, + legendHeightForBottom = + $$.isLegendRight || $$.isLegendInset ? 0 : legendHeight, + hasArc = $$.hasArcType(), + xAxisHeight = + config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), + subchartHeight = + config.subchart_show && !hasArc + ? config.subchart_size_height + xAxisHeight + : 0; + + $$.currentWidth = $$.getCurrentWidth(); + $$.currentHeight = $$.getCurrentHeight(); + + // for main + $$.margin = config.axis_rotated + ? { + top: $$.getHorizontalAxisHeight('y2') + $$.getCurrentPaddingTop(), + right: hasArc ? 0 : $$.getCurrentPaddingRight(), + bottom: + $$.getHorizontalAxisHeight('y') + + legendHeightForBottom + + $$.getCurrentPaddingBottom(), + left: subchartHeight + (hasArc ? 0 : $$.getCurrentPaddingLeft()) + } + : { + top: 4 + $$.getCurrentPaddingTop(), // for top tick text + right: hasArc ? 0 : $$.getCurrentPaddingRight(), + bottom: + xAxisHeight + + subchartHeight + + legendHeightForBottom + + $$.getCurrentPaddingBottom(), + left: hasArc ? 0 : $$.getCurrentPaddingLeft() + }; + + // for subchart + $$.margin2 = config.axis_rotated + ? { + top: $$.margin.top, + right: NaN, + bottom: 20 + legendHeightForBottom, + left: $$.rotated_padding_left + } + : { + top: $$.currentHeight - subchartHeight - legendHeightForBottom, + right: NaN, + bottom: xAxisHeight + legendHeightForBottom, + left: $$.margin.left + }; + + // for legend + $$.margin3 = { + top: 0, + right: NaN, + bottom: 0, + left: 0 + }; + if ($$.updateSizeForLegend) { + $$.updateSizeForLegend(legendHeight, legendWidth); + } + + $$.width = $$.currentWidth - $$.margin.left - $$.margin.right; + $$.height = $$.currentHeight - $$.margin.top - $$.margin.bottom; + if ($$.width < 0) { + $$.width = 0; + } + if ($$.height < 0) { + $$.height = 0; + } + + $$.width2 = config.axis_rotated + ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right + : $$.width; + $$.height2 = config.axis_rotated + ? $$.height + : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; + if ($$.width2 < 0) { + $$.width2 = 0; + } + if ($$.height2 < 0) { + $$.height2 = 0; + } + + // for arc + $$.arcWidth = $$.width - ($$.isLegendRight ? legendWidth + 10 : 0); + $$.arcHeight = $$.height - ($$.isLegendRight ? 0 : 10); + if ($$.hasType('gauge') && !config.gauge_fullCircle) { + $$.arcHeight += $$.height - $$.getGaugeLabelHeight(); + } + if ($$.updateRadius) { + $$.updateRadius(); + } + + if ($$.isLegendRight && hasArc) { + $$.margin3.left = $$.arcWidth / 2 + $$.radiusExpanded * 1.1; + } +}; + +ChartInternal.prototype.updateTargets = function(targets) { + var $$ = this, + config = $$.config; + + /*-- Main --*/ + + //-- Text --// + $$.updateTargetsForText(targets); + + //-- Bar --// + $$.updateTargetsForBar(targets); + + //-- Line --// + $$.updateTargetsForLine(targets); + + //-- Arc --// + if ($$.hasArcType() && $$.updateTargetsForArc) { + $$.updateTargetsForArc(targets); + } + + /*-- Sub --*/ + + if (config.subchart_show && $$.updateTargetsForSubchart) { + $$.updateTargetsForSubchart(targets); + } + + // Fade-in each chart + $$.showTargets(); +}; +ChartInternal.prototype.showTargets = function() { + var $$ = this; + $$.svg + .selectAll('.' + CLASS.target) + .filter(function(d) { + return $$.isTargetToShow(d.id) + }) + .transition() + .duration($$.config.transition_duration) + .style('opacity', 1); +}; + +ChartInternal.prototype.redraw = function(options, transitions) { + var $$ = this, + main = $$.main, + d3 = $$.d3, + config = $$.config; + var areaIndices = $$.getShapeIndices($$.isAreaType), + barIndices = $$.getShapeIndices($$.isBarType), + lineIndices = $$.getShapeIndices($$.isLineType); + var withY, + withSubchart, + withTransition, + withTransitionForExit, + withTransitionForAxis, + withTransform, + withUpdateXDomain, + withUpdateOrgXDomain, + withTrimXDomain, + withLegend, + withEventRect, + withDimension, + withUpdateXAxis; + var hideAxis = $$.hasArcType(); + var drawArea, drawBar, drawLine, xForText, yForText; + var duration, durationForExit, durationForAxis; + var transitionsToWait, waitForDraw, flow, transition; + var targetsToShow = $$.filterTargetsToShow($$.data.targets), + tickValues, + i, + intervalForCulling, + xDomainForZoom; + var xv = $$.xv.bind($$), + cx, + cy; + + options = options || {}; + withY = getOption(options, 'withY', true); + withSubchart = getOption(options, 'withSubchart', true); + withTransition = getOption(options, 'withTransition', true); + withTransform = getOption(options, 'withTransform', false); + withUpdateXDomain = getOption(options, 'withUpdateXDomain', false); + withUpdateOrgXDomain = getOption(options, 'withUpdateOrgXDomain', false); + withTrimXDomain = getOption(options, 'withTrimXDomain', true); + withUpdateXAxis = getOption(options, 'withUpdateXAxis', withUpdateXDomain); + withLegend = getOption(options, 'withLegend', false); + withEventRect = getOption(options, 'withEventRect', true); + withDimension = getOption(options, 'withDimension', true); + withTransitionForExit = getOption( + options, + 'withTransitionForExit', + withTransition + ); + withTransitionForAxis = getOption( + options, + 'withTransitionForAxis', + withTransition + ); + + duration = withTransition ? config.transition_duration : 0; + durationForExit = withTransitionForExit ? duration : 0; + durationForAxis = withTransitionForAxis ? duration : 0; + + transitions = transitions || $$.axis.generateTransitions(durationForAxis); + + // update legend and transform each g + if (withLegend && config.legend_show) { + $$.updateLegend($$.mapToIds($$.data.targets), options, transitions); + } else if (withDimension) { + // need to update dimension (e.g. axis.y.tick.values) because y tick values should change + // no need to update axis in it because they will be updated in redraw() + $$.updateDimension(true); + } + + // MEMO: needed for grids calculation + if ($$.isCategorized() && targetsToShow.length === 0) { + $$.x.domain([0, $$.axes.x.selectAll('.tick').size()]); + } + + if (targetsToShow.length) { + $$.updateXDomain( + targetsToShow, + withUpdateXDomain, + withUpdateOrgXDomain, + withTrimXDomain + ); + if (!config.axis_x_tick_values) { + tickValues = $$.axis.updateXAxisTickValues(targetsToShow); + } + } else { + $$.xAxis.tickValues([]); + $$.subXAxis.tickValues([]); + } + + if (config.zoom_rescale && !options.flow) { + xDomainForZoom = $$.x.orgDomain(); + } + + $$.y.domain($$.getYDomain(targetsToShow, 'y', xDomainForZoom)); + $$.y2.domain($$.getYDomain(targetsToShow, 'y2', xDomainForZoom)); + + if (!config.axis_y_tick_values && config.axis_y_tick_count) { + $$.yAxis.tickValues( + $$.axis.generateTickValues($$.y.domain(), config.axis_y_tick_count) + ); + } + if (!config.axis_y2_tick_values && config.axis_y2_tick_count) { + $$.y2Axis.tickValues( + $$.axis.generateTickValues($$.y2.domain(), config.axis_y2_tick_count) + ); + } + + // axes + $$.axis.redraw(durationForAxis, hideAxis); + + // Update axis label + $$.axis.updateLabels(withTransition); + + // show/hide if manual culling needed + if ((withUpdateXDomain || withUpdateXAxis) && targetsToShow.length) { + if (config.axis_x_tick_culling && tickValues) { + for (i = 1; i < tickValues.length; i++) { + if (tickValues.length / i < config.axis_x_tick_culling_max) { + intervalForCulling = i; + break + } + } + $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').each(function(e) { + var index = tickValues.indexOf(e); + if (index >= 0) { + d3.select(this).style( + 'display', + index % intervalForCulling ? 'none' : 'block' + ); + } + }); + } else { + $$.svg + .selectAll('.' + CLASS.axisX + ' .tick text') + .style('display', 'block'); + } + } + + // setup drawer - MEMO: these must be called after axis updated + drawArea = $$.generateDrawArea + ? $$.generateDrawArea(areaIndices, false) + : undefined; + drawBar = $$.generateDrawBar ? $$.generateDrawBar(barIndices) : undefined; + drawLine = $$.generateDrawLine + ? $$.generateDrawLine(lineIndices, false) + : undefined; + xForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, true); + yForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, false); + + // update circleY based on updated parameters + $$.updateCircleY(); + // generate circle x/y functions depending on updated params + cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$); + cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); + + // Update sub domain + if (withY) { + $$.subY.domain($$.getYDomain(targetsToShow, 'y')); + $$.subY2.domain($$.getYDomain(targetsToShow, 'y2')); + } + + // xgrid focus + $$.updateXgridFocus(); + + // Data empty label positioning and text. + main + .select('text.' + CLASS.text + '.' + CLASS.empty) + .attr('x', $$.width / 2) + .attr('y', $$.height / 2) + .text(config.data_empty_label_text) + .transition() + .style('opacity', targetsToShow.length ? 0 : 1); + + // event rect + if (withEventRect) { + $$.redrawEventRect(); + } + + // grid + $$.updateGrid(duration); + + $$.updateStanfordElements(duration); + + // rect for regions + $$.updateRegion(duration); + + // bars + $$.updateBar(durationForExit); + + // lines, areas and circles + $$.updateLine(durationForExit); + $$.updateArea(durationForExit); + $$.updateCircle(cx, cy); + + // text + if ($$.hasDataLabel()) { + $$.updateText(xForText, yForText, durationForExit); + } + + // title + if ($$.redrawTitle) { + $$.redrawTitle(); + } + + // arc + if ($$.redrawArc) { + $$.redrawArc(duration, durationForExit, withTransform); + } + + // subchart + if (config.subchart_show && $$.redrawSubchart) { + $$.redrawSubchart( + withSubchart, + transitions, + duration, + durationForExit, + areaIndices, + barIndices, + lineIndices + ); + } + + if ($$.isStanfordGraphType()) { + $$.drawColorScale(); + } + + // circles for select + main + .selectAll('.' + CLASS.selectedCircles) + .filter($$.isBarType.bind($$)) + .selectAll('circle') + .remove(); + + if (options.flow) { + flow = $$.generateFlow({ + targets: targetsToShow, + flow: options.flow, + duration: options.flow.duration, + drawBar: drawBar, + drawLine: drawLine, + drawArea: drawArea, + cx: cx, + cy: cy, + xv: xv, + xForText: xForText, + yForText: yForText + }); + } + + if (duration && $$.isTabVisible()) { + // Only use transition if tab visible. See #938. + // transition should be derived from one transition + transition = d3.transition().duration(duration); + transitionsToWait = [] + ;[ + $$.redrawBar(drawBar, true, transition), + $$.redrawLine(drawLine, true, transition), + $$.redrawArea(drawArea, true, transition), + $$.redrawCircle(cx, cy, true, transition), + $$.redrawText(xForText, yForText, options.flow, true, transition), + $$.redrawRegion(true, transition), + $$.redrawGrid(true, transition) + ].forEach(function(transitions) { + transitions.forEach(function(transition) { + transitionsToWait.push(transition); + }); + }); + // Wait for end of transitions to call flow and onrendered callback + waitForDraw = $$.generateWait(); + transitionsToWait.forEach(function(t) { + waitForDraw.add(t); + }); + waitForDraw(function() { + if (flow) { + flow(); + } + if (config.onrendered) { + config.onrendered.call($$); + } + }); + } else { + $$.redrawBar(drawBar); + $$.redrawLine(drawLine); + $$.redrawArea(drawArea); + $$.redrawCircle(cx, cy); + $$.redrawText(xForText, yForText, options.flow); + $$.redrawRegion(); + $$.redrawGrid(); + if (flow) { + flow(); + } + if (config.onrendered) { + config.onrendered.call($$); + } + } + + // update fadein condition + $$.mapToIds($$.data.targets).forEach(function(id) { + $$.withoutFadeIn[id] = true; + }); +}; + +ChartInternal.prototype.updateAndRedraw = function(options) { + var $$ = this, + config = $$.config, + transitions; + options = options || {}; + // same with redraw + options.withTransition = getOption(options, 'withTransition', true); + options.withTransform = getOption(options, 'withTransform', false); + options.withLegend = getOption(options, 'withLegend', false); + // NOT same with redraw + options.withUpdateXDomain = getOption(options, 'withUpdateXDomain', true); + options.withUpdateOrgXDomain = getOption( + options, + 'withUpdateOrgXDomain', + true + ); + options.withTransitionForExit = false; + options.withTransitionForTransform = getOption( + options, + 'withTransitionForTransform', + options.withTransition + ); + // MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called) + $$.updateSizes(); + // MEMO: called in updateLegend in redraw if withLegend + if (!(options.withLegend && config.legend_show)) { + transitions = $$.axis.generateTransitions( + options.withTransitionForAxis ? config.transition_duration : 0 + ); + // Update scales + $$.updateScales(); + $$.updateSvgSize(); + // Update g positions + $$.transformAll(options.withTransitionForTransform, transitions); + } + // Draw with new sizes & scales + $$.redraw(options, transitions); +}; +ChartInternal.prototype.redrawWithoutRescale = function() { + this.redraw({ + withY: false, + withSubchart: false, + withEventRect: false, + withTransitionForAxis: false + }); +}; + +ChartInternal.prototype.isTimeSeries = function() { + return this.config.axis_x_type === 'timeseries' +}; +ChartInternal.prototype.isCategorized = function() { + return this.config.axis_x_type.indexOf('categor') >= 0 +}; +ChartInternal.prototype.isCustomX = function() { + var $$ = this, + config = $$.config; + return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)) +}; + +ChartInternal.prototype.isTimeSeriesY = function() { + return this.config.axis_y_type === 'timeseries' +}; + +ChartInternal.prototype.getTranslate = function(target) { + var $$ = this, + config = $$.config, + x, + y; + if (target === 'main') { + x = asHalfPixel($$.margin.left); + y = asHalfPixel($$.margin.top); + } else if (target === 'context') { + x = asHalfPixel($$.margin2.left); + y = asHalfPixel($$.margin2.top); + } else if (target === 'legend') { + x = $$.margin3.left; + y = $$.margin3.top; + } else if (target === 'x') { + x = 0; + y = config.axis_rotated ? 0 : $$.height; + } else if (target === 'y') { + x = 0; + y = config.axis_rotated ? $$.height : 0; + } else if (target === 'y2') { + x = config.axis_rotated ? 0 : $$.width; + y = config.axis_rotated ? 1 : 0; + } else if (target === 'subx') { + x = 0; + y = config.axis_rotated ? 0 : $$.height2; + } else if (target === 'arc') { + x = $$.arcWidth / 2; + y = $$.arcHeight / 2 - ($$.hasType('gauge') ? 6 : 0); // to prevent wrong display of min and max label + } + return 'translate(' + x + ',' + y + ')' +}; +ChartInternal.prototype.initialOpacity = function(d) { + return d.value !== null && this.withoutFadeIn[d.id] ? 1 : 0 +}; +ChartInternal.prototype.initialOpacityForCircle = function(d) { + return d.value !== null && this.withoutFadeIn[d.id] + ? this.opacityForCircle(d) + : 0 +}; +ChartInternal.prototype.opacityForCircle = function(d) { + var isPointShouldBeShown = isFunction(this.config.point_show) + ? this.config.point_show(d) + : this.config.point_show; + var opacity = isPointShouldBeShown || this.isStanfordType(d) ? 1 : 0; + return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0 +}; +ChartInternal.prototype.opacityForText = function() { + return this.hasDataLabel() ? 1 : 0 +}; +ChartInternal.prototype.xx = function(d) { + return d ? this.x(d.x) : null +}; +ChartInternal.prototype.xvCustom = function(d, xyValue) { + var $$ = this, + value = xyValue ? d[xyValue] : d.value; + if ($$.isTimeSeries()) { + value = $$.parseDate(d.value); + } else if ($$.isCategorized() && typeof d.value === 'string') { + value = $$.config.axis_x_categories.indexOf(d.value); + } + return Math.ceil($$.x(value)) +}; +ChartInternal.prototype.yvCustom = function(d, xyValue) { + var $$ = this, + yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y, + value = xyValue ? d[xyValue] : d.value; + return Math.ceil(yScale(value)) +}; +ChartInternal.prototype.xv = function(d) { + var $$ = this, + value = d.value; + if ($$.isTimeSeries()) { + value = $$.parseDate(d.value); + } else if ($$.isCategorized() && typeof d.value === 'string') { + value = $$.config.axis_x_categories.indexOf(d.value); + } + return Math.ceil($$.x(value)) +}; +ChartInternal.prototype.yv = function(d) { + var $$ = this, + yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y; + return Math.ceil(yScale(d.value)) +}; +ChartInternal.prototype.subxx = function(d) { + return d ? this.subX(d.x) : null +}; + +ChartInternal.prototype.transformMain = function(withTransition, transitions) { + var $$ = this, + xAxis, + yAxis, + y2Axis; + if (transitions && transitions.axisX) { + xAxis = transitions.axisX; + } else { + xAxis = $$.main.select('.' + CLASS.axisX); + if (withTransition) { + xAxis = xAxis.transition(); + } + } + if (transitions && transitions.axisY) { + yAxis = transitions.axisY; + } else { + yAxis = $$.main.select('.' + CLASS.axisY); + if (withTransition) { + yAxis = yAxis.transition(); + } + } + if (transitions && transitions.axisY2) { + y2Axis = transitions.axisY2; + } else { + y2Axis = $$.main.select('.' + CLASS.axisY2); + if (withTransition) { + y2Axis = y2Axis.transition(); + } + } +(withTransition ? $$.main.transition() : $$.main).attr( + 'transform', + $$.getTranslate('main') + ); + xAxis.attr('transform', $$.getTranslate('x')); + yAxis.attr('transform', $$.getTranslate('y')); + y2Axis.attr('transform', $$.getTranslate('y2')); + $$.main + .select('.' + CLASS.chartArcs) + .attr('transform', $$.getTranslate('arc')); +}; +ChartInternal.prototype.transformAll = function(withTransition, transitions) { + var $$ = this; + $$.transformMain(withTransition, transitions); + if ($$.config.subchart_show) { + $$.transformContext(withTransition, transitions); + } + if ($$.legend) { + $$.transformLegend(withTransition); + } +}; + +ChartInternal.prototype.updateSvgSize = function() { + var $$ = this, + brush = $$.svg.select(`.${CLASS.brush} .overlay`); + $$.svg.attr('width', $$.currentWidth).attr('height', $$.currentHeight); + $$.svg + .selectAll(['#' + $$.clipId, '#' + $$.clipIdForGrid]) + .select('rect') + .attr('width', $$.width) + .attr('height', $$.height); + $$.svg + .select('#' + $$.clipIdForXAxis) + .select('rect') + .attr('x', $$.getXAxisClipX.bind($$)) + .attr('y', $$.getXAxisClipY.bind($$)) + .attr('width', $$.getXAxisClipWidth.bind($$)) + .attr('height', $$.getXAxisClipHeight.bind($$)); + $$.svg + .select('#' + $$.clipIdForYAxis) + .select('rect') + .attr('x', $$.getYAxisClipX.bind($$)) + .attr('y', $$.getYAxisClipY.bind($$)) + .attr('width', $$.getYAxisClipWidth.bind($$)) + .attr('height', $$.getYAxisClipHeight.bind($$)); + $$.svg + .select('#' + $$.clipIdForSubchart) + .select('rect') + .attr('width', $$.width) + .attr('height', (brush.size() && brush.attr('height')) || 0); + // MEMO: parent div's height will be bigger than svg when + $$.selectChart.style('max-height', $$.currentHeight + 'px'); +}; + +ChartInternal.prototype.updateDimension = function(withoutAxis) { + var $$ = this; + if (!withoutAxis) { + if ($$.config.axis_rotated) { + $$.axes.x.call($$.xAxis); + $$.axes.subx.call($$.subXAxis); + } else { + $$.axes.y.call($$.yAxis); + $$.axes.y2.call($$.y2Axis); + } + } + $$.updateSizes(); + $$.updateScales(); + $$.updateSvgSize(); + $$.transformAll(false); +}; + +ChartInternal.prototype.observeInserted = function(selection) { + var $$ = this, + observer; + if (typeof MutationObserver === 'undefined') { + window.console.error('MutationObserver not defined.'); + return + } + observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.type === 'childList' && mutation.previousSibling) { + observer.disconnect(); + // need to wait for completion of load because size calculation requires the actual sizes determined after that completion + $$.intervalForObserveInserted = window.setInterval(function() { + // parentNode will NOT be null when completed + if (selection.node().parentNode) { + window.clearInterval($$.intervalForObserveInserted); + $$.updateDimension(); + if ($$.brush) { + $$.brush.update(); + } + $$.config.oninit.call($$); + $$.redraw({ + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransition: false, + withTransitionForTransform: false, + withLegend: true + }); + selection.transition().style('opacity', 1); + } + }, 10); + } + }); + }); + observer.observe(selection.node(), { + attributes: true, + childList: true, + characterData: true + }); +}; + +/** + * Binds handlers to the window resize event. + */ +ChartInternal.prototype.bindResize = function() { + var $$ = this, + config = $$.config; + + $$.resizeFunction = $$.generateResize(); // need to call .remove + + $$.resizeFunction.add(function() { + config.onresize.call($$); + }); + if (config.resize_auto) { + $$.resizeFunction.add(function() { + if ($$.resizeTimeout !== undefined) { + window.clearTimeout($$.resizeTimeout); + } + $$.resizeTimeout = window.setTimeout(function() { + delete $$.resizeTimeout; + $$.updateAndRedraw({ + withUpdateXDomain: false, + withUpdateOrgXDomain: false, + withTransition: false, + withTransitionForTransform: false, + withLegend: true + }); + if ($$.brush) { + $$.brush.update(); + } + }, 100); + }); + } + $$.resizeFunction.add(function() { + config.onresized.call($$); + }); + + $$.resizeIfElementDisplayed = function() { + // if element not displayed skip it + if ($$.api == null || !$$.api.element.offsetParent) { + return + } + + $$.resizeFunction(); + }; + + if (window.attachEvent) { + window.attachEvent('onresize', $$.resizeIfElementDisplayed); + } else if (window.addEventListener) { + window.addEventListener('resize', $$.resizeIfElementDisplayed, false); + } else { + // fallback to this, if this is a very old browser + var wrapper = window.onresize; + if (!wrapper) { + // create a wrapper that will call all charts + wrapper = $$.generateResize(); + } else if (!wrapper.add || !wrapper.remove) { + // there is already a handler registered, make sure we call it too + wrapper = $$.generateResize(); + wrapper.add(window.onresize); + } + // add this graph to the wrapper, we will be removed if the user calls destroy + wrapper.add($$.resizeFunction); + window.onresize = function() { + // if element not displayed skip it + if (!$$.api.element.offsetParent) { + return + } + + wrapper(); + }; + } +}; + +/** + * Binds handlers to the window focus event. + */ +ChartInternal.prototype.bindWindowFocus = function() { + if (this.windowFocusHandler) { + // The handler is already set + return + } + + this.windowFocusHandler = () => { + this.redraw(); + }; + + window.addEventListener('focus', this.windowFocusHandler); +}; + +/** + * Unbinds from the window focus event. + */ +ChartInternal.prototype.unbindWindowFocus = function() { + window.removeEventListener('focus', this.windowFocusHandler); + delete this.windowFocusHandler; +}; + +ChartInternal.prototype.generateResize = function() { + var resizeFunctions = []; + + function callResizeFunctions() { + resizeFunctions.forEach(function(f) { + f(); + }); + } + callResizeFunctions.add = function(f) { + resizeFunctions.push(f); + }; + callResizeFunctions.remove = function(f) { + for (var i = 0; i < resizeFunctions.length; i++) { + if (resizeFunctions[i] === f) { + resizeFunctions.splice(i, 1); + break + } + } + }; + return callResizeFunctions +}; + +ChartInternal.prototype.endall = function(transition, callback) { + var n = 0; + transition + .each(function() { + ++n; + }) + .on('end', function() { + if (!--n) { + callback.apply(this, arguments); + } + }); +}; +ChartInternal.prototype.generateWait = function() { + var $$ = this; + var transitionsToWait = [], + f = function(callback) { + var timer = setInterval(function() { + if (!$$.isTabVisible()) { + return + } + + var done = 0; + transitionsToWait.forEach(function(t) { + if (t.empty()) { + done += 1; + return + } + try { + t.transition(); + } catch (e) { + done += 1; + } + }); + if (done === transitionsToWait.length) { + clearInterval(timer); + if (callback) { + callback(); + } + } + }, 50); + }; + f.add = function(transition) { + transitionsToWait.push(transition); + }; + return f +}; + +ChartInternal.prototype.parseDate = function(date) { + var $$ = this, + parsedDate; + if (date instanceof Date) { + parsedDate = date; + } else if (typeof date === 'string') { + parsedDate = $$.dataTimeParse(date); + } else if (typeof date === 'object') { + parsedDate = new Date(+date); + } else if (typeof date === 'number' && !isNaN(date)) { + parsedDate = new Date(+date); + } + if (!parsedDate || isNaN(+parsedDate)) { + window.console.error("Failed to parse x '" + date + "' to Date object"); + } + return parsedDate +}; + +ChartInternal.prototype.isTabVisible = function() { + return !document.hidden +}; + +ChartInternal.prototype.getPathBox = getPathBox; +ChartInternal.prototype.CLASS = CLASS; + +/* jshint ignore:start */ +(function() { + if (!('SVGPathSeg' in window)) { + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg + window.SVGPathSeg = function(type, typeAsLetter, owningPathSegList) { + this.pathSegType = type; + this.pathSegTypeAsLetter = typeAsLetter; + this._owningPathSegList = owningPathSegList; + }; + + window.SVGPathSeg.prototype.classname = 'SVGPathSeg'; + + window.SVGPathSeg.PATHSEG_UNKNOWN = 0; + window.SVGPathSeg.PATHSEG_CLOSEPATH = 1; + window.SVGPathSeg.PATHSEG_MOVETO_ABS = 2; + window.SVGPathSeg.PATHSEG_MOVETO_REL = 3; + window.SVGPathSeg.PATHSEG_LINETO_ABS = 4; + window.SVGPathSeg.PATHSEG_LINETO_REL = 5; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; + window.SVGPathSeg.PATHSEG_ARC_ABS = 10; + window.SVGPathSeg.PATHSEG_ARC_REL = 11; + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; + + // Notify owning PathSegList on any changes so they can be synchronized back to the path element. + window.SVGPathSeg.prototype._segmentChanged = function() { + if (this._owningPathSegList) this._owningPathSegList.segmentChanged(this); + }; + + window.SVGPathSegClosePath = function(owningPathSegList) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CLOSEPATH, + 'z', + owningPathSegList + ); + }; + window.SVGPathSegClosePath.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegClosePath.prototype.toString = function() { + return '[object SVGPathSegClosePath]' + }; + window.SVGPathSegClosePath.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + }; + window.SVGPathSegClosePath.prototype.clone = function() { + return new window.SVGPathSegClosePath(undefined) + }; + + window.SVGPathSegMovetoAbs = function(owningPathSegList, x, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_MOVETO_ABS, + 'M', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegMovetoAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegMovetoAbs.prototype.toString = function() { + return '[object SVGPathSegMovetoAbs]' + }; + window.SVGPathSegMovetoAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegMovetoAbs.prototype.clone = function() { + return new window.SVGPathSegMovetoAbs(undefined, this._x, this._y) + }; + Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegMovetoRel = function(owningPathSegList, x, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_MOVETO_REL, + 'm', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegMovetoRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegMovetoRel.prototype.toString = function() { + return '[object SVGPathSegMovetoRel]' + }; + window.SVGPathSegMovetoRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegMovetoRel.prototype.clone = function() { + return new window.SVGPathSegMovetoRel(undefined, this._x, this._y) + }; + Object.defineProperty(window.SVGPathSegMovetoRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegMovetoRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoAbs = function(owningPathSegList, x, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_ABS, + 'L', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegLinetoAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoAbs.prototype.toString = function() { + return '[object SVGPathSegLinetoAbs]' + }; + window.SVGPathSegLinetoAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegLinetoAbs.prototype.clone = function() { + return new window.SVGPathSegLinetoAbs(undefined, this._x, this._y) + }; + Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoRel = function(owningPathSegList, x, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_REL, + 'l', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegLinetoRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoRel.prototype.toString = function() { + return '[object SVGPathSegLinetoRel]' + }; + window.SVGPathSegLinetoRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegLinetoRel.prototype.clone = function() { + return new window.SVGPathSegLinetoRel(undefined, this._x, this._y) + }; + Object.defineProperty(window.SVGPathSegLinetoRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegLinetoRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegCurvetoCubicAbs = function( + owningPathSegList, + x, + y, + x1, + y1, + x2, + y2 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, + 'C', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoCubicAbs.prototype.toString = function() { + return '[object SVGPathSegCurvetoCubicAbs]' + }; + window.SVGPathSegCurvetoCubicAbs.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoCubicAbs.prototype.clone = function() { + return new window.SVGPathSegCurvetoCubicAbs( + undefined, + this._x, + this._y, + this._x1, + this._y1, + this._x2, + this._y2 + ) + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x1', { + get: function() { + return this._x1 + }, + set: function(x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y1', { + get: function() { + return this._y1 + }, + set: function(y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x2', { + get: function() { + return this._x2 + }, + set: function(x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y2', { + get: function() { + return this._y2 + }, + set: function(y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegCurvetoCubicRel = function( + owningPathSegList, + x, + y, + x1, + y1, + x2, + y2 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, + 'c', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoCubicRel.prototype.toString = function() { + return '[object SVGPathSegCurvetoCubicRel]' + }; + window.SVGPathSegCurvetoCubicRel.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoCubicRel.prototype.clone = function() { + return new window.SVGPathSegCurvetoCubicRel( + undefined, + this._x, + this._y, + this._x1, + this._y1, + this._x2, + this._y2 + ) + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x1', { + get: function() { + return this._x1 + }, + set: function(x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y1', { + get: function() { + return this._y1 + }, + set: function(y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x2', { + get: function() { + return this._x2 + }, + set: function(x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y2', { + get: function() { + return this._y2 + }, + set: function(y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegCurvetoQuadraticAbs = function( + owningPathSegList, + x, + y, + x1, + y1 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, + 'Q', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoQuadraticAbs.prototype.toString = function() { + return '[object SVGPathSegCurvetoQuadraticAbs]' + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype.clone = function() { + return new window.SVGPathSegCurvetoQuadraticAbs( + undefined, + this._x, + this._y, + this._x1, + this._y1 + ) + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticAbs.prototype, + 'x1', + { + get: function() { + return this._x1 + }, + set: function(x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticAbs.prototype, + 'y1', + { + get: function() { + return this._y1 + }, + set: function(y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegCurvetoQuadraticRel = function( + owningPathSegList, + x, + y, + x1, + y1 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, + 'q', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + }; + window.SVGPathSegCurvetoQuadraticRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoQuadraticRel.prototype.toString = function() { + return '[object SVGPathSegCurvetoQuadraticRel]' + }; + window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoQuadraticRel.prototype.clone = function() { + return new window.SVGPathSegCurvetoQuadraticRel( + undefined, + this._x, + this._y, + this._x1, + this._y1 + ) + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticRel.prototype, + 'x1', + { + get: function() { + return this._x1 + }, + set: function(x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticRel.prototype, + 'y1', + { + get: function() { + return this._y1 + }, + set: function(y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegArcAbs = function( + owningPathSegList, + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_ARC_ABS, + 'A', + owningPathSegList + ); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + }; + window.SVGPathSegArcAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegArcAbs.prototype.toString = function() { + return '[object SVGPathSegArcAbs]' + }; + window.SVGPathSegArcAbs.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._r1 + + ' ' + + this._r2 + + ' ' + + this._angle + + ' ' + + (this._largeArcFlag ? '1' : '0') + + ' ' + + (this._sweepFlag ? '1' : '0') + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegArcAbs.prototype.clone = function() { + return new window.SVGPathSegArcAbs( + undefined, + this._x, + this._y, + this._r1, + this._r2, + this._angle, + this._largeArcFlag, + this._sweepFlag + ) + }; + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'r1', { + get: function() { + return this._r1 + }, + set: function(r1) { + this._r1 = r1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'r2', { + get: function() { + return this._r2 + }, + set: function(r2) { + this._r2 = r2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'angle', { + get: function() { + return this._angle + }, + set: function(angle) { + this._angle = angle; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'largeArcFlag', { + get: function() { + return this._largeArcFlag + }, + set: function(largeArcFlag) { + this._largeArcFlag = largeArcFlag; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'sweepFlag', { + get: function() { + return this._sweepFlag + }, + set: function(sweepFlag) { + this._sweepFlag = sweepFlag; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegArcRel = function( + owningPathSegList, + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_ARC_REL, + 'a', + owningPathSegList + ); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + }; + window.SVGPathSegArcRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegArcRel.prototype.toString = function() { + return '[object SVGPathSegArcRel]' + }; + window.SVGPathSegArcRel.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._r1 + + ' ' + + this._r2 + + ' ' + + this._angle + + ' ' + + (this._largeArcFlag ? '1' : '0') + + ' ' + + (this._sweepFlag ? '1' : '0') + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegArcRel.prototype.clone = function() { + return new window.SVGPathSegArcRel( + undefined, + this._x, + this._y, + this._r1, + this._r2, + this._angle, + this._largeArcFlag, + this._sweepFlag + ) + }; + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'r1', { + get: function() { + return this._r1 + }, + set: function(r1) { + this._r1 = r1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'r2', { + get: function() { + return this._r2 + }, + set: function(r2) { + this._r2 = r2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'angle', { + get: function() { + return this._angle + }, + set: function(angle) { + this._angle = angle; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'largeArcFlag', { + get: function() { + return this._largeArcFlag + }, + set: function(largeArcFlag) { + this._largeArcFlag = largeArcFlag; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'sweepFlag', { + get: function() { + return this._sweepFlag + }, + set: function(sweepFlag) { + this._sweepFlag = sweepFlag; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoHorizontalAbs = function(owningPathSegList, x) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, + 'H', + owningPathSegList + ); + this._x = x; + }; + window.SVGPathSegLinetoHorizontalAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoHorizontalAbs.prototype.toString = function() { + return '[object SVGPathSegLinetoHorizontalAbs]' + }; + window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + }; + window.SVGPathSegLinetoHorizontalAbs.prototype.clone = function() { + return new window.SVGPathSegLinetoHorizontalAbs(undefined, this._x) + }; + Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoHorizontalRel = function(owningPathSegList, x) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, + 'h', + owningPathSegList + ); + this._x = x; + }; + window.SVGPathSegLinetoHorizontalRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoHorizontalRel.prototype.toString = function() { + return '[object SVGPathSegLinetoHorizontalRel]' + }; + window.SVGPathSegLinetoHorizontalRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + }; + window.SVGPathSegLinetoHorizontalRel.prototype.clone = function() { + return new window.SVGPathSegLinetoHorizontalRel(undefined, this._x) + }; + Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype, 'x', { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoVerticalAbs = function(owningPathSegList, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, + 'V', + owningPathSegList + ); + this._y = y; + }; + window.SVGPathSegLinetoVerticalAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoVerticalAbs.prototype.toString = function() { + return '[object SVGPathSegLinetoVerticalAbs]' + }; + window.SVGPathSegLinetoVerticalAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._y + }; + window.SVGPathSegLinetoVerticalAbs.prototype.clone = function() { + return new window.SVGPathSegLinetoVerticalAbs(undefined, this._y) + }; + Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegLinetoVerticalRel = function(owningPathSegList, y) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, + 'v', + owningPathSegList + ); + this._y = y; + }; + window.SVGPathSegLinetoVerticalRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegLinetoVerticalRel.prototype.toString = function() { + return '[object SVGPathSegLinetoVerticalRel]' + }; + window.SVGPathSegLinetoVerticalRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._y + }; + window.SVGPathSegLinetoVerticalRel.prototype.clone = function() { + return new window.SVGPathSegLinetoVerticalRel(undefined, this._y) + }; + Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype, 'y', { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + + window.SVGPathSegCurvetoCubicSmoothAbs = function( + owningPathSegList, + x, + y, + x2, + y2 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, + 'S', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString = function() { + return '[object SVGPathSegCurvetoCubicSmoothAbs]' + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone = function() { + return new window.SVGPathSegCurvetoCubicSmoothAbs( + undefined, + this._x, + this._y, + this._x2, + this._y2 + ) + }; + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothAbs.prototype, + 'x', + { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothAbs.prototype, + 'y', + { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothAbs.prototype, + 'x2', + { + get: function() { + return this._x2 + }, + set: function(x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothAbs.prototype, + 'y2', + { + get: function() { + return this._y2 + }, + set: function(y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegCurvetoCubicSmoothRel = function( + owningPathSegList, + x, + y, + x2, + y2 + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, + 's', + owningPathSegList + ); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString = function() { + return '[object SVGPathSegCurvetoCubicSmoothRel]' + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString = function() { + return ( + this.pathSegTypeAsLetter + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y + ) + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone = function() { + return new window.SVGPathSegCurvetoCubicSmoothRel( + undefined, + this._x, + this._y, + this._x2, + this._y2 + ) + }; + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothRel.prototype, + 'x', + { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothRel.prototype, + 'y', + { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothRel.prototype, + 'x2', + { + get: function() { + return this._x2 + }, + set: function(x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoCubicSmoothRel.prototype, + 'y2', + { + get: function() { + return this._y2 + }, + set: function(y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegCurvetoQuadraticSmoothAbs = function( + owningPathSegList, + x, + y + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, + 'T', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString = function() { + return '[object SVGPathSegCurvetoQuadraticSmoothAbs]' + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone = function() { + return new window.SVGPathSegCurvetoQuadraticSmoothAbs( + undefined, + this._x, + this._y + ) + }; + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, + 'x', + { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, + 'y', + { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + } + ); + + window.SVGPathSegCurvetoQuadraticSmoothRel = function( + owningPathSegList, + x, + y + ) { + window.SVGPathSeg.call( + this, + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, + 't', + owningPathSegList + ); + this._x = x; + this._y = y; + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype = Object.create( + window.SVGPathSeg.prototype + ); + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString = function() { + return '[object SVGPathSegCurvetoQuadraticSmoothRel]' + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString = function() { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone = function() { + return new window.SVGPathSegCurvetoQuadraticSmoothRel( + undefined, + this._x, + this._y + ) + }; + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, + 'x', + { + get: function() { + return this._x + }, + set: function(x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, + 'y', + { + get: function() { + return this._y + }, + set: function(y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + } + ); + + // Add createSVGPathSeg* functions to window.SVGPathElement. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-Interfacewindow.SVGPathElement. + window.SVGPathElement.prototype.createSVGPathSegClosePath = function() { + return new window.SVGPathSegClosePath(undefined) + }; + window.SVGPathElement.prototype.createSVGPathSegMovetoAbs = function(x, y) { + return new window.SVGPathSegMovetoAbs(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegMovetoRel = function(x, y) { + return new window.SVGPathSegMovetoRel(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoAbs = function(x, y) { + return new window.SVGPathSegLinetoAbs(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoRel = function(x, y) { + return new window.SVGPathSegLinetoRel(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function( + x, + y, + x1, + y1, + x2, + y2 + ) { + return new window.SVGPathSegCurvetoCubicAbs( + undefined, + x, + y, + x1, + y1, + x2, + y2 + ) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function( + x, + y, + x1, + y1, + x2, + y2 + ) { + return new window.SVGPathSegCurvetoCubicRel( + undefined, + x, + y, + x1, + y1, + x2, + y2 + ) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function( + x, + y, + x1, + y1 + ) { + return new window.SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function( + x, + y, + x1, + y1 + ) { + return new window.SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1) + }; + window.SVGPathElement.prototype.createSVGPathSegArcAbs = function( + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) { + return new window.SVGPathSegArcAbs( + undefined, + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) + }; + window.SVGPathElement.prototype.createSVGPathSegArcRel = function( + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) { + return new window.SVGPathSegArcRel( + undefined, + x, + y, + r1, + r2, + angle, + largeArcFlag, + sweepFlag + ) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function( + x + ) { + return new window.SVGPathSegLinetoHorizontalAbs(undefined, x) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function( + x + ) { + return new window.SVGPathSegLinetoHorizontalRel(undefined, x) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function( + y + ) { + return new window.SVGPathSegLinetoVerticalAbs(undefined, y) + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function( + y + ) { + return new window.SVGPathSegLinetoVerticalRel(undefined, y) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function( + x, + y, + x2, + y2 + ) { + return new window.SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function( + x, + y, + x2, + y2 + ) { + return new window.SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function( + x, + y + ) { + return new window.SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y) + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function( + x, + y + ) { + return new window.SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y) + }; + + if (!('getPathSegAtLength' in window.SVGPathElement.prototype)) { + // Add getPathSegAtLength to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength + // This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm. + window.SVGPathElement.prototype.getPathSegAtLength = function(distance) { + if (distance === undefined || !isFinite(distance)) + throw 'Invalid arguments.' + + var measurementElement = document.createElementNS( + 'http://www.w3.org/2000/svg', + 'path' + ); + measurementElement.setAttribute('d', this.getAttribute('d')); + var lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; + + // If the path is empty, return 0. + if (lastPathSegment <= 0) return 0 + + do { + measurementElement.pathSegList.removeItem(lastPathSegment); + if (distance > measurementElement.getTotalLength()) break + lastPathSegment--; + } while (lastPathSegment > 0) + return lastPathSegment + }; + } + } + + if (!('SVGPathSegList' in window)) { + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList + window.SVGPathSegList = function(pathElement) { + this._pathElement = pathElement; + this._list = this._parsePath(this._pathElement.getAttribute('d')); + + // Use a MutationObserver to catch changes to the path's "d" attribute. + this._mutationObserverConfig = { + attributes: true, + attributeFilter: ['d'] + }; + this._pathElementMutationObserver = new MutationObserver( + this._updateListFromPathMutations.bind(this) + ); + this._pathElementMutationObserver.observe( + this._pathElement, + this._mutationObserverConfig + ); + }; + + window.SVGPathSegList.prototype.classname = 'SVGPathSegList'; + + Object.defineProperty(window.SVGPathSegList.prototype, 'numberOfItems', { + get: function() { + this._checkPathSynchronizedToList(); + return this._list.length + }, + enumerable: true + }); + + // Add the pathSegList accessors to window.SVGPathElement. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData + Object.defineProperty(window.SVGPathElement.prototype, 'pathSegList', { + get: function() { + if (!this._pathSegList) + this._pathSegList = new window.SVGPathSegList(this); + return this._pathSegList + }, + enumerable: true + }); + // FIXME: The following are not implemented and simply return window.SVGPathElement.pathSegList. + Object.defineProperty( + window.SVGPathElement.prototype, + 'normalizedPathSegList', + { + get: function() { + return this.pathSegList + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathElement.prototype, + 'animatedPathSegList', + { + get: function() { + return this.pathSegList + }, + enumerable: true + } + ); + Object.defineProperty( + window.SVGPathElement.prototype, + 'animatedNormalizedPathSegList', + { + get: function() { + return this.pathSegList + }, + enumerable: true + } + ); + + // Process any pending mutations to the path element and update the list as needed. + // This should be the first call of all public functions and is needed because + // MutationObservers are not synchronous so we can have pending asynchronous mutations. + window.SVGPathSegList.prototype._checkPathSynchronizedToList = function() { + this._updateListFromPathMutations( + this._pathElementMutationObserver.takeRecords() + ); + }; + + window.SVGPathSegList.prototype._updateListFromPathMutations = function( + mutationRecords + ) { + if (!this._pathElement) return + var hasPathMutations = false; + mutationRecords.forEach(function(record) { + if (record.attributeName == 'd') hasPathMutations = true; + }); + if (hasPathMutations) + this._list = this._parsePath(this._pathElement.getAttribute('d')); + }; + + // Serialize the list and update the path's 'd' attribute. + window.SVGPathSegList.prototype._writeListToPath = function() { + this._pathElementMutationObserver.disconnect(); + this._pathElement.setAttribute( + 'd', + window.SVGPathSegList._pathSegArrayAsString(this._list) + ); + this._pathElementMutationObserver.observe( + this._pathElement, + this._mutationObserverConfig + ); + }; + + // When a path segment changes the list needs to be synchronized back to the path element. + window.SVGPathSegList.prototype.segmentChanged = function(pathSeg) { + this._writeListToPath(); + }; + + window.SVGPathSegList.prototype.clear = function() { + this._checkPathSynchronizedToList(); + + this._list.forEach(function(pathSeg) { + pathSeg._owningPathSegList = null; + }); + this._list = []; + this._writeListToPath(); + }; + + window.SVGPathSegList.prototype.initialize = function(newItem) { + this._checkPathSynchronizedToList(); + + this._list = [newItem]; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem + }; + + window.SVGPathSegList.prototype._checkValidIndex = function(index) { + if (isNaN(index) || index < 0 || index >= this.numberOfItems) + throw 'INDEX_SIZE_ERR' + }; + + window.SVGPathSegList.prototype.getItem = function(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + return this._list[index] + }; + + window.SVGPathSegList.prototype.insertItemBefore = function( + newItem, + index + ) { + this._checkPathSynchronizedToList(); + + // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + if (index > this.numberOfItems) index = this.numberOfItems; + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.splice(index, 0, newItem); + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem + }; + + window.SVGPathSegList.prototype.replaceItem = function(newItem, index) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._checkValidIndex(index); + this._list[index] = newItem; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem + }; + + window.SVGPathSegList.prototype.removeItem = function(index) { + this._checkPathSynchronizedToList(); + + this._checkValidIndex(index); + var item = this._list[index]; + this._list.splice(index, 1); + this._writeListToPath(); + return item + }; + + window.SVGPathSegList.prototype.appendItem = function(newItem) { + this._checkPathSynchronizedToList(); + + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.push(newItem); + newItem._owningPathSegList = this; + // TODO: Optimize this to just append to the existing attribute. + this._writeListToPath(); + return newItem + }; + + window.SVGPathSegList._pathSegArrayAsString = function(pathSegArray) { + var string = ''; + var first = true; + pathSegArray.forEach(function(pathSeg) { + if (first) { + first = false; + string += pathSeg._asPathString(); + } else { + string += ' ' + pathSeg._asPathString(); + } + }); + return string + }; + + // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. + window.SVGPathSegList.prototype._parsePath = function(string) { + if (!string || string.length == 0) return [] + + var owningPathSegList = this; + + var Builder = function() { + this.pathSegList = []; + }; + + Builder.prototype.appendSegment = function(pathSeg) { + this.pathSegList.push(pathSeg); + }; + + var Source = function(string) { + this._string = string; + this._currentIndex = 0; + this._endIndex = this._string.length; + this._previousCommand = window.SVGPathSeg.PATHSEG_UNKNOWN; + + this._skipOptionalSpaces(); + }; + + Source.prototype._isCurrentSpace = function() { + var character = this._string[this._currentIndex]; + return ( + character <= ' ' && + (character == ' ' || + character == '\n' || + character == '\t' || + character == '\r' || + character == '\f') + ) + }; + + Source.prototype._skipOptionalSpaces = function() { + while (this._currentIndex < this._endIndex && this._isCurrentSpace()) + this._currentIndex++; + return this._currentIndex < this._endIndex + }; + + Source.prototype._skipOptionalSpacesOrDelimiter = function() { + if ( + this._currentIndex < this._endIndex && + !this._isCurrentSpace() && + this._string.charAt(this._currentIndex) != ',' + ) + return false + if (this._skipOptionalSpaces()) { + if ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == ',' + ) { + this._currentIndex++; + this._skipOptionalSpaces(); + } + } + return this._currentIndex < this._endIndex + }; + + Source.prototype.hasMoreData = function() { + return this._currentIndex < this._endIndex + }; + + Source.prototype.peekSegmentType = function() { + var lookahead = this._string[this._currentIndex]; + return this._pathSegTypeFromChar(lookahead) + }; + + Source.prototype._pathSegTypeFromChar = function(lookahead) { + switch (lookahead) { + case 'Z': + case 'z': + return window.SVGPathSeg.PATHSEG_CLOSEPATH + case 'M': + return window.SVGPathSeg.PATHSEG_MOVETO_ABS + case 'm': + return window.SVGPathSeg.PATHSEG_MOVETO_REL + case 'L': + return window.SVGPathSeg.PATHSEG_LINETO_ABS + case 'l': + return window.SVGPathSeg.PATHSEG_LINETO_REL + case 'C': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS + case 'c': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL + case 'Q': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS + case 'q': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL + case 'A': + return window.SVGPathSeg.PATHSEG_ARC_ABS + case 'a': + return window.SVGPathSeg.PATHSEG_ARC_REL + case 'H': + return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS + case 'h': + return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL + case 'V': + return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS + case 'v': + return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL + case 'S': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS + case 's': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL + case 'T': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS + case 't': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL + default: + return window.SVGPathSeg.PATHSEG_UNKNOWN + } + }; + + Source.prototype._nextCommandHelper = function( + lookahead, + previousCommand + ) { + // Check for remaining coordinates in the current command. + if ( + (lookahead == '+' || + lookahead == '-' || + lookahead == '.' || + (lookahead >= '0' && lookahead <= '9')) && + previousCommand != window.SVGPathSeg.PATHSEG_CLOSEPATH + ) { + if (previousCommand == window.SVGPathSeg.PATHSEG_MOVETO_ABS) + return window.SVGPathSeg.PATHSEG_LINETO_ABS + if (previousCommand == window.SVGPathSeg.PATHSEG_MOVETO_REL) + return window.SVGPathSeg.PATHSEG_LINETO_REL + return previousCommand + } + return window.SVGPathSeg.PATHSEG_UNKNOWN + }; + + Source.prototype.initialCommandIsMoveTo = function() { + // If the path is empty it is still valid, so return true. + if (!this.hasMoreData()) return true + var command = this.peekSegmentType(); + // Path must start with moveTo. + return ( + command == window.SVGPathSeg.PATHSEG_MOVETO_ABS || + command == window.SVGPathSeg.PATHSEG_MOVETO_REL + ) + }; + + // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF + Source.prototype._parseNumber = function() { + var exponent = 0; + var integer = 0; + var frac = 1; + var decimal = 0; + var sign = 1; + var expsign = 1; + + var startIndex = this._currentIndex; + + this._skipOptionalSpaces(); + + // Read the sign. + if ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '+' + ) + this._currentIndex++; + else if ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '-' + ) { + this._currentIndex++; + sign = -1; + } + + if ( + this._currentIndex == this._endIndex || + ((this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9') && + this._string.charAt(this._currentIndex) != '.') + ) + // The first character of a number must be one of [0-9+-.]. + return undefined + + // Read the integer part, build right-to-left. + var startIntPartIndex = this._currentIndex; + while ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9' + ) + this._currentIndex++; // Advance to first non-digit. + + if (this._currentIndex != startIntPartIndex) { + var scanIntPartIndex = this._currentIndex - 1; + var multiplier = 1; + while (scanIntPartIndex >= startIntPartIndex) { + integer += + multiplier * (this._string.charAt(scanIntPartIndex--) - '0'); + multiplier *= 10; + } + } + + // Read the decimals. + if ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '.' + ) { + this._currentIndex++; + + // There must be a least one digit following the . + if ( + this._currentIndex >= this._endIndex || + this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9' + ) + return undefined + while ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9' + ) { + frac *= 10; + decimal += (this._string.charAt(this._currentIndex) - '0') / frac; + this._currentIndex += 1; + } + } + + // Read the exponent part. + if ( + this._currentIndex != startIndex && + this._currentIndex + 1 < this._endIndex && + (this._string.charAt(this._currentIndex) == 'e' || + this._string.charAt(this._currentIndex) == 'E') && + this._string.charAt(this._currentIndex + 1) != 'x' && + this._string.charAt(this._currentIndex + 1) != 'm' + ) { + this._currentIndex++; + + // Read the sign of the exponent. + if (this._string.charAt(this._currentIndex) == '+') { + this._currentIndex++; + } else if (this._string.charAt(this._currentIndex) == '-') { + this._currentIndex++; + expsign = -1; + } + + // There must be an exponent. + if ( + this._currentIndex >= this._endIndex || + this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9' + ) + return undefined + + while ( + this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9' + ) { + exponent *= 10; + exponent += this._string.charAt(this._currentIndex) - '0'; + this._currentIndex++; + } + } + + var number = integer + decimal; + number *= sign; + + if (exponent) number *= Math.pow(10, expsign * exponent); + + if (startIndex == this._currentIndex) return undefined + + this._skipOptionalSpacesOrDelimiter(); + + return number + }; + + Source.prototype._parseArcFlag = function() { + if (this._currentIndex >= this._endIndex) return undefined + var flag = false; + var flagChar = this._string.charAt(this._currentIndex++); + if (flagChar == '0') flag = false; + else if (flagChar == '1') flag = true; + else return undefined + + this._skipOptionalSpacesOrDelimiter(); + return flag + }; + + Source.prototype.parseSegment = function() { + var lookahead = this._string[this._currentIndex]; + var command = this._pathSegTypeFromChar(lookahead); + if (command == window.SVGPathSeg.PATHSEG_UNKNOWN) { + // Possibly an implicit command. Not allowed if this is the first command. + if (this._previousCommand == window.SVGPathSeg.PATHSEG_UNKNOWN) + return null + command = this._nextCommandHelper(lookahead, this._previousCommand); + if (command == window.SVGPathSeg.PATHSEG_UNKNOWN) return null + } else { + this._currentIndex++; + } + + this._previousCommand = command; + + switch (command) { + case window.SVGPathSeg.PATHSEG_MOVETO_REL: + return new window.SVGPathSegMovetoRel( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_MOVETO_ABS: + return new window.SVGPathSegMovetoAbs( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_REL: + return new window.SVGPathSegLinetoRel( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_ABS: + return new window.SVGPathSegLinetoAbs( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: + return new window.SVGPathSegLinetoHorizontalRel( + owningPathSegList, + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: + return new window.SVGPathSegLinetoHorizontalAbs( + owningPathSegList, + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: + return new window.SVGPathSegLinetoVerticalRel( + owningPathSegList, + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: + return new window.SVGPathSegLinetoVerticalAbs( + owningPathSegList, + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_CLOSEPATH: + this._skipOptionalSpaces(); + return new window.SVGPathSegClosePath(owningPathSegList) + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicRel( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1, + points.x2, + points.y2 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicAbs( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1, + points.x2, + points.y2 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + var points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicSmoothRel( + owningPathSegList, + points.x, + points.y, + points.x2, + points.y2 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + var points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicSmoothAbs( + owningPathSegList, + points.x, + points.y, + points.x2, + points.y2 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoQuadraticRel( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoQuadraticAbs( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1 + ) + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + return new window.SVGPathSegCurvetoQuadraticSmoothRel( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + return new window.SVGPathSegCurvetoQuadraticSmoothAbs( + owningPathSegList, + this._parseNumber(), + this._parseNumber() + ) + case window.SVGPathSeg.PATHSEG_ARC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegArcRel( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1, + points.arcAngle, + points.arcLarge, + points.arcSweep + ) + case window.SVGPathSeg.PATHSEG_ARC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegArcAbs( + owningPathSegList, + points.x, + points.y, + points.x1, + points.y1, + points.arcAngle, + points.arcLarge, + points.arcSweep + ) + default: + throw 'Unknown path seg type.' + } + }; + + var builder = new Builder(); + var source = new Source(string); + + if (!source.initialCommandIsMoveTo()) return [] + while (source.hasMoreData()) { + var pathSeg = source.parseSegment(); + if (!pathSeg) return [] + builder.appendSegment(pathSeg); + } + + return builder.pathSegList + }; + } +})(); + +// String.padEnd polyfill for IE11 +// +// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd +if (!String.prototype.padEnd) { + String.prototype.padEnd = function padEnd(targetLength, padString) { + targetLength = targetLength >> 0; //floor if number or convert non-number to 0; + padString = String(typeof padString !== 'undefined' ? padString : ' '); + if (this.length > targetLength) { + return String(this) + } else { + targetLength = targetLength - this.length; + if (targetLength > padString.length) { + padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed + } + return String(this) + padString.slice(0, targetLength) + } + }; +} + +// Object.assign polyfill for IE11 +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill +if (typeof Object.assign !== 'function') { + // Must be writable: true, enumerable: false, configurable: true + Object.defineProperty(Object, 'assign', { + value: function assign(target, varArgs) { + if (target === null || target === undefined) { + throw new TypeError('Cannot convert undefined or null to object') + } + + var to = Object(target); + + for (var index = 1; index < arguments.length; index++) { + var nextSource = arguments[index]; + + if (nextSource !== null && nextSource !== undefined) { + for (var nextKey in nextSource) { + // Avoid bugs when hasOwnProperty is shadowed + if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { + to[nextKey] = nextSource[nextKey]; + } + } + } + } + return to + }, + writable: true, + configurable: true + }); +} + +/* jshint ignore:end */ + +Chart.prototype.axis = function() {}; +Chart.prototype.axis.labels = function(labels) { + var $$ = this.internal; + if (arguments.length) { + Object.keys(labels).forEach(function(axisId) { + $$.axis.setLabelText(axisId, labels[axisId]); + }); + $$.axis.updateLabels(); + } + // TODO: return some values? +}; +Chart.prototype.axis.max = function(max) { + var $$ = this.internal, + config = $$.config; + if (arguments.length) { + if (typeof max === 'object') { + if (isValue(max.x)) { + config.axis_x_max = max.x; + } + if (isValue(max.y)) { + config.axis_y_max = max.y; + } + if (isValue(max.y2)) { + config.axis_y2_max = max.y2; + } + } else { + config.axis_y_max = config.axis_y2_max = max; + } + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } else { + return { + x: config.axis_x_max, + y: config.axis_y_max, + y2: config.axis_y2_max + } + } +}; +Chart.prototype.axis.min = function(min) { + var $$ = this.internal, + config = $$.config; + if (arguments.length) { + if (typeof min === 'object') { + if (isValue(min.x)) { + config.axis_x_min = min.x; + } + if (isValue(min.y)) { + config.axis_y_min = min.y; + } + if (isValue(min.y2)) { + config.axis_y2_min = min.y2; + } + } else { + config.axis_y_min = config.axis_y2_min = min; + } + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } else { + return { + x: config.axis_x_min, + y: config.axis_y_min, + y2: config.axis_y2_min + } + } +}; +Chart.prototype.axis.range = function(range) { + if (arguments.length) { + if (isDefined(range.max)) { + this.axis.max(range.max); + } + if (isDefined(range.min)) { + this.axis.min(range.min); + } + } else { + return { + max: this.axis.max(), + min: this.axis.min() + } + } +}; + +Chart.prototype.axis.types = function(types) { + const $$ = this.internal; + if (types === undefined) { + return { + y: $$.config.axis_y_type, + y2: $$.config.axis_y2_type + } + } else { + if (isDefined(types.y)) { + $$.config.axis_y_type = types.y; + } + + if (isDefined(types.y2)) { + $$.config.axis_y2_type = types.y2; + } + + $$.updateScales(); + $$.redraw(); + } +}; + +Chart.prototype.category = function(i, category) { + var $$ = this.internal, + config = $$.config; + if (arguments.length > 1) { + config.axis_x_categories[i] = category; + $$.redraw(); + } + return config.axis_x_categories[i] +}; +Chart.prototype.categories = function(categories) { + var $$ = this.internal, + config = $$.config; + if (!arguments.length) { + return config.axis_x_categories + } + config.axis_x_categories = categories; + $$.redraw(); + return config.axis_x_categories +}; + +Chart.prototype.resize = function(size) { + var $$ = this.internal, + config = $$.config; + config.size_width = size ? size.width : null; + config.size_height = size ? size.height : null; + this.flush(); +}; + +Chart.prototype.flush = function() { + var $$ = this.internal; + $$.updateAndRedraw({ + withLegend: true, + withTransition: false, + withTransitionForTransform: false + }); +}; + +Chart.prototype.destroy = function() { + var $$ = this.internal; + + window.clearInterval($$.intervalForObserveInserted); + + if ($$.resizeTimeout !== undefined) { + window.clearTimeout($$.resizeTimeout); + } + + if (window.detachEvent) { + window.detachEvent('onresize', $$.resizeIfElementDisplayed); + } else if (window.removeEventListener) { + window.removeEventListener('resize', $$.resizeIfElementDisplayed); + } else { + var wrapper = window.onresize; + // check if no one else removed our wrapper and remove our resizeFunction from it + if (wrapper && wrapper.add && wrapper.remove) { + wrapper.remove($$.resizeFunction); + } + } + + // Removes the inner resize functions + $$.resizeFunction.remove(); + + // Unbinds from the window focus event + $$.unbindWindowFocus(); + + $$.selectChart.classed('c3', false).html(''); + + // MEMO: this is needed because the reference of some elements will not be released, then memory leak will happen. + Object.keys($$).forEach(function(key) { + $$[key] = null; + }); + + return null +}; + +// TODO: fix +Chart.prototype.color = function(id) { + var $$ = this.internal; + return $$.color(id) // more patterns +}; + +Chart.prototype.data = function(targetIds) { + var targets = this.internal.data.targets; + return typeof targetIds === 'undefined' + ? targets + : targets.filter(function(t) { + return [].concat(targetIds).indexOf(t.id) >= 0 + }) +}; +Chart.prototype.data.shown = function(targetIds) { + return this.internal.filterTargetsToShow(this.data(targetIds)) +}; + +/** + * Get values of the data loaded in the chart. + * + * @param {String|Array} targetId This API returns the value of specified target. + * @param flat + * @return {Array} Data values + */ +Chart.prototype.data.values = function(targetId, flat = true) { + let values = null; + + if (targetId) { + const targets = this.data(targetId); + if (targets && isArray(targets)) { + values = targets.reduce((ret, v) => { + const dataValue = v.values.map(d => d.value); + if (flat) { + ret = ret.concat(dataValue); + } else { + ret.push(dataValue); + } + return ret + }, []); + } + } + + return values +}; +Chart.prototype.data.names = function(names) { + this.internal.clearLegendItemTextBoxCache(); + return this.internal.updateDataAttributes('names', names) +}; +Chart.prototype.data.colors = function(colors) { + return this.internal.updateDataAttributes('colors', colors) +}; +Chart.prototype.data.axes = function(axes) { + return this.internal.updateDataAttributes('axes', axes) +}; + +Chart.prototype.data.stackNormalized = function(normalized) { + if (normalized === undefined) { + return this.internal.isStackNormalized() + } + + this.internal.config.data_stack_normalize = !!normalized; + this.internal.redraw(); +}; + +Chart.prototype.donut = function() {}; + +Chart.prototype.donut.padAngle = function(padAngle) { + if (padAngle === undefined) { + return this.internal.config.donut_padAngle + } + this.internal.config.donut_padAngle = padAngle; + this.flush(); +}; + +Chart.prototype.flow = function(args) { + var $$ = this.internal, + targets, + data, + notfoundIds = [], + orgDataCount = $$.getMaxDataCount(), + dataCount, + domain, + baseTarget, + baseValue, + length = 0, + tail = 0, + diff, + to; + + if (args.json) { + data = $$.convertJsonToData(args.json, args.keys); + } else if (args.rows) { + data = $$.convertRowsToData(args.rows); + } else if (args.columns) { + data = $$.convertColumnsToData(args.columns); + } else { + return + } + targets = $$.convertDataToTargets(data, true); + + // Update/Add data + $$.data.targets.forEach(function(t) { + var found = false, + i, + j; + for (i = 0; i < targets.length; i++) { + if (t.id === targets[i].id) { + found = true; + + if (t.values[t.values.length - 1]) { + tail = t.values[t.values.length - 1].index + 1; + } + length = targets[i].values.length; + + for (j = 0; j < length; j++) { + targets[i].values[j].index = tail + j; + if (!$$.isTimeSeries()) { + targets[i].values[j].x = tail + j; + } + } + t.values = t.values.concat(targets[i].values); + + targets.splice(i, 1); + break + } + } + if (!found) { + notfoundIds.push(t.id); + } + }); + + // Append null for not found targets + $$.data.targets.forEach(function(t) { + var i, j; + for (i = 0; i < notfoundIds.length; i++) { + if (t.id === notfoundIds[i]) { + tail = t.values[t.values.length - 1].index + 1; + for (j = 0; j < length; j++) { + t.values.push({ + id: t.id, + index: tail + j, + x: $$.isTimeSeries() ? $$.getOtherTargetX(tail + j) : tail + j, + value: null + }); + } + } + } + }); + + // Generate null values for new target + if ($$.data.targets.length) { + targets.forEach(function(t) { + var i, + missing = []; + for (i = $$.data.targets[0].values[0].index; i < tail; i++) { + missing.push({ + id: t.id, + index: i, + x: $$.isTimeSeries() ? $$.getOtherTargetX(i) : i, + value: null + }); + } + t.values.forEach(function(v) { + v.index += tail; + if (!$$.isTimeSeries()) { + v.x += tail; + } + }); + t.values = missing.concat(t.values); + }); + } + $$.data.targets = $$.data.targets.concat(targets); // add remained + + // check data count because behavior needs to change when it's only one + dataCount = $$.getMaxDataCount(); + baseTarget = $$.data.targets[0]; + baseValue = baseTarget.values[0]; + + // Update length to flow if needed + if (isDefined(args.to)) { + length = 0; + to = $$.isTimeSeries() ? $$.parseDate(args.to) : args.to; + baseTarget.values.forEach(function(v) { + if (v.x < to) { + length++; + } + }); + } else if (isDefined(args.length)) { + length = args.length; + } + + // If only one data, update the domain to flow from left edge of the chart + if (!orgDataCount) { + if ($$.isTimeSeries()) { + if (baseTarget.values.length > 1) { + diff = baseTarget.values[baseTarget.values.length - 1].x - baseValue.x; + } else { + diff = baseValue.x - $$.getXDomain($$.data.targets)[0]; + } + } else { + diff = 1; + } + domain = [baseValue.x - diff, baseValue.x]; + $$.updateXDomain(null, true, true, false, domain); + } else if (orgDataCount === 1) { + if ($$.isTimeSeries()) { + diff = + (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2; + domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)]; + $$.updateXDomain(null, true, true, false, domain); + } + } + + // Set targets + $$.updateTargets($$.data.targets); + + // Redraw with new targets + $$.redraw({ + flow: { + index: baseValue.index, + length: length, + duration: isValue(args.duration) + ? args.duration + : $$.config.transition_duration, + done: args.done, + orgDataCount: orgDataCount + }, + withLegend: true, + withTransition: orgDataCount > 1, + withTrimXDomain: false, + withUpdateXAxis: true + }); +}; + +ChartInternal.prototype.generateFlow = function(args) { + var $$ = this, + config = $$.config, + d3 = $$.d3; + + return function() { + var targets = args.targets, + flow = args.flow, + drawBar = args.drawBar, + drawLine = args.drawLine, + drawArea = args.drawArea, + cx = args.cx, + cy = args.cy, + xv = args.xv, + xForText = args.xForText, + yForText = args.yForText, + duration = args.duration; + + var translateX, + scaleX = 1, + transform, + flowIndex = flow.index, + flowLength = flow.length, + flowStart = $$.getValueOnIndex($$.data.targets[0].values, flowIndex), + flowEnd = $$.getValueOnIndex( + $$.data.targets[0].values, + flowIndex + flowLength + ), + orgDomain = $$.x.domain(), + domain, + durationForFlow = flow.duration || duration, + done = flow.done || function() {}, + wait = $$.generateWait(); + + var xgrid, + xgridLines, + mainRegion, + mainText, + mainBar, + mainLine, + mainArea, + mainCircle; + + // set flag + $$.flowing = true; + + // remove head data after rendered + $$.data.targets.forEach(function(d) { + d.values.splice(0, flowLength); + }); + + // update x domain to generate axis elements for flow + domain = $$.updateXDomain(targets, true, true); + // update elements related to x scale + if ($$.updateXGrid) { + $$.updateXGrid(true); + } + + xgrid = $$.xgrid || d3.selectAll([]); // xgrid needs to be obtained after updateXGrid + xgridLines = $$.xgridLines || d3.selectAll([]); + mainRegion = $$.mainRegion || d3.selectAll([]); + mainText = $$.mainText || d3.selectAll([]); + mainBar = $$.mainBar || d3.selectAll([]); + mainLine = $$.mainLine || d3.selectAll([]); + mainArea = $$.mainArea || d3.selectAll([]); + mainCircle = $$.mainCircle || d3.selectAll([]); + + // generate transform to flow + if (!flow.orgDataCount) { + // if empty + if ($$.data.targets[0].values.length !== 1) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } else { + if ($$.isTimeSeries()) { + flowStart = $$.getValueOnIndex($$.data.targets[0].values, 0); + flowEnd = $$.getValueOnIndex( + $$.data.targets[0].values, + $$.data.targets[0].values.length - 1 + ); + translateX = $$.x(flowStart.x) - $$.x(flowEnd.x); + } else { + translateX = diffDomain(domain) / 2; + } + } + } else if ( + flow.orgDataCount === 1 || + (flowStart && flowStart.x) === (flowEnd && flowEnd.x) + ) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } else { + if ($$.isTimeSeries()) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } else { + translateX = $$.x(flowStart.x) - $$.x(flowEnd.x); + } + } + scaleX = diffDomain(orgDomain) / diffDomain(domain); + transform = 'translate(' + translateX + ',0) scale(' + scaleX + ',1)'; + + $$.hideXGridFocus(); + + var flowTransition = d3 + .transition() + .ease(d3.easeLinear) + .duration(durationForFlow); + wait.add($$.xAxis($$.axes.x, flowTransition)); + wait.add(mainBar.transition(flowTransition).attr('transform', transform)); + wait.add(mainLine.transition(flowTransition).attr('transform', transform)); + wait.add(mainArea.transition(flowTransition).attr('transform', transform)); + wait.add(mainCircle.transition(flowTransition).attr('transform', transform)); + wait.add(mainText.transition(flowTransition).attr('transform', transform)); + wait.add( + mainRegion + .filter($$.isRegionOnX) + .transition(flowTransition) + .attr('transform', transform) + ); + wait.add(xgrid.transition(flowTransition).attr('transform', transform)); + wait.add(xgridLines.transition(flowTransition).attr('transform', transform)); + wait(function() { + var i, + shapes = [], + texts = []; + + // remove flowed elements + if (flowLength) { + for (i = 0; i < flowLength; i++) { + shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); + texts.push('.' + CLASS.text + '-' + (flowIndex + i)); + } + $$.svg + .selectAll('.' + CLASS.shapes) + .selectAll(shapes) + .remove(); + $$.svg + .selectAll('.' + CLASS.texts) + .selectAll(texts) + .remove(); + $$.svg.select('.' + CLASS.xgrid).remove(); + } + + // draw again for removing flowed elements and reverting attr + xgrid + .attr('transform', null) + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', $$.xgridAttr.opacity); + xgridLines.attr('transform', null); + xgridLines + .select('line') + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv); + xgridLines + .select('text') + .attr('x', config.axis_rotated ? $$.width : 0) + .attr('y', xv); + mainBar.attr('transform', null).attr('d', drawBar); + mainLine.attr('transform', null).attr('d', drawLine); + mainArea.attr('transform', null).attr('d', drawArea); + mainCircle + .attr('transform', null) + .attr('cx', cx) + .attr('cy', cy); + mainText + .attr('transform', null) + .attr('x', xForText) + .attr('y', yForText) + .style('fill-opacity', $$.opacityForText.bind($$)); + mainRegion.attr('transform', null); + mainRegion + .filter($$.isRegionOnX) + .attr('x', $$.regionX.bind($$)) + .attr('width', $$.regionWidth.bind($$)); + + // callback for end of flow + done(); + + $$.flowing = false; + }); + } +}; + +Chart.prototype.focus = function(targetIds) { + var $$ = this.internal, + candidates; + + targetIds = $$.mapToTargetIds(targetIds) + ;(candidates = $$.svg.selectAll( + $$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)) + )), + this.revert(); + this.defocus(); + candidates.classed(CLASS.focused, true).classed(CLASS.defocused, false); + if ($$.hasArcType()) { + $$.expandArc(targetIds); + } + $$.toggleFocusLegend(targetIds, true); + + $$.focusedTargetIds = targetIds; + $$.defocusedTargetIds = $$.defocusedTargetIds.filter(function(id) { + return targetIds.indexOf(id) < 0 + }); +}; + +Chart.prototype.defocus = function(targetIds) { + var $$ = this.internal, + candidates; + + targetIds = $$.mapToTargetIds(targetIds) + ;(candidates = $$.svg.selectAll( + $$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)) + )), + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, true); + if ($$.hasArcType()) { + $$.unexpandArc(targetIds); + } + $$.toggleFocusLegend(targetIds, false); + + $$.focusedTargetIds = $$.focusedTargetIds.filter(function(id) { + return targetIds.indexOf(id) < 0 + }); + $$.defocusedTargetIds = targetIds; +}; + +Chart.prototype.revert = function(targetIds) { + var $$ = this.internal, + candidates; + + targetIds = $$.mapToTargetIds(targetIds); + candidates = $$.svg.selectAll($$.selectorTargets(targetIds)); // should be for all targets + + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, false); + if ($$.hasArcType()) { + $$.unexpandArc(targetIds); + } + if ($$.config.legend_show) { + $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$))); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .filter(function() { + return $$.d3.select(this).classed(CLASS.legendItemFocused) + }) + .classed(CLASS.legendItemFocused, false); + } + + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; +}; + +Chart.prototype.xgrids = function(grids) { + var $$ = this.internal, + config = $$.config; + if (!grids) { + return config.grid_x_lines + } + config.grid_x_lines = grids; + $$.redrawWithoutRescale(); + return config.grid_x_lines +}; +Chart.prototype.xgrids.add = function(grids) { + var $$ = this.internal; + return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : [])) +}; +Chart.prototype.xgrids.remove = function(params) { + // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, true); +}; + +Chart.prototype.ygrids = function(grids) { + var $$ = this.internal, + config = $$.config; + if (!grids) { + return config.grid_y_lines + } + config.grid_y_lines = grids; + $$.redrawWithoutRescale(); + return config.grid_y_lines +}; +Chart.prototype.ygrids.add = function(grids) { + var $$ = this.internal; + return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : [])) +}; +Chart.prototype.ygrids.remove = function(params) { + // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, false); +}; + +Chart.prototype.groups = function(groups) { + var $$ = this.internal, + config = $$.config; + if (isUndefined(groups)) { + return config.data_groups + } + config.data_groups = groups; + $$.redraw(); + return config.data_groups +}; + +Chart.prototype.legend = function() {}; +Chart.prototype.legend.show = function(targetIds) { + var $$ = this.internal; + $$.showLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({ withLegend: true }); +}; +Chart.prototype.legend.hide = function(targetIds) { + var $$ = this.internal; + $$.hideLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({ withLegend: false }); +}; + +Chart.prototype.load = function(args) { + var $$ = this.internal, + config = $$.config; + // update xs if specified + if (args.xs) { + $$.addXs(args.xs); + } + // update names if exists + if ('names' in args) { + Chart.prototype.data.names.bind(this)(args.names); + } + // update classes if exists + if ('classes' in args) { + Object.keys(args.classes).forEach(function(id) { + config.data_classes[id] = args.classes[id]; + }); + } + // update categories if exists + if ('categories' in args && $$.isCategorized()) { + config.axis_x_categories = args.categories; + } + // update axes if exists + if ('axes' in args) { + Object.keys(args.axes).forEach(function(id) { + config.data_axes[id] = args.axes[id]; + }); + } + // update colors if exists + if ('colors' in args) { + Object.keys(args.colors).forEach(function(id) { + config.data_colors[id] = args.colors[id]; + }); + } + // use cache if exists + if ('cacheIds' in args && $$.hasCaches(args.cacheIds)) { + $$.load($$.getCaches(args.cacheIds), args.done); + return + } + // unload if needed + if (args.unload) { + // TODO: do not unload if target will load (included in url/rows/columns) + $$.unload( + $$.mapToTargetIds(args.unload === true ? null : args.unload), + function() { + $$.loadFromArgs(args); + } + ); + } else { + $$.loadFromArgs(args); + } +}; + +Chart.prototype.unload = function(args) { + var $$ = this.internal; + args = args || {}; + if (args instanceof Array) { + args = { ids: args }; + } else if (typeof args === 'string') { + args = { ids: [args] }; + } + $$.unload($$.mapToTargetIds(args.ids), function() { + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + if (args.done) { + args.done(); + } + }); +}; + +Chart.prototype.pie = function() {}; + +Chart.prototype.pie.padAngle = function(padAngle) { + if (padAngle === undefined) { + return this.internal.config.pie_padAngle + } + this.internal.config.pie_padAngle = padAngle; + this.flush(); +}; + +Chart.prototype.regions = function(regions) { + var $$ = this.internal, + config = $$.config; + if (!regions) { + return config.regions + } + config.regions = regions; + $$.redrawWithoutRescale(); + return config.regions +}; +Chart.prototype.regions.add = function(regions) { + var $$ = this.internal, + config = $$.config; + if (!regions) { + return config.regions + } + config.regions = config.regions.concat(regions); + $$.redrawWithoutRescale(); + return config.regions +}; +Chart.prototype.regions.remove = function(options) { + var $$ = this.internal, + config = $$.config, + duration, + classes, + regions; + + options = options || {}; + duration = getOption(options, 'duration', config.transition_duration); + classes = getOption(options, 'classes', [CLASS.region]); + + regions = $$.main.select('.' + CLASS.regions).selectAll( + classes.map(function(c) { + return '.' + c + }) + ) + ;(duration ? regions.transition().duration(duration) : regions) + .style('opacity', 0) + .remove(); + + config.regions = config.regions.filter(function(region) { + var found = false; + if (!region['class']) { + return true + } + region['class'].split(' ').forEach(function(c) { + if (classes.indexOf(c) >= 0) { + found = true; + } + }); + return !found + }); + + return config.regions +}; + +Chart.prototype.selected = function(targetId) { + var $$ = this.internal, + d3 = $$.d3; + return $$.main + .selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)) + .selectAll('.' + CLASS.shape) + .filter(function() { + return d3.select(this).classed(CLASS.SELECTED) + }) + .nodes() + .map(function(d) { + var data = d.__data__; + return data.data ? data.data : data + }) +}; +Chart.prototype.select = function(ids, indices, resetOther) { + var $$ = this.internal, + d3 = $$.d3, + config = $$.config; + if (!config.data_selection_enabled) { + return + } + $$.main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function(d, i) { + var shape = d3.select(this), + id = d.data ? d.data.id : d.id, + toggle = $$.getToggle(this, d).bind($$), + isTargetId = + config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, + isTargetIndex = !indices || indices.indexOf(i) >= 0, + isSelected = shape.classed(CLASS.SELECTED); + // line/area selection not supported yet + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { + return + } + if (isTargetId && isTargetIndex) { + if (config.data_selection_isselectable(d) && !isSelected) { + toggle(true, shape.classed(CLASS.SELECTED, true), d, i); + } + } else if (isDefined(resetOther) && resetOther) { + if (isSelected) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + } + }); +}; +Chart.prototype.unselect = function(ids, indices) { + var $$ = this.internal, + d3 = $$.d3, + config = $$.config; + if (!config.data_selection_enabled) { + return + } + $$.main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function(d, i) { + var shape = d3.select(this), + id = d.data ? d.data.id : d.id, + toggle = $$.getToggle(this, d).bind($$), + isTargetId = + config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, + isTargetIndex = !indices || indices.indexOf(i) >= 0, + isSelected = shape.classed(CLASS.SELECTED); + // line/area selection not supported yet + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { + return + } + if (isTargetId && isTargetIndex) { + if (config.data_selection_isselectable(d)) { + if (isSelected) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + } + } + }); +}; + +Chart.prototype.show = function(targetIds, options) { + var $$ = this.internal, + targets; + + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + + $$.removeHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + + targets + .transition() + .style('display', isIE() ? 'block' : 'initial', 'important') + .style('opacity', 1, 'important') + .call($$.endall, function() { + targets.style('opacity', null).style('opacity', 1); + }); + + if (options.withLegend) { + $$.showLegend(targetIds); + } + + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); +}; + +Chart.prototype.hide = function(targetIds, options) { + var $$ = this.internal, + targets; + + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + + $$.addHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + + targets + .transition() + .style('opacity', 0, 'important') + .call($$.endall, function() { + targets.style('opacity', null).style('opacity', 0); + targets.style('display', 'none'); + }); + + if (options.withLegend) { + $$.hideLegend(targetIds); + } + + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); +}; + +Chart.prototype.toggle = function(targetIds, options) { + var that = this, + $$ = this.internal; + $$.mapToTargetIds(targetIds).forEach(function(targetId) { + $$.isTargetToShow(targetId) + ? that.hide(targetId, options) + : that.show(targetId, options); + }); +}; + +Chart.prototype.subchart = function() {}; + +Chart.prototype.subchart.isShown = function() { + const $$ = this.internal; + + return $$.config.subchart_show +}; + +Chart.prototype.subchart.show = function() { + const $$ = this.internal; + + if ($$.config.subchart_show) { + return + } + + $$.config.subchart_show = true; + + // insert DOM + $$.initSubchart(); + + // update dimensions with sub chart now visible + $$.updateDimension(); + + // insert brush (depends on sizes previously updated) + $$.initSubchartBrush(); + + // attach data + $$.updateTargetsForSubchart($$.getTargets()); + + // reset fade-in state + $$.mapToIds($$.data.targets).forEach(function(id) { + $$.withoutFadeIn[id] = false; + }); + + // redraw chart ! + $$.updateAndRedraw(); + + // update visible targets ! + $$.showTargets(); +}; + +Chart.prototype.subchart.hide = function() { + const $$ = this.internal; + + if (!$$.config.subchart_show) { + return + } + + $$.config.subchart_show = false; + + // remove DOM + $$.removeSubchart(); + + // re-render chart + $$.redraw(); +}; + +Chart.prototype.tooltip = function() {}; +Chart.prototype.tooltip.show = function(args) { + var $$ = this.internal, + targets, + data, + mouse = {}; + + // determine mouse position on the chart + if (args.mouse) { + mouse = args.mouse; + } else { + // determine focus data + if (args.data) { + data = args.data; + } else if (typeof args.x !== 'undefined') { + if (args.id) { + targets = $$.data.targets.filter(function(t) { + return t.id === args.id + }); + } else { + targets = $$.data.targets; + } + data = $$.filterByX(targets, args.x).slice(0, 1)[0]; + } + mouse = data ? $$.getMousePosition(data) : null; + } + + // emulate mouse events to show + $$.dispatchEvent('mousemove', mouse); + + $$.config.tooltip_onshow.call($$, data); +}; +Chart.prototype.tooltip.hide = function() { + // TODO: get target data by checking the state of focus + this.internal.dispatchEvent('mouseout', 0); + + this.internal.config.tooltip_onhide.call(this); +}; + +Chart.prototype.transform = function(type, targetIds) { + var $$ = this.internal, + options = + ['pie', 'donut'].indexOf(type) >= 0 ? { withTransform: true } : null; + $$.transformTo(targetIds, type, options); +}; + +ChartInternal.prototype.transformTo = function( + targetIds, + type, + optionsForRedraw +) { + var $$ = this, + withTransitionForAxis = !$$.hasArcType(), + options = optionsForRedraw || { + withTransitionForAxis: withTransitionForAxis + }; + options.withTransitionForTransform = false; + $$.transiting = false; + $$.setTargetType(targetIds, type); + $$.updateTargets($$.data.targets); // this is needed when transforming to arc + $$.updateAndRedraw(options); +}; + +Chart.prototype.x = function(x) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetX($$.data.targets, x); + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + return $$.data.xs +}; +Chart.prototype.xs = function(xs) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetXs($$.data.targets, xs); + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + return $$.data.xs +}; + +Chart.prototype.zoom = function(domain) { + var $$ = this.internal; + if (domain) { + if ($$.isTimeSeries()) { + domain = domain.map(function(x) { + return $$.parseDate(x) + }); + } + if ($$.config.subchart_show) { + $$.brush.selectionAsValue(domain, true); + } else { + $$.updateXDomain(null, true, false, false, domain); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } + $$.config.zoom_onzoom.call(this, $$.x.orgDomain()); + return domain + } else { + return $$.x.domain() + } +}; +Chart.prototype.zoom.enable = function(enabled) { + var $$ = this.internal; + $$.config.zoom_enabled = enabled; + $$.updateAndRedraw(); +}; +Chart.prototype.unzoom = function() { + var $$ = this.internal; + if ($$.config.subchart_show) { + $$.brush.clear(); + } else { + $$.updateXDomain(null, true, false, false, $$.subX.domain()); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } +}; + +Chart.prototype.zoom.max = function(max) { + var $$ = this.internal, + config = $$.config, + d3 = $$.d3; + if (max === 0 || max) { + config.zoom_x_max = d3.max([$$.orgXDomain[1], max]); + } else { + return config.zoom_x_max + } +}; + +Chart.prototype.zoom.min = function(min) { + var $$ = this.internal, + config = $$.config, + d3 = $$.d3; + if (min === 0 || min) { + config.zoom_x_min = d3.min([$$.orgXDomain[0], min]); + } else { + return config.zoom_x_min + } +}; + +Chart.prototype.zoom.range = function(range) { + if (arguments.length) { + if (isDefined(range.max)) { + this.domain.max(range.max); + } + if (isDefined(range.min)) { + this.domain.min(range.min); + } + } else { + return { + max: this.domain.max(), + min: this.domain.min() + } + } +}; + +ChartInternal.prototype.initPie = function() { + var $$ = this, + d3 = $$.d3; + $$.pie = d3 + .pie() + .padAngle(this.getPadAngle.bind(this)) + .value(function(d) { + return d.values.reduce(function(a, b) { + return a + b.value + }, 0) + }); + + let orderFct = $$.getOrderFunction(); + + // we need to reverse the returned order if asc or desc to have the slice in expected order. + if (orderFct && ($$.isOrderAsc() || $$.isOrderDesc())) { + let defaultSort = orderFct; + orderFct = (t1, t2) => defaultSort(t1, t2) * -1; + } + + $$.pie.sort(orderFct || null); +}; + +ChartInternal.prototype.updateRadius = function() { + var $$ = this, + config = $$.config, + w = config.gauge_width || config.donut_width, + gaugeArcWidth = + $$.filterTargetsToShow($$.data.targets).length * + $$.config.gauge_arcs_minWidth; + $$.radiusExpanded = + (Math.min($$.arcWidth, $$.arcHeight) / 2) * ($$.hasType('gauge') ? 0.85 : 1); + $$.radius = $$.radiusExpanded * 0.95; + $$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6; + $$.innerRadius = + $$.hasType('donut') || $$.hasType('gauge') + ? $$.radius * $$.innerRadiusRatio + : 0; + $$.gaugeArcWidth = w + ? w + : gaugeArcWidth <= $$.radius - $$.innerRadius + ? $$.radius - $$.innerRadius + : gaugeArcWidth <= $$.radius + ? gaugeArcWidth + : $$.radius; +}; + +ChartInternal.prototype.getPadAngle = function() { + if (this.hasType('pie')) { + return this.config.pie_padAngle || 0 + } else if (this.hasType('donut')) { + return this.config.donut_padAngle || 0 + } else { + return 0 + } +}; + +ChartInternal.prototype.updateArc = function() { + var $$ = this; + $$.svgArc = $$.getSvgArc(); + $$.svgArcExpanded = $$.getSvgArcExpanded(); + $$.svgArcExpandedSub = $$.getSvgArcExpanded(0.98); +}; + +ChartInternal.prototype.updateAngle = function(d) { + var $$ = this, + config = $$.config, + found = false, + index = 0, + gMin, + gMax, + gTic, + gValue; + + if (!config) { + return null + } + + $$.pie($$.filterTargetsToShow($$.data.targets)).forEach(function(t) { + if (!found && t.data.id === d.data.id) { + found = true; + d = t; + d.index = index; + } + index++; + }); + if (isNaN(d.startAngle)) { + d.startAngle = 0; + } + if (isNaN(d.endAngle)) { + d.endAngle = d.startAngle; + } + if ($$.isGaugeType(d.data)) { + gMin = config.gauge_min; + gMax = config.gauge_max; + gTic = (Math.PI * (config.gauge_fullCircle ? 2 : 1)) / (gMax - gMin); + gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : gMax - gMin; + d.startAngle = config.gauge_startingAngle; + d.endAngle = d.startAngle + gTic * gValue; + } + return found ? d : null +}; + +ChartInternal.prototype.getSvgArc = function() { + var $$ = this, + hasGaugeType = $$.hasType('gauge'), + singleArcWidth = + $$.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length, + arc = $$.d3 + .arc() + .outerRadius(function(d) { + return hasGaugeType ? $$.radius - singleArcWidth * d.index : $$.radius + }) + .innerRadius(function(d) { + return hasGaugeType + ? $$.radius - singleArcWidth * (d.index + 1) + : $$.innerRadius + }), + newArc = function(d, withoutUpdate) { + var updated; + if (withoutUpdate) { + return arc(d) + } // for interpolate + updated = $$.updateAngle(d); + return updated ? arc(updated) : 'M 0 0' + }; + // TODO: extends all function + newArc.centroid = arc.centroid; + return newArc +}; + +ChartInternal.prototype.getSvgArcExpanded = function(rate) { + rate = rate || 1; + var $$ = this, + hasGaugeType = $$.hasType('gauge'), + singleArcWidth = + $$.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length, + expandWidth = Math.min( + $$.radiusExpanded * rate - $$.radius, + singleArcWidth * 0.8 - (1 - rate) * 100 + ), + arc = $$.d3 + .arc() + .outerRadius(function(d) { + return hasGaugeType + ? $$.radius - singleArcWidth * d.index + expandWidth + : $$.radiusExpanded * rate + }) + .innerRadius(function(d) { + return hasGaugeType + ? $$.radius - singleArcWidth * (d.index + 1) + : $$.innerRadius + }); + return function(d) { + var updated = $$.updateAngle(d); + return updated ? arc(updated) : 'M 0 0' + } +}; + +ChartInternal.prototype.getArc = function(d, withoutUpdate, force) { + return force || this.isArcType(d.data) + ? this.svgArc(d, withoutUpdate) + : 'M 0 0' +}; + +ChartInternal.prototype.transformForArcLabel = function(d) { + var $$ = this, + config = $$.config, + updated = $$.updateAngle(d), + c, + x, + y, + h, + ratio, + translate = '', + hasGauge = $$.hasType('gauge'); + if (updated && !hasGauge) { + c = this.svgArc.centroid(updated); + x = isNaN(c[0]) ? 0 : c[0]; + y = isNaN(c[1]) ? 0 : c[1]; + h = Math.sqrt(x * x + y * y); + if ($$.hasType('donut') && config.donut_label_ratio) { + ratio = isFunction(config.donut_label_ratio) + ? config.donut_label_ratio(d, $$.radius, h) + : config.donut_label_ratio; + } else if ($$.hasType('pie') && config.pie_label_ratio) { + ratio = isFunction(config.pie_label_ratio) + ? config.pie_label_ratio(d, $$.radius, h) + : config.pie_label_ratio; + } else { + ratio = + $$.radius && h + ? ((36 / $$.radius > 0.375 ? 1.175 - 36 / $$.radius : 0.8) * + $$.radius) / + h + : 0; + } + translate = 'translate(' + x * ratio + ',' + y * ratio + ')'; + } else if ( + updated && + hasGauge && + $$.filterTargetsToShow($$.data.targets).length > 1 + ) { + var y1 = Math.sin(updated.endAngle - Math.PI / 2); + x = Math.cos(updated.endAngle - Math.PI / 2) * ($$.radiusExpanded + 25); + y = y1 * ($$.radiusExpanded + 15 - Math.abs(y1 * 10)) + 3; + translate = 'translate(' + x + ',' + y + ')'; + } + return translate +}; + +/** + * @deprecated Use `getRatio('arc', d)` instead. + */ +ChartInternal.prototype.getArcRatio = function(d) { + return this.getRatio('arc', d) +}; + +ChartInternal.prototype.convertToArcData = function(d) { + return this.addName({ + id: d.data.id, + value: d.value, + ratio: this.getRatio('arc', d), + index: d.index + }) +}; + +ChartInternal.prototype.textForArcLabel = function(d) { + var $$ = this, + updated, + value, + ratio, + id, + format; + if (!$$.shouldShowArcLabel()) { + return '' + } + updated = $$.updateAngle(d); + value = updated ? updated.value : null; + ratio = $$.getRatio('arc', updated); + id = d.data.id; + if (!$$.hasType('gauge') && !$$.meetsArcLabelThreshold(ratio)) { + return '' + } + format = $$.getArcLabelFormat(); + return format + ? format(value, ratio, id) + : $$.defaultArcValueFormat(value, ratio) +}; + +ChartInternal.prototype.textForGaugeMinMax = function(value, isMax) { + var $$ = this, + format = $$.getGaugeLabelExtents(); + + return format ? format(value, isMax) : value +}; + +ChartInternal.prototype.expandArc = function(targetIds) { + var $$ = this, + interval; + + // MEMO: avoid to cancel transition + if ($$.transiting) { + interval = window.setInterval(function() { + if (!$$.transiting) { + window.clearInterval(interval); + if ($$.legend.selectAll('.c3-legend-item-focused').size() > 0) { + $$.expandArc(targetIds); + } + } + }, 10); + return + } + + targetIds = $$.mapToTargetIds(targetIds); + + $$.svg + .selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)) + .each(function(d) { + if (!$$.shouldExpand(d.data.id)) { + return + } + $$.d3 + .select(this) + .selectAll('path') + .transition() + .duration($$.expandDuration(d.data.id)) + .attr('d', $$.svgArcExpanded) + .transition() + .duration($$.expandDuration(d.data.id) * 2) + .attr('d', $$.svgArcExpandedSub) + .each(function(d) { + if ($$.isDonutType(d.data)) ; + }); + }); +}; + +ChartInternal.prototype.unexpandArc = function(targetIds) { + var $$ = this; + + if ($$.transiting) { + return + } + + targetIds = $$.mapToTargetIds(targetIds); + + $$.svg + .selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)) + .selectAll('path') + .transition() + .duration(function(d) { + return $$.expandDuration(d.data.id) + }) + .attr('d', $$.svgArc); + $$.svg.selectAll('.' + CLASS.arc); +}; + +ChartInternal.prototype.expandDuration = function(id) { + var $$ = this, + config = $$.config; + + if ($$.isDonutType(id)) { + return config.donut_expand_duration + } else if ($$.isGaugeType(id)) { + return config.gauge_expand_duration + } else if ($$.isPieType(id)) { + return config.pie_expand_duration + } else { + return 50 + } +}; + +ChartInternal.prototype.shouldExpand = function(id) { + var $$ = this, + config = $$.config; + return ( + ($$.isDonutType(id) && config.donut_expand) || + ($$.isGaugeType(id) && config.gauge_expand) || + ($$.isPieType(id) && config.pie_expand) + ) +}; + +ChartInternal.prototype.shouldShowArcLabel = function() { + var $$ = this, + config = $$.config, + shouldShow = true; + if ($$.hasType('donut')) { + shouldShow = config.donut_label_show; + } else if ($$.hasType('pie')) { + shouldShow = config.pie_label_show; + } + // when gauge, always true + return shouldShow +}; + +ChartInternal.prototype.meetsArcLabelThreshold = function(ratio) { + var $$ = this, + config = $$.config, + threshold = $$.hasType('donut') + ? config.donut_label_threshold + : config.pie_label_threshold; + return ratio >= threshold +}; + +ChartInternal.prototype.getArcLabelFormat = function() { + var $$ = this, + config = $$.config, + format = config.pie_label_format; + if ($$.hasType('gauge')) { + format = config.gauge_label_format; + } else if ($$.hasType('donut')) { + format = config.donut_label_format; + } + return format +}; + +ChartInternal.prototype.getGaugeLabelExtents = function() { + var $$ = this, + config = $$.config; + return config.gauge_label_extents +}; + +ChartInternal.prototype.getArcTitle = function() { + var $$ = this; + return $$.hasType('donut') ? $$.config.donut_title : '' +}; + +ChartInternal.prototype.updateTargetsForArc = function(targets) { + var $$ = this, + main = $$.main, + mainPies, + mainPieEnter, + classChartArc = $$.classChartArc.bind($$), + classArcs = $$.classArcs.bind($$), + classFocus = $$.classFocus.bind($$); + mainPies = main + .select('.' + CLASS.chartArcs) + .selectAll('.' + CLASS.chartArc) + .data($$.pie(targets)) + .attr('class', function(d) { + return classChartArc(d) + classFocus(d.data) + }); + mainPieEnter = mainPies + .enter() + .append('g') + .attr('class', classChartArc); + mainPieEnter.append('g').attr('class', classArcs); + mainPieEnter + .append('text') + .attr('dy', $$.hasType('gauge') ? '-.1em' : '.35em') + .style('opacity', 0) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + // MEMO: can not keep same color..., but not bad to update color in redraw + //mainPieUpdate.exit().remove(); +}; + +ChartInternal.prototype.initArc = function() { + var $$ = this; + $$.arcs = $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartArcs) + .attr('transform', $$.getTranslate('arc')); + $$.arcs + .append('text') + .attr('class', CLASS.chartArcsTitle) + .style('text-anchor', 'middle') + .text($$.getArcTitle()); +}; + +ChartInternal.prototype.redrawArc = function( + duration, + durationForExit, + withTransform +) { + var $$ = this, + d3 = $$.d3, + config = $$.config, + main = $$.main, + arcs, + mainArc, + arcLabelLines, + mainArcLabelLine, + hasGaugeType = $$.hasType('gauge'); + arcs = main + .selectAll('.' + CLASS.arcs) + .selectAll('.' + CLASS.arc) + .data($$.arcData.bind($$)); + mainArc = arcs + .enter() + .append('path') + .attr('class', $$.classArc.bind($$)) + .style('fill', function(d) { + return $$.color(d.data) + }) + .style('cursor', function(d) { + return config.interaction_enabled && config.data_selection_isselectable(d) + ? 'pointer' + : null + }) + .each(function(d) { + if ($$.isGaugeType(d.data)) { + d.startAngle = d.endAngle = config.gauge_startingAngle; + } + this._current = d; + }) + .merge(arcs); + if (hasGaugeType) { + arcLabelLines = main + .selectAll('.' + CLASS.arcs) + .selectAll('.' + CLASS.arcLabelLine) + .data($$.arcData.bind($$)); + mainArcLabelLine = arcLabelLines + .enter() + .append('rect') + .attr('class', function(d) { + return ( + CLASS.arcLabelLine + + ' ' + + CLASS.target + + ' ' + + CLASS.target + + '-' + + d.data.id + ) + }) + .merge(arcLabelLines); + + if ($$.filterTargetsToShow($$.data.targets).length === 1) { + mainArcLabelLine.style('display', 'none'); + } else { + mainArcLabelLine + .style('fill', function(d) { + return $$.levelColor + ? $$.levelColor( + d.data.values.reduce(function(total, item) { + return total + item.value + }, 0) + ) + : $$.color(d.data) + }) + .style('display', config.gauge_labelLine_show ? '' : 'none') + .each(function(d) { + var lineLength = 0, + lineThickness = 2, + x = 0, + y = 0, + transform = ''; + if ($$.hiddenTargetIds.indexOf(d.data.id) < 0) { + var updated = $$.updateAngle(d), + innerLineLength = + ($$.gaugeArcWidth / + $$.filterTargetsToShow($$.data.targets).length) * + (updated.index + 1), + lineAngle = updated.endAngle - Math.PI / 2, + arcInnerRadius = $$.radius - innerLineLength, + linePositioningAngle = + lineAngle - (arcInnerRadius === 0 ? 0 : 1 / arcInnerRadius); + lineLength = $$.radiusExpanded - $$.radius + innerLineLength; + x = Math.cos(linePositioningAngle) * arcInnerRadius; + y = Math.sin(linePositioningAngle) * arcInnerRadius; + transform = + 'rotate(' + + (lineAngle * 180) / Math.PI + + ', ' + + x + + ', ' + + y + + ')'; + } + d3.select(this) + .attr('x', x) + .attr('y', y) + .attr('width', lineLength) + .attr('height', lineThickness) + .attr('transform', transform) + .style( + 'stroke-dasharray', + '0, ' + (lineLength + lineThickness) + ', 0' + ); + }); + } + } + mainArc + .attr('transform', function(d) { + return !$$.isGaugeType(d.data) && withTransform ? 'scale(0)' : '' + }) + .on( + 'mouseover', + config.interaction_enabled + ? function(d) { + var updated, arcData; + if ($$.transiting) { + // skip while transiting + return + } + updated = $$.updateAngle(d); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.expandArc(updated.data.id); + $$.api.focus(updated.data.id); + $$.toggleFocusLegend(updated.data.id, true); + $$.config.data_onmouseover(arcData, this); + } + } + : null + ) + .on( + 'mousemove', + config.interaction_enabled + ? function(d) { + var updated = $$.updateAngle(d), + arcData, + selectedData; + if (updated) { +(arcData = $$.convertToArcData(updated)), + (selectedData = [arcData]); + $$.showTooltip(selectedData, this); + } + } + : null + ) + .on( + 'mouseout', + config.interaction_enabled + ? function(d) { + var updated, arcData; + if ($$.transiting) { + // skip while transiting + return + } + updated = $$.updateAngle(d); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.unexpandArc(updated.data.id); + $$.api.revert(); + $$.revertLegend(); + $$.hideTooltip(); + $$.config.data_onmouseout(arcData, this); + } + } + : null + ) + .on( + 'click', + config.interaction_enabled + ? function(d, i) { + var updated = $$.updateAngle(d), + arcData; + if (updated) { + arcData = $$.convertToArcData(updated); + if ($$.toggleShape) { + $$.toggleShape(this, arcData, i); + } + $$.config.data_onclick.call($$.api, arcData, this); + } + } + : null + ) + .each(function() { + $$.transiting = true; + }) + .transition() + .duration(duration) + .attrTween('d', function(d) { + var updated = $$.updateAngle(d), + interpolate; + if (!updated) { + return function() { + return 'M 0 0' + } + } + // if (this._current === d) { + // this._current = { + // startAngle: Math.PI*2, + // endAngle: Math.PI*2, + // }; + // } + if (isNaN(this._current.startAngle)) { + this._current.startAngle = 0; + } + if (isNaN(this._current.endAngle)) { + this._current.endAngle = this._current.startAngle; + } + interpolate = d3.interpolate(this._current, updated); + this._current = interpolate(0); + return function(t) { + // prevents crashing the charts once in transition and chart.destroy() has been called + if ($$.config === null) { + return 'M 0 0' + } + var interpolated = interpolate(t); + interpolated.data = d.data; // data.id will be updated by interporator + return $$.getArc(interpolated, true) + } + }) + .attr('transform', withTransform ? 'scale(1)' : '') + .style('fill', function(d) { + return $$.levelColor + ? $$.levelColor( + d.data.values.reduce(function(total, item) { + return total + item.value + }, 0) + ) + : $$.color(d.data.id) + }) // Where gauge reading color would receive customization. + .call($$.endall, function() { + $$.transiting = false; + }); + arcs + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + main + .selectAll('.' + CLASS.chartArc) + .select('text') + .style('opacity', 0) + .attr('class', function(d) { + return $$.isGaugeType(d.data) ? CLASS.gaugeValue : '' + }) + .text($$.textForArcLabel.bind($$)) + .attr('transform', $$.transformForArcLabel.bind($$)) + .style('font-size', function(d) { + return $$.isGaugeType(d.data) && + $$.filterTargetsToShow($$.data.targets).length === 1 + ? Math.round($$.radius / 5) + 'px' + : '' + }) + .transition() + .duration(duration) + .style('opacity', function(d) { + return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? 1 : 0 + }); + main + .select('.' + CLASS.chartArcsTitle) + .style('opacity', $$.hasType('donut') || hasGaugeType ? 1 : 0); + + if (hasGaugeType) { + let index = 0; + const backgroundArc = $$.arcs + .select('g.' + CLASS.chartArcsBackground) + .selectAll('path.' + CLASS.chartArcsBackground) + .data($$.data.targets); + + backgroundArc + .enter() + .append('path') + .attr( + 'class', + (d, i) => + CLASS.chartArcsBackground + ' ' + CLASS.chartArcsBackground + '-' + i + ) + .merge(backgroundArc) + .attr('d', d1 => { + if ($$.hiddenTargetIds.indexOf(d1.id) >= 0) { + return 'M 0 0' + } + + var d = { + data: [{ value: config.gauge_max }], + startAngle: config.gauge_startingAngle, + endAngle: + -1 * + config.gauge_startingAngle * + (config.gauge_fullCircle ? Math.PI : 1), + index: index++ + }; + return $$.getArc(d, true, true) + }); + + backgroundArc.exit().remove(); + + $$.arcs + .select('.' + CLASS.chartArcsGaugeUnit) + .attr('dy', '.75em') + .text(config.gauge_label_show ? config.gauge_units : ''); + $$.arcs + .select('.' + CLASS.chartArcsGaugeMin) + .attr( + 'dx', + -1 * + ($$.innerRadius + + ($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2)) + + 'px' + ) + .attr('dy', '1.2em') + .text( + config.gauge_label_show + ? $$.textForGaugeMinMax(config.gauge_min, false) + : '' + ); + $$.arcs + .select('.' + CLASS.chartArcsGaugeMax) + .attr( + 'dx', + $$.innerRadius + + ($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2) + + 'px' + ) + .attr('dy', '1.2em') + .text( + config.gauge_label_show + ? $$.textForGaugeMinMax(config.gauge_max, true) + : '' + ); + } +}; +ChartInternal.prototype.initGauge = function() { + var arcs = this.arcs; + if (this.hasType('gauge')) { + arcs.append('g').attr('class', CLASS.chartArcsBackground); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeUnit) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeMin) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeMax) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + } +}; +ChartInternal.prototype.getGaugeLabelHeight = function() { + return this.config.gauge_label_show ? 20 : 0 +}; + +/** + * Store value into cache + * + * @param key + * @param value + */ +ChartInternal.prototype.addToCache = function(key, value) { + this.cache[`$${key}`] = value; +}; + +/** + * Returns a cached value or undefined + * + * @param key + * @return {*} + */ +ChartInternal.prototype.getFromCache = function(key) { + return this.cache[`$${key}`] +}; + +/** + * Reset cached data + */ +ChartInternal.prototype.resetCache = function() { + Object.keys(this.cache) + .filter(key => /^\$/.test(key)) + .forEach(key => { + delete this.cache[key]; + }); +}; + +// Old API that stores Targets + +ChartInternal.prototype.hasCaches = function(ids) { + for (var i = 0; i < ids.length; i++) { + if (!(ids[i] in this.cache)) { + return false + } + } + return true +}; +ChartInternal.prototype.addCache = function(id, target) { + this.cache[id] = this.cloneTarget(target); +}; +ChartInternal.prototype.getCaches = function(ids) { + var targets = [], + i; + for (i = 0; i < ids.length; i++) { + if (ids[i] in this.cache) { + targets.push(this.cloneTarget(this.cache[ids[i]])); + } + } + return targets +}; + +ChartInternal.prototype.categoryName = function(i) { + var config = this.config; + return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i +}; + +ChartInternal.prototype.generateTargetClass = function(targetId) { + return targetId || targetId === 0 ? ('-' + targetId).replace(/\s/g, '-') : '' +}; +ChartInternal.prototype.generateClass = function(prefix, targetId) { + return ' ' + prefix + ' ' + prefix + this.generateTargetClass(targetId) +}; +ChartInternal.prototype.classText = function(d) { + return this.generateClass(CLASS.text, d.index) +}; +ChartInternal.prototype.classTexts = function(d) { + return this.generateClass(CLASS.texts, d.id) +}; +ChartInternal.prototype.classShape = function(d) { + return this.generateClass(CLASS.shape, d.index) +}; +ChartInternal.prototype.classShapes = function(d) { + return this.generateClass(CLASS.shapes, d.id) +}; +ChartInternal.prototype.classLine = function(d) { + return this.classShape(d) + this.generateClass(CLASS.line, d.id) +}; +ChartInternal.prototype.classLines = function(d) { + return this.classShapes(d) + this.generateClass(CLASS.lines, d.id) +}; +ChartInternal.prototype.classCircle = function(d) { + return this.classShape(d) + this.generateClass(CLASS.circle, d.index) +}; +ChartInternal.prototype.classCircles = function(d) { + return this.classShapes(d) + this.generateClass(CLASS.circles, d.id) +}; +ChartInternal.prototype.classBar = function(d) { + return this.classShape(d) + this.generateClass(CLASS.bar, d.index) +}; +ChartInternal.prototype.classBars = function(d) { + return this.classShapes(d) + this.generateClass(CLASS.bars, d.id) +}; +ChartInternal.prototype.classArc = function(d) { + return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id) +}; +ChartInternal.prototype.classArcs = function(d) { + return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id) +}; +ChartInternal.prototype.classArea = function(d) { + return this.classShape(d) + this.generateClass(CLASS.area, d.id) +}; +ChartInternal.prototype.classAreas = function(d) { + return this.classShapes(d) + this.generateClass(CLASS.areas, d.id) +}; +ChartInternal.prototype.classRegion = function(d, i) { + return ( + this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d['class'] : '') + ) +}; +ChartInternal.prototype.classEvent = function(d) { + return this.generateClass(CLASS.eventRect, d.index) +}; +ChartInternal.prototype.classTarget = function(id) { + var $$ = this; + var additionalClassSuffix = $$.config.data_classes[id], + additionalClass = ''; + if (additionalClassSuffix) { + additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; + } + return $$.generateClass(CLASS.target, id) + additionalClass +}; +ChartInternal.prototype.classFocus = function(d) { + return this.classFocused(d) + this.classDefocused(d) +}; +ChartInternal.prototype.classFocused = function(d) { + return ' ' + (this.focusedTargetIds.indexOf(d.id) >= 0 ? CLASS.focused : '') +}; +ChartInternal.prototype.classDefocused = function(d) { + return ( + ' ' + (this.defocusedTargetIds.indexOf(d.id) >= 0 ? CLASS.defocused : '') + ) +}; +ChartInternal.prototype.classChartText = function(d) { + return CLASS.chartText + this.classTarget(d.id) +}; +ChartInternal.prototype.classChartLine = function(d) { + return CLASS.chartLine + this.classTarget(d.id) +}; +ChartInternal.prototype.classChartBar = function(d) { + return CLASS.chartBar + this.classTarget(d.id) +}; +ChartInternal.prototype.classChartArc = function(d) { + return CLASS.chartArc + this.classTarget(d.data.id) +}; +ChartInternal.prototype.getTargetSelectorSuffix = function(targetId) { + const targetClass = this.generateTargetClass(targetId); + if (window.CSS && window.CSS.escape) { + return window.CSS.escape(targetClass) + } + + // fallback on imperfect method for old browsers (does not handles unicode) + return targetClass.replace(/([?!@#$%^&*()=+,.<>'":;\[\]\/|~`{}\\])/g, '\\$1') +}; +ChartInternal.prototype.selectorTarget = function(id, prefix) { + return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id) +}; +ChartInternal.prototype.selectorTargets = function(ids, prefix) { + var $$ = this; + ids = ids || []; + return ids.length + ? ids.map(function(id) { + return $$.selectorTarget(id, prefix) + }) + : null +}; +ChartInternal.prototype.selectorLegend = function(id) { + return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id) +}; +ChartInternal.prototype.selectorLegends = function(ids) { + var $$ = this; + return ids && ids.length + ? ids.map(function(id) { + return $$.selectorLegend(id) + }) + : null +}; + +ChartInternal.prototype.getClipPath = function(id) { + return 'url(' + (isIE(9) ? '' : document.URL.split('#')[0]) + '#' + id + ')' +}; +ChartInternal.prototype.appendClip = function(parent, id) { + return parent + .append('clipPath') + .attr('id', id) + .append('rect') +}; +ChartInternal.prototype.getAxisClipX = function(forHorizontal) { + // axis line width + padding for left + var left = Math.max(30, this.margin.left); + return forHorizontal ? -(1 + left) : -(left - 1) +}; +ChartInternal.prototype.getAxisClipY = function(forHorizontal) { + return forHorizontal ? -20 : -this.margin.top +}; +ChartInternal.prototype.getXAxisClipX = function() { + var $$ = this; + return $$.getAxisClipX(!$$.config.axis_rotated) +}; +ChartInternal.prototype.getXAxisClipY = function() { + var $$ = this; + return $$.getAxisClipY(!$$.config.axis_rotated) +}; +ChartInternal.prototype.getYAxisClipX = function() { + var $$ = this; + return $$.config.axis_y_inner ? -1 : $$.getAxisClipX($$.config.axis_rotated) +}; +ChartInternal.prototype.getYAxisClipY = function() { + var $$ = this; + return $$.getAxisClipY($$.config.axis_rotated) +}; +ChartInternal.prototype.getAxisClipWidth = function(forHorizontal) { + var $$ = this, + left = Math.max(30, $$.margin.left), + right = Math.max(30, $$.margin.right); + // width + axis line width + padding for left/right + return forHorizontal ? $$.width + 2 + left + right : $$.margin.left + 20 +}; +ChartInternal.prototype.getAxisClipHeight = function(forHorizontal) { + // less than 20 is not enough to show the axis label 'outer' without legend + return ( + (forHorizontal ? this.margin.bottom : this.margin.top + this.height) + 20 + ) +}; +ChartInternal.prototype.getXAxisClipWidth = function() { + var $$ = this; + return $$.getAxisClipWidth(!$$.config.axis_rotated) +}; +ChartInternal.prototype.getXAxisClipHeight = function() { + var $$ = this; + return $$.getAxisClipHeight(!$$.config.axis_rotated) +}; +ChartInternal.prototype.getYAxisClipWidth = function() { + var $$ = this; + return ( + $$.getAxisClipWidth($$.config.axis_rotated) + + ($$.config.axis_y_inner ? 20 : 0) + ) +}; +ChartInternal.prototype.getYAxisClipHeight = function() { + var $$ = this; + return $$.getAxisClipHeight($$.config.axis_rotated) +}; + +ChartInternal.prototype.generateColor = function() { + var $$ = this, + config = $$.config, + d3 = $$.d3, + colors = config.data_colors, + pattern = notEmpty(config.color_pattern) + ? config.color_pattern + : d3.schemeCategory10, + callback = config.data_color, + ids = []; + + return function(d) { + var id = d.id || (d.data && d.data.id) || d, + color; + + // if callback function is provided + if (colors[id] instanceof Function) { + color = colors[id](d); + } + // if specified, choose that color + else if (colors[id]) { + color = colors[id]; + } + // if not specified, choose from pattern + else { + if (ids.indexOf(id) < 0) { + ids.push(id); + } + color = pattern[ids.indexOf(id) % pattern.length]; + colors[id] = color; + } + return callback instanceof Function ? callback(color, d) : color + } +}; +ChartInternal.prototype.generateLevelColor = function() { + var $$ = this, + config = $$.config, + colors = config.color_pattern, + threshold = config.color_threshold, + asValue = threshold.unit === 'value', + values = + threshold.values && threshold.values.length ? threshold.values : [], + max = threshold.max || 100; + return notEmpty(threshold) && notEmpty(colors) + ? function(value) { + var i, + v, + color = colors[colors.length - 1]; + for (i = 0; i < values.length; i++) { + v = asValue ? value : (value * 100) / max; + if (v < values[i]) { + color = colors[i]; + break + } + } + return color + } + : null +}; + +ChartInternal.prototype.getDefaultConfig = function() { + var config = { + bindto: '#chart', + svg_classname: undefined, + size_width: undefined, + size_height: undefined, + padding_left: undefined, + padding_right: undefined, + padding_top: undefined, + padding_bottom: undefined, + resize_auto: true, + zoom_enabled: false, + zoom_initialRange: undefined, + zoom_type: 'scroll', + zoom_disableDefaultBehavior: false, + zoom_privileged: false, + zoom_rescale: false, + zoom_onzoom: function() {}, + zoom_onzoomstart: function() {}, + zoom_onzoomend: function() {}, + zoom_x_min: undefined, + zoom_x_max: undefined, + interaction_brighten: true, + interaction_enabled: true, + onmouseover: function() {}, + onmouseout: function() {}, + onresize: function() {}, + onresized: function() {}, + oninit: function() {}, + onrendered: function() {}, + transition_duration: 350, + data_epochs: 'epochs', + data_x: undefined, + data_xs: {}, + data_xFormat: '%Y-%m-%d', + data_xLocaltime: true, + data_xSort: true, + data_idConverter: function(id) { + return id + }, + data_names: {}, + data_classes: {}, + data_groups: [], + data_axes: {}, + data_type: undefined, + data_types: {}, + data_labels: {}, + data_order: 'desc', + data_regions: {}, + data_color: undefined, + data_colors: {}, + data_hide: false, + data_filter: undefined, + data_selection_enabled: false, + data_selection_grouped: false, + data_selection_isselectable: function() { + return true + }, + data_selection_multiple: true, + data_selection_draggable: false, + data_stack_normalize: false, + data_onclick: function() {}, + data_onmouseover: function() {}, + data_onmouseout: function() {}, + data_onselected: function() {}, + data_onunselected: function() {}, + data_url: undefined, + data_headers: undefined, + data_json: undefined, + data_rows: undefined, + data_columns: undefined, + data_mimeType: undefined, + data_keys: undefined, + // configuration for no plot-able data supplied. + data_empty_label_text: '', + // subchart + subchart_show: false, + subchart_size_height: 60, + subchart_axis_x_show: true, + subchart_onbrush: function() {}, + // color + color_pattern: [], + color_threshold: {}, + // legend + legend_show: true, + legend_hide: false, + legend_position: 'bottom', + legend_inset_anchor: 'top-left', + legend_inset_x: 10, + legend_inset_y: 0, + legend_inset_step: undefined, + legend_item_onclick: undefined, + legend_item_onmouseover: undefined, + legend_item_onmouseout: undefined, + legend_equally: false, + legend_padding: 0, + legend_item_tile_width: 10, + legend_item_tile_height: 10, + // axis + axis_rotated: false, + axis_x_show: true, + axis_x_type: 'indexed', + axis_x_localtime: true, + axis_x_categories: [], + axis_x_tick_centered: false, + axis_x_tick_format: undefined, + axis_x_tick_culling: {}, + axis_x_tick_culling_max: 10, + axis_x_tick_count: undefined, + axis_x_tick_fit: true, + axis_x_tick_values: null, + axis_x_tick_rotate: 0, + axis_x_tick_outer: true, + axis_x_tick_multiline: true, + axis_x_tick_multilineMax: 0, + axis_x_tick_width: null, + axis_x_max: undefined, + axis_x_min: undefined, + axis_x_padding: {}, + axis_x_height: undefined, + axis_x_selection: undefined, + axis_x_label: {}, + axis_x_inner: undefined, + axis_y_show: true, + axis_y_type: 'linear', + axis_y_max: undefined, + axis_y_min: undefined, + axis_y_inverted: false, + axis_y_center: undefined, + axis_y_inner: undefined, + axis_y_label: {}, + axis_y_tick_format: undefined, + axis_y_tick_outer: true, + axis_y_tick_values: null, + axis_y_tick_rotate: 0, + axis_y_tick_count: undefined, + axis_y_tick_time_type: undefined, + axis_y_tick_time_interval: undefined, + axis_y_padding: {}, + axis_y_default: undefined, + axis_y2_show: false, + axis_y2_type: 'linear', + axis_y2_max: undefined, + axis_y2_min: undefined, + axis_y2_inverted: false, + axis_y2_center: undefined, + axis_y2_inner: undefined, + axis_y2_label: {}, + axis_y2_tick_format: undefined, + axis_y2_tick_outer: true, + axis_y2_tick_values: null, + axis_y2_tick_count: undefined, + axis_y2_padding: {}, + axis_y2_default: undefined, + // grid + grid_x_show: false, + grid_x_type: 'tick', + grid_x_lines: [], + grid_y_show: false, + // not used + // grid_y_type: 'tick', + grid_y_lines: [], + grid_y_ticks: 10, + grid_focus_show: true, + grid_lines_front: true, + // point - point of each data + point_show: true, + point_r: 2.5, + point_sensitivity: 10, + point_focus_expand_enabled: true, + point_focus_expand_r: undefined, + point_select_r: undefined, + // line + line_connectNull: false, + line_step_type: 'step', + // bar + bar_width: undefined, + bar_width_ratio: 0.6, + bar_width_max: undefined, + bar_zerobased: true, + bar_space: 0, + // area + area_zerobased: true, + area_above: false, + // pie + pie_label_show: true, + pie_label_format: undefined, + pie_label_threshold: 0.05, + pie_label_ratio: undefined, + pie_expand: {}, + pie_expand_duration: 50, + pie_padAngle: 0, + // gauge + gauge_fullCircle: false, + gauge_label_show: true, + gauge_labelLine_show: true, + gauge_label_format: undefined, + gauge_min: 0, + gauge_max: 100, + gauge_startingAngle: (-1 * Math.PI) / 2, + gauge_label_extents: undefined, + gauge_units: undefined, + gauge_width: undefined, + gauge_arcs_minWidth: 5, + gauge_expand: {}, + gauge_expand_duration: 50, + // donut + donut_label_show: true, + donut_label_format: undefined, + donut_label_threshold: 0.05, + donut_label_ratio: undefined, + donut_width: undefined, + donut_title: '', + donut_expand: {}, + donut_expand_duration: 50, + donut_padAngle: 0, + // spline + spline_interpolation_type: 'cardinal', + // stanford + stanford_lines: [], + stanford_regions: [], + stanford_texts: [], + stanford_scaleMin: undefined, + stanford_scaleMax: undefined, + stanford_scaleWidth: undefined, + stanford_scaleFormat: undefined, + stanford_scaleValues: undefined, + stanford_colors: undefined, + stanford_padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + // region - region to change style + regions: [], + // tooltip - show when mouseover on each data + tooltip_show: true, + tooltip_grouped: true, + tooltip_order: undefined, + tooltip_format_title: undefined, + tooltip_format_name: undefined, + tooltip_format_value: undefined, + tooltip_horizontal: undefined, + tooltip_position: undefined, + tooltip_contents: function( + d, + defaultTitleFormat, + defaultValueFormat, + color + ) { + return this.getTooltipContent + ? this.getTooltipContent( + d, + defaultTitleFormat, + defaultValueFormat, + color + ) + : '' + }, + tooltip_init_show: false, + tooltip_init_x: 0, + tooltip_init_position: { top: '0px', left: '50px' }, + tooltip_onshow: function() {}, + tooltip_onhide: function() {}, + // title + title_text: undefined, + title_padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + title_position: 'top-center' + }; + + Object.keys(this.additionalConfig).forEach(function(key) { + config[key] = this.additionalConfig[key]; + }, this); + + return config +}; +ChartInternal.prototype.additionalConfig = {}; + +ChartInternal.prototype.loadConfig = function(config) { + var this_config = this.config, + target, + keys, + read; + function find() { + var key = keys.shift(); + // console.log("key =>", key, ", target =>", target); + if (key && target && typeof target === 'object' && key in target) { + target = target[key]; + return find() + } else if (!key) { + return target + } else { + return undefined + } + } + Object.keys(this_config).forEach(function(key) { + target = config; + keys = key.split('_'); + read = find(); + // console.log("CONFIG : ", key, read); + if (isDefined(read)) { + this_config[key] = read; + } + }); +}; + +ChartInternal.prototype.convertUrlToData = function( + url, + mimeType, + headers, + keys, + done +) { + var $$ = this, + type = mimeType ? mimeType : 'csv', + f, + converter; + + if (type === 'json') { + f = $$.d3.json; + converter = $$.convertJsonToData; + } else if (type === 'tsv') { + f = $$.d3.tsv; + converter = $$.convertXsvToData; + } else { + f = $$.d3.csv; + converter = $$.convertXsvToData; + } + + f(url, headers) + .then(function(data) { + done.call($$, converter.call($$, data, keys)); + }) + .catch(function(error) { + throw error + }); +}; +ChartInternal.prototype.convertXsvToData = function(xsv) { + var keys = xsv.columns, + rows = xsv; + if (rows.length === 0) { + return { + keys, + rows: [keys.reduce((row, key) => Object.assign(row, { [key]: null }), {})] + } + } else { + // [].concat() is to convert result into a plain array otherwise + // test is not happy because rows have properties. + return { keys, rows: [].concat(xsv) } + } +}; +ChartInternal.prototype.convertJsonToData = function(json, keys) { + var $$ = this, + new_rows = [], + targetKeys, + data; + if (keys) { + // when keys specified, json would be an array that includes objects + if (keys.x) { + targetKeys = keys.value.concat(keys.x); + $$.config.data_x = keys.x; + } else { + targetKeys = keys.value; + } + new_rows.push(targetKeys); + json.forEach(function(o) { + var new_row = []; + targetKeys.forEach(function(key) { + // convert undefined to null because undefined data will be removed in convertDataToTargets() + var v = $$.findValueInJson(o, key); + if (isUndefined(v)) { + v = null; + } + new_row.push(v); + }); + new_rows.push(new_row); + }); + data = $$.convertRowsToData(new_rows); + } else { + Object.keys(json).forEach(function(key) { + new_rows.push([key].concat(json[key])); + }); + data = $$.convertColumnsToData(new_rows); + } + return data +}; +/** + * Finds value from the given nested object by the given path. + * If it's not found, then this returns undefined. + * @param {Object} object the object + * @param {string} path the path + */ +ChartInternal.prototype.findValueInJson = function(object, path) { + if (path in object) { + // If object has a key that contains . or [], return the key's value + // instead of searching for an inner object. + // See https://github.com/c3js/c3/issues/1691 for details. + return object[path] + } + + path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties (replace [] with .) + path = path.replace(/^\./, ''); // strip a leading dot + var pathArray = path.split('.'); + for (var i = 0; i < pathArray.length; ++i) { + var k = pathArray[i]; + if (k in object) { + object = object[k]; + } else { + return + } + } + return object +}; + +/** + * Converts the rows to normalized data. + * @param {any[][]} rows The row data + * @return {Object} + */ +ChartInternal.prototype.convertRowsToData = rows => { + const newRows = []; + const keys = rows[0]; + + for (let i = 1; i < rows.length; i++) { + const newRow = {}; + for (let j = 0; j < rows[i].length; j++) { + if (isUndefined(rows[i][j])) { + throw new Error( + 'Source data is missing a component at (' + i + ',' + j + ')!' + ) + } + newRow[keys[j]] = rows[i][j]; + } + newRows.push(newRow); + } + return { keys, rows: newRows } +}; + +/** + * Converts the columns to normalized data. + * @param {any[][]} columns The column data + * @return {Object} + */ +ChartInternal.prototype.convertColumnsToData = columns => { + const newRows = []; + const keys = []; + + for (let i = 0; i < columns.length; i++) { + const key = columns[i][0]; + for (let j = 1; j < columns[i].length; j++) { + if (isUndefined(newRows[j - 1])) { + newRows[j - 1] = {}; + } + if (isUndefined(columns[i][j])) { + throw new Error( + 'Source data is missing a component at (' + i + ',' + j + ')!' + ) + } + newRows[j - 1][key] = columns[i][j]; + } + keys.push(key); + } + + return { keys, rows: newRows } +}; + +/** + * Converts the data format into the target format. + * @param {!Object} data + * @param {!Array} data.keys Ordered list of target IDs. + * @param {!Array} data.rows Rows of data to convert. + * @param {boolean} appendXs True to append to $$.data.xs, False to replace. + * @return {!Array} + */ +ChartInternal.prototype.convertDataToTargets = function(data, appendXs) { + var $$ = this, + config = $$.config, + targets, + ids, + xs, + keys, + epochs; + + // handles format where keys are not orderly provided + if (isArray(data)) { + keys = Object.keys(data[0]); + } else { + keys = data.keys; + data = data.rows; + } + + xs = keys.filter($$.isX, $$); + + if (!$$.isStanfordGraphType()) { + ids = keys.filter($$.isNotX, $$); + } else { + epochs = keys.filter($$.isEpochs, $$); + ids = keys.filter($$.isNotXAndNotEpochs, $$); + + if (xs.length !== 1 || epochs.length !== 1 || ids.length !== 1) { + throw new Error( + "You must define the 'x' key name and the 'epochs' for Stanford Diagrams" + ) + } + } + + // save x for update data by load when custom x and c3.x API + ids.forEach(function(id) { + var xKey = $$.getXKey(id); + + if ($$.isCustomX() || $$.isTimeSeries()) { + // if included in input data + if (xs.indexOf(xKey) >= 0) { + $$.data.xs[id] = (appendXs && $$.data.xs[id] + ? $$.data.xs[id] + : [] + ).concat( + data + .map(function(d) { + return d[xKey] + }) + .filter(isValue) + .map(function(rawX, i) { + return $$.generateTargetX(rawX, id, i) + }) + ); + } + // if not included in input data, find from preloaded data of other id's x + else if (config.data_x) { + $$.data.xs[id] = $$.getOtherTargetXs(); + } + // if not included in input data, find from preloaded data + else if (notEmpty(config.data_xs)) { + $$.data.xs[id] = $$.getXValuesOfXKey(xKey, $$.data.targets); + } + // MEMO: if no x included, use same x of current will be used + } else { + $$.data.xs[id] = data.map(function(d, i) { + return i + }); + } + }); + + // check x is defined + ids.forEach(function(id) { + if (!$$.data.xs[id]) { + throw new Error('x is not defined for id = "' + id + '".') + } + }); + + // convert to target + targets = ids.map(function(id, index) { + var convertedId = config.data_idConverter(id); + return { + id: convertedId, + id_org: id, + values: data + .map(function(d, i) { + var xKey = $$.getXKey(id), + rawX = d[xKey], + value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null, + x, + returnData; + // use x as categories if custom x and categorized + if ($$.isCustomX() && $$.isCategorized() && !isUndefined(rawX)) { + if (index === 0 && i === 0) { + config.axis_x_categories = []; + } + x = config.axis_x_categories.indexOf(rawX); + if (x === -1) { + x = config.axis_x_categories.length; + config.axis_x_categories.push(rawX); + } + } else { + x = $$.generateTargetX(rawX, id, i); + } + // mark as x = undefined if value is undefined and filter to remove after mapped + if (isUndefined(d[id]) || $$.data.xs[id].length <= i) { + x = undefined; + } + + returnData = { x: x, value: value, id: convertedId }; + + if ($$.isStanfordGraphType()) { + returnData.epochs = d[epochs]; + } + + return returnData + }) + .filter(function(v) { + return isDefined(v.x) + }) + } + }); + + // finish targets + targets.forEach(function(t) { + var i; + // sort values by its x + if (config.data_xSort) { + t.values = t.values.sort(function(v1, v2) { + var x1 = v1.x || v1.x === 0 ? v1.x : Infinity, + x2 = v2.x || v2.x === 0 ? v2.x : Infinity; + return x1 - x2 + }); + } + // indexing each value + i = 0; + t.values.forEach(function(v) { + v.index = i++; + }); + // this needs to be sorted because its index and value.index is identical + $$.data.xs[t.id].sort(function(v1, v2) { + return v1 - v2 + }); + }); + + // cache information about values + $$.hasNegativeValue = $$.hasNegativeValueInTargets(targets); + $$.hasPositiveValue = $$.hasPositiveValueInTargets(targets); + + // set target types + if (config.data_type) { + $$.setTargetType( + $$.mapToIds(targets).filter(function(id) { + return !(id in config.data_types) + }), + config.data_type + ); + } + + // cache as original id keyed + targets.forEach(function(d) { + $$.addCache(d.id_org, d); + }); + + return targets +}; + +ChartInternal.prototype.isEpochs = function(key) { + var $$ = this, + config = $$.config; + return config.data_epochs && key === config.data_epochs +}; +ChartInternal.prototype.isX = function(key) { + var $$ = this, + config = $$.config; + return ( + (config.data_x && key === config.data_x) || + (notEmpty(config.data_xs) && hasValue(config.data_xs, key)) + ) +}; +ChartInternal.prototype.isNotX = function(key) { + return !this.isX(key) +}; +ChartInternal.prototype.isNotXAndNotEpochs = function(key) { + return !this.isX(key) && !this.isEpochs(key) +}; + +/** + * Returns whether the normalized stack option is enabled or not. + * + * To be enabled it must also have data.groups defined. + * + * @return {boolean} + */ +ChartInternal.prototype.isStackNormalized = function() { + return this.config.data_stack_normalize && this.config.data_groups.length > 0 +}; + +/** + * Returns whether the axis is normalized or not. + * + * An axis is normalized as long as one of its associated target + * is normalized. + * + * @param axisId Axis ID (y or y2) + * @return {Boolean} + */ +ChartInternal.prototype.isAxisNormalized = function(axisId) { + const $$ = this; + + if (!$$.isStackNormalized()) { + // shortcut + return false + } + + return $$.data.targets + .filter(target => $$.axis.getId(target.id) === axisId) + .some(target => $$.isTargetNormalized(target.id)) +}; + +/** + * Returns whether the values for this target ID is normalized or not. + * + * To be normalized the option needs to be enabled and target needs + * to be defined in `data.groups`. + * + * @param targetId ID of the target + * @return {Boolean} True if the target is normalized, false otherwise. + */ +ChartInternal.prototype.isTargetNormalized = function(targetId) { + const $$ = this; + + return ( + $$.isStackNormalized() && + $$.config.data_groups.some(group => group.includes(targetId)) + ) +}; + +ChartInternal.prototype.getXKey = function(id) { + var $$ = this, + config = $$.config; + return config.data_x + ? config.data_x + : notEmpty(config.data_xs) + ? config.data_xs[id] + : null +}; + +/** + * Get sum of visible data per index for given axis. + * + * Expect axisId to be either 'y' or 'y2'. + * + * @private + * @param axisId Compute sum for data associated to given axis. + * @return {Array} + */ +ChartInternal.prototype.getTotalPerIndex = function(axisId) { + const $$ = this; + + if (!$$.isStackNormalized()) { + return null + } + + const cached = $$.getFromCache('getTotalPerIndex'); + if (cached !== undefined) { + return cached[axisId] + } + + const sum = { y: [], y2: [] }; + + $$.data.targets + // keep only target that are normalized + .filter(target => $$.isTargetNormalized(target.id)) + + // keep only target that are visible + .filter(target => $$.isTargetToShow(target.id)) + + // compute sum per axis + .forEach(target => { + const sumByAxis = sum[$$.axis.getId(target.id)]; + + target.values.forEach((v, i) => { + if (!sumByAxis[i]) { + sumByAxis[i] = 0; + } + sumByAxis[i] += isNumber(v.value) ? v.value : 0; + }); + }); + + $$.addToCache('getTotalPerIndex', sum); + + return sum[axisId] +}; + +/** + * Get sum of visible data. + * + * Should be used for normalised data only since all values + * are expected to be positive. + * + * @private + * @return {Number} + */ +ChartInternal.prototype.getTotalDataSum = function() { + const $$ = this; + + const cached = $$.getFromCache('getTotalDataSum'); + if (cached !== undefined) { + return cached + } + + const totalDataSum = flattenArray( + $$.data.targets + .filter(target => $$.isTargetToShow(target.id)) + .map(target => target.values) + ) + .map(d => d.value) + .reduce((p, c) => p + c, 0); + + $$.addToCache('getTotalDataSum', totalDataSum); + + return totalDataSum +}; + +ChartInternal.prototype.getXValuesOfXKey = function(key, targets) { + var $$ = this, + xValues, + ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : []; + ids.forEach(function(id) { + if ($$.getXKey(id) === key) { + xValues = $$.data.xs[id]; + } + }); + return xValues +}; +ChartInternal.prototype.getXValue = function(id, i) { + var $$ = this; + return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) + ? $$.data.xs[id][i] + : i +}; +ChartInternal.prototype.getOtherTargetXs = function() { + var $$ = this, + idsForX = Object.keys($$.data.xs); + return idsForX.length ? $$.data.xs[idsForX[0]] : null +}; +ChartInternal.prototype.getOtherTargetX = function(index) { + var xs = this.getOtherTargetXs(); + return xs && index < xs.length ? xs[index] : null +}; +ChartInternal.prototype.addXs = function(xs) { + var $$ = this; + Object.keys(xs).forEach(function(id) { + $$.config.data_xs[id] = xs[id]; + }); +}; +ChartInternal.prototype.addName = function(data) { + var $$ = this, + name; + if (data) { + name = $$.config.data_names[data.id]; + data.name = name !== undefined ? name : data.id; + } + return data +}; +ChartInternal.prototype.getValueOnIndex = function(values, index) { + var valueOnIndex = values.filter(function(v) { + return v.index === index + }); + return valueOnIndex.length ? valueOnIndex[0] : null +}; +ChartInternal.prototype.updateTargetX = function(targets, x) { + var $$ = this; + targets.forEach(function(t) { + t.values.forEach(function(v, i) { + v.x = $$.generateTargetX(x[i], t.id, i); + }); + $$.data.xs[t.id] = x; + }); +}; +ChartInternal.prototype.updateTargetXs = function(targets, xs) { + var $$ = this; + targets.forEach(function(t) { + if (xs[t.id]) { + $$.updateTargetX([t], xs[t.id]); + } + }); +}; +ChartInternal.prototype.generateTargetX = function(rawX, id, index) { + var $$ = this, + x; + if ($$.isTimeSeries()) { + x = rawX ? $$.parseDate(rawX) : $$.parseDate($$.getXValue(id, index)); + } else if ($$.isCustomX() && !$$.isCategorized()) { + x = isValue(rawX) ? +rawX : $$.getXValue(id, index); + } else { + x = index; + } + return x +}; +ChartInternal.prototype.cloneTarget = function(target) { + return { + id: target.id, + id_org: target.id_org, + values: target.values.map(function(d) { + return { + x: d.x, + value: d.value, + id: d.id + } + }) + } +}; +ChartInternal.prototype.getMaxDataCount = function() { + var $$ = this; + return $$.d3.max($$.data.targets, function(t) { + return t.values.length + }) +}; +ChartInternal.prototype.mapToIds = function(targets) { + return targets.map(function(d) { + return d.id + }) +}; +ChartInternal.prototype.mapToTargetIds = function(ids) { + var $$ = this; + return ids ? [].concat(ids) : $$.mapToIds($$.data.targets) +}; +ChartInternal.prototype.hasTarget = function(targets, id) { + var ids = this.mapToIds(targets), + i; + for (i = 0; i < ids.length; i++) { + if (ids[i] === id) { + return true + } + } + return false +}; +ChartInternal.prototype.isTargetToShow = function(targetId) { + return this.hiddenTargetIds.indexOf(targetId) < 0 +}; +ChartInternal.prototype.isLegendToShow = function(targetId) { + return this.hiddenLegendIds.indexOf(targetId) < 0 +}; + +/** + * Returns only visible targets. + * + * This is the same as calling {@link filterTargetsToShow} on $$.data.targets. + * + * @return {Array} + */ +ChartInternal.prototype.getTargetsToShow = function() { + const $$ = this; + return $$.filterTargetsToShow($$.data.targets) +}; + +ChartInternal.prototype.filterTargetsToShow = function(targets) { + var $$ = this; + return targets.filter(function(t) { + return $$.isTargetToShow(t.id) + }) +}; + +/** + * @return {Array} Returns all the targets attached to the chart, visible or not + */ +ChartInternal.prototype.getTargets = function() { + const $$ = this; + return $$.data.targets +}; + +ChartInternal.prototype.mapTargetsToUniqueXs = function(targets) { + var $$ = this; + var xs = $$.d3 + .set( + $$.d3.merge( + targets.map(function(t) { + return t.values.map(function(v) { + return +v.x + }) + }) + ) + ) + .values(); + xs = $$.isTimeSeries() + ? xs.map(function(x) { + return new Date(+x) + }) + : xs.map(function(x) { + return +x + }); + return xs.sort(function(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN + }) +}; +ChartInternal.prototype.addHiddenTargetIds = function(targetIds) { + targetIds = targetIds instanceof Array ? targetIds : new Array(targetIds); + for (var i = 0; i < targetIds.length; i++) { + if (this.hiddenTargetIds.indexOf(targetIds[i]) < 0) { + this.hiddenTargetIds = this.hiddenTargetIds.concat(targetIds[i]); + } + } + this.resetCache(); +}; +ChartInternal.prototype.removeHiddenTargetIds = function(targetIds) { + this.hiddenTargetIds = this.hiddenTargetIds.filter(function(id) { + return targetIds.indexOf(id) < 0 + }); + this.resetCache(); +}; +ChartInternal.prototype.addHiddenLegendIds = function(targetIds) { + targetIds = targetIds instanceof Array ? targetIds : new Array(targetIds); + for (var i = 0; i < targetIds.length; i++) { + if (this.hiddenLegendIds.indexOf(targetIds[i]) < 0) { + this.hiddenLegendIds = this.hiddenLegendIds.concat(targetIds[i]); + } + } +}; +ChartInternal.prototype.removeHiddenLegendIds = function(targetIds) { + this.hiddenLegendIds = this.hiddenLegendIds.filter(function(id) { + return targetIds.indexOf(id) < 0 + }); +}; +ChartInternal.prototype.getValuesAsIdKeyed = function(targets) { + var ys = {}; + targets.forEach(function(t) { + ys[t.id] = []; + t.values.forEach(function(v) { + ys[t.id].push(v.value); + }); + }); + return ys +}; +ChartInternal.prototype.checkValueInTargets = function(targets, checker) { + var ids = Object.keys(targets), + i, + j, + values; + for (i = 0; i < ids.length; i++) { + values = targets[ids[i]].values; + for (j = 0; j < values.length; j++) { + if (checker(values[j].value)) { + return true + } + } + } + return false +}; +ChartInternal.prototype.hasNegativeValueInTargets = function(targets) { + return this.checkValueInTargets(targets, function(v) { + return v < 0 + }) +}; +ChartInternal.prototype.hasPositiveValueInTargets = function(targets) { + return this.checkValueInTargets(targets, function(v) { + return v > 0 + }) +}; +ChartInternal.prototype.isOrderDesc = function() { + var config = this.config; + return ( + typeof config.data_order === 'string' && + config.data_order.toLowerCase() === 'desc' + ) +}; +ChartInternal.prototype.isOrderAsc = function() { + var config = this.config; + return ( + typeof config.data_order === 'string' && + config.data_order.toLowerCase() === 'asc' + ) +}; +ChartInternal.prototype.getOrderFunction = function() { + var $$ = this, + config = $$.config, + orderAsc = $$.isOrderAsc(), + orderDesc = $$.isOrderDesc(); + if (orderAsc || orderDesc) { + var reducer = function(p, c) { + return p + Math.abs(c.value) + }; + return function(t1, t2) { + var t1Sum = t1.values.reduce(reducer, 0), + t2Sum = t2.values.reduce(reducer, 0); + return orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum + } + } else if (isFunction(config.data_order)) { + return config.data_order + } else if (isArray(config.data_order)) { + var order = config.data_order; + return function(t1, t2) { + return order.indexOf(t1.id) - order.indexOf(t2.id) + } + } +}; +ChartInternal.prototype.orderTargets = function(targets) { + var fct = this.getOrderFunction(); + if (fct) { + targets.sort(fct); + } + return targets +}; + +/** + * Returns all the values from the given targets at the given index. + * + * @param {Array} targets + * @param {Number} index + * @return {Array} + */ +ChartInternal.prototype.filterByIndex = function(targets, index) { + return this.d3.merge( + targets.map(t => t.values.filter(v => v.index === index)) + ) +}; + +ChartInternal.prototype.filterByX = function(targets, x) { + return this.d3 + .merge( + targets.map(function(t) { + return t.values + }) + ) + .filter(function(v) { + return v.x - x === 0 + }) +}; +ChartInternal.prototype.filterRemoveNull = function(data) { + return data.filter(function(d) { + return isValue(d.value) + }) +}; +ChartInternal.prototype.filterByXDomain = function(targets, xDomain) { + return targets.map(function(t) { + return { + id: t.id, + id_org: t.id_org, + values: t.values.filter(function(v) { + return xDomain[0] <= v.x && v.x <= xDomain[1] + }) + } + }) +}; +ChartInternal.prototype.hasDataLabel = function() { + var config = this.config; + if (typeof config.data_labels === 'boolean' && config.data_labels) { + return true + } else if ( + typeof config.data_labels === 'object' && + notEmpty(config.data_labels) + ) { + return true + } + return false +}; +ChartInternal.prototype.getDataLabelLength = function(min, max, key) { + var $$ = this, + lengths = [0, 0], + paddingCoef = 1.3; + $$.selectChart + .select('svg') + .selectAll('.dummy') + .data([min, max]) + .enter() + .append('text') + .text(function(d) { + return $$.dataLabelFormat(d.id)(d) + }) + .each(function(d, i) { + lengths[i] = getBBox(this)[key] * paddingCoef; + }) + .remove(); + return lengths +}; +/** + * Returns true if the given data point is not arc type, otherwise false. + * @param {Object} d The data point + * @return {boolean} + */ +ChartInternal.prototype.isNoneArc = function(d) { + return this.hasTarget(this.data.targets, d.id) +}; + +/** + * Returns true if the given data point is arc type, otherwise false. + * @param {Object} d The data point + * @return {boolean} + */ +ChartInternal.prototype.isArc = function(d) { + return 'data' in d && this.hasTarget(this.data.targets, d.data.id) +}; + +/** + * Find the closest point from the given pos among the given targets or + * undefined if none satisfies conditions. + * + * @param {Array} targets + * @param {Array} pos An [x,y] coordinate + * @return {Object|undefined} + */ +ChartInternal.prototype.findClosestFromTargets = function(targets, pos) { + const $$ = this; + + // for each target, find the closest point + const candidates = targets + .map(t => + $$.findClosest( + t.values, + pos, + $$.config.tooltip_horizontal + ? $$.horizontalDistance.bind($$) + : $$.dist.bind($$), + $$.config.point_sensitivity + ) + ) + .filter(v => v); + + // returns the closest of candidates + if (candidates.length === 0) { + return undefined + } else if (candidates.length === 1) { + return candidates[0] + } else { + return $$.findClosest(candidates, pos, $$.dist.bind($$)) + } +}; + +/** + * Find the closest point from the x value or undefined if none satisfies conditions. + * + * @param {Array} targets + * @param {Array} x A value on X axis + * @return {Object|undefined} + */ +ChartInternal.prototype.findClosestFromTargetsByX = function(targets, x) { + let closest; + let diff; + + targets.forEach(t => { + t.values.forEach(d => { + let newDiff = Math.abs(x - d.x); + + if (diff === undefined || newDiff < diff) { + closest = d; + diff = newDiff; + } + }); + }); + + return closest +}; + +/** + * Using given compute distance method, returns the closest data point from the + * given position. + * + * Giving optionally a minimum distance to satisfy. + * + * @param {Array} dataPoints List of DataPoints + * @param {Array} pos An [x,y] coordinate + * @param {Function} computeDist Function to compute distance between 2 points + * @param {Number} minDist Minimal distance to satisfy + * @return {Object|undefined} Closest data point + */ +ChartInternal.prototype.findClosest = function( + dataPoints, + pos, + computeDist, + minDist = Infinity +) { + const $$ = this; + + let closest; + + // find closest bar + dataPoints + .filter(v => v && $$.isBarType(v.id)) + .forEach(function(v) { + if (!closest) { + const shape = $$.main + .select( + '.' + + CLASS.bars + + $$.getTargetSelectorSuffix(v.id) + + ' .' + + CLASS.bar + + '-' + + v.index + ) + .node(); + if ($$.isWithinBar(pos, shape)) { + closest = v; + } + } + }); + + // find closest point from non-bar + dataPoints + .filter(v => v && !$$.isBarType(v.id)) + .forEach(v => { + let d = computeDist(v, pos); + if (d < minDist) { + minDist = d; + closest = v; + } + }); + + return closest +}; +ChartInternal.prototype.dist = function(data, pos) { + var $$ = this, + config = $$.config, + xIndex = config.axis_rotated ? 1 : 0, + yIndex = config.axis_rotated ? 0 : 1, + y = $$.circleY(data, data.index), + x = $$.x(data.x); + return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2)) +}; +ChartInternal.prototype.horizontalDistance = function(data, pos) { + var $$ = this, + config = $$.config, + xIndex = config.axis_rotated ? 1 : 0, + x = $$.x(data.x); + + return Math.abs(x - pos[xIndex]) +}; +ChartInternal.prototype.convertValuesToStep = function(values) { + var converted = [].concat(values), + i; + + if (!this.isCategorized()) { + return values + } + + for (i = values.length + 1; 0 < i; i--) { + converted[i] = converted[i - 1]; + } + + converted[0] = { + x: converted[0].x - 1, + value: converted[0].value, + id: converted[0].id + }; + converted[values.length + 1] = { + x: converted[values.length].x + 1, + value: converted[values.length].value, + id: converted[values.length].id + }; + + return converted +}; + +/** + * Get ratio value + * + * @param {String} type Ratio for given type + * @param {Object} d Data value object + * @param {Boolean} asPercent Convert the return as percent or not + * @return {Number} Ratio value + * @private + */ +ChartInternal.prototype.getRatio = function(type, d, asPercent = false) { + const $$ = this; + const api = $$.api; + let ratio = 0; + + if (d && api.data.shown.call(api).length) { + ratio = d.ratio || d.value; + + if (type === 'arc') { + if ($$.hasType('gauge')) { + ratio = + (d.endAngle - d.startAngle) / + (Math.PI * ($$.config.gauge_fullCircle ? 2 : 1)); + } else { + const total = $$.getTotalDataSum(); + + ratio = d.value / total; + } + } else if (type === 'index') { + const total = $$.getTotalPerIndex($$.axis.getId(d.id)); + + d.ratio = + isNumber(d.value) && total && total[d.index] > 0 + ? d.value / total[d.index] + : 0; + + ratio = d.ratio; + } + } + + return asPercent && ratio ? ratio * 100 : ratio +}; + +ChartInternal.prototype.updateDataAttributes = function(name, attrs) { + var $$ = this, + config = $$.config, + current = config['data_' + name]; + if (typeof attrs === 'undefined') { + return current + } + Object.keys(attrs).forEach(function(id) { + current[id] = attrs[id]; + }); + $$.redraw({ + withLegend: true + }); + return current +}; + +ChartInternal.prototype.load = function(targets, args) { + var $$ = this; + if (targets) { + // filter loading targets if needed + if (args.filter) { + targets = targets.filter(args.filter); + } + // set type if args.types || args.type specified + if (args.type || args.types) { + targets.forEach(function(t) { + var type = args.types && args.types[t.id] ? args.types[t.id] : args.type; + $$.setTargetType(t.id, type); + }); + } + // Update/Add data + $$.data.targets.forEach(function(d) { + for (var i = 0; i < targets.length; i++) { + if (d.id === targets[i].id) { + d.values = targets[i].values; + targets.splice(i, 1); + break + } + } + }); + $$.data.targets = $$.data.targets.concat(targets); // add remained + } + + // Set targets + $$.updateTargets($$.data.targets); + + // Redraw with new targets + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + + if (args.done) { + args.done(); + } +}; +ChartInternal.prototype.loadFromArgs = function(args) { + var $$ = this; + + $$.resetCache(); + + if (args.data) { + $$.load($$.convertDataToTargets(args.data), args); + } else if (args.url) { + $$.convertUrlToData( + args.url, + args.mimeType, + args.headers, + args.keys, + function(data) { + $$.load($$.convertDataToTargets(data), args); + } + ); + } else if (args.json) { + $$.load( + $$.convertDataToTargets($$.convertJsonToData(args.json, args.keys)), + args + ); + } else if (args.rows) { + $$.load($$.convertDataToTargets($$.convertRowsToData(args.rows)), args); + } else if (args.columns) { + $$.load( + $$.convertDataToTargets($$.convertColumnsToData(args.columns)), + args + ); + } else { + $$.load(null, args); + } +}; +ChartInternal.prototype.unload = function(targetIds, done) { + var $$ = this; + + $$.resetCache(); + + if (!done) { + done = function() {}; + } + // filter existing target + targetIds = targetIds.filter(function(id) { + return $$.hasTarget($$.data.targets, id) + }); + // If no target, call done and return + if (!targetIds || targetIds.length === 0) { + done(); + return + } + $$.svg + .selectAll( + targetIds.map(function(id) { + return $$.selectorTarget(id) + }) + ) + .transition() + .style('opacity', 0) + .remove() + .call($$.endall, done); + targetIds.forEach(function(id) { + // Reset fadein for future load + $$.withoutFadeIn[id] = false; + // Remove target's elements + if ($$.legend) { + $$.legend + .selectAll('.' + CLASS.legendItem + $$.getTargetSelectorSuffix(id)) + .remove(); + } + // Remove target + $$.data.targets = $$.data.targets.filter(function(t) { + return t.id !== id + }); + }); +}; + +ChartInternal.prototype.getYDomainMin = function(targets) { + var $$ = this, + config = $$.config, + ids = $$.mapToIds(targets), + ys = $$.getValuesAsIdKeyed(targets), + j, + k, + baseId, + idsInGroup, + id, + hasNegativeValue; + if (config.data_groups.length > 0) { + hasNegativeValue = $$.hasNegativeValueInTargets(targets); + for (j = 0; j < config.data_groups.length; j++) { + // Determine baseId + idsInGroup = config.data_groups[j].filter(function(id) { + return ids.indexOf(id) >= 0 + }); + if (idsInGroup.length === 0) { + continue + } + baseId = idsInGroup[0]; + // Consider negative values + if (hasNegativeValue && ys[baseId]) { + ys[baseId].forEach(function(v, i) { + ys[baseId][i] = v < 0 ? v : 0; + }); + } + // Compute min + for (k = 1; k < idsInGroup.length; k++) { + id = idsInGroup[k]; + if (!ys[id]) { + continue + } + ys[id].forEach(function(v, i) { + if ( + $$.axis.getId(id) === $$.axis.getId(baseId) && + ys[baseId] && + !(hasNegativeValue && +v > 0) + ) { + ys[baseId][i] += +v; + } + }); + } + } + } + return $$.d3.min( + Object.keys(ys).map(function(key) { + return $$.d3.min(ys[key]) + }) + ) +}; +ChartInternal.prototype.getYDomainMax = function(targets) { + var $$ = this, + config = $$.config, + ids = $$.mapToIds(targets), + ys = $$.getValuesAsIdKeyed(targets), + j, + k, + baseId, + idsInGroup, + id, + hasPositiveValue; + if (config.data_groups.length > 0) { + hasPositiveValue = $$.hasPositiveValueInTargets(targets); + for (j = 0; j < config.data_groups.length; j++) { + // Determine baseId + idsInGroup = config.data_groups[j].filter(function(id) { + return ids.indexOf(id) >= 0 + }); + if (idsInGroup.length === 0) { + continue + } + baseId = idsInGroup[0]; + // Consider positive values + if (hasPositiveValue && ys[baseId]) { + ys[baseId].forEach(function(v, i) { + ys[baseId][i] = v > 0 ? v : 0; + }); + } + // Compute max + for (k = 1; k < idsInGroup.length; k++) { + id = idsInGroup[k]; + if (!ys[id]) { + continue + } + ys[id].forEach(function(v, i) { + if ( + $$.axis.getId(id) === $$.axis.getId(baseId) && + ys[baseId] && + !(hasPositiveValue && +v < 0) + ) { + ys[baseId][i] += +v; + } + }); + } + } + } + return $$.d3.max( + Object.keys(ys).map(function(key) { + return $$.d3.max(ys[key]) + }) + ) +}; +ChartInternal.prototype.getYDomain = function(targets, axisId, xDomain) { + var $$ = this, + config = $$.config; + + if ($$.isAxisNormalized(axisId)) { + return [0, 100] + } + + var targetsByAxisId = targets.filter(function(t) { + return $$.axis.getId(t.id) === axisId + }), + yTargets = xDomain + ? $$.filterByXDomain(targetsByAxisId, xDomain) + : targetsByAxisId, + yMin = axisId === 'y2' ? config.axis_y2_min : config.axis_y_min, + yMax = axisId === 'y2' ? config.axis_y2_max : config.axis_y_max, + yDomainMin = $$.getYDomainMin(yTargets), + yDomainMax = $$.getYDomainMax(yTargets), + domain, + domainLength, + padding_top, + padding_bottom, + center = axisId === 'y2' ? config.axis_y2_center : config.axis_y_center, + yDomainAbs, + lengths, + diff, + ratio, + isAllPositive, + isAllNegative, + isZeroBased = + ($$.hasType('bar', yTargets) && config.bar_zerobased) || + ($$.hasType('area', yTargets) && config.area_zerobased), + isInverted = + axisId === 'y2' ? config.axis_y2_inverted : config.axis_y_inverted, + showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated, + showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated; + + // MEMO: avoid inverting domain unexpectedly + yDomainMin = isValue(yMin) + ? yMin + : isValue(yMax) + ? yDomainMin < yMax + ? yDomainMin + : yMax - 10 + : yDomainMin; + yDomainMax = isValue(yMax) + ? yMax + : isValue(yMin) + ? yMin < yDomainMax + ? yDomainMax + : yMin + 10 + : yDomainMax; + + if (yTargets.length === 0) { + // use current domain if target of axisId is none + return axisId === 'y2' ? $$.y2.domain() : $$.y.domain() + } + if (isNaN(yDomainMin)) { + // set minimum to zero when not number + yDomainMin = 0; + } + if (isNaN(yDomainMax)) { + // set maximum to have same value as yDomainMin + yDomainMax = yDomainMin; + } + if (yDomainMin === yDomainMax) { + yDomainMin < 0 ? (yDomainMax = 0) : (yDomainMin = 0); + } + isAllPositive = yDomainMin >= 0 && yDomainMax >= 0; + isAllNegative = yDomainMin <= 0 && yDomainMax <= 0; + + // Cancel zerobased if axis_*_min / axis_*_max specified + if ((isValue(yMin) && isAllPositive) || (isValue(yMax) && isAllNegative)) { + isZeroBased = false; + } + + // Bar/Area chart should be 0-based if all positive|negative + if (isZeroBased) { + if (isAllPositive) { + yDomainMin = 0; + } + if (isAllNegative) { + yDomainMax = 0; + } + } + + domainLength = Math.abs(yDomainMax - yDomainMin); + padding_top = padding_bottom = domainLength * 0.1; + + if (typeof center !== 'undefined') { + yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax)); + yDomainMax = center + yDomainAbs; + yDomainMin = center - yDomainAbs; + } + // add padding for data label + if (showHorizontalDataLabel) { + lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'width'); + diff = diffDomain($$.y.range()); + ratio = [lengths[0] / diff, lengths[1] / diff]; + padding_top += domainLength * (ratio[1] / (1 - ratio[0] - ratio[1])); + padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1])); + } else if (showVerticalDataLabel) { + lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'height'); + + const pixelsToAxisPadding = $$.getY( + config[`axis_${axisId}_type`], + // input domain as pixels + [0, config.axis_rotated ? $$.width : $$.height], + // output range as axis padding + [0, domainLength] + ); + + padding_top += pixelsToAxisPadding(lengths[1]); + padding_bottom += pixelsToAxisPadding(lengths[0]); + } + if (axisId === 'y' && notEmpty(config.axis_y_padding)) { + padding_top = $$.axis.getPadding( + config.axis_y_padding, + 'top', + padding_top, + domainLength + ); + padding_bottom = $$.axis.getPadding( + config.axis_y_padding, + 'bottom', + padding_bottom, + domainLength + ); + } + if (axisId === 'y2' && notEmpty(config.axis_y2_padding)) { + padding_top = $$.axis.getPadding( + config.axis_y2_padding, + 'top', + padding_top, + domainLength + ); + padding_bottom = $$.axis.getPadding( + config.axis_y2_padding, + 'bottom', + padding_bottom, + domainLength + ); + } + // Bar/Area chart should be 0-based if all positive|negative + if (isZeroBased) { + if (isAllPositive) { + padding_bottom = yDomainMin; + } + if (isAllNegative) { + padding_top = -yDomainMax; + } + } + domain = [yDomainMin - padding_bottom, yDomainMax + padding_top]; + return isInverted ? domain.reverse() : domain +}; +ChartInternal.prototype.getXDomainMin = function(targets) { + var $$ = this, + config = $$.config; + return isDefined(config.axis_x_min) + ? $$.isTimeSeries() + ? this.parseDate(config.axis_x_min) + : config.axis_x_min + : $$.d3.min(targets, function(t) { + return $$.d3.min(t.values, function(v) { + return v.x + }) + }) +}; +ChartInternal.prototype.getXDomainMax = function(targets) { + var $$ = this, + config = $$.config; + return isDefined(config.axis_x_max) + ? $$.isTimeSeries() + ? this.parseDate(config.axis_x_max) + : config.axis_x_max + : $$.d3.max(targets, function(t) { + return $$.d3.max(t.values, function(v) { + return v.x + }) + }) +}; +ChartInternal.prototype.getXDomainPadding = function(domain) { + var $$ = this, + config = $$.config, + diff = domain[1] - domain[0], + maxDataCount, + padding, + paddingLeft, + paddingRight; + if ($$.isCategorized()) { + padding = 0; + } else if ($$.hasType('bar')) { + maxDataCount = $$.getMaxDataCount(); + padding = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : 0.5; + } else { + padding = diff * 0.01; + } + if ( + typeof config.axis_x_padding === 'object' && + notEmpty(config.axis_x_padding) + ) { + paddingLeft = isValue(config.axis_x_padding.left) + ? config.axis_x_padding.left + : padding; + paddingRight = isValue(config.axis_x_padding.right) + ? config.axis_x_padding.right + : padding; + } else if (typeof config.axis_x_padding === 'number') { + paddingLeft = paddingRight = config.axis_x_padding; + } else { + paddingLeft = paddingRight = padding; + } + return { left: paddingLeft, right: paddingRight } +}; +ChartInternal.prototype.getXDomain = function(targets) { + var $$ = this, + xDomain = [$$.getXDomainMin(targets), $$.getXDomainMax(targets)], + firstX = xDomain[0], + lastX = xDomain[1], + padding = $$.getXDomainPadding(xDomain), + min = 0, + max = 0; + // show center of x domain if min and max are the same + if (firstX - lastX === 0 && !$$.isCategorized()) { + if ($$.isTimeSeries()) { + firstX = new Date(firstX.getTime() * 0.5); + lastX = new Date(lastX.getTime() * 1.5); + } else { + firstX = firstX === 0 ? 1 : firstX * 0.5; + lastX = lastX === 0 ? -1 : lastX * 1.5; + } + } + if (firstX || firstX === 0) { + min = $$.isTimeSeries() + ? new Date(firstX.getTime() - padding.left) + : firstX - padding.left; + } + if (lastX || lastX === 0) { + max = $$.isTimeSeries() + ? new Date(lastX.getTime() + padding.right) + : lastX + padding.right; + } + return [min, max] +}; +ChartInternal.prototype.updateXDomain = function( + targets, + withUpdateXDomain, + withUpdateOrgXDomain, + withTrim, + domain +) { + var $$ = this, + config = $$.config; + + if (withUpdateOrgXDomain) { + $$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets))); + $$.orgXDomain = $$.x.domain(); + if (config.zoom_enabled) { + $$.zoom.update(); + } + $$.subX.domain($$.x.domain()); + if ($$.brush) { + $$.brush.updateScale($$.subX); + } + } + if (withUpdateXDomain) { + $$.x.domain( + domain + ? domain + : !$$.brush || $$.brush.empty() + ? $$.orgXDomain + : $$.brush.selectionAsValue() + ); + } + + // Trim domain when too big by zoom mousemove event + if (withTrim) { + $$.x.domain($$.trimXDomain($$.x.orgDomain())); + } + + return $$.x.domain() +}; +ChartInternal.prototype.trimXDomain = function(domain) { + var zoomDomain = this.getZoomDomain(), + min = zoomDomain[0], + max = zoomDomain[1]; + if (domain[0] <= min) { + domain[1] = +domain[1] + (min - domain[0]); + domain[0] = min; + } + if (max <= domain[1]) { + domain[0] = +domain[0] - (domain[1] - max); + domain[1] = max; + } + return domain +}; + +ChartInternal.prototype.drag = function(mouse) { + var $$ = this, + config = $$.config, + main = $$.main, + d3 = $$.d3; + var sx, sy, mx, my, minX, maxX, minY, maxY; + + if ($$.hasArcType()) { + return + } + if (!config.data_selection_enabled) { + return + } // do nothing if not selectable + if (!config.data_selection_multiple) { + return + } // skip when single selection because drag is used for multiple selection + + sx = $$.dragStart[0]; + sy = $$.dragStart[1]; + mx = mouse[0]; + my = mouse[1]; + minX = Math.min(sx, mx); + maxX = Math.max(sx, mx); + minY = config.data_selection_grouped ? $$.margin.top : Math.min(sy, my); + maxY = config.data_selection_grouped ? $$.height : Math.max(sy, my); + + main + .select('.' + CLASS.dragarea) + .attr('x', minX) + .attr('y', minY) + .attr('width', maxX - minX) + .attr('height', maxY - minY); + // TODO: binary search when multiple xs + main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function(d, i) { + if (!config.data_selection_isselectable(d)) { + return + } + var shape = d3.select(this), + isSelected = shape.classed(CLASS.SELECTED), + isIncluded = shape.classed(CLASS.INCLUDED), + _x, + _y, + _w, + _h, + toggle, + isWithin = false, + box; + if (shape.classed(CLASS.circle)) { + _x = shape.attr('cx') * 1; + _y = shape.attr('cy') * 1; + toggle = $$.togglePoint; + isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY; + } else if (shape.classed(CLASS.bar)) { + box = getPathBox(this); + _x = box.x; + _y = box.y; + _w = box.width; + _h = box.height; + toggle = $$.togglePath; + isWithin = + !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY); + } else { + // line/area selection not supported yet + return + } + if (isWithin ^ isIncluded) { + shape.classed(CLASS.INCLUDED, !isIncluded); + // TODO: included/unincluded callback here + shape.classed(CLASS.SELECTED, !isSelected); + toggle.call($$, !isSelected, shape, d, i); + } + }); +}; + +ChartInternal.prototype.dragstart = function(mouse) { + var $$ = this, + config = $$.config; + if ($$.hasArcType()) { + return + } + if (!config.data_selection_enabled) { + return + } // do nothing if not selectable + $$.dragStart = mouse; + $$.main + .select('.' + CLASS.chart) + .append('rect') + .attr('class', CLASS.dragarea) + .style('opacity', 0.1); + $$.dragging = true; +}; + +ChartInternal.prototype.dragend = function() { + var $$ = this, + config = $$.config; + if ($$.hasArcType()) { + return + } + if (!config.data_selection_enabled) { + return + } // do nothing if not selectable + $$.main + .select('.' + CLASS.dragarea) + .transition() + .duration(100) + .style('opacity', 0) + .remove(); + $$.main.selectAll('.' + CLASS.shape).classed(CLASS.INCLUDED, false); + $$.dragging = false; +}; + +ChartInternal.prototype.getYFormat = function(forArc) { + var $$ = this, + formatForY = + forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.yFormat, + formatForY2 = + forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.y2Format; + return function(v, ratio, id) { + var format = $$.axis.getId(id) === 'y2' ? formatForY2 : formatForY; + return format.call($$, v, ratio) + } +}; +ChartInternal.prototype.yFormat = function(v) { + var $$ = this, + config = $$.config, + format = config.axis_y_tick_format + ? config.axis_y_tick_format + : $$.defaultValueFormat; + return format(v) +}; +ChartInternal.prototype.y2Format = function(v) { + var $$ = this, + config = $$.config, + format = config.axis_y2_tick_format + ? config.axis_y2_tick_format + : $$.defaultValueFormat; + return format(v) +}; +ChartInternal.prototype.defaultValueFormat = function(v) { + return isValue(v) ? +v : '' +}; +ChartInternal.prototype.defaultArcValueFormat = function(v, ratio) { + return (ratio * 100).toFixed(1) + '%' +}; +ChartInternal.prototype.dataLabelFormat = function(targetId) { + var $$ = this, + data_labels = $$.config.data_labels, + format, + defaultFormat = function(v) { + return isValue(v) ? +v : '' + }; + // find format according to axis id + if (typeof data_labels.format === 'function') { + format = data_labels.format; + } else if (typeof data_labels.format === 'object') { + if (data_labels.format[targetId]) { + format = + data_labels.format[targetId] === true + ? defaultFormat + : data_labels.format[targetId]; + } else { + format = function() { + return '' + }; + } + } else { + format = defaultFormat; + } + return format +}; + +ChartInternal.prototype.initGrid = function() { + var $$ = this, + config = $$.config, + d3 = $$.d3; + $$.grid = $$.main + .append('g') + .attr('clip-path', $$.clipPathForGrid) + .attr('class', CLASS.grid); + if (config.grid_x_show) { + $$.grid.append('g').attr('class', CLASS.xgrids); + } + if (config.grid_y_show) { + $$.grid.append('g').attr('class', CLASS.ygrids); + } + if (config.grid_focus_show) { + $$.grid + .append('g') + .attr('class', CLASS.xgridFocus) + .append('line') + .attr('class', CLASS.xgridFocus); + } + $$.xgrid = d3.selectAll([]); + if (!config.grid_lines_front) { + $$.initGridLines(); + } +}; +ChartInternal.prototype.initGridLines = function() { + var $$ = this, + d3 = $$.d3; + $$.gridLines = $$.main + .append('g') + .attr('clip-path', $$.clipPathForGrid) + .attr('class', CLASS.grid + ' ' + CLASS.gridLines); + $$.gridLines.append('g').attr('class', CLASS.xgridLines); + $$.gridLines.append('g').attr('class', CLASS.ygridLines); + $$.xgridLines = d3.selectAll([]); +}; +ChartInternal.prototype.updateXGrid = function(withoutUpdate) { + var $$ = this, + config = $$.config, + d3 = $$.d3, + xgridData = $$.generateGridData(config.grid_x_type, $$.x), + tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; + + $$.xgridAttr = config.axis_rotated + ? { + x1: 0, + x2: $$.width, + y1: function(d) { + return $$.x(d) - tickOffset + }, + y2: function(d) { + return $$.x(d) - tickOffset + } + } + : { + x1: function(d) { + return $$.x(d) + tickOffset + }, + x2: function(d) { + return $$.x(d) + tickOffset + }, + y1: 0, + y2: $$.height + }; + $$.xgridAttr.opacity = function() { + var pos = +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1'); + return pos === (config.axis_rotated ? $$.height : 0) ? 0 : 1 + }; + + var xgrid = $$.main + .select('.' + CLASS.xgrids) + .selectAll('.' + CLASS.xgrid) + .data(xgridData); + var xgridEnter = xgrid + .enter() + .append('line') + .attr('class', CLASS.xgrid) + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', 0); + $$.xgrid = xgridEnter.merge(xgrid); + if (!withoutUpdate) { + $$.xgrid + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', $$.xgridAttr.opacity); + } + xgrid.exit().remove(); +}; + +ChartInternal.prototype.updateYGrid = function() { + var $$ = this, + config = $$.config, + gridValues = $$.yAxis.tickValues() || $$.y.ticks(config.grid_y_ticks); + var ygrid = $$.main + .select('.' + CLASS.ygrids) + .selectAll('.' + CLASS.ygrid) + .data(gridValues); + var ygridEnter = ygrid + .enter() + .append('line') + // TODO: x1, x2, y1, y2, opacity need to be set here maybe + .attr('class', CLASS.ygrid); + $$.ygrid = ygridEnter.merge(ygrid); + $$.ygrid + .attr('x1', config.axis_rotated ? $$.y : 0) + .attr('x2', config.axis_rotated ? $$.y : $$.width) + .attr('y1', config.axis_rotated ? 0 : $$.y) + .attr('y2', config.axis_rotated ? $$.height : $$.y); + ygrid.exit().remove(); + $$.smoothLines($$.ygrid, 'grid'); +}; + +ChartInternal.prototype.gridTextAnchor = function(d) { + return d.position ? d.position : 'end' +}; +ChartInternal.prototype.gridTextDx = function(d) { + return d.position === 'start' ? 4 : d.position === 'middle' ? 0 : -4 +}; +ChartInternal.prototype.xGridTextX = function(d) { + return d.position === 'start' + ? -this.height + : d.position === 'middle' + ? -this.height / 2 + : 0 +}; +ChartInternal.prototype.yGridTextX = function(d) { + return d.position === 'start' + ? 0 + : d.position === 'middle' + ? this.width / 2 + : this.width +}; +ChartInternal.prototype.updateGrid = function(duration) { + var $$ = this, + main = $$.main, + config = $$.config, + xgridLine, + xgridLineEnter, + ygridLine, + ygridLineEnter, + xv = $$.xv.bind($$), + yv = $$.yv.bind($$), + xGridTextX = $$.xGridTextX.bind($$), + yGridTextX = $$.yGridTextX.bind($$); + + // hide if arc type + $$.grid.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + + main.select('line.' + CLASS.xgridFocus).style('visibility', 'hidden'); + if (config.grid_x_show) { + $$.updateXGrid(); + } + xgridLine = main + .select('.' + CLASS.xgridLines) + .selectAll('.' + CLASS.xgridLine) + .data(config.grid_x_lines); + // enter + xgridLineEnter = xgridLine + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.xgridLine + (d['class'] ? ' ' + d['class'] : '') + }); + xgridLineEnter + .append('line') + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv) + .attr('y1', config.axis_rotated ? xv : 0) + .attr('y2', config.axis_rotated ? xv : $$.height) + .style('opacity', 0); + xgridLineEnter + .append('text') + .attr('text-anchor', $$.gridTextAnchor) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .attr('x', config.axis_rotated ? yGridTextX : xGridTextX) + .attr('y', xv) + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style('opacity', 0); + // udpate + $$.xgridLines = xgridLineEnter.merge(xgridLine); + // done in d3.transition() of the end of this function + // exit + xgridLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + + // Y-Grid + if (config.grid_y_show) { + $$.updateYGrid(); + } + ygridLine = main + .select('.' + CLASS.ygridLines) + .selectAll('.' + CLASS.ygridLine) + .data(config.grid_y_lines); + // enter + ygridLineEnter = ygridLine + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.ygridLine + (d['class'] ? ' ' + d['class'] : '') + }); + ygridLineEnter + .append('line') + .attr('x1', config.axis_rotated ? yv : 0) + .attr('x2', config.axis_rotated ? yv : $$.width) + .attr('y1', config.axis_rotated ? 0 : yv) + .attr('y2', config.axis_rotated ? $$.height : yv) + .style('opacity', 0); + ygridLineEnter + .append('text') + .attr('text-anchor', $$.gridTextAnchor) + .attr('transform', config.axis_rotated ? 'rotate(-90)' : '') + .attr('x', config.axis_rotated ? xGridTextX : yGridTextX) + .attr('y', yv) + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style('opacity', 0); + // update + $$.ygridLines = ygridLineEnter.merge(ygridLine); + $$.ygridLines + .select('line') + .transition() + .duration(duration) + .attr('x1', config.axis_rotated ? yv : 0) + .attr('x2', config.axis_rotated ? yv : $$.width) + .attr('y1', config.axis_rotated ? 0 : yv) + .attr('y2', config.axis_rotated ? $$.height : yv) + .style('opacity', 1); + $$.ygridLines + .select('text') + .transition() + .duration(duration) + .attr( + 'x', + config.axis_rotated ? $$.xGridTextX.bind($$) : $$.yGridTextX.bind($$) + ) + .attr('y', yv) + .text(function(d) { + return d.text + }) + .style('opacity', 1); + // exit + ygridLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); +}; +ChartInternal.prototype.redrawGrid = function(withTransition, transition) { + var $$ = this, + config = $$.config, + xv = $$.xv.bind($$), + lines = $$.xgridLines.select('line'), + texts = $$.xgridLines.select('text'); + return [ + (withTransition ? lines.transition(transition) : lines) + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv) + .attr('y1', config.axis_rotated ? xv : 0) + .attr('y2', config.axis_rotated ? xv : $$.height) + .style('opacity', 1), + (withTransition ? texts.transition(transition) : texts) + .attr( + 'x', + config.axis_rotated ? $$.yGridTextX.bind($$) : $$.xGridTextX.bind($$) + ) + .attr('y', xv) + .text(function(d) { + return d.text + }) + .style('opacity', 1) + ] +}; +ChartInternal.prototype.showXGridFocus = function(selectedData) { + var $$ = this, + config = $$.config, + dataToShow = selectedData.filter(function(d) { + return d && isValue(d.value) + }), + focusEl = $$.main.selectAll('line.' + CLASS.xgridFocus), + xx = $$.xx.bind($$); + if (!config.tooltip_show) { + return + } + // Hide when stanford plot exists + if ($$.hasType('stanford') || $$.hasArcType()) { + return + } + focusEl + .style('visibility', 'visible') + .data([dataToShow[0]]) + .attr(config.axis_rotated ? 'y1' : 'x1', xx) + .attr(config.axis_rotated ? 'y2' : 'x2', xx); + $$.smoothLines(focusEl, 'grid'); +}; +ChartInternal.prototype.hideXGridFocus = function() { + this.main.select('line.' + CLASS.xgridFocus).style('visibility', 'hidden'); +}; +ChartInternal.prototype.updateXgridFocus = function() { + var $$ = this, + config = $$.config; + $$.main + .select('line.' + CLASS.xgridFocus) + .attr('x1', config.axis_rotated ? 0 : -10) + .attr('x2', config.axis_rotated ? $$.width : -10) + .attr('y1', config.axis_rotated ? -10 : 0) + .attr('y2', config.axis_rotated ? -10 : $$.height); +}; +ChartInternal.prototype.generateGridData = function(type, scale) { + var $$ = this, + gridData = [], + xDomain, + firstYear, + lastYear, + i, + tickNum = $$.main + .select('.' + CLASS.axisX) + .selectAll('.tick') + .size(); + if (type === 'year') { + xDomain = $$.getXDomain(); + firstYear = xDomain[0].getFullYear(); + lastYear = xDomain[1].getFullYear(); + for (i = firstYear; i <= lastYear; i++) { + gridData.push(new Date(i + '-01-01 00:00:00')); + } + } else { + gridData = scale.ticks(10); + if (gridData.length > tickNum) { + // use only int + gridData = gridData.filter(function(d) { + return ('' + d).indexOf('.') < 0 + }); + } + } + return gridData +}; +ChartInternal.prototype.getGridFilterToRemove = function(params) { + return params + ? function(line) { + var found = false + ;[].concat(params).forEach(function(param) { + if ( + ('value' in param && line.value === param.value) || + ('class' in param && line['class'] === param['class']) + ) { + found = true; + } + }); + return found + } + : function() { + return true + } +}; +ChartInternal.prototype.removeGridLines = function(params, forX) { + var $$ = this, + config = $$.config, + toRemove = $$.getGridFilterToRemove(params), + toShow = function(line) { + return !toRemove(line) + }, + classLines = forX ? CLASS.xgridLines : CLASS.ygridLines, + classLine = forX ? CLASS.xgridLine : CLASS.ygridLine; + $$.main + .select('.' + classLines) + .selectAll('.' + classLine) + .filter(toRemove) + .transition() + .duration(config.transition_duration) + .style('opacity', 0) + .remove(); + if (forX) { + config.grid_x_lines = config.grid_x_lines.filter(toShow); + } else { + config.grid_y_lines = config.grid_y_lines.filter(toShow); + } +}; + +ChartInternal.prototype.initEventRect = function() { + var $$ = this, + config = $$.config; + + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.eventRects) + .style('fill-opacity', 0); + $$.eventRect = $$.main + .select('.' + CLASS.eventRects) + .append('rect') + .attr('class', CLASS.eventRect); + + // event rect handle zoom event as well + if (config.zoom_enabled && $$.zoom) { + $$.eventRect.call($$.zoom).on('dblclick.zoom', null); + if (config.zoom_initialRange) { + // WORKAROUND: Add transition to apply transform immediately when no subchart + $$.eventRect + .transition() + .duration(0) + .call($$.zoom.transform, $$.zoomTransform(config.zoom_initialRange)); + } + } +}; +ChartInternal.prototype.redrawEventRect = function() { + const $$ = this, + d3 = $$.d3, + config = $$.config; + + function mouseout() { + $$.svg.select('.' + CLASS.eventRect).style('cursor', null); + $$.hideXGridFocus(); + $$.hideTooltip(); + $$.unexpandCircles(); + $$.unexpandBars(); + } + + const isHoveringDataPoint = (mouse, closest) => + closest && + ($$.isBarType(closest.id) || + $$.dist(closest, mouse) < config.point_sensitivity); + + const withName = d => (d ? $$.addName(Object.assign({}, d)) : null); + + // rects for mouseover + $$.main + .select('.' + CLASS.eventRects) + .style( + 'cursor', + config.zoom_enabled + ? config.axis_rotated + ? 'ns-resize' + : 'ew-resize' + : null + ); + + $$.eventRect + .attr('x', 0) + .attr('y', 0) + .attr('width', $$.width) + .attr('height', $$.height) + .on( + 'mouseout', + config.interaction_enabled + ? function() { + if (!config) { + return + } // chart is destroyed + if ($$.hasArcType()) { + return + } + if ($$.mouseover) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + mouseout(); + } + : null + ) + .on( + 'mousemove', + config.interaction_enabled + ? function() { + // do nothing when dragging + if ($$.dragging) { + return + } + + const targetsToShow = $$.getTargetsToShow(); + + // do nothing if arc type + if ($$.hasArcType(targetsToShow)) { + return + } + + const mouse = d3.mouse(this); + const closest = withName( + $$.findClosestFromTargets(targetsToShow, mouse) + ); + const isMouseCloseToDataPoint = isHoveringDataPoint(mouse, closest); + + // ensure onmouseout is always called if mousemove switch between 2 targets + if ( + $$.mouseover && + (!closest || + closest.id !== $$.mouseover.id || + closest.index !== $$.mouseover.index) + ) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + if (closest && !$$.mouseover) { + config.data_onmouseover.call($$.api, closest); + $$.mouseover = closest; + } + + // show cursor as pointer if we're hovering a data point close enough + $$.svg + .select('.' + CLASS.eventRect) + .style('cursor', isMouseCloseToDataPoint ? 'pointer' : null); + + // if tooltip not grouped, we want to display only data from closest data point + const showSingleDataPoint = + !config.tooltip_grouped || $$.hasType('stanford', targetsToShow); + + // find data to highlight + let selectedData; + if (showSingleDataPoint) { + if (closest) { + selectedData = [closest]; + } + } else { + let closestByX; + if (closest) { + // reuse closest value + closestByX = closest; + } else { + // try to find the closest value by X values from the mouse position + const mouseX = config.axis_rotated ? mouse[1] : mouse[0]; + closestByX = $$.findClosestFromTargetsByX( + targetsToShow, + $$.x.invert(mouseX) + ); + } + + // highlight all data for this 'x' value + if (closestByX) { + selectedData = $$.filterByX(targetsToShow, closestByX.x); + } + } + + // ensure we have data to show + if (!selectedData || selectedData.length === 0) { + return mouseout() + } + + // inject names for each point + selectedData = selectedData.map(withName); + + // show tooltip + $$.showTooltip(selectedData, this); + + // expand points + if (config.point_focus_expand_enabled) { + $$.unexpandCircles(); + selectedData.forEach(function(d) { + $$.expandCircles(d.index, d.id, false); + }); + } + + // expand bars + $$.unexpandBars(); + selectedData.forEach(function(d) { + $$.expandBars(d.index, d.id, false); + }); + + // Show xgrid focus line + $$.showXGridFocus(selectedData); + } + : null + ) + .on( + 'click', + config.interaction_enabled + ? function() { + const targetsToShow = $$.getTargetsToShow(); + + if ($$.hasArcType(targetsToShow)) { + return + } + + const mouse = d3.mouse(this); + const closest = withName( + $$.findClosestFromTargets(targetsToShow, mouse) + ); + + if (!isHoveringDataPoint(mouse, closest)) { + return + } + + // select if selection enabled + let sameXData; + if (!config.data_selection_grouped || $$.isStanfordType(closest)) { + sameXData = [closest]; + } else { + sameXData = $$.filterByX(targetsToShow, closest.x); + } + + // toggle selected state + sameXData.forEach(function(d) { + $$.main + .selectAll( + '.' + CLASS.shapes + $$.getTargetSelectorSuffix(d.id) + ) + .selectAll('.' + CLASS.shape + '-' + d.index) + .each(function() { + if ( + config.data_selection_grouped || + $$.isWithinShape(this, d) + ) { + $$.toggleShape(this, d, d.index); + } + }); + }); + + // call data_onclick on the closest data point + if (closest) { + const shape = $$.main + .selectAll( + '.' + CLASS.shapes + $$.getTargetSelectorSuffix(closest.id) + ) + .select('.' + CLASS.shape + '-' + closest.index); + config.data_onclick.call($$.api, closest, shape.node()); + } + } + : null + ) + .call( + config.interaction_enabled && config.data_selection_draggable && $$.drag + ? d3 + .drag() + .on('drag', function() { + $$.drag(d3.mouse(this)); + }) + .on('start', function() { + $$.dragstart(d3.mouse(this)); + }) + .on('end', function() { + $$.dragend(); + }) + : function() {} + ); +}; +ChartInternal.prototype.getMousePosition = function(data) { + var $$ = this; + return [$$.x(data.x), $$.getYScale(data.id)(data.value)] +}; +ChartInternal.prototype.dispatchEvent = function(type, mouse) { + var $$ = this, + selector = '.' + CLASS.eventRect, + eventRect = $$.main.select(selector).node(), + box = eventRect.getBoundingClientRect(), + x = box.left + (mouse ? mouse[0] : 0), + y = box.top + (mouse ? mouse[1] : 0), + event = document.createEvent('MouseEvents'); + + event.initMouseEvent( + type, + true, + true, + window, + 0, + x, + y, + x, + y, + false, + false, + false, + false, + 0, + null + ); + eventRect.dispatchEvent(event); +}; + +ChartInternal.prototype.initLegend = function() { + var $$ = this; + $$.legendItemTextBox = {}; + $$.legendHasRendered = false; + $$.legend = $$.svg.append('g').attr('transform', $$.getTranslate('legend')); + if (!$$.config.legend_show) { + $$.legend.style('visibility', 'hidden'); + $$.hiddenLegendIds = $$.mapToIds($$.data.targets); + return + } + // MEMO: call here to update legend box and tranlate for all + // MEMO: translate will be updated by this, so transform not needed in updateLegend() + $$.updateLegendWithDefaults(); +}; +ChartInternal.prototype.updateLegendWithDefaults = function() { + var $$ = this; + $$.updateLegend($$.mapToIds($$.data.targets), { + withTransform: false, + withTransitionForTransform: false, + withTransition: false + }); +}; +ChartInternal.prototype.updateSizeForLegend = function( + legendHeight, + legendWidth +) { + var $$ = this, + config = $$.config, + insetLegendPosition = { + top: $$.isLegendTop + ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 + : $$.currentHeight - + legendHeight - + $$.getCurrentPaddingBottom() - + config.legend_inset_y, + left: $$.isLegendLeft + ? $$.getCurrentPaddingLeft() + config.legend_inset_x + 0.5 + : $$.currentWidth - + legendWidth - + $$.getCurrentPaddingRight() - + config.legend_inset_x + + 0.5 + }; + + $$.margin3 = { + top: $$.isLegendRight + ? 0 + : $$.isLegendInset + ? insetLegendPosition.top + : $$.currentHeight - legendHeight, + right: NaN, + bottom: 0, + left: $$.isLegendRight + ? $$.currentWidth - legendWidth + : $$.isLegendInset + ? insetLegendPosition.left + : 0 + }; +}; +ChartInternal.prototype.transformLegend = function(withTransition) { + var $$ = this + ;(withTransition ? $$.legend.transition() : $$.legend).attr( + 'transform', + $$.getTranslate('legend') + ); +}; +ChartInternal.prototype.updateLegendStep = function(step) { + this.legendStep = step; +}; +ChartInternal.prototype.updateLegendItemWidth = function(w) { + this.legendItemWidth = w; +}; +ChartInternal.prototype.updateLegendItemHeight = function(h) { + this.legendItemHeight = h; +}; +ChartInternal.prototype.getLegendWidth = function() { + var $$ = this; + return $$.config.legend_show + ? $$.isLegendRight || $$.isLegendInset + ? $$.legendItemWidth * ($$.legendStep + 1) + : $$.currentWidth + : 0 +}; +ChartInternal.prototype.getLegendHeight = function() { + var $$ = this, + h = 0; + if ($$.config.legend_show) { + if ($$.isLegendRight) { + h = $$.currentHeight; + } else { + h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1); + } + } + return h +}; +ChartInternal.prototype.opacityForLegend = function(legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 1 +}; +ChartInternal.prototype.opacityForUnfocusedLegend = function(legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 0.3 +}; +ChartInternal.prototype.toggleFocusLegend = function(targetIds, focus) { + var $$ = this; + targetIds = $$.mapToTargetIds(targetIds); + $$.legend + .selectAll('.' + CLASS.legendItem) + .filter(function(id) { + return targetIds.indexOf(id) >= 0 + }) + .classed(CLASS.legendItemFocused, focus) + .transition() + .duration(100) + .style('opacity', function() { + var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend; + return opacity.call($$, $$.d3.select(this)) + }); +}; +ChartInternal.prototype.revertLegend = function() { + var $$ = this, + d3 = $$.d3; + $$.legend + .selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemFocused, false) + .transition() + .duration(100) + .style('opacity', function() { + return $$.opacityForLegend(d3.select(this)) + }); +}; +ChartInternal.prototype.showLegend = function(targetIds) { + var $$ = this, + config = $$.config; + if (!config.legend_show) { + config.legend_show = true; + $$.legend.style('visibility', 'visible'); + if (!$$.legendHasRendered) { + $$.updateLegendWithDefaults(); + } + } + $$.removeHiddenLegendIds(targetIds); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .style('visibility', 'visible') + .transition() + .style('opacity', function() { + return $$.opacityForLegend($$.d3.select(this)) + }); +}; +ChartInternal.prototype.hideLegend = function(targetIds) { + var $$ = this, + config = $$.config; + if (config.legend_show && isEmpty(targetIds)) { + config.legend_show = false; + $$.legend.style('visibility', 'hidden'); + } + $$.addHiddenLegendIds(targetIds); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .style('opacity', 0) + .style('visibility', 'hidden'); +}; +ChartInternal.prototype.clearLegendItemTextBoxCache = function() { + this.legendItemTextBox = {}; +}; +ChartInternal.prototype.updateLegend = function( + targetIds, + options, + transitions +) { + var $$ = this, + config = $$.config; + var xForLegend, + xForLegendText, + xForLegendRect, + yForLegend, + yForLegendText, + yForLegendRect, + x1ForLegendTile, + x2ForLegendTile, + yForLegendTile; + var paddingTop = 4, + paddingRight = 10, + maxWidth = 0, + maxHeight = 0, + posMin = 10, + tileWidth = config.legend_item_tile_width + 5; + var l, + totalLength = 0, + offsets = {}, + widths = {}, + heights = {}, + margins = [0], + steps = {}, + step = 0; + var withTransition, withTransitionForTransform; + var texts, rects, tiles, background; + + // Skip elements when their name is set to null + targetIds = targetIds.filter(function(id) { + return !isDefined(config.data_names[id]) || config.data_names[id] !== null + }); + + options = options || {}; + withTransition = getOption(options, 'withTransition', true); + withTransitionForTransform = getOption( + options, + 'withTransitionForTransform', + true + ); + + function getTextBox(textElement, id) { + if (!$$.legendItemTextBox[id]) { + $$.legendItemTextBox[id] = $$.getTextRect( + textElement.textContent, + CLASS.legendItem, + textElement + ); + } + return $$.legendItemTextBox[id] + } + + function updatePositions(textElement, id, index) { + var reset = index === 0, + isLast = index === targetIds.length - 1, + box = getTextBox(textElement, id), + itemWidth = + box.width + + tileWidth + + (isLast && !($$.isLegendRight || $$.isLegendInset) ? 0 : paddingRight) + + config.legend_padding, + itemHeight = box.height + paddingTop, + itemLength = + $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth, + areaLength = + $$.isLegendRight || $$.isLegendInset + ? $$.getLegendHeight() + : $$.getLegendWidth(), + margin, + maxLength; + + // MEMO: care about condifion of step, totalLength + function updateValues(id, withoutStep) { + if (!withoutStep) { + margin = (areaLength - totalLength - itemLength) / 2; + if (margin < posMin) { + margin = (areaLength - itemLength) / 2; + totalLength = 0; + step++; + } + } + steps[id] = step; + margins[step] = $$.isLegendInset ? 10 : margin; + offsets[id] = totalLength; + totalLength += itemLength; + } + + if (reset) { + totalLength = 0; + step = 0; + maxWidth = 0; + maxHeight = 0; + } + + if (config.legend_show && !$$.isLegendToShow(id)) { + widths[id] = heights[id] = steps[id] = offsets[id] = 0; + return + } + + widths[id] = itemWidth; + heights[id] = itemHeight; + + if (!maxWidth || itemWidth >= maxWidth) { + maxWidth = itemWidth; + } + if (!maxHeight || itemHeight >= maxHeight) { + maxHeight = itemHeight; + } + maxLength = $$.isLegendRight || $$.isLegendInset ? maxHeight : maxWidth; + + if (config.legend_equally) { + Object.keys(widths).forEach(function(id) { + widths[id] = maxWidth; + }); + Object.keys(heights).forEach(function(id) { + heights[id] = maxHeight; + }); + margin = (areaLength - maxLength * targetIds.length) / 2; + if (margin < posMin) { + totalLength = 0; + step = 0; + targetIds.forEach(function(id) { + updateValues(id); + }); + } else { + updateValues(id, true); + } + } else { + updateValues(id); + } + } + + if ($$.isLegendInset) { + step = config.legend_inset_step + ? config.legend_inset_step + : targetIds.length; + $$.updateLegendStep(step); + } + + if ($$.isLegendRight) { + xForLegend = function(id) { + return maxWidth * steps[id] + }; + yForLegend = function(id) { + return margins[steps[id]] + offsets[id] + }; + } else if ($$.isLegendInset) { + xForLegend = function(id) { + return maxWidth * steps[id] + 10 + }; + yForLegend = function(id) { + return margins[steps[id]] + offsets[id] + }; + } else { + xForLegend = function(id) { + return margins[steps[id]] + offsets[id] + }; + yForLegend = function(id) { + return maxHeight * steps[id] + }; + } + xForLegendText = function(id, i) { + return xForLegend(id, i) + 4 + config.legend_item_tile_width + }; + yForLegendText = function(id, i) { + return yForLegend(id, i) + 9 + }; + xForLegendRect = function(id, i) { + return xForLegend(id, i) + }; + yForLegendRect = function(id, i) { + return yForLegend(id, i) - 5 + }; + x1ForLegendTile = function(id, i) { + return xForLegend(id, i) - 2 + }; + x2ForLegendTile = function(id, i) { + return xForLegend(id, i) - 2 + config.legend_item_tile_width + }; + yForLegendTile = function(id, i) { + return yForLegend(id, i) + 4 + }; + + // Define g for legend area + l = $$.legend + .selectAll('.' + CLASS.legendItem) + .data(targetIds) + .enter() + .append('g') + .attr('class', function(id) { + return $$.generateClass(CLASS.legendItem, id) + }) + .style('visibility', function(id) { + return $$.isLegendToShow(id) ? 'visible' : 'hidden' + }) + .style('cursor', function() { + return config.interaction_enabled ? 'pointer' : 'auto' + }) + .on( + 'click', + config.interaction_enabled + ? function(id) { + if (config.legend_item_onclick) { + config.legend_item_onclick.call($$, id); + } else { + if ($$.d3.event.altKey) { + $$.api.hide(); + $$.api.show(id); + } else { + $$.api.toggle(id); + $$.isTargetToShow(id) ? $$.api.focus(id) : $$.api.revert(); + } + } + } + : null + ) + .on( + 'mouseover', + config.interaction_enabled + ? function(id) { + if (config.legend_item_onmouseover) { + config.legend_item_onmouseover.call($$, id); + } else { + $$.d3.select(this).classed(CLASS.legendItemFocused, true); + if (!$$.transiting && $$.isTargetToShow(id)) { + $$.api.focus(id); + } + } + } + : null + ) + .on( + 'mouseout', + config.interaction_enabled + ? function(id) { + if (config.legend_item_onmouseout) { + config.legend_item_onmouseout.call($$, id); + } else { + $$.d3.select(this).classed(CLASS.legendItemFocused, false); + $$.api.revert(); + } + } + : null + ); + + l.append('text') + .text(function(id) { + return isDefined(config.data_names[id]) ? config.data_names[id] : id + }) + .each(function(id, i) { + updatePositions(this, id, i); + }) + .style('pointer-events', 'none') + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendText); + + l.append('rect') + .attr('class', CLASS.legendItemEvent) + .style('fill-opacity', 0) + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendRect : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendRect); + + l.append('line') + .attr('class', CLASS.legendItemTile) + .style('stroke', $$.color) + .style('pointer-events', 'none') + .attr('x1', $$.isLegendRight || $$.isLegendInset ? x1ForLegendTile : -200) + .attr('y1', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) + .attr('x2', $$.isLegendRight || $$.isLegendInset ? x2ForLegendTile : -200) + .attr('y2', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) + .attr('stroke-width', config.legend_item_tile_height); + + // Set background for inset legend + background = $$.legend.select('.' + CLASS.legendBackground + ' rect'); + if ($$.isLegendInset && maxWidth > 0 && background.size() === 0) { + background = $$.legend + .insert('g', '.' + CLASS.legendItem) + .attr('class', CLASS.legendBackground) + .append('rect'); + } + + texts = $$.legend + .selectAll('text') + .data(targetIds) + .text(function(id) { + return isDefined(config.data_names[id]) ? config.data_names[id] : id + }) // MEMO: needed for update + .each(function(id, i) { + updatePositions(this, id, i); + }) + ;(withTransition ? texts.transition() : texts) + .attr('x', xForLegendText) + .attr('y', yForLegendText); + + rects = $$.legend.selectAll('rect.' + CLASS.legendItemEvent).data(targetIds) + ;(withTransition ? rects.transition() : rects) + .attr('width', function(id) { + return widths[id] + }) + .attr('height', function(id) { + return heights[id] + }) + .attr('x', xForLegendRect) + .attr('y', yForLegendRect); + + tiles = $$.legend.selectAll('line.' + CLASS.legendItemTile).data(targetIds) + ;(withTransition ? tiles.transition() : tiles) + .style( + 'stroke', + $$.levelColor + ? function(id) { + return $$.levelColor( + $$.cache[id].values.reduce(function(total, item) { + return total + item.value + }, 0) + ) + } + : $$.color + ) + .attr('x1', x1ForLegendTile) + .attr('y1', yForLegendTile) + .attr('x2', x2ForLegendTile) + .attr('y2', yForLegendTile); + + if (background) { +(withTransition ? background.transition() : background) + .attr('height', $$.getLegendHeight() - 12) + .attr('width', maxWidth * (step + 1) + 10); + } + + // toggle legend state + $$.legend + .selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemHidden, function(id) { + return !$$.isTargetToShow(id) + }); + + // Update all to reflect change of legend + $$.updateLegendItemWidth(maxWidth); + $$.updateLegendItemHeight(maxHeight); + $$.updateLegendStep(step); + // Update size and scale + $$.updateSizes(); + $$.updateScales(); + $$.updateSvgSize(); + // Update g positions + $$.transformAll(withTransitionForTransform, transitions); + $$.legendHasRendered = true; +}; + +ChartInternal.prototype.initRegion = function() { + var $$ = this; + $$.region = $$.main + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.regions); +}; +ChartInternal.prototype.updateRegion = function(duration) { + var $$ = this, + config = $$.config; + + // hide if arc type + $$.region.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + + var mainRegion = $$.main + .select('.' + CLASS.regions) + .selectAll('.' + CLASS.region) + .data(config.regions); + var g = mainRegion.enter().append('g'); + g.append('rect') + .attr('x', $$.regionX.bind($$)) + .attr('y', $$.regionY.bind($$)) + .attr('width', $$.regionWidth.bind($$)) + .attr('height', $$.regionHeight.bind($$)) + .style('fill-opacity', function(d) { + return isValue(d.opacity) ? d.opacity : 0.1 + }); + g.append('text').text($$.labelRegion.bind($$)); + $$.mainRegion = g.merge(mainRegion).attr('class', $$.classRegion.bind($$)); + mainRegion + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); +}; +ChartInternal.prototype.redrawRegion = function(withTransition, transition) { + var $$ = this, + regions = $$.mainRegion, + regionLabels = $$.mainRegion.selectAll('text'); + return [ + (withTransition ? regions.transition(transition) : regions) + .attr('x', $$.regionX.bind($$)) + .attr('y', $$.regionY.bind($$)) + .attr('width', $$.regionWidth.bind($$)) + .attr('height', $$.regionHeight.bind($$)) + .style('fill-opacity', function(d) { + return isValue(d.opacity) ? d.opacity : 0.1 + }), + (withTransition ? regionLabels.transition(transition) : regionLabels) + .attr('x', $$.labelOffsetX.bind($$)) + .attr('y', $$.labelOffsetY.bind($$)) + .attr('transform', $$.labelTransform.bind($$)) + .attr('style', 'text-anchor: left;') + ] +}; +ChartInternal.prototype.regionX = function(d) { + var $$ = this, + config = $$.config, + xPos, + yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + xPos = config.axis_rotated ? ('start' in d ? yScale(d.start) : 0) : 0; + } else { + xPos = config.axis_rotated + ? 0 + : 'start' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) + : 0; + } + return xPos +}; +ChartInternal.prototype.regionY = function(d) { + var $$ = this, + config = $$.config, + yPos, + yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + yPos = config.axis_rotated ? 0 : 'end' in d ? yScale(d.end) : 0; + } else { + yPos = config.axis_rotated + ? 'start' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) + : 0 + : 0; + } + return yPos +}; +ChartInternal.prototype.regionWidth = function(d) { + var $$ = this, + config = $$.config, + start = $$.regionX(d), + end, + yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + end = config.axis_rotated + ? 'end' in d + ? yScale(d.end) + : $$.width + : $$.width; + } else { + end = config.axis_rotated + ? $$.width + : 'end' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) + : $$.width; + } + return end < start ? 0 : end - start +}; +ChartInternal.prototype.regionHeight = function(d) { + var $$ = this, + config = $$.config, + start = this.regionY(d), + end, + yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + end = config.axis_rotated + ? $$.height + : 'start' in d + ? yScale(d.start) + : $$.height; + } else { + end = config.axis_rotated + ? 'end' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) + : $$.height + : $$.height; + } + return end < start ? 0 : end - start +}; +ChartInternal.prototype.isRegionOnX = function(d) { + return !d.axis || d.axis === 'x' +}; +ChartInternal.prototype.labelRegion = function(d) { + return 'label' in d ? d.label : '' +}; +ChartInternal.prototype.labelTransform = function(d) { + return 'vertical' in d && d.vertical ? 'rotate(90)' : '' +}; +ChartInternal.prototype.labelOffsetX = function(d) { + var paddingX = 'paddingX' in d ? d.paddingX : 3; + var paddingY = 'paddingY' in d ? d.paddingY : 3; + return 'vertical' in d && d.vertical + ? this.regionY(d) + paddingY + : this.regionX(d) + paddingX +}; +ChartInternal.prototype.labelOffsetY = function(d) { + var paddingX = 'paddingX' in d ? d.paddingX : 3; + var paddingY = 'paddingY' in d ? d.paddingY : 3; + return 'vertical' in d && d.vertical + ? -(this.regionX(d) + paddingX) + : this.regionY(d) + 10 + paddingY +}; + +function c3LogScale(d3, linearScale, logScale) { + var PROJECTION = [0.01, 10]; + + if (!linearScale) { + linearScale = d3.scaleLinear(); + linearScale.range(PROJECTION); + } + + if (!logScale) { + logScale = d3.scaleLog(); + logScale.domain(PROJECTION); + logScale.nice(); + } + + // copied from https://github.com/compute-io/logspace + function logspace(a, b, len) { + var arr, end, tmp, d; + + if (arguments.length < 3) { + len = 10; + } else { + if (len === 0) { + return [] + } + } + // Calculate the increment: + end = len - 1; + d = (b - a) / end; + + // Build the output array... + arr = new Array(len); + tmp = a; + arr[0] = Math.pow(10, tmp); + for (var i = 1; i < end; i++) { + tmp += d; + arr[i] = Math.pow(10, tmp); + } + arr[end] = Math.pow(10, b); + return arr + } + + function scale(x) { + return logScale(linearScale(x)) + } + + scale.domain = function(x) { + if (!arguments.length) { + return linearScale.domain() + } + linearScale.domain(x); + return scale + }; + + scale.range = function(x) { + if (!arguments.length) { + return logScale.range() + } + logScale.range(x); + return scale + }; + + scale.ticks = function(m) { + return logspace(-2, 1, m || 10).map(function(v) { + return linearScale.invert(v) + }) + }; + + scale.copy = function() { + return c3LogScale(d3, linearScale.copy(), logScale.copy()) + }; + + return scale +} + +ChartInternal.prototype.getScale = function(min, max, forTimeseries) { + return (forTimeseries ? this.d3.scaleTime() : this.d3.scaleLinear()).range([ + min, + max + ]) +}; +ChartInternal.prototype.getX = function(min, max, domain, offset) { + var $$ = this, + scale = $$.getScale(min, max, $$.isTimeSeries()), + _scale = domain ? scale.domain(domain) : scale, + key; + // Define customized scale if categorized axis + if ($$.isCategorized()) { + offset = + offset || + function() { + return 0 + }; + scale = function(d, raw) { + var v = _scale(d) + offset(d); + return raw ? v : Math.ceil(v) + }; + } else { + scale = function(d, raw) { + var v = _scale(d); + return raw ? v : Math.ceil(v) + }; + } + // define functions + for (key in _scale) { + scale[key] = _scale[key]; + } + scale.orgDomain = function() { + return _scale.domain() + }; + // define custom domain() for categorized axis + if ($$.isCategorized()) { + scale.domain = function(domain) { + if (!arguments.length) { + domain = this.orgDomain(); + return [domain[0], domain[1] + 1] + } + _scale.domain(domain); + return scale + }; + } + return scale +}; + +/** + * Creates and configures a D3 scale instance for the given type. + * + * By defaults it returns a Linear scale. + * + * @param {String} type Type of d3-scale to create. Type can be 'linear', 'time', 'timeseries' or 'log'. + * @param {Array} domain The scale domain such as [from, to] + * @param {Array} range The scale's range such as [from, to] + * + * @return A d3-scale instance + */ +ChartInternal.prototype.getY = function(type, domain, range) { + let scale; + if (type === 'timeseries' || type === 'time') { + scale = this.d3.scaleTime(); + } else if (type === 'log') { + scale = c3LogScale(this.d3); + } else if (type === 'linear' || type === undefined) { + scale = this.d3.scaleLinear(); + } else { + throw new Error(`Invalid Y axis type: "${type}"`) + } + + if (domain) { + scale.domain(domain); + } + + if (range) { + scale.range(range); + } + + return scale +}; +ChartInternal.prototype.getYScale = function(id) { + return this.axis.getId(id) === 'y2' ? this.y2 : this.y +}; +ChartInternal.prototype.getSubYScale = function(id) { + return this.axis.getId(id) === 'y2' ? this.subY2 : this.subY +}; +ChartInternal.prototype.updateScales = function() { + var $$ = this, + config = $$.config, + forInit = !$$.x; + // update edges + $$.xMin = config.axis_rotated ? 1 : 0; + $$.xMax = config.axis_rotated ? $$.height : $$.width; + $$.yMin = config.axis_rotated ? 0 : $$.height; + $$.yMax = config.axis_rotated ? $$.width : 1; + $$.subXMin = $$.xMin; + $$.subXMax = $$.xMax; + $$.subYMin = config.axis_rotated ? 0 : $$.height2; + $$.subYMax = config.axis_rotated ? $$.width2 : 1; + // update scales + $$.x = $$.getX( + $$.xMin, + $$.xMax, + forInit ? undefined : $$.x.orgDomain(), + function() { + return $$.xAxis.tickOffset() + } + ); + $$.y = $$.getY( + config.axis_y_type, + forInit ? config.axis_y_default : $$.y.domain(), + [$$.yMin, $$.yMax] + ); + $$.y2 = $$.getY( + config.axis_y2_type, + forInit ? config.axis_y2_default : $$.y2.domain(), + [$$.yMin, $$.yMax] + ); + $$.subX = $$.getX($$.xMin, $$.xMax, $$.orgXDomain, function(d) { + return d % 1 ? 0 : $$.subXAxis.tickOffset() + }); + $$.subY = $$.getY( + config.axis_y_type, + forInit ? config.axis_y_default : $$.subY.domain(), + [$$.subYMin, $$.subYMax] + ); + $$.subY2 = $$.getY( + config.axis_y2_type, + forInit ? config.axis_y2_default : $$.subY2.domain(), + [$$.subYMin, $$.subYMax] + ); + // update axes + $$.xAxisTickFormat = $$.axis.getXAxisTickFormat(); + $$.xAxisTickValues = $$.axis.getXAxisTickValues(); + $$.yAxisTickValues = $$.axis.getYAxisTickValues(); + $$.y2AxisTickValues = $$.axis.getY2AxisTickValues(); + + $$.xAxis = $$.axis.getXAxis( + $$.x, + $$.xOrient, + $$.xAxisTickFormat, + $$.xAxisTickValues, + config.axis_x_tick_outer + ); + $$.subXAxis = $$.axis.getXAxis( + $$.subX, + $$.subXOrient, + $$.xAxisTickFormat, + $$.xAxisTickValues, + config.axis_x_tick_outer + ); + $$.yAxis = $$.axis.getYAxis( + 'y', + $$.y, + $$.yOrient, + $$.yAxisTickValues, + config.axis_y_tick_outer + ); + $$.y2Axis = $$.axis.getYAxis( + 'y2', + $$.y2, + $$.y2Orient, + $$.y2AxisTickValues, + config.axis_y2_tick_outer + ); + + // Set initialized scales to brush and zoom + if (!forInit) { + if ($$.brush) { + $$.brush.updateScale($$.subX); + } + } + // update for arc + if ($$.updateArc) { + $$.updateArc(); + } +}; + +ChartInternal.prototype.selectPoint = function(target, d, i) { + var $$ = this, + config = $$.config, + cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$), + cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$), + r = $$.pointSelectR.bind($$); + config.data_onselected.call($$.api, d, target.node()); + // add selected-circle on low layer g + $$.main + .select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.selectedCircle + '-' + i) + .data([d]) + .enter() + .append('circle') + .attr('class', function() { + return $$.generateClass(CLASS.selectedCircle, i) + }) + .attr('cx', cx) + .attr('cy', cy) + .attr('stroke', function() { + return $$.color(d) + }) + .attr('r', function(d) { + return $$.pointSelectR(d) * 1.4 + }) + .transition() + .duration(100) + .attr('r', r); +}; +ChartInternal.prototype.unselectPoint = function(target, d, i) { + var $$ = this; + $$.config.data_onunselected.call($$.api, d, target.node()); + // remove selected-circle from low layer g + $$.main + .select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.selectedCircle + '-' + i) + .transition() + .duration(100) + .attr('r', 0) + .remove(); +}; +ChartInternal.prototype.togglePoint = function(selected, target, d, i) { + selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i); +}; +ChartInternal.prototype.selectPath = function(target, d) { + var $$ = this; + $$.config.data_onselected.call($$, d, target.node()); + if ($$.config.interaction_brighten) { + target + .transition() + .duration(100) + .style('fill', function() { + return $$.d3.rgb($$.color(d)).brighter(0.75) + }); + } +}; +ChartInternal.prototype.unselectPath = function(target, d) { + var $$ = this; + $$.config.data_onunselected.call($$, d, target.node()); + if ($$.config.interaction_brighten) { + target + .transition() + .duration(100) + .style('fill', function() { + return $$.color(d) + }); + } +}; +ChartInternal.prototype.togglePath = function(selected, target, d, i) { + selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i); +}; +ChartInternal.prototype.getToggle = function(that, d) { + var $$ = this, + toggle; + if (that.nodeName === 'circle') { + if ($$.isStepType(d)) { + // circle is hidden in step chart, so treat as within the click area + toggle = function() {}; // TODO: how to select step chart? + } else { + toggle = $$.togglePoint; + } + } else if (that.nodeName === 'path') { + toggle = $$.togglePath; + } + return toggle +}; +ChartInternal.prototype.toggleShape = function(that, d, i) { + var $$ = this, + d3 = $$.d3, + config = $$.config, + shape = d3.select(that), + isSelected = shape.classed(CLASS.SELECTED), + toggle = $$.getToggle(that, d).bind($$); + + if (config.data_selection_enabled && config.data_selection_isselectable(d)) { + if (!config.data_selection_multiple) { + $$.main + .selectAll( + '.' + + CLASS.shapes + + (config.data_selection_grouped + ? $$.getTargetSelectorSuffix(d.id) + : '') + ) + .selectAll('.' + CLASS.shape) + .each(function(d, i) { + var shape = d3.select(this); + if (shape.classed(CLASS.SELECTED)) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + }); + } + shape.classed(CLASS.SELECTED, !isSelected); + toggle(!isSelected, shape, d, i); + } +}; + +ChartInternal.prototype.initBar = function() { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartBars); +}; +ChartInternal.prototype.updateTargetsForBar = function(targets) { + var $$ = this, + config = $$.config, + mainBars, + mainBarEnter, + classChartBar = $$.classChartBar.bind($$), + classBars = $$.classBars.bind($$), + classFocus = $$.classFocus.bind($$); + mainBars = $$.main + .select('.' + CLASS.chartBars) + .selectAll('.' + CLASS.chartBar) + .data(targets) + .attr('class', function(d) { + return classChartBar(d) + classFocus(d) + }); + mainBarEnter = mainBars + .enter() + .append('g') + .attr('class', classChartBar) + .style('pointer-events', 'none'); + // Bars for each data + mainBarEnter + .append('g') + .attr('class', classBars) + .style('cursor', function(d) { + return config.data_selection_isselectable(d) ? 'pointer' : null + }); +}; +ChartInternal.prototype.updateBar = function(durationForExit) { + var $$ = this, + barData = $$.barData.bind($$), + classBar = $$.classBar.bind($$), + initialOpacity = $$.initialOpacity.bind($$), + color = function(d) { + return $$.color(d.id) + }; + var mainBar = $$.main + .selectAll('.' + CLASS.bars) + .selectAll('.' + CLASS.bar) + .data(barData); + var mainBarEnter = mainBar + .enter() + .append('path') + .attr('class', classBar) + .style('stroke', color) + .style('fill', color); + $$.mainBar = mainBarEnter.merge(mainBar).style('opacity', initialOpacity); + mainBar + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); +}; +ChartInternal.prototype.redrawBar = function( + drawBar, + withTransition, + transition +) { + const $$ = this; + + return [ + (withTransition ? this.mainBar.transition(transition) : this.mainBar) + .attr('d', drawBar) + .style('stroke', this.color) + .style('fill', this.color) + .style('opacity', d => ($$.isTargetToShow(d.id) ? 1 : 0)) + ] +}; +ChartInternal.prototype.getBarW = function(axis, barTargetsNum) { + var $$ = this, + config = $$.config, + w = + typeof config.bar_width === 'number' + ? config.bar_width + : barTargetsNum + ? (axis.tickInterval() * config.bar_width_ratio) / barTargetsNum + : 0; + return config.bar_width_max && w > config.bar_width_max + ? config.bar_width_max + : w +}; +ChartInternal.prototype.getBars = function(i, id) { + var $$ = this; + return (id + ? $$.main.selectAll('.' + CLASS.bars + $$.getTargetSelectorSuffix(id)) + : $$.main + ).selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')) +}; +ChartInternal.prototype.expandBars = function(i, id, reset) { + var $$ = this; + if (reset) { + $$.unexpandBars(); + } + $$.getBars(i, id).classed(CLASS.EXPANDED, true); +}; +ChartInternal.prototype.unexpandBars = function(i) { + var $$ = this; + $$.getBars(i).classed(CLASS.EXPANDED, false); +}; +ChartInternal.prototype.generateDrawBar = function(barIndices, isSub) { + var $$ = this, + config = $$.config, + getPoints = $$.generateGetBarPoints(barIndices, isSub); + return function(d, i) { + // 4 points that make a bar + var points = getPoints(d, i); + + // switch points if axis is rotated, not applicable for sub chart + var indexX = config.axis_rotated ? 1 : 0; + var indexY = config.axis_rotated ? 0 : 1; + + var path = + 'M ' + + points[0][indexX] + + ',' + + points[0][indexY] + + ' ' + + 'L' + + points[1][indexX] + + ',' + + points[1][indexY] + + ' ' + + 'L' + + points[2][indexX] + + ',' + + points[2][indexY] + + ' ' + + 'L' + + points[3][indexX] + + ',' + + points[3][indexY] + + ' ' + + 'z'; + + return path + } +}; +ChartInternal.prototype.generateGetBarPoints = function(barIndices, isSub) { + var $$ = this, + axis = isSub ? $$.subXAxis : $$.xAxis, + barTargetsNum = barIndices.__max__ + 1, + barW = $$.getBarW(axis, barTargetsNum), + barX = $$.getShapeX(barW, barTargetsNum, barIndices, !!isSub), + barY = $$.getShapeY(!!isSub), + barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub), + barSpaceOffset = barW * ($$.config.bar_space / 2), + yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function(d, i) { + var y0 = yScale.call($$, d.id)(0), + offset = barOffset(d, i) || y0, // offset is for stacked bar chart + posX = barX(d), + posY = barY(d); + // fix posY not to overflow opposite quadrant + if ($$.config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + + posY -= y0 - offset; + + // 4 points that make a bar + return [ + [posX + barSpaceOffset, offset], + [posX + barSpaceOffset, posY], + [posX + barW - barSpaceOffset, posY], + [posX + barW - barSpaceOffset, offset] + ] + } +}; + +/** + * Returns whether the data point is within the given bar shape. + * + * @param mouse + * @param barShape + * @return {boolean} + */ +ChartInternal.prototype.isWithinBar = function(mouse, barShape) { + return isWithinBox(mouse, getBBox(barShape), 2) +}; + +ChartInternal.prototype.getShapeIndices = function(typeFilter) { + var $$ = this, + config = $$.config, + indices = {}, + i = 0, + j, + k; + $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach( + function(d) { + for (j = 0; j < config.data_groups.length; j++) { + if (config.data_groups[j].indexOf(d.id) < 0) { + continue + } + for (k = 0; k < config.data_groups[j].length; k++) { + if (config.data_groups[j][k] in indices) { + indices[d.id] = indices[config.data_groups[j][k]]; + break + } + } + } + if (isUndefined(indices[d.id])) { + indices[d.id] = i++; + } + } + ); + indices.__max__ = i - 1; + return indices +}; +ChartInternal.prototype.getShapeX = function( + offset, + targetsNum, + indices, + isSub +) { + var $$ = this, + scale = isSub ? $$.subX : $$.x; + return function(d) { + var index = d.id in indices ? indices[d.id] : 0; + return d.x || d.x === 0 ? scale(d.x) - offset * (targetsNum / 2 - index) : 0 + } +}; +ChartInternal.prototype.getShapeY = function(isSub) { + const $$ = this; + + return function(d) { + const scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id); + return scale( + $$.isTargetNormalized(d.id) ? $$.getRatio('index', d, true) : d.value + ) + } +}; +ChartInternal.prototype.getShapeOffset = function(typeFilter, indices, isSub) { + var $$ = this, + targets = $$.orderTargets( + $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)) + ), + targetIds = targets.map(function(t) { + return t.id + }); + return function(d, i) { + var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id), + y0 = scale(0), + offset = y0; + targets.forEach(function(t) { + const rowValues = $$.isStepType(d) + ? $$.convertValuesToStep(t.values) + : t.values; + const isTargetNormalized = $$.isTargetNormalized(d.id); + const values = rowValues.map(v => + isTargetNormalized ? $$.getRatio('index', v, true) : v.value + ); + + if (t.id === d.id || indices[t.id] !== indices[d.id]) { + return + } + if (targetIds.indexOf(t.id) < targetIds.indexOf(d.id)) { + // check if the x values line up + if (isUndefined(rowValues[i]) || +rowValues[i].x !== +d.x) { + // "+" for timeseries + // if not, try to find the value that does line up + i = -1; + rowValues.forEach(function(v, j) { + const x1 = v.x.constructor === Date ? +v.x : v.x; + const x2 = d.x.constructor === Date ? +d.x : d.x; + + if (x1 === x2) { + i = j; + } + }); + } + if (i in rowValues && rowValues[i].value * d.value >= 0) { + offset += scale(values[i]) - y0; + } + } + }); + return offset + } +}; +ChartInternal.prototype.isWithinShape = function(that, d) { + var $$ = this, + shape = $$.d3.select(that), + isWithin; + if (!$$.isTargetToShow(d.id)) { + isWithin = false; + } else if (that.nodeName === 'circle') { + isWithin = $$.isStepType(d) + ? $$.isWithinStep(that, $$.getYScale(d.id)(d.value)) + : $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); + } else if (that.nodeName === 'path') { + isWithin = shape.classed(CLASS.bar) + ? $$.isWithinBar($$.d3.mouse(that), that) + : true; + } + return isWithin +}; + +ChartInternal.prototype.getInterpolate = function(d) { + var $$ = this, + d3 = $$.d3, + types = { + linear: d3.curveLinear, + 'linear-closed': d3.curveLinearClosed, + basis: d3.curveBasis, + 'basis-open': d3.curveBasisOpen, + 'basis-closed': d3.curveBasisClosed, + bundle: d3.curveBundle, + cardinal: d3.curveCardinal, + 'cardinal-open': d3.curveCardinalOpen, + 'cardinal-closed': d3.curveCardinalClosed, + monotone: d3.curveMonotoneX, + step: d3.curveStep, + 'step-before': d3.curveStepBefore, + 'step-after': d3.curveStepAfter + }, + type; + + if ($$.isSplineType(d)) { + type = types[$$.config.spline_interpolation_type] || types.cardinal; + } else if ($$.isStepType(d)) { + type = types[$$.config.line_step_type]; + } else { + type = types.linear; + } + return type +}; + +ChartInternal.prototype.initLine = function() { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartLines); +}; +ChartInternal.prototype.updateTargetsForLine = function(targets) { + var $$ = this, + config = $$.config, + mainLines, + mainLineEnter, + classChartLine = $$.classChartLine.bind($$), + classLines = $$.classLines.bind($$), + classAreas = $$.classAreas.bind($$), + classCircles = $$.classCircles.bind($$), + classFocus = $$.classFocus.bind($$); + mainLines = $$.main + .select('.' + CLASS.chartLines) + .selectAll('.' + CLASS.chartLine) + .data(targets) + .attr('class', function(d) { + return classChartLine(d) + classFocus(d) + }); + mainLineEnter = mainLines + .enter() + .append('g') + .attr('class', classChartLine) + .style('opacity', 0) + .style('pointer-events', 'none'); + // Lines for each data + mainLineEnter.append('g').attr('class', classLines); + // Areas + mainLineEnter.append('g').attr('class', classAreas); + // Circles for each data point on lines + mainLineEnter.append('g').attr('class', function(d) { + return $$.generateClass(CLASS.selectedCircles, d.id) + }); + mainLineEnter + .append('g') + .attr('class', classCircles) + .style('cursor', function(d) { + return config.data_selection_isselectable(d) ? 'pointer' : null + }); + // Update date for selected circles + targets.forEach(function(t) { + $$.main + .selectAll('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(t.id)) + .selectAll('.' + CLASS.selectedCircle) + .each(function(d) { + d.value = t.values[d.index].value; + }); + }); + // MEMO: can not keep same color... + //mainLineUpdate.exit().remove(); +}; +ChartInternal.prototype.updateLine = function(durationForExit) { + var $$ = this; + var mainLine = $$.main + .selectAll('.' + CLASS.lines) + .selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + var mainLineEnter = mainLine + .enter() + .append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + $$.mainLine = mainLineEnter + .merge(mainLine) + .style('opacity', $$.initialOpacity.bind($$)) + .style('shape-rendering', function(d) { + return $$.isStepType(d) ? 'crispEdges' : '' + }) + .attr('transform', null); + mainLine + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); +}; +ChartInternal.prototype.redrawLine = function( + drawLine, + withTransition, + transition +) { + return [ + (withTransition ? this.mainLine.transition(transition) : this.mainLine) + .attr('d', drawLine) + .style('stroke', this.color) + .style('opacity', 1) + ] +}; +ChartInternal.prototype.generateDrawLine = function(lineIndices, isSub) { + var $$ = this, + config = $$.config, + line = $$.d3.line(), + getPoints = $$.generateGetLinePoints(lineIndices, isSub), + yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, + xValue = function(d) { + return (isSub ? $$.subxx : $$.xx).call($$, d) + }, + yValue = function(d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[0][1] + : yScaleGetter.call($$, d.id)(d.value) + }; + + line = config.axis_rotated + ? line.x(yValue).y(xValue) + : line.x(xValue).y(yValue); + if (!config.line_connectNull) { + line = line.defined(function(d) { + return d.value != null + }); + } + return function(d) { + var values = config.line_connectNull + ? $$.filterRemoveNull(d.values) + : d.values, + x = isSub ? $$.subX : $$.x, + y = yScaleGetter.call($$, d.id), + x0 = 0, + y0 = 0, + path; + if ($$.isLineType(d)) { + if (config.data_regions[d.id]) { + path = $$.lineWithRegions(values, x, y, config.data_regions[d.id]); + } else { + if ($$.isStepType(d)) { + values = $$.convertValuesToStep(values); + } + path = line.curve($$.getInterpolate(d))(values); + } + } else { + if (values[0]) { + x0 = x(values[0].x); + y0 = y(values[0].value); + } + path = config.axis_rotated ? 'M ' + y0 + ' ' + x0 : 'M ' + x0 + ' ' + y0; + } + return path ? path : 'M 0 0' + } +}; +ChartInternal.prototype.generateGetLinePoints = function(lineIndices, isSub) { + // partial duplication of generateGetBarPoints + var $$ = this, + config = $$.config, + lineTargetsNum = lineIndices.__max__ + 1, + x = $$.getShapeX(0, lineTargetsNum, lineIndices, !!isSub), + y = $$.getShapeY(!!isSub), + lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, !!isSub), + yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function(d, i) { + var y0 = yScale.call($$, d.id)(0), + offset = lineOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), + posY = y(d); + // fix posY not to overflow opposite quadrant + if (config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + // 1 point that marks the line position + return [ + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], // needed for compatibility + [posX, posY - (y0 - offset)], // needed for compatibility + [posX, posY - (y0 - offset)] // needed for compatibility + ] + } +}; + +ChartInternal.prototype.lineWithRegions = function(d, x, y, _regions) { + var $$ = this, + config = $$.config, + prev = -1, + i, + j, + s = 'M', + sWithRegion, + xp, + yp, + dx, + dy, + dd, + diff, + diffx2, + xOffset = $$.isCategorized() ? 0.5 : 0, + xValue, + yValue, + regions = []; + + function isWithinRegions(x, regions) { + var i; + for (i = 0; i < regions.length; i++) { + if (regions[i].start < x && x <= regions[i].end) { + return true + } + } + return false + } + + // Check start/end of regions + if (isDefined(_regions)) { + for (i = 0; i < _regions.length; i++) { + regions[i] = {}; + if (isUndefined(_regions[i].start)) { + regions[i].start = d[0].x; + } else { + regions[i].start = $$.isTimeSeries() + ? $$.parseDate(_regions[i].start) + : _regions[i].start; + } + if (isUndefined(_regions[i].end)) { + regions[i].end = d[d.length - 1].x; + } else { + regions[i].end = $$.isTimeSeries() + ? $$.parseDate(_regions[i].end) + : _regions[i].end; + } + } + } + + // Set scales + xValue = config.axis_rotated + ? function(d) { + return y(d.value) + } + : function(d) { + return x(d.x) + }; + yValue = config.axis_rotated + ? function(d) { + return x(d.x) + } + : function(d) { + return y(d.value) + }; + + // Define svg generator function for region + function generateM(points) { + return ( + 'M' + + points[0][0] + + ' ' + + points[0][1] + + ' ' + + points[1][0] + + ' ' + + points[1][1] + ) + } + if ($$.isTimeSeries()) { + sWithRegion = function(d0, d1, j, diff) { + var x0 = d0.x.getTime(), + x_diff = d1.x - d0.x, + xv0 = new Date(x0 + x_diff * j), + xv1 = new Date(x0 + x_diff * (j + diff)), + points; + if (config.axis_rotated) { + points = [ + [y(yp(j)), x(xv0)], + [y(yp(j + diff)), x(xv1)] + ]; + } else { + points = [ + [x(xv0), y(yp(j))], + [x(xv1), y(yp(j + diff))] + ]; + } + return generateM(points) + }; + } else { + sWithRegion = function(d0, d1, j, diff) { + var points; + if (config.axis_rotated) { + points = [ + [y(yp(j), true), x(xp(j))], + [y(yp(j + diff), true), x(xp(j + diff))] + ]; + } else { + points = [ + [x(xp(j), true), y(yp(j))], + [x(xp(j + diff), true), y(yp(j + diff))] + ]; + } + return generateM(points) + }; + } + + // Generate + for (i = 0; i < d.length; i++) { + // Draw as normal + if (isUndefined(regions) || !isWithinRegions(d[i].x, regions)) { + s += ' ' + xValue(d[i]) + ' ' + yValue(d[i]); + } + // Draw with region // TODO: Fix for horizotal charts + else { + xp = $$.getScale( + d[i - 1].x + xOffset, + d[i].x + xOffset, + $$.isTimeSeries() + ); + yp = $$.getScale(d[i - 1].value, d[i].value); + + dx = x(d[i].x) - x(d[i - 1].x); + dy = y(d[i].value) - y(d[i - 1].value); + dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); + diff = 2 / dd; + diffx2 = diff * 2; + + for (j = diff; j <= 1; j += diffx2) { + s += sWithRegion(d[i - 1], d[i], j, diff); + } + } + prev = d[i].x; + } + + return s +}; + +ChartInternal.prototype.updateArea = function(durationForExit) { + var $$ = this, + d3 = $$.d3; + var mainArea = $$.main + .selectAll('.' + CLASS.areas) + .selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + var mainAreaEnter = mainArea + .enter() + .append('path') + .attr('class', $$.classArea.bind($$)) + .style('fill', $$.color) + .style('opacity', function() { + $$.orgAreaOpacity = +d3.select(this).style('opacity'); + return 0 + }); + $$.mainArea = mainAreaEnter + .merge(mainArea) + .style('opacity', $$.orgAreaOpacity); + mainArea + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); +}; +ChartInternal.prototype.redrawArea = function( + drawArea, + withTransition, + transition +) { + return [ + (withTransition ? this.mainArea.transition(transition) : this.mainArea) + .attr('d', drawArea) + .style('fill', this.color) + .style('opacity', this.orgAreaOpacity) + ] +}; +ChartInternal.prototype.generateDrawArea = function(areaIndices, isSub) { + var $$ = this, + config = $$.config, + area = $$.d3.area(), + getPoints = $$.generateGetAreaPoints(areaIndices, isSub), + yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, + xValue = function(d) { + return (isSub ? $$.subxx : $$.xx).call($$, d) + }, + value0 = function(d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[0][1] + : yScaleGetter.call($$, d.id)($$.getAreaBaseValue(d.id)) + }, + value1 = function(d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[1][1] + : yScaleGetter.call($$, d.id)(d.value) + }; + + area = config.axis_rotated + ? area + .x0(value0) + .x1(value1) + .y(xValue) + : area + .x(xValue) + .y0(config.area_above ? 0 : value0) + .y1(value1); + if (!config.line_connectNull) { + area = area.defined(function(d) { + return d.value !== null + }); + } + + return function(d) { + var values = config.line_connectNull + ? $$.filterRemoveNull(d.values) + : d.values, + x0 = 0, + y0 = 0, + path; + if ($$.isAreaType(d)) { + if ($$.isStepType(d)) { + values = $$.convertValuesToStep(values); + } + path = area.curve($$.getInterpolate(d))(values); + } else { + if (values[0]) { + x0 = $$.x(values[0].x); + y0 = $$.getYScale(d.id)(values[0].value); + } + path = config.axis_rotated ? 'M ' + y0 + ' ' + x0 : 'M ' + x0 + ' ' + y0; + } + return path ? path : 'M 0 0' + } +}; +ChartInternal.prototype.getAreaBaseValue = function() { + return 0 +}; +ChartInternal.prototype.generateGetAreaPoints = function(areaIndices, isSub) { + // partial duplication of generateGetBarPoints + var $$ = this, + config = $$.config, + areaTargetsNum = areaIndices.__max__ + 1, + x = $$.getShapeX(0, areaTargetsNum, areaIndices, !!isSub), + y = $$.getShapeY(!!isSub), + areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, !!isSub), + yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function(d, i) { + var y0 = yScale.call($$, d.id)(0), + offset = areaOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), + posY = y(d); + // fix posY not to overflow opposite quadrant + if (config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + // 1 point that marks the area position + return [ + [posX, offset], + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], // needed for compatibility + [posX, offset] // needed for compatibility + ] + } +}; + +ChartInternal.prototype.updateCircle = function(cx, cy) { + var $$ = this; + var mainCircle = $$.main + .selectAll('.' + CLASS.circles) + .selectAll('.' + CLASS.circle) + .data($$.lineOrScatterOrStanfordData.bind($$)); + + var mainCircleEnter = mainCircle + .enter() + .append('circle') + .attr('shape-rendering', $$.isStanfordGraphType() ? 'crispEdges' : '') + .attr('class', $$.classCircle.bind($$)) + .attr('cx', cx) + .attr('cy', cy) + .attr('r', $$.pointR.bind($$)) + .style( + 'color', + $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color + ); + + $$.mainCircle = mainCircleEnter + .merge(mainCircle) + .style( + 'opacity', + $$.isStanfordGraphType() ? 1 : $$.initialOpacityForCircle.bind($$) + ); + + mainCircle.exit().style('opacity', 0); +}; +ChartInternal.prototype.redrawCircle = function( + cx, + cy, + withTransition, + transition +) { + var $$ = this, + selectedCircles = $$.main.selectAll('.' + CLASS.selectedCircle); + return [ + (withTransition ? $$.mainCircle.transition(transition) : $$.mainCircle) + .style('opacity', this.opacityForCircle.bind($$)) + .style( + 'color', + $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color + ) + .attr('cx', cx) + .attr('cy', cy), + (withTransition ? selectedCircles.transition(transition) : selectedCircles) + .attr('cx', cx) + .attr('cy', cy) + ] +}; +ChartInternal.prototype.circleX = function(d) { + return d.x || d.x === 0 ? this.x(d.x) : null +}; +ChartInternal.prototype.updateCircleY = function() { + var $$ = this, + lineIndices, + getPoints; + if ($$.config.data_groups.length > 0) { +(lineIndices = $$.getShapeIndices($$.isLineType)), + (getPoints = $$.generateGetLinePoints(lineIndices)); + $$.circleY = function(d, i) { + return getPoints(d, i)[0][1] + }; + } else { + $$.circleY = function(d) { + return $$.getYScale(d.id)(d.value) + }; + } +}; +ChartInternal.prototype.getCircles = function(i, id) { + var $$ = this; + return (id + ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) + : $$.main + ).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')) +}; +ChartInternal.prototype.expandCircles = function(i, id, reset) { + var $$ = this, + r = $$.pointExpandedR.bind($$); + if (reset) { + $$.unexpandCircles(); + } + $$.getCircles(i, id) + .classed(CLASS.EXPANDED, true) + .attr('r', r); +}; +ChartInternal.prototype.unexpandCircles = function(i) { + var $$ = this, + r = $$.pointR.bind($$); + $$.getCircles(i) + .filter(function() { + return $$.d3.select(this).classed(CLASS.EXPANDED) + }) + .classed(CLASS.EXPANDED, false) + .attr('r', r); +}; +ChartInternal.prototype.pointR = function(d) { + var $$ = this, + config = $$.config; + return $$.isStepType(d) + ? 0 + : isFunction(config.point_r) + ? config.point_r(d) + : config.point_r +}; +ChartInternal.prototype.pointExpandedR = function(d) { + var $$ = this, + config = $$.config; + if (config.point_focus_expand_enabled) { + return isFunction(config.point_focus_expand_r) + ? config.point_focus_expand_r(d) + : config.point_focus_expand_r + ? config.point_focus_expand_r + : $$.pointR(d) * 1.75 + } else { + return $$.pointR(d) + } +}; +ChartInternal.prototype.pointSelectR = function(d) { + var $$ = this, + config = $$.config; + return isFunction(config.point_select_r) + ? config.point_select_r(d) + : config.point_select_r + ? config.point_select_r + : $$.pointR(d) * 4 +}; +ChartInternal.prototype.isWithinCircle = function(that, r) { + var d3 = this.d3, + mouse = d3.mouse(that), + d3_this = d3.select(that), + cx = +d3_this.attr('cx'), + cy = +d3_this.attr('cy'); + return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < r +}; +ChartInternal.prototype.isWithinStep = function(that, y) { + return Math.abs(y - this.d3.mouse(that)[1]) < 30 +}; + +ChartInternal.prototype.getCurrentWidth = function() { + var $$ = this, + config = $$.config; + return config.size_width ? config.size_width : $$.getParentWidth() +}; +ChartInternal.prototype.getCurrentHeight = function() { + var $$ = this, + config = $$.config, + h = config.size_height ? config.size_height : $$.getParentHeight(); + return h > 0 + ? h + : 320 / ($$.hasType('gauge') && !config.gauge_fullCircle ? 2 : 1) +}; +ChartInternal.prototype.getCurrentPaddingTop = function() { + var $$ = this, + config = $$.config, + padding = isValue(config.padding_top) ? config.padding_top : 0; + if ($$.title && $$.title.node()) { + padding += $$.getTitlePadding(); + } + return padding +}; +ChartInternal.prototype.getCurrentPaddingBottom = function() { + var config = this.config; + return isValue(config.padding_bottom) ? config.padding_bottom : 0 +}; +ChartInternal.prototype.getCurrentPaddingLeft = function(withoutRecompute) { + var $$ = this, + config = $$.config; + if (isValue(config.padding_left)) { + return config.padding_left + } else if (config.axis_rotated) { + return !config.axis_x_show || config.axis_x_inner + ? 1 + : Math.max(ceil10($$.getAxisWidthByAxisId('x', withoutRecompute)), 40) + } else if (!config.axis_y_show || config.axis_y_inner) { + // && !config.axis_rotated + return $$.axis.getYAxisLabelPosition().isOuter ? 30 : 1 + } else { + return ceil10($$.getAxisWidthByAxisId('y', withoutRecompute)) + } +}; +ChartInternal.prototype.getCurrentPaddingRight = function() { + var $$ = this, + config = $$.config, + padding = 0, + defaultPadding = 10, + legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0; + + if (isValue(config.padding_right)) { + padding = config.padding_right + 1; // 1 is needed not to hide tick line + } else if (config.axis_rotated) { + padding = defaultPadding + legendWidthOnRight; + } else if (!config.axis_y2_show || config.axis_y2_inner) { + // && !config.axis_rotated + padding = + 2 + + legendWidthOnRight + + ($$.axis.getY2AxisLabelPosition().isOuter ? 20 : 0); + } else { + padding = ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight; + } + + if ($$.colorScale && $$.colorScale.node()) { + padding += $$.getColorScalePadding(); + } + + return padding +}; + +ChartInternal.prototype.getParentRectValue = function(key) { + var parent = this.selectChart.node(), + v; + while (parent && parent.tagName !== 'BODY') { + try { + v = parent.getBoundingClientRect()[key]; + } catch (e) { + if (key === 'width') { + // In IE in certain cases getBoundingClientRect + // will cause an "unspecified error" + v = parent.offsetWidth; + } + } + if (v) { + break + } + parent = parent.parentNode; + } + return v +}; +ChartInternal.prototype.getParentWidth = function() { + return this.getParentRectValue('width') +}; +ChartInternal.prototype.getParentHeight = function() { + var h = this.selectChart.style('height'); + return h.indexOf('px') > 0 ? +h.replace('px', '') : 0 +}; + +ChartInternal.prototype.getSvgLeft = function(withoutRecompute) { + var $$ = this, + config = $$.config, + hasLeftAxisRect = + config.axis_rotated || (!config.axis_rotated && !config.axis_y_inner), + leftAxisClass = config.axis_rotated ? CLASS.axisX : CLASS.axisY, + leftAxis = $$.main.select('.' + leftAxisClass).node(), + svgRect = + leftAxis && hasLeftAxisRect + ? leftAxis.getBoundingClientRect() + : { right: 0 }, + chartRect = $$.selectChart.node().getBoundingClientRect(), + hasArc = $$.hasArcType(), + svgLeft = + svgRect.right - + chartRect.left - + (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute)); + return svgLeft > 0 ? svgLeft : 0 +}; + +ChartInternal.prototype.getAxisWidthByAxisId = function(id, withoutRecompute) { + var $$ = this, + position = $$.axis.getLabelPositionById(id); + return ( + $$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40) + ) +}; +ChartInternal.prototype.getHorizontalAxisHeight = function(axisId) { + var $$ = this, + config = $$.config, + h = 30; + if (axisId === 'x' && !config.axis_x_show) { + return 8 + } + if (axisId === 'x' && config.axis_x_height) { + return config.axis_x_height + } + if (axisId === 'y' && !config.axis_y_show) { + return config.legend_show && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1 + } + if (axisId === 'y2' && !config.axis_y2_show) { + return $$.rotated_padding_top + } + // Calculate x axis height when tick rotated + if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) { + h = + 30 + + $$.axis.getMaxTickWidth(axisId) * + Math.cos((Math.PI * (90 - Math.abs(config.axis_x_tick_rotate))) / 180); + } + // Calculate y axis height when tick rotated + if (axisId === 'y' && config.axis_rotated && config.axis_y_tick_rotate) { + h = + 30 + + $$.axis.getMaxTickWidth(axisId) * + Math.cos((Math.PI * (90 - Math.abs(config.axis_y_tick_rotate))) / 180); + } + return ( + h + + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + + (axisId === 'y2' ? -10 : 0) + ) +}; + +ChartInternal.prototype.initBrush = function(scale) { + var $$ = this, + d3 = $$.d3; + // TODO: dynamically change brushY/brushX according to axis_rotated. + $$.brush = ($$.config.axis_rotated ? d3.brushY() : d3.brushX()) + .on('brush', function() { + var event = d3.event.sourceEvent; + if (event && event.type === 'zoom') { + return + } + $$.redrawForBrush(); + }) + .on('end', function() { + var event = d3.event.sourceEvent; + if (event && event.type === 'zoom') { + return + } + if ($$.brush.empty() && event && event.type !== 'end') { + $$.brush.clear(); + } + }); + $$.brush.updateExtent = function() { + var range = this.scale.range(), + extent; + if ($$.config.axis_rotated) { + extent = [ + [0, range[0]], + [$$.width2, range[1]] + ]; + } else { + extent = [ + [range[0], 0], + [range[1], $$.height2] + ]; + } + this.extent(extent); + return this + }; + $$.brush.updateScale = function(scale) { + this.scale = scale; + return this + }; + $$.brush.update = function(scale) { + this.updateScale(scale || $$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call(this); + }; + $$.brush.clear = function() { + $$.context.select('.' + CLASS.brush).call($$.brush.move, null); + }; + $$.brush.selection = function() { + return d3.brushSelection($$.context.select('.' + CLASS.brush).node()) + }; + $$.brush.selectionAsValue = function(selectionAsValue, withTransition) { + var selection, brush; + if (selectionAsValue) { + if ($$.context) { + selection = [ + this.scale(selectionAsValue[0]), + this.scale(selectionAsValue[1]) + ]; + brush = $$.context.select('.' + CLASS.brush); + if (withTransition) { + brush = brush.transition(); + } + $$.brush.move(brush, selection); + } + return [] + } + selection = $$.brush.selection() || [0, 0]; + return [this.scale.invert(selection[0]), this.scale.invert(selection[1])] + }; + $$.brush.empty = function() { + var selection = $$.brush.selection(); + return !selection || selection[0] === selection[1] + }; + return $$.brush.updateScale(scale) +}; +ChartInternal.prototype.initSubchart = function() { + var $$ = this, + config = $$.config, + context = ($$.context = $$.svg + .append('g') + .attr('transform', $$.getTranslate('context'))); + + // set style + context.style('visibility', 'visible'); + + // Define g for chart area + context + .append('g') + .attr('clip-path', $$.clipPathForSubchart) + .attr('class', CLASS.chart); + + // Define g for bar chart area + context + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartBars); + + // Define g for line chart area + context + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartLines); + + // Add extent rect for Brush + context + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.brush); + + // ATTENTION: This must be called AFTER chart added + // Add Axis + $$.axes.subx = context + .append('g') + .attr('class', CLASS.axisX) + .attr('transform', $$.getTranslate('subx')) + .attr('clip-path', config.axis_rotated ? '' : $$.clipPathForXAxis); +}; +ChartInternal.prototype.initSubchartBrush = function() { + var $$ = this; + // Add extent rect for Brush + $$.initBrush($$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call($$.brush); +}; +ChartInternal.prototype.updateTargetsForSubchart = function(targets) { + var $$ = this, + context = $$.context, + config = $$.config, + contextLineEnter, + contextLine, + contextBarEnter, + contextBar, + classChartBar = $$.classChartBar.bind($$), + classBars = $$.classBars.bind($$), + classChartLine = $$.classChartLine.bind($$), + classLines = $$.classLines.bind($$), + classAreas = $$.classAreas.bind($$); + + //-- Bar --// + contextBar = context + .select('.' + CLASS.chartBars) + .selectAll('.' + CLASS.chartBar) + .data(targets); + contextBarEnter = contextBar + .enter() + .append('g') + .style('opacity', 0); + contextBarEnter.merge(contextBar).attr('class', classChartBar); + // Bars for each data + contextBarEnter.append('g').attr('class', classBars); + + //-- Line --// + contextLine = context + .select('.' + CLASS.chartLines) + .selectAll('.' + CLASS.chartLine) + .data(targets); + contextLineEnter = contextLine + .enter() + .append('g') + .style('opacity', 0); + contextLineEnter.merge(contextLine).attr('class', classChartLine); + // Lines for each data + contextLineEnter.append('g').attr('class', classLines); + // Area + contextLineEnter.append('g').attr('class', classAreas); + + //-- Brush --// + context + .selectAll('.' + CLASS.brush + ' rect') + .attr( + config.axis_rotated ? 'width' : 'height', + config.axis_rotated ? $$.width2 : $$.height2 + ); +}; +ChartInternal.prototype.updateBarForSubchart = function(durationForExit) { + var $$ = this; + var contextBar = $$.context + .selectAll('.' + CLASS.bars) + .selectAll('.' + CLASS.bar) + .data($$.barData.bind($$)); + var contextBarEnter = contextBar + .enter() + .append('path') + .attr('class', $$.classBar.bind($$)) + .style('stroke', 'none') + .style('fill', $$.color); + contextBar + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextBar = contextBarEnter + .merge(contextBar) + .style('opacity', $$.initialOpacity.bind($$)); +}; +ChartInternal.prototype.redrawBarForSubchart = function( + drawBarOnSub, + withTransition, + duration +) { +(withTransition + ? this.contextBar.transition(Math.random().toString()).duration(duration) + : this.contextBar + ) + .attr('d', drawBarOnSub) + .style('opacity', 1); +}; +ChartInternal.prototype.updateLineForSubchart = function(durationForExit) { + var $$ = this; + var contextLine = $$.context + .selectAll('.' + CLASS.lines) + .selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + var contextLineEnter = contextLine + .enter() + .append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + contextLine + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextLine = contextLineEnter + .merge(contextLine) + .style('opacity', $$.initialOpacity.bind($$)); +}; +ChartInternal.prototype.redrawLineForSubchart = function( + drawLineOnSub, + withTransition, + duration +) { +(withTransition + ? this.contextLine.transition(Math.random().toString()).duration(duration) + : this.contextLine + ) + .attr('d', drawLineOnSub) + .style('opacity', 1); +}; +ChartInternal.prototype.updateAreaForSubchart = function(durationForExit) { + var $$ = this, + d3 = $$.d3; + var contextArea = $$.context + .selectAll('.' + CLASS.areas) + .selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + var contextAreaEnter = contextArea + .enter() + .append('path') + .attr('class', $$.classArea.bind($$)) + .style('fill', $$.color) + .style('opacity', function() { + $$.orgAreaOpacity = +d3.select(this).style('opacity'); + return 0 + }); + contextArea + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextArea = contextAreaEnter.merge(contextArea).style('opacity', 0); +}; +ChartInternal.prototype.redrawAreaForSubchart = function( + drawAreaOnSub, + withTransition, + duration +) { +(withTransition + ? this.contextArea.transition(Math.random().toString()).duration(duration) + : this.contextArea + ) + .attr('d', drawAreaOnSub) + .style('fill', this.color) + .style('opacity', this.orgAreaOpacity); +}; +ChartInternal.prototype.redrawSubchart = function( + withSubchart, + transitions, + duration, + durationForExit, + areaIndices, + barIndices, + lineIndices +) { + var $$ = this, + d3 = $$.d3, + drawAreaOnSub, + drawBarOnSub, + drawLineOnSub; + + // reflect main chart to extent on subchart if zoomed + if (d3.event && d3.event.type === 'zoom') { + $$.brush.selectionAsValue($$.x.orgDomain()); + } + // update subchart elements if needed + if (withSubchart) { + // extent rect + if (!$$.brush.empty()) { + $$.brush.selectionAsValue($$.x.orgDomain()); + } + // setup drawer - MEMO: this must be called after axis updated + drawAreaOnSub = $$.generateDrawArea(areaIndices, true); + drawBarOnSub = $$.generateDrawBar(barIndices, true); + drawLineOnSub = $$.generateDrawLine(lineIndices, true); + + $$.updateBarForSubchart(duration); + $$.updateLineForSubchart(duration); + $$.updateAreaForSubchart(duration); + + $$.redrawBarForSubchart(drawBarOnSub, duration, duration); + $$.redrawLineForSubchart(drawLineOnSub, duration, duration); + $$.redrawAreaForSubchart(drawAreaOnSub, duration, duration); + } +}; +ChartInternal.prototype.redrawForBrush = function() { + var $$ = this, + x = $$.x, + d3 = $$.d3, + s; + $$.redraw({ + withTransition: false, + withY: $$.config.zoom_rescale, + withSubchart: false, + withUpdateXDomain: true, + withEventRect: false, + withDimension: false + }); + // update zoom transation binded to event rect + s = d3.event.selection || $$.brush.scale.range(); + $$.main + .select('.' + CLASS.eventRect) + .call( + $$.zoom.transform, + d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0) + ); + $$.config.subchart_onbrush.call($$.api, x.orgDomain()); +}; +ChartInternal.prototype.transformContext = function( + withTransition, + transitions +) { + var $$ = this, + subXAxis; + if (transitions && transitions.axisSubX) { + subXAxis = transitions.axisSubX; + } else { + subXAxis = $$.context.select('.' + CLASS.axisX); + if (withTransition) { + subXAxis = subXAxis.transition(); + } + } + $$.context.attr('transform', $$.getTranslate('context')); + subXAxis.attr('transform', $$.getTranslate('subx')); +}; +ChartInternal.prototype.getDefaultSelection = function() { + var $$ = this, + config = $$.config, + selection = isFunction(config.axis_x_selection) + ? config.axis_x_selection($$.getXDomain($$.data.targets)) + : config.axis_x_selection; + if ($$.isTimeSeries()) { + selection = [$$.parseDate(selection[0]), $$.parseDate(selection[1])]; + } + return selection +}; + +ChartInternal.prototype.removeSubchart = function() { + const $$ = this; + + $$.brush = null; + $$.context.remove(); + $$.context = null; +}; + +ChartInternal.prototype.initText = function() { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartTexts); + $$.mainText = $$.d3.selectAll([]); +}; +ChartInternal.prototype.updateTargetsForText = function(targets) { + var $$ = this, + classChartText = $$.classChartText.bind($$), + classTexts = $$.classTexts.bind($$), + classFocus = $$.classFocus.bind($$); + var mainText = $$.main + .select('.' + CLASS.chartTexts) + .selectAll('.' + CLASS.chartText) + .data(targets); + var mainTextEnter = mainText + .enter() + .append('g') + .attr('class', classChartText) + .style('opacity', 0) + .style('pointer-events', 'none'); + mainTextEnter.append('g').attr('class', classTexts); + mainTextEnter.merge(mainText).attr('class', function(d) { + return classChartText(d) + classFocus(d) + }); +}; +ChartInternal.prototype.updateText = function( + xForText, + yForText, + durationForExit +) { + var $$ = this, + config = $$.config, + barOrLineData = $$.barOrLineData.bind($$), + classText = $$.classText.bind($$); + var mainText = $$.main + .selectAll('.' + CLASS.texts) + .selectAll('.' + CLASS.text) + .data(barOrLineData); + var mainTextEnter = mainText + .enter() + .append('text') + .attr('class', classText) + .attr('text-anchor', function(d) { + return config.axis_rotated ? (d.value < 0 ? 'end' : 'start') : 'middle' + }) + .style('stroke', 'none') + .attr('x', xForText) + .attr('y', yForText) + .style('fill', function(d) { + return $$.color(d) + }) + .style('fill-opacity', 0); + $$.mainText = mainTextEnter.merge(mainText).text(function(d, i, j) { + return $$.dataLabelFormat(d.id)(d.value, d.id, i, j) + }); + mainText + .exit() + .transition() + .duration(durationForExit) + .style('fill-opacity', 0) + .remove(); +}; +ChartInternal.prototype.redrawText = function( + xForText, + yForText, + forFlow, + withTransition, + transition +) { + return [ + (withTransition ? this.mainText.transition(transition) : this.mainText) + .attr('x', xForText) + .attr('y', yForText) + .style('fill', this.color) + .style('fill-opacity', forFlow ? 0 : this.opacityForText.bind(this)) + ] +}; +ChartInternal.prototype.getTextRect = function(text, cls, element) { + var dummy = this.d3 + .select('body') + .append('div') + .classed('c3', true), + svg = dummy + .append('svg') + .style('visibility', 'hidden') + .style('position', 'fixed') + .style('top', 0) + .style('left', 0), + font = this.d3.select(element).style('font'), + rect; + svg + .selectAll('.dummy') + .data([text]) + .enter() + .append('text') + .classed(cls ? cls : '', true) + .style('font', font) + .text(text) + .each(function() { + rect = getBBox(this); + }); + dummy.remove(); + return rect +}; +ChartInternal.prototype.generateXYForText = function( + areaIndices, + barIndices, + lineIndices, + forX +) { + var $$ = this, + getAreaPoints = $$.generateGetAreaPoints(areaIndices, false), + getBarPoints = $$.generateGetBarPoints(barIndices, false), + getLinePoints = $$.generateGetLinePoints(lineIndices, false), + getter = forX ? $$.getXForText : $$.getYForText; + return function(d, i) { + var getPoints = $$.isAreaType(d) + ? getAreaPoints + : $$.isBarType(d) + ? getBarPoints + : getLinePoints; + return getter.call($$, getPoints(d, i), d, this) + } +}; +ChartInternal.prototype.getXForText = function(points, d, textElement) { + var $$ = this, + box = getBBox(textElement), + xPos, + padding; + if ($$.config.axis_rotated) { + padding = $$.isBarType(d) ? 4 : 6; + xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1); + } else { + xPos = $$.hasType('bar') ? (points[2][0] + points[0][0]) / 2 : points[0][0]; + } + // show labels regardless of the domain if value is null + if (d.value === null) { + if (xPos > $$.width) { + xPos = $$.width - box.width; + } else if (xPos < 0) { + xPos = 4; + } + } + return xPos +}; +ChartInternal.prototype.getYForText = function(points, d, textElement) { + var $$ = this, + box = getBBox(textElement), + yPos; + if ($$.config.axis_rotated) { + yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2; + } else { + yPos = points[2][1]; + if (d.value < 0 || (d.value === 0 && !$$.hasPositiveValue)) { + yPos += box.height; + if ($$.isBarType(d) && $$.isSafari()) { + yPos -= 3; + } else if (!$$.isBarType(d) && $$.isChrome()) { + yPos += 3; + } + } else { + yPos += $$.isBarType(d) ? -3 : -6; + } + } + // show labels regardless of the domain if value is null + if (d.value === null && !$$.config.axis_rotated) { + if (yPos < box.height) { + yPos = box.height; + } else if (yPos > this.height) { + yPos = this.height - 4; + } + } + return yPos +}; + +ChartInternal.prototype.initTitle = function() { + var $$ = this; + $$.title = $$.svg + .append('text') + .text($$.config.title_text) + .attr('class', $$.CLASS.title); +}; +ChartInternal.prototype.redrawTitle = function() { + var $$ = this; + $$.title.attr('x', $$.xForTitle.bind($$)).attr('y', $$.yForTitle.bind($$)); +}; +ChartInternal.prototype.xForTitle = function() { + var $$ = this, + config = $$.config, + position = config.title_position || 'left', + x; + if (position.indexOf('right') >= 0) { + x = + $$.currentWidth - + $$.getTextRect( + $$.title.node().textContent, + $$.CLASS.title, + $$.title.node() + ).width - + config.title_padding.right; + } else if (position.indexOf('center') >= 0) { + x = Math.max( + ($$.currentWidth - + $$.getTextRect( + $$.title.node().textContent, + $$.CLASS.title, + $$.title.node() + ).width) / + 2, + 0 + ); + } else { + // left + x = config.title_padding.left; + } + return x +}; +ChartInternal.prototype.yForTitle = function() { + var $$ = this; + return ( + $$.config.title_padding.top + + $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()) + .height + ) +}; +ChartInternal.prototype.getTitlePadding = function() { + var $$ = this; + return $$.yForTitle() + $$.config.title_padding.bottom +}; + +function powerOfTen(d) { + return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1 +} + +ChartInternal.prototype.drawColorScale = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config, + target = $$.data.targets[0], + barWidth, + barHeight, + axis, + points, + legendAxis, + axisScale, + inverseScale, + height; + + barWidth = !isNaN(config.stanford_scaleWidth) + ? config.stanford_scaleWidth + : 20; + barHeight = 5; + + if (barHeight < 0 || barWidth < 0) { + throw Error("Colorscale's barheight and barwidth must be greater than 0.") + } + + height = + $$.height - config.stanford_padding.bottom - config.stanford_padding.top; + + points = d3.range(config.stanford_padding.bottom, height, barHeight); + + inverseScale = d3 + .scaleSequential(target.colors) + .domain([points[points.length - 1], points[0]]); + + if ($$.colorScale) { + $$.colorScale.remove(); + } + + $$.colorScale = $$.svg + .append('g') + .attr('width', 50) + .attr('height', height) + .attr('class', CLASS.colorScale); + + $$.colorScale + .append('g') + .attr('transform', `translate(0, ${config.stanford_padding.top})`) + .selectAll('bars') + .data(points) + .enter() + .append('rect') + .attr('y', (d, i) => i * barHeight) + .attr('x', 0) + .attr('width', barWidth) + .attr('height', barHeight) + .attr('fill', function(d) { + return inverseScale(d) + }); + + // Legend Axis + axisScale = d3 + .scaleLog() + .domain([target.minEpochs, target.maxEpochs]) + .range([ + points[0] + + config.stanford_padding.top + + points[points.length - 1] + + barHeight - + 1, + points[0] + config.stanford_padding.top + ]); + + legendAxis = d3.axisRight(axisScale); + + if (config.stanford_scaleFormat === 'pow10') { + legendAxis.tickValues([1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]); + } else if (isFunction(config.stanford_scaleFormat)) { + legendAxis.tickFormat(config.stanford_scaleFormat); + } else { + legendAxis.tickFormat(d3.format('d')); + } + + if (isFunction(config.stanford_scaleValues)) { + legendAxis.tickValues( + config.stanford_scaleValues(target.minEpochs, target.maxEpochs) + ); + } + + // Draw Axis + axis = $$.colorScale + .append('g') + .attr('class', 'legend axis') + .attr('transform', `translate(${barWidth},0)`) + .call(legendAxis); + + if (config.stanford_scaleFormat === 'pow10') { + axis + .selectAll('.tick text') + .text(null) + .filter(powerOfTen) + .text(10) + .append('tspan') + .attr('dy', '-.7em') // https://bl.ocks.org/mbostock/6738229 + .text(function(d) { + return Math.round(Math.log(d) / Math.LN10) + }); + } + + $$.colorScale.attr( + 'transform', + `translate(${$$.currentWidth - $$.xForColorScale()}, 0)` + ); +}; + +ChartInternal.prototype.xForColorScale = function() { + var $$ = this; + + return $$.config.stanford_padding.right + getBBox($$.colorScale.node()).width +}; + +ChartInternal.prototype.getColorScalePadding = function() { + var $$ = this; + return $$.xForColorScale() + $$.config.stanford_padding.left + 20 +}; + +ChartInternal.prototype.isStanfordGraphType = function() { + var $$ = this; + + return $$.config.data_type === 'stanford' +}; + +ChartInternal.prototype.initStanfordData = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config, + target = $$.data.targets[0], + epochs, + maxEpochs, + minEpochs; + + // Make larger values appear on top + target.values.sort(compareEpochs); + + // Get array of epochs + epochs = target.values.map(a => a.epochs); + + minEpochs = !isNaN(config.stanford_scaleMin) + ? config.stanford_scaleMin + : d3.min(epochs); + maxEpochs = !isNaN(config.stanford_scaleMax) + ? config.stanford_scaleMax + : d3.max(epochs); + + if (minEpochs > maxEpochs) { + throw Error('Number of minEpochs has to be smaller than maxEpochs') + } + + target.colors = isFunction(config.stanford_colors) + ? config.stanford_colors + : d3.interpolateHslLong(d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)); + + target.colorscale = d3 + .scaleSequentialLog(target.colors) + .domain([minEpochs, maxEpochs]); + + target.minEpochs = minEpochs; + target.maxEpochs = maxEpochs; +}; + +ChartInternal.prototype.getStanfordPointColor = function(d) { + var $$ = this, + target = $$.data.targets[0]; + + return target.colorscale(d.epochs) +}; + +// http://jsfiddle.net/Xotic750/KtzLq/ +ChartInternal.prototype.getCentroid = function(points) { + var area = getRegionArea(points); + + var x = 0, + y = 0, + i, + j, + f, + point1, + point2; + + for (i = 0, j = points.length - 1; i < points.length; j = i, i += 1) { + point1 = points[i]; + point2 = points[j]; + f = point1.x * point2.y - point2.x * point1.y; + x += (point1.x + point2.x) * f; + y += (point1.y + point2.y) * f; + } + + f = area * 6; + + return { + x: x / f, + y: y / f + } +}; + +ChartInternal.prototype.getStanfordTooltipTitle = function(d) { + var $$ = this, + labelX = $$.axis.getLabelText('x'), + labelY = $$.axis.getLabelText('y'); + + return ` + ${labelX ? sanitise(labelX) : 'x'}${ + d.x + } + ${labelY ? sanitise(labelY) : 'y'}${ + d.value + } + ` +}; + +ChartInternal.prototype.countEpochsInRegion = function(region) { + var $$ = this, + target = $$.data.targets[0], + total, + count; + + total = target.values.reduce( + (accumulator, currentValue) => accumulator + Number(currentValue.epochs), + 0 + ); + + count = target.values.reduce((accumulator, currentValue) => { + if (pointInRegion(currentValue, region)) { + return accumulator + Number(currentValue.epochs) + } + + return accumulator + }, 0); + + return { + value: count, + percentage: count !== 0 ? ((count / total) * 100).toFixed(1) : 0 + } +}; + +var getRegionArea = function(points) { + // thanks to: https://stackoverflow.com/questions/16282330/find-centerpoint-of-polygon-in-javascript + var area = 0, + i, + j, + point1, + point2; + + for (i = 0, j = points.length - 1; i < points.length; j = i, i += 1) { + point1 = points[i]; + point2 = points[j]; + area += point1.x * point2.y; + area -= point1.y * point2.x; + } + + area /= 2; + + return area +}; + +var pointInRegion = function(point, region) { + // thanks to: http://bl.ocks.org/bycoffe/5575904 + // ray-casting algorithm based on + // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html + let xi, + yi, + yj, + xj, + intersect, + x = point.x, + y = point.value, + inside = false; + + for (let i = 0, j = region.length - 1; i < region.length; j = i++) { + xi = region[i].x; + yi = region[i].y; + + xj = region[j].x; + yj = region[j].y; + + intersect = yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi; + + if (intersect) { + inside = !inside; + } + } + + return inside +}; + +var compareEpochs = function(a, b) { + if (a.epochs < b.epochs) { + return -1 + } + if (a.epochs > b.epochs) { + return 1 + } + + return 0 +}; + +ChartInternal.prototype.initStanfordElements = function() { + var $$ = this; + + // Avoid blocking eventRect + $$.stanfordElements = $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.stanfordElements); + + $$.stanfordElements.append('g').attr('class', CLASS.stanfordLines); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordTexts); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordRegions); +}; + +ChartInternal.prototype.updateStanfordElements = function(duration) { + var $$ = this, + main = $$.main, + config = $$.config, + stanfordLine, + stanfordLineEnter, + stanfordRegion, + stanfordRegionEnter, + stanfordText, + stanfordTextEnter, + xvCustom = $$.xvCustom.bind($$), + yvCustom = $$.yvCustom.bind($$), + countPointsInRegion = $$.countEpochsInRegion.bind($$); + + // Stanford-Lines + stanfordLine = main + .select('.' + CLASS.stanfordLines) + .style('shape-rendering', 'geometricprecision') + .selectAll('.' + CLASS.stanfordLine) + .data(config.stanford_lines); + + // enter + stanfordLineEnter = stanfordLine + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.stanfordLine + (d['class'] ? ' ' + d['class'] : '') + }); + stanfordLineEnter + .append('line') + .attr('x1', d => + config.axis_rotated ? yvCustom(d, 'value_y1') : xvCustom(d, 'value_x1') + ) + .attr('x2', d => + config.axis_rotated ? yvCustom(d, 'value_y2') : xvCustom(d, 'value_x2') + ) + .attr('y1', d => + config.axis_rotated ? xvCustom(d, 'value_x1') : yvCustom(d, 'value_y1') + ) + .attr('y2', d => + config.axis_rotated ? xvCustom(d, 'value_x2') : yvCustom(d, 'value_y2') + ) + .style('opacity', 0); + + // update + $$.stanfordLines = stanfordLineEnter.merge(stanfordLine); + $$.stanfordLines + .select('line') + .transition() + .duration(duration) + .attr('x1', d => + config.axis_rotated ? yvCustom(d, 'value_y1') : xvCustom(d, 'value_x1') + ) + .attr('x2', d => + config.axis_rotated ? yvCustom(d, 'value_y2') : xvCustom(d, 'value_x2') + ) + .attr('y1', d => + config.axis_rotated ? xvCustom(d, 'value_x1') : yvCustom(d, 'value_y1') + ) + .attr('y2', d => + config.axis_rotated ? xvCustom(d, 'value_x2') : yvCustom(d, 'value_y2') + ) + .style('opacity', 1); + + // exit + stanfordLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + + // Stanford-Text + stanfordText = main + .select('.' + CLASS.stanfordTexts) + .selectAll('.' + CLASS.stanfordText) + .data(config.stanford_texts); + + // enter + stanfordTextEnter = stanfordText + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.stanfordText + (d['class'] ? ' ' + d['class'] : '') + }); + stanfordTextEnter + .append('text') + .attr('x', d => (config.axis_rotated ? yvCustom(d, 'y') : xvCustom(d, 'x'))) + .attr('y', d => (config.axis_rotated ? xvCustom(d, 'x') : yvCustom(d, 'y'))) + .style('opacity', 0); + + // update + $$.stanfordTexts = stanfordTextEnter.merge(stanfordText); + $$.stanfordTexts + .select('text') + .transition() + .duration(duration) + .attr('x', d => (config.axis_rotated ? yvCustom(d, 'y') : xvCustom(d, 'x'))) + .attr('y', d => (config.axis_rotated ? xvCustom(d, 'x') : yvCustom(d, 'y'))) + .text(function(d) { + return d.content + }) + .style('opacity', 1); + + // exit + stanfordText + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + + // Stanford-Regions + stanfordRegion = main + .select('.' + CLASS.stanfordRegions) + .selectAll('.' + CLASS.stanfordRegion) + .data(config.stanford_regions); + + // enter + stanfordRegionEnter = stanfordRegion + .enter() + .append('g') + .attr('class', function(d) { + return CLASS.stanfordRegion + (d['class'] ? ' ' + d['class'] : '') + }); + stanfordRegionEnter + .append('polygon') + .attr('points', d => { + return d.points + .map(value => { + return [ + config.axis_rotated ? yvCustom(value, 'y') : xvCustom(value, 'x'), + config.axis_rotated ? xvCustom(value, 'x') : yvCustom(value, 'y') + ].join(',') + }) + .join(' ') + }) + .style('opacity', 0); + stanfordRegionEnter + .append('text') + .attr('x', d => $$.getCentroid(d.points).x) + .attr('y', d => $$.getCentroid(d.points).y) + .style('opacity', 0); + + // update + $$.stanfordRegions = stanfordRegionEnter.merge(stanfordRegion); + $$.stanfordRegions + .select('polygon') + .transition() + .duration(duration) + .attr('points', d => { + return d.points + .map(value => { + return [ + config.axis_rotated ? yvCustom(value, 'y') : xvCustom(value, 'x'), + config.axis_rotated ? xvCustom(value, 'x') : yvCustom(value, 'y') + ].join(',') + }) + .join(' ') + }) + .style('opacity', d => { + return d.opacity ? d.opacity : 0.2 + }); + $$.stanfordRegions + .select('text') + .transition() + .duration(duration) + .attr('x', d => + config.axis_rotated + ? yvCustom($$.getCentroid(d.points), 'y') + : xvCustom($$.getCentroid(d.points), 'x') + ) + .attr('y', d => + config.axis_rotated + ? xvCustom($$.getCentroid(d.points), 'x') + : yvCustom($$.getCentroid(d.points), 'y') + ) + .text(function(d) { + if (d.text) { + var value, percentage, temp; + + if ($$.isStanfordGraphType()) { + temp = countPointsInRegion(d.points); + value = temp.value; + percentage = temp.percentage; + } + + return d.text(value, percentage) + } + + return '' + }) + .attr('text-anchor', 'middle') + .attr('dominant-baseline', 'middle') + .style('opacity', 1); + // exit + stanfordRegion + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); +}; + +ChartInternal.prototype.initTooltip = function() { + var $$ = this, + config = $$.config, + i; + $$.tooltip = $$.selectChart + .style('position', 'relative') + .append('div') + .attr('class', CLASS.tooltipContainer) + .style('position', 'absolute') + .style('pointer-events', 'none') + .style('display', 'none'); + // Show tooltip if needed + if (config.tooltip_init_show) { + if ($$.isTimeSeries() && isString(config.tooltip_init_x)) { + config.tooltip_init_x = $$.parseDate(config.tooltip_init_x); + for (i = 0; i < $$.data.targets[0].values.length; i++) { + if ($$.data.targets[0].values[i].x - config.tooltip_init_x === 0) { + break + } + } + config.tooltip_init_x = i; + } + $$.tooltip.html( + config.tooltip_contents.call( + $$, + $$.data.targets.map(function(d) { + return $$.addName(d.values[config.tooltip_init_x]) + }), + $$.axis.getXAxisTickFormat(), + $$.getYFormat($$.hasArcType()), + $$.color + ) + ); + $$.tooltip + .style('top', config.tooltip_init_position.top) + .style('left', config.tooltip_init_position.left) + .style('display', 'block'); + } +}; +ChartInternal.prototype.getTooltipSortFunction = function() { + var $$ = this, + config = $$.config; + + if (config.data_groups.length === 0 || config.tooltip_order !== undefined) { + // if data are not grouped or if an order is specified + // for the tooltip values we sort them by their values + + var order = config.tooltip_order; + if (order === undefined) { + order = config.data_order; + } + + var valueOf = function(obj) { + return obj ? obj.value : null + }; + + // if data are not grouped, we sort them by their value + if (isString(order) && order.toLowerCase() === 'asc') { + return function(a, b) { + return valueOf(a) - valueOf(b) + } + } else if (isString(order) && order.toLowerCase() === 'desc') { + return function(a, b) { + return valueOf(b) - valueOf(a) + } + } else if (isFunction(order)) { + // if the function is from data_order we need + // to wrap the returned function in order to format + // the sorted value to the expected format + + var sortFunction = order; + + if (config.tooltip_order === undefined) { + sortFunction = function(a, b) { + return order( + a + ? { + id: a.id, + values: [a] + } + : null, + b + ? { + id: b.id, + values: [b] + } + : null + ) + }; + } + + return sortFunction + } else if (isArray(order)) { + return function(a, b) { + return order.indexOf(a.id) - order.indexOf(b.id) + } + } + } else { + // if data are grouped, we follow the order of grouped targets + var ids = $$.orderTargets($$.data.targets).map(function(i) { + return i.id + }); + + // if it was either asc or desc we need to invert the order + // returned by orderTargets + if ($$.isOrderAsc() || $$.isOrderDesc()) { + ids = ids.reverse(); + } + + return function(a, b) { + return ids.indexOf(a.id) - ids.indexOf(b.id) + } + } +}; +ChartInternal.prototype.getTooltipContent = function( + d, + defaultTitleFormat, + defaultValueFormat, + color +) { + var $$ = this, + config = $$.config, + titleFormat = config.tooltip_format_title || defaultTitleFormat, + nameFormat = + config.tooltip_format_name || + function(name) { + return name + }, + text, + i, + title, + value, + name, + bgcolor; + + var valueFormat = config.tooltip_format_value; + if (!valueFormat) { + valueFormat = $$.isTargetNormalized(d.id) + ? (v, ratio) => `${(ratio * 100).toFixed(2)}%` + : defaultValueFormat; + } + + var tooltipSortFunction = this.getTooltipSortFunction(); + if (tooltipSortFunction) { + d.sort(tooltipSortFunction); + } + + for (i = 0; i < d.length; i++) { + if (!(d[i] && (d[i].value || d[i].value === 0))) { + continue + } + + if ($$.isStanfordGraphType()) { + // Custom tooltip for stanford plots + if (!text) { + title = $$.getStanfordTooltipTitle(d[i]); + text = "" + title; + } + + bgcolor = $$.getStanfordPointColor(d[i]); + name = sanitise(config.data_epochs); // Epochs key name + value = d[i].epochs; + } else { + // Regular tooltip + if (!text) { + title = sanitise(titleFormat ? titleFormat(d[i].x, d[i].index) : d[i].x); + text = + "
" + + (title || title === 0 + ? "' + : ''); + } + + value = sanitise( + valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index, d) + ); + if (value !== undefined) { + // Skip elements when their name is set to null + if (d[i].name === null) { + continue + } + + name = sanitise(nameFormat(d[i].name, d[i].ratio, d[i].id, d[i].index)); + bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); + } + } + + if (value !== undefined) { + text += + ""; + text += + "'; + text += "'; + text += ''; + } + } + return text + '
" + title + '
" + + name + + '" + value + '
' +}; +ChartInternal.prototype.tooltipPosition = function( + dataToShow, + tWidth, + tHeight, + element +) { + var $$ = this, + config = $$.config, + d3 = $$.d3; + var svgLeft, tooltipLeft, tooltipRight, tooltipTop, chartRight; + var forArc = $$.hasArcType(), + mouse = d3.mouse(element); + // Determin tooltip position + if (forArc) { + tooltipLeft = + ($$.width - ($$.isLegendRight ? $$.getLegendWidth() : 0)) / 2 + mouse[0]; + tooltipTop = + ($$.hasType('gauge') ? $$.height : $$.height / 2) + mouse[1] + 20; + } else { + svgLeft = $$.getSvgLeft(true); + if (config.axis_rotated) { + tooltipLeft = svgLeft + mouse[0] + 100; + tooltipRight = tooltipLeft + tWidth; + chartRight = $$.currentWidth - $$.getCurrentPaddingRight(); + tooltipTop = $$.x(dataToShow[0].x) + 20; + } else { + tooltipLeft = + svgLeft + $$.getCurrentPaddingLeft(true) + $$.x(dataToShow[0].x) + 20; + tooltipRight = tooltipLeft + tWidth; + chartRight = svgLeft + $$.currentWidth - $$.getCurrentPaddingRight(); + tooltipTop = mouse[1] + 15; + } + + if (tooltipRight > chartRight) { + // 20 is needed for Firefox to keep tooltip width + tooltipLeft -= tooltipRight - chartRight + 20; + } + if (tooltipTop + tHeight > $$.currentHeight) { + tooltipTop -= tHeight + 30; + } + } + if (tooltipTop < 0) { + tooltipTop = 0; + } + return { + top: tooltipTop, + left: tooltipLeft + } +}; +ChartInternal.prototype.showTooltip = function(selectedData, element) { + var $$ = this, + config = $$.config; + var tWidth, tHeight, position; + var forArc = $$.hasArcType(), + dataToShow = selectedData.filter(function(d) { + return d && isValue(d.value) + }), + positionFunction = + config.tooltip_position || ChartInternal.prototype.tooltipPosition; + if (dataToShow.length === 0 || !config.tooltip_show) { + $$.hideTooltip(); + return + } + $$.tooltip + .html( + config.tooltip_contents.call( + $$, + selectedData, + $$.axis.getXAxisTickFormat(), + $$.getYFormat(forArc), + $$.color + ) + ) + .style('display', 'block'); + + // Get tooltip dimensions + tWidth = $$.tooltip.property('offsetWidth'); + tHeight = $$.tooltip.property('offsetHeight'); + + position = positionFunction.call(this, dataToShow, tWidth, tHeight, element); + // Set tooltip + $$.tooltip + .style('top', position.top + 'px') + .style('left', position.left + 'px'); +}; +ChartInternal.prototype.hideTooltip = function() { + this.tooltip.style('display', 'none'); +}; + +ChartInternal.prototype.setTargetType = function(targetIds, type) { + var $$ = this, + config = $$.config; + $$.mapToTargetIds(targetIds).forEach(function(id) { + $$.withoutFadeIn[id] = type === config.data_types[id]; + config.data_types[id] = type; + }); + if (!targetIds) { + config.data_type = type; + } +}; +ChartInternal.prototype.hasType = function(type, targets) { + var $$ = this, + types = $$.config.data_types, + has = false; + targets = targets || $$.data.targets; + if (targets && targets.length) { + targets.forEach(function(target) { + var t = types[target.id]; + if ((t && t.indexOf(type) >= 0) || (!t && type === 'line')) { + has = true; + } + }); + } else if (Object.keys(types).length) { + Object.keys(types).forEach(function(id) { + if (types[id] === type) { + has = true; + } + }); + } else { + has = $$.config.data_type === type; + } + return has +}; +ChartInternal.prototype.hasArcType = function(targets) { + return ( + this.hasType('pie', targets) || + this.hasType('donut', targets) || + this.hasType('gauge', targets) + ) +}; +ChartInternal.prototype.isLineType = function(d) { + var config = this.config, + id = isString(d) ? d : d.id; + return ( + !config.data_types[id] || + ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf( + config.data_types[id] + ) >= 0 + ) +}; +ChartInternal.prototype.isStepType = function(d) { + var id = isString(d) ? d : d.id; + return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0 +}; +ChartInternal.prototype.isSplineType = function(d) { + var id = isString(d) ? d : d.id; + return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0 +}; +ChartInternal.prototype.isAreaType = function(d) { + var id = isString(d) ? d : d.id; + return ( + ['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= + 0 + ) +}; +ChartInternal.prototype.isBarType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'bar' +}; +ChartInternal.prototype.isScatterType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'scatter' +}; +ChartInternal.prototype.isStanfordType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'stanford' +}; +ChartInternal.prototype.isPieType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'pie' +}; +ChartInternal.prototype.isGaugeType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'gauge' +}; +ChartInternal.prototype.isDonutType = function(d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'donut' +}; +ChartInternal.prototype.isArcType = function(d) { + return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d) +}; +ChartInternal.prototype.lineData = function(d) { + return this.isLineType(d) ? [d] : [] +}; +ChartInternal.prototype.arcData = function(d) { + return this.isArcType(d.data) ? [d] : [] +}; +/* not used + function scatterData(d) { + return isScatterType(d) ? d.values : []; + } + */ +ChartInternal.prototype.barData = function(d) { + return this.isBarType(d) ? d.values : [] +}; +ChartInternal.prototype.lineOrScatterOrStanfordData = function(d) { + return this.isLineType(d) || this.isScatterType(d) || this.isStanfordType(d) + ? d.values + : [] +}; +ChartInternal.prototype.barOrLineData = function(d) { + return this.isBarType(d) || this.isLineType(d) ? d.values : [] +}; + +ChartInternal.prototype.isSafari = function() { + var ua = window.navigator.userAgent; + return ua.indexOf('Safari') >= 0 && ua.indexOf('Chrome') < 0 +}; +ChartInternal.prototype.isChrome = function() { + var ua = window.navigator.userAgent; + return ua.indexOf('Chrome') >= 0 +}; + +ChartInternal.prototype.initZoom = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config, + startEvent; + + $$.zoom = d3 + .zoom() + .on('start', function() { + if (config.zoom_type !== 'scroll') { + return + } + + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return + } + startEvent = e; + config.zoom_onzoomstart.call($$.api, e); + }) + .on('zoom', function() { + if (config.zoom_type !== 'scroll') { + return + } + + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return + } + + $$.redrawForZoom(); + + config.zoom_onzoom.call($$.api, $$.x.orgDomain()); + }) + .on('end', function() { + if (config.zoom_type !== 'scroll') { + return + } + + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return + } + // if click, do nothing. otherwise, click interaction will be canceled. + if ( + e && + startEvent.clientX === e.clientX && + startEvent.clientY === e.clientY + ) { + return + } + config.zoom_onzoomend.call($$.api, $$.x.orgDomain()); + }); + + $$.zoom.updateDomain = function() { + if (d3.event && d3.event.transform) { + $$.x.domain(d3.event.transform.rescaleX($$.subX).domain()); + } + return this + }; + $$.zoom.updateExtent = function() { + this.scaleExtent([1, Infinity]) + .translateExtent([ + [0, 0], + [$$.width, $$.height] + ]) + .extent([ + [0, 0], + [$$.width, $$.height] + ]); + return this + }; + $$.zoom.update = function() { + return this.updateExtent().updateDomain() + }; + + return $$.zoom.updateExtent() +}; +ChartInternal.prototype.zoomTransform = function(range) { + var $$ = this, + s = [$$.x(range[0]), $$.x(range[1])]; + return $$.d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0) +}; + +ChartInternal.prototype.initDragZoom = function() { + const $$ = this; + const d3 = $$.d3; + const config = $$.config; + const context = ($$.context = $$.svg); + const brushXPos = $$.margin.left + 20.5; + const brushYPos = $$.margin.top + 0.5; + + if (!(config.zoom_type === 'drag' && config.zoom_enabled)) { + return + } + + const getZoomedDomain = selection => + selection && selection.map(x => $$.x.invert(x)); + + const brush = ($$.dragZoomBrush = d3 + .brushX() + .on('start', () => { + $$.api.unzoom(); + + $$.svg.select('.' + CLASS.dragZoom).classed('disabled', false); + + config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent); + }) + .on('brush', () => { + config.zoom_onzoom.call($$.api, getZoomedDomain(d3.event.selection)); + }) + .on('end', () => { + if (d3.event.selection == null) { + return + } + + const zoomedDomain = getZoomedDomain(d3.event.selection); + + if (!config.zoom_disableDefaultBehavior) { + $$.api.zoom(zoomedDomain); + } + + $$.svg.select('.' + CLASS.dragZoom).classed('disabled', true); + + config.zoom_onzoomend.call($$.api, zoomedDomain); + })); + + context + .append('g') + .classed(CLASS.dragZoom, true) + .attr('clip-path', $$.clipPath) + .attr('transform', 'translate(' + brushXPos + ',' + brushYPos + ')') + .call(brush); +}; + +ChartInternal.prototype.getZoomDomain = function() { + var $$ = this, + config = $$.config, + d3 = $$.d3, + min = d3.min([$$.orgXDomain[0], config.zoom_x_min]), + max = d3.max([$$.orgXDomain[1], config.zoom_x_max]); + return [min, max] +}; +ChartInternal.prototype.redrawForZoom = function() { + var $$ = this, + d3 = $$.d3, + config = $$.config, + zoom = $$.zoom, + x = $$.x; + if (!config.zoom_enabled) { + return + } + if ($$.filterTargetsToShow($$.data.targets).length === 0) { + return + } + + zoom.update(); + + if (config.zoom_disableDefaultBehavior) { + return + } + + if ($$.isCategorized() && x.orgDomain()[0] === $$.orgXDomain[0]) { + x.domain([$$.orgXDomain[0] - 1e-10, x.orgDomain()[1]]); + } + + $$.redraw({ + withTransition: false, + withY: config.zoom_rescale, + withSubchart: false, + withEventRect: false, + withDimension: false + }); + + if (d3.event.sourceEvent && d3.event.sourceEvent.type === 'mousemove') { + $$.cancelClick = true; + } +}; + +export default c3; diff --git a/server/static/server/c3/docs/js/c3.js b/server/static/server/c3/docs/js/c3.js new file mode 100644 index 0000000..d4b4c1e --- /dev/null +++ b/server/static/server/c3/docs/js/c3.js @@ -0,0 +1,11320 @@ +/* @license C3.js v0.7.20 | (c) C3 Team and other contributors | http://c3js.org/ */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global.c3 = factory()); +}(this, (function () { 'use strict'; + + function ChartInternal(api) { + var $$ = this; + // Note: This part will be replaced by rollup-plugin-modify + // When bundling esm output. Beware of changing this line. + // TODO: Maybe we should check that the modification by rollup-plugin-modify + // is valid during unit tests. + $$.d3 = window.d3 + ? window.d3 + : typeof require !== 'undefined' + ? require('d3') + : undefined; + $$.api = api; + $$.config = $$.getDefaultConfig(); + $$.data = {}; + $$.cache = {}; + $$.axes = {}; + } + + /** + * The Chart class + * + * The methods of this class is the public APIs of the chart object. + */ + function Chart(config) { + this.internal = new ChartInternal(this); + this.internal.loadConfig(config); + this.internal.beforeInit(config); + this.internal.init(); + this.internal.afterInit(config); + (function bindThis(fn, target, argThis) { + Object.keys(fn).forEach(function (key) { + target[key] = fn[key].bind(argThis); + if (Object.keys(fn[key]).length > 0) { + bindThis(fn[key], target[key], argThis); + } + }); + })(Chart.prototype, this, this); + } + + var asHalfPixel = function (n) { + return Math.ceil(n) + 0.5; + }; + var ceil10 = function (v) { + return Math.ceil(v / 10) * 10; + }; + var diffDomain = function (d) { + return d[1] - d[0]; + }; + var getOption = function (options, key, defaultValue) { + return isDefined(options[key]) ? options[key] : defaultValue; + }; + var getPathBox = function (path) { + var box = getBBox(path), items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)], minX = items[0].x, minY = Math.min(items[0].y, items[1].y); + return { x: minX, y: minY, width: box.width, height: box.height }; + }; + var getBBox = function (element) { + try { + return element.getBBox(); + } + catch (ignore) { + // Firefox will throw an exception if getBBox() is called whereas the + // element is rendered with display:none + // See https://github.com/c3js/c3/issues/2692 + // The previous code was using `getBoundingClientRect` which was returning + // everything at 0 in this case so let's reproduce this behavior here. + return { x: 0, y: 0, width: 0, height: 0 }; + } + }; + var hasValue = function (dict, value) { + var found = false; + Object.keys(dict).forEach(function (key) { + if (dict[key] === value) { + found = true; + } + }); + return found; + }; + var isArray = function (o) { + return Array.isArray(o); + }; + var isDefined = function (v) { + return typeof v !== 'undefined'; + }; + var isEmpty = function (o) { + return (typeof o === 'undefined' || + o === null || + (isString(o) && o.length === 0) || + (typeof o === 'object' && Object.keys(o).length === 0)); + }; + var isFunction = function (o) { + return typeof o === 'function'; + }; + var isNumber = function (o) { + return typeof o === 'number'; + }; + var isString = function (o) { + return typeof o === 'string'; + }; + var isUndefined = function (v) { + return typeof v === 'undefined'; + }; + var isValue = function (v) { + return v || v === 0; + }; + var notEmpty = function (o) { + return !isEmpty(o); + }; + var sanitise = function (str) { + return typeof str === 'string' + ? str.replace(//g, '>') + : str; + }; + var flattenArray = function (arr) { + return Array.isArray(arr) ? [].concat.apply([], arr) : []; + }; + /** + * Returns whether the point is within the given box. + * + * @param {Array} point An [x,y] coordinate + * @param {Object} box An object with {x, y, width, height} keys + * @param {Number} sensitivity An offset to ease check on very small boxes + */ + var isWithinBox = function (point, box, sensitivity) { + if (sensitivity === void 0) { sensitivity = 0; } + var xStart = box.x - sensitivity; + var xEnd = box.x + box.width + sensitivity; + var yStart = box.y + box.height + sensitivity; + var yEnd = box.y - sensitivity; + return (xStart < point[0] && point[0] < xEnd && yEnd < point[1] && point[1] < yStart); + }; + /** + * Returns Internet Explorer version number (or false if no Internet Explorer used). + * + * @param string agent Optional parameter to specify user agent + */ + var getIEVersion = function (agent) { + // https://stackoverflow.com/questions/19999388/check-if-user-is-using-ie + if (typeof agent === 'undefined') { + agent = window.navigator.userAgent; + } + var pos = agent.indexOf('MSIE '); // up to IE10 + if (pos > 0) { + return parseInt(agent.substring(pos + 5, agent.indexOf('.', pos)), 10); + } + pos = agent.indexOf('Trident/'); // IE11 + if (pos > 0) { + pos = agent.indexOf('rv:'); + return parseInt(agent.substring(pos + 3, agent.indexOf('.', pos)), 10); + } + return false; + }; + /** + * Returns whether the used browser is Internet Explorer. + * + * @param version Optional parameter to specify IE version + */ + var isIE = function (version) { + var ver = getIEVersion(); + if (typeof version === 'undefined') { + return !!ver; + } + return version === ver; + }; + + function AxisInternal(component, params) { + var internal = this; + internal.component = component; + internal.params = params || {}; + internal.d3 = component.d3; + internal.scale = internal.d3.scaleLinear(); + internal.range; + internal.orient = 'bottom'; + internal.innerTickSize = 6; + internal.outerTickSize = this.params.withOuterTick ? 6 : 0; + internal.tickPadding = 3; + internal.tickValues = null; + internal.tickFormat; + internal.tickArguments; + internal.tickOffset = 0; + internal.tickCulling = true; + internal.tickCentered; + internal.tickTextCharSize; + internal.tickTextRotate = internal.params.tickTextRotate; + internal.tickLength; + internal.axis = internal.generateAxis(); + } + AxisInternal.prototype.axisX = function (selection, x, tickOffset) { + selection.attr('transform', function (d) { + return 'translate(' + Math.ceil(x(d) + tickOffset) + ', 0)'; + }); + }; + AxisInternal.prototype.axisY = function (selection, y) { + selection.attr('transform', function (d) { + return 'translate(0,' + Math.ceil(y(d)) + ')'; + }); + }; + AxisInternal.prototype.scaleExtent = function (domain) { + var start = domain[0], stop = domain[domain.length - 1]; + return start < stop ? [start, stop] : [stop, start]; + }; + AxisInternal.prototype.generateTicks = function (scale) { + var internal = this; + var i, domain, ticks = []; + if (scale.ticks) { + return scale.ticks.apply(scale, internal.tickArguments); + } + domain = scale.domain(); + for (i = Math.ceil(domain[0]); i < domain[1]; i++) { + ticks.push(i); + } + if (ticks.length > 0 && ticks[0] > 0) { + ticks.unshift(ticks[0] - (ticks[1] - ticks[0])); + } + return ticks; + }; + AxisInternal.prototype.copyScale = function () { + var internal = this; + var newScale = internal.scale.copy(), domain; + if (internal.params.isCategory) { + domain = internal.scale.domain(); + newScale.domain([domain[0], domain[1] - 1]); + } + return newScale; + }; + AxisInternal.prototype.textFormatted = function (v) { + var internal = this, formatted = internal.tickFormat ? internal.tickFormat(v) : v; + return typeof formatted !== 'undefined' ? formatted : ''; + }; + AxisInternal.prototype.updateRange = function () { + var internal = this; + internal.range = internal.scale.rangeExtent + ? internal.scale.rangeExtent() + : internal.scaleExtent(internal.scale.range()); + return internal.range; + }; + AxisInternal.prototype.updateTickTextCharSize = function (tick) { + var internal = this; + if (internal.tickTextCharSize) { + return internal.tickTextCharSize; + } + var size = { + h: 11.5, + w: 5.5 + }; + tick + .select('text') + .text(function (d) { + return internal.textFormatted(d); + }) + .each(function (d) { + var box = getBBox(this), text = internal.textFormatted(d), h = box.height, w = text ? box.width / text.length : undefined; + if (h && w) { + size.h = h; + size.w = w; + } + }) + .text(''); + internal.tickTextCharSize = size; + return size; + }; + AxisInternal.prototype.isVertical = function () { + return this.orient === 'left' || this.orient === 'right'; + }; + AxisInternal.prototype.tspanData = function (d, i, scale) { + var internal = this; + var splitted = internal.params.tickMultiline + ? internal.splitTickText(d, scale) + : [].concat(internal.textFormatted(d)); + if (internal.params.tickMultiline && internal.params.tickMultilineMax > 0) { + splitted = internal.ellipsify(splitted, internal.params.tickMultilineMax); + } + return splitted.map(function (s) { + return { index: i, splitted: s, length: splitted.length }; + }); + }; + AxisInternal.prototype.splitTickText = function (d, scale) { + var internal = this, tickText = internal.textFormatted(d), maxWidth = internal.params.tickWidth, subtext, spaceIndex, textWidth, splitted = []; + if (Object.prototype.toString.call(tickText) === '[object Array]') { + return tickText; + } + if (!maxWidth || maxWidth <= 0) { + maxWidth = internal.isVertical() + ? 95 + : internal.params.isCategory + ? Math.ceil(scale(1) - scale(0)) - 12 + : 110; + } + function split(splitted, text) { + spaceIndex = undefined; + for (var i = 1; i < text.length; i++) { + if (text.charAt(i) === ' ') { + spaceIndex = i; + } + subtext = text.substr(0, i + 1); + textWidth = internal.tickTextCharSize.w * subtext.length; + // if text width gets over tick width, split by space index or crrent index + if (maxWidth < textWidth) { + return split(splitted.concat(text.substr(0, spaceIndex ? spaceIndex : i)), text.slice(spaceIndex ? spaceIndex + 1 : i)); + } + } + return splitted.concat(text); + } + return split(splitted, tickText + ''); + }; + AxisInternal.prototype.ellipsify = function (splitted, max) { + if (splitted.length <= max) { + return splitted; + } + var ellipsified = splitted.slice(0, max); + var remaining = 3; + for (var i = max - 1; i >= 0; i--) { + var available = ellipsified[i].length; + ellipsified[i] = ellipsified[i] + .substr(0, available - remaining) + .padEnd(available, '.'); + remaining -= available; + if (remaining <= 0) { + break; + } + } + return ellipsified; + }; + AxisInternal.prototype.updateTickLength = function () { + var internal = this; + internal.tickLength = + Math.max(internal.innerTickSize, 0) + internal.tickPadding; + }; + AxisInternal.prototype.lineY2 = function (d) { + var internal = this, tickPosition = internal.scale(d) + (internal.tickCentered ? 0 : internal.tickOffset); + return internal.range[0] < tickPosition && tickPosition < internal.range[1] + ? internal.innerTickSize + : 0; + }; + AxisInternal.prototype.textY = function () { + var internal = this, rotate = internal.tickTextRotate; + return rotate + ? 11.5 - 2.5 * (rotate / 15) * (rotate > 0 ? 1 : -1) + : internal.tickLength; + }; + AxisInternal.prototype.textTransform = function () { + var internal = this, rotate = internal.tickTextRotate; + return rotate ? 'rotate(' + rotate + ')' : ''; + }; + AxisInternal.prototype.textTextAnchor = function () { + var internal = this, rotate = internal.tickTextRotate; + return rotate ? (rotate > 0 ? 'start' : 'end') : 'middle'; + }; + AxisInternal.prototype.tspanDx = function () { + var internal = this, rotate = internal.tickTextRotate; + return rotate ? 8 * Math.sin(Math.PI * (rotate / 180)) : 0; + }; + AxisInternal.prototype.tspanDy = function (d, i) { + var internal = this, dy = internal.tickTextCharSize.h; + if (i === 0) { + if (internal.isVertical()) { + dy = -((d.length - 1) * (internal.tickTextCharSize.h / 2) - 3); + } + else { + dy = '.71em'; + } + } + return dy; + }; + AxisInternal.prototype.generateAxis = function () { + var internal = this, d3 = internal.d3, params = internal.params; + function axis(g, transition) { + var self; + g.each(function () { + var g = (axis.g = d3.select(this)); + var scale0 = this.__chart__ || internal.scale, scale1 = (this.__chart__ = internal.copyScale()); + var ticksValues = internal.tickValues + ? internal.tickValues + : internal.generateTicks(scale1), ticks = g.selectAll('.tick').data(ticksValues, scale1), tickEnter = ticks + .enter() + .insert('g', '.domain') + .attr('class', 'tick') + .style('opacity', 1e-6), + // MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks. + tickExit = ticks.exit().remove(), tickUpdate = ticks.merge(tickEnter), tickTransform, tickX, tickY; + if (params.isCategory) { + internal.tickOffset = Math.ceil((scale1(1) - scale1(0)) / 2); + tickX = internal.tickCentered ? 0 : internal.tickOffset; + tickY = internal.tickCentered ? internal.tickOffset : 0; + } + else { + internal.tickOffset = tickX = 0; + } + internal.updateRange(); + internal.updateTickLength(); + internal.updateTickTextCharSize(g.select('.tick')); + var lineUpdate = tickUpdate + .select('line') + .merge(tickEnter.append('line')), textUpdate = tickUpdate.select('text').merge(tickEnter.append('text')); + var tspans = tickUpdate + .selectAll('text') + .selectAll('tspan') + .data(function (d, i) { + return internal.tspanData(d, i, scale1); + }), tspanEnter = tspans.enter().append('tspan'), tspanUpdate = tspanEnter.merge(tspans).text(function (d) { + return d.splitted; + }); + tspans.exit().remove(); + var path = g.selectAll('.domain').data([0]), pathUpdate = path + .enter() + .append('path') + .merge(path) + .attr('class', 'domain'); + // TODO: each attr should be one function and change its behavior by internal.orient, probably + switch (internal.orient) { + case 'bottom': { + tickTransform = internal.axisX; + lineUpdate + .attr('x1', tickX) + .attr('x2', tickX) + .attr('y2', function (d, i) { + return internal.lineY2(d, i); + }); + textUpdate + .attr('x', 0) + .attr('y', function (d, i) { + return internal.textY(d, i); + }) + .attr('transform', function (d, i) { + return internal.textTransform(d, i); + }) + .style('text-anchor', function (d, i) { + return internal.textTextAnchor(d, i); + }); + tspanUpdate + .attr('x', 0) + .attr('dy', function (d, i) { + return internal.tspanDy(d, i); + }) + .attr('dx', function (d, i) { + return internal.tspanDx(d, i); + }); + pathUpdate.attr('d', 'M' + + internal.range[0] + + ',' + + internal.outerTickSize + + 'V0H' + + internal.range[1] + + 'V' + + internal.outerTickSize); + break; + } + case 'top': { + // TODO: rotated tick text + tickTransform = internal.axisX; + lineUpdate + .attr('x1', tickX) + .attr('x2', tickX) + .attr('y2', function (d, i) { + return -1 * internal.lineY2(d, i); + }); + textUpdate + .attr('x', 0) + .attr('y', function (d, i) { + return (-1 * internal.textY(d, i) - + (params.isCategory ? 2 : internal.tickLength - 2)); + }) + .attr('transform', function (d, i) { + return internal.textTransform(d, i); + }) + .style('text-anchor', function (d, i) { + return internal.textTextAnchor(d, i); + }); + tspanUpdate + .attr('x', 0) + .attr('dy', function (d, i) { + return internal.tspanDy(d, i); + }) + .attr('dx', function (d, i) { + return internal.tspanDx(d, i); + }); + pathUpdate.attr('d', 'M' + + internal.range[0] + + ',' + + -internal.outerTickSize + + 'V0H' + + internal.range[1] + + 'V' + + -internal.outerTickSize); + break; + } + case 'left': { + tickTransform = internal.axisY; + lineUpdate + .attr('x2', -internal.innerTickSize) + .attr('y1', tickY) + .attr('y2', tickY); + textUpdate + .attr('x', -internal.tickLength) + .attr('y', internal.tickOffset) + .style('text-anchor', 'end'); + tspanUpdate + .attr('x', -internal.tickLength) + .attr('dy', function (d, i) { + return internal.tspanDy(d, i); + }); + pathUpdate.attr('d', 'M' + + -internal.outerTickSize + + ',' + + internal.range[0] + + 'H0V' + + internal.range[1] + + 'H' + + -internal.outerTickSize); + break; + } + case 'right': { + tickTransform = internal.axisY; + lineUpdate + .attr('x2', internal.innerTickSize) + .attr('y1', tickY) + .attr('y2', tickY); + textUpdate + .attr('x', internal.tickLength) + .attr('y', internal.tickOffset) + .style('text-anchor', 'start'); + tspanUpdate.attr('x', internal.tickLength).attr('dy', function (d, i) { + return internal.tspanDy(d, i); + }); + pathUpdate.attr('d', 'M' + + internal.outerTickSize + + ',' + + internal.range[0] + + 'H0V' + + internal.range[1] + + 'H' + + internal.outerTickSize); + break; + } + } + if (scale1.rangeBand) { + var x = scale1, dx = x.rangeBand() / 2; + scale0 = scale1 = function (d) { + return x(d) + dx; + }; + } + else if (scale0.rangeBand) { + scale0 = scale1; + } + else { + tickExit.call(tickTransform, scale1, internal.tickOffset); + } + tickEnter.call(tickTransform, scale0, internal.tickOffset); + self = (transition ? tickUpdate.transition(transition) : tickUpdate) + .style('opacity', 1) + .call(tickTransform, scale1, internal.tickOffset); + }); + return self; + } + axis.scale = function (x) { + if (!arguments.length) { + return internal.scale; + } + internal.scale = x; + return axis; + }; + axis.orient = function (x) { + if (!arguments.length) { + return internal.orient; + } + internal.orient = + x in { top: 1, right: 1, bottom: 1, left: 1 } ? x + '' : 'bottom'; + return axis; + }; + axis.tickFormat = function (format) { + if (!arguments.length) { + return internal.tickFormat; + } + internal.tickFormat = format; + return axis; + }; + axis.tickCentered = function (isCentered) { + if (!arguments.length) { + return internal.tickCentered; + } + internal.tickCentered = isCentered; + return axis; + }; + axis.tickOffset = function () { + return internal.tickOffset; + }; + axis.tickInterval = function () { + var interval, length; + if (params.isCategory) { + interval = internal.tickOffset * 2; + } + else { + length = + axis.g + .select('path.domain') + .node() + .getTotalLength() - + internal.outerTickSize * 2; + interval = length / axis.g.selectAll('line').size(); + } + return interval === Infinity ? 0 : interval; + }; + axis.ticks = function () { + if (!arguments.length) { + return internal.tickArguments; + } + internal.tickArguments = arguments; + return axis; + }; + axis.tickCulling = function (culling) { + if (!arguments.length) { + return internal.tickCulling; + } + internal.tickCulling = culling; + return axis; + }; + axis.tickValues = function (x) { + if (typeof x === 'function') { + internal.tickValues = function () { + return x(internal.scale.domain()); + }; + } + else { + if (!arguments.length) { + return internal.tickValues; + } + internal.tickValues = x; + } + return axis; + }; + return axis; + }; + + var CLASS = { + target: 'c3-target', + chart: 'c3-chart', + chartLine: 'c3-chart-line', + chartLines: 'c3-chart-lines', + chartBar: 'c3-chart-bar', + chartBars: 'c3-chart-bars', + chartText: 'c3-chart-text', + chartTexts: 'c3-chart-texts', + chartArc: 'c3-chart-arc', + chartArcs: 'c3-chart-arcs', + chartArcsTitle: 'c3-chart-arcs-title', + chartArcsBackground: 'c3-chart-arcs-background', + chartArcsGaugeUnit: 'c3-chart-arcs-gauge-unit', + chartArcsGaugeMax: 'c3-chart-arcs-gauge-max', + chartArcsGaugeMin: 'c3-chart-arcs-gauge-min', + selectedCircle: 'c3-selected-circle', + selectedCircles: 'c3-selected-circles', + eventRect: 'c3-event-rect', + eventRects: 'c3-event-rects', + eventRectsSingle: 'c3-event-rects-single', + eventRectsMultiple: 'c3-event-rects-multiple', + zoomRect: 'c3-zoom-rect', + brush: 'c3-brush', + dragZoom: 'c3-drag-zoom', + focused: 'c3-focused', + defocused: 'c3-defocused', + region: 'c3-region', + regions: 'c3-regions', + title: 'c3-title', + tooltipContainer: 'c3-tooltip-container', + tooltip: 'c3-tooltip', + tooltipName: 'c3-tooltip-name', + shape: 'c3-shape', + shapes: 'c3-shapes', + line: 'c3-line', + lines: 'c3-lines', + bar: 'c3-bar', + bars: 'c3-bars', + circle: 'c3-circle', + circles: 'c3-circles', + arc: 'c3-arc', + arcLabelLine: 'c3-arc-label-line', + arcs: 'c3-arcs', + area: 'c3-area', + areas: 'c3-areas', + empty: 'c3-empty', + text: 'c3-text', + texts: 'c3-texts', + gaugeValue: 'c3-gauge-value', + grid: 'c3-grid', + gridLines: 'c3-grid-lines', + xgrid: 'c3-xgrid', + xgrids: 'c3-xgrids', + xgridLine: 'c3-xgrid-line', + xgridLines: 'c3-xgrid-lines', + xgridFocus: 'c3-xgrid-focus', + ygrid: 'c3-ygrid', + ygrids: 'c3-ygrids', + ygridLine: 'c3-ygrid-line', + ygridLines: 'c3-ygrid-lines', + colorScale: 'c3-colorscale', + stanfordElements: 'c3-stanford-elements', + stanfordLine: 'c3-stanford-line', + stanfordLines: 'c3-stanford-lines', + stanfordRegion: 'c3-stanford-region', + stanfordRegions: 'c3-stanford-regions', + stanfordText: 'c3-stanford-text', + stanfordTexts: 'c3-stanford-texts', + axis: 'c3-axis', + axisX: 'c3-axis-x', + axisXLabel: 'c3-axis-x-label', + axisY: 'c3-axis-y', + axisYLabel: 'c3-axis-y-label', + axisY2: 'c3-axis-y2', + axisY2Label: 'c3-axis-y2-label', + legendBackground: 'c3-legend-background', + legendItem: 'c3-legend-item', + legendItemEvent: 'c3-legend-item-event', + legendItemTile: 'c3-legend-item-tile', + legendItemHidden: 'c3-legend-item-hidden', + legendItemFocused: 'c3-legend-item-focused', + dragarea: 'c3-dragarea', + EXPANDED: '_expanded_', + SELECTED: '_selected_', + INCLUDED: '_included_' + }; + + var AxisClass = /** @class */ (function () { + function AxisClass(owner) { + this.owner = owner; + this.d3 = owner.d3; + this.internal = AxisInternal; + } + return AxisClass; + }()); + var Axis = AxisClass; + Axis.prototype.init = function init() { + var $$ = this.owner, config = $$.config, main = $$.main; + $$.axes.x = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisX) + .attr('clip-path', config.axis_x_inner ? '' : $$.clipPathForXAxis) + .attr('transform', $$.getTranslate('x')) + .style('visibility', config.axis_x_show ? 'visible' : 'hidden'); + $$.axes.x + .append('text') + .attr('class', CLASS.axisXLabel) + .attr('transform', config.axis_rotated ? 'rotate(-90)' : '') + .style('text-anchor', this.textAnchorForXAxisLabel.bind(this)); + $$.axes.y = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisY) + .attr('clip-path', config.axis_y_inner ? '' : $$.clipPathForYAxis) + .attr('transform', $$.getTranslate('y')) + .style('visibility', config.axis_y_show ? 'visible' : 'hidden'); + $$.axes.y + .append('text') + .attr('class', CLASS.axisYLabel) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .style('text-anchor', this.textAnchorForYAxisLabel.bind(this)); + $$.axes.y2 = main + .append('g') + .attr('class', CLASS.axis + ' ' + CLASS.axisY2) + // clip-path? + .attr('transform', $$.getTranslate('y2')) + .style('visibility', config.axis_y2_show ? 'visible' : 'hidden'); + $$.axes.y2 + .append('text') + .attr('class', CLASS.axisY2Label) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .style('text-anchor', this.textAnchorForY2AxisLabel.bind(this)); + }; + Axis.prototype.getXAxis = function getXAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { + var $$ = this.owner, config = $$.config, axisParams = { + isCategory: $$.isCategorized(), + withOuterTick: withOuterTick, + tickMultiline: config.axis_x_tick_multiline, + tickMultilineMax: config.axis_x_tick_multiline + ? Number(config.axis_x_tick_multilineMax) + : 0, + tickWidth: config.axis_x_tick_width, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_x_tick_rotate, + withoutTransition: withoutTransition + }, axis = new this.internal(this, axisParams).axis.scale(scale).orient(orient); + if ($$.isTimeSeries() && tickValues && typeof tickValues !== 'function') { + tickValues = tickValues.map(function (v) { + return $$.parseDate(v); + }); + } + // Set tick + axis.tickFormat(tickFormat).tickValues(tickValues); + if ($$.isCategorized()) { + axis.tickCentered(config.axis_x_tick_centered); + if (isEmpty(config.axis_x_tick_culling)) { + config.axis_x_tick_culling = false; + } + } + return axis; + }; + Axis.prototype.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) { + var $$ = this.owner, config = $$.config, tickValues; + if (config.axis_x_tick_fit || config.axis_x_tick_count) { + tickValues = this.generateTickValues($$.mapTargetsToUniqueXs(targets), config.axis_x_tick_count, $$.isTimeSeries()); + } + if (axis) { + axis.tickValues(tickValues); + } + else { + $$.xAxis.tickValues(tickValues); + $$.subXAxis.tickValues(tickValues); + } + return tickValues; + }; + Axis.prototype.getYAxis = function getYAxis(axisId, scale, orient, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) { + var $$ = this.owner; + var config = $$.config; + var tickFormat = config["axis_" + axisId + "_tick_format"]; + if (!tickFormat && $$.isAxisNormalized(axisId)) { + tickFormat = function (x) { return x + "%"; }; + } + var axis = new this.internal(this, { + withOuterTick: withOuterTick, + withoutTransition: withoutTransition, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate + }).axis + .scale(scale) + .orient(orient); + if (tickFormat) { + axis.tickFormat(tickFormat); + } + if ($$.isTimeSeriesY()) { + axis.ticks(config.axis_y_tick_time_type, config.axis_y_tick_time_interval); + } + else { + axis.tickValues(tickValues); + } + return axis; + }; + Axis.prototype.getId = function getId(id) { + var config = this.owner.config; + return id in config.data_axes ? config.data_axes[id] : 'y'; + }; + Axis.prototype.getXAxisTickFormat = function getXAxisTickFormat() { + // #2251 previously set any negative values to a whole number, + // however both should be truncated according to the users format specification + var $$ = this.owner, config = $$.config; + var format = $$.isTimeSeries() + ? $$.defaultAxisTimeFormat + : $$.isCategorized() + ? $$.categoryName + : function (v) { + return v; + }; + if (config.axis_x_tick_format) { + if (isFunction(config.axis_x_tick_format)) { + format = config.axis_x_tick_format; + } + else if ($$.isTimeSeries()) { + format = function (date) { + return date ? $$.axisTimeFormat(config.axis_x_tick_format)(date) : ''; + }; + } + } + return isFunction(format) + ? function (v) { + return format.call($$, v); + } + : format; + }; + Axis.prototype.getTickValues = function getTickValues(tickValues, axis) { + return tickValues ? tickValues : axis ? axis.tickValues() : undefined; + }; + Axis.prototype.getXAxisTickValues = function getXAxisTickValues() { + return this.getTickValues(this.owner.config.axis_x_tick_values, this.owner.xAxis); + }; + Axis.prototype.getYAxisTickValues = function getYAxisTickValues() { + return this.getTickValues(this.owner.config.axis_y_tick_values, this.owner.yAxis); + }; + Axis.prototype.getY2AxisTickValues = function getY2AxisTickValues() { + return this.getTickValues(this.owner.config.axis_y2_tick_values, this.owner.y2Axis); + }; + Axis.prototype.getLabelOptionByAxisId = function getLabelOptionByAxisId(axisId) { + var $$ = this.owner, config = $$.config, option; + if (axisId === 'y') { + option = config.axis_y_label; + } + else if (axisId === 'y2') { + option = config.axis_y2_label; + } + else if (axisId === 'x') { + option = config.axis_x_label; + } + return option; + }; + Axis.prototype.getLabelText = function getLabelText(axisId) { + var option = this.getLabelOptionByAxisId(axisId); + return isString(option) ? option : option ? option.text : null; + }; + Axis.prototype.setLabelText = function setLabelText(axisId, text) { + var $$ = this.owner, config = $$.config, option = this.getLabelOptionByAxisId(axisId); + if (isString(option)) { + if (axisId === 'y') { + config.axis_y_label = text; + } + else if (axisId === 'y2') { + config.axis_y2_label = text; + } + else if (axisId === 'x') { + config.axis_x_label = text; + } + } + else if (option) { + option.text = text; + } + }; + Axis.prototype.getLabelPosition = function getLabelPosition(axisId, defaultPosition) { + var option = this.getLabelOptionByAxisId(axisId), position = option && typeof option === 'object' && option.position + ? option.position + : defaultPosition; + return { + isInner: position.indexOf('inner') >= 0, + isOuter: position.indexOf('outer') >= 0, + isLeft: position.indexOf('left') >= 0, + isCenter: position.indexOf('center') >= 0, + isRight: position.indexOf('right') >= 0, + isTop: position.indexOf('top') >= 0, + isMiddle: position.indexOf('middle') >= 0, + isBottom: position.indexOf('bottom') >= 0 + }; + }; + Axis.prototype.getXAxisLabelPosition = function getXAxisLabelPosition() { + return this.getLabelPosition('x', this.owner.config.axis_rotated ? 'inner-top' : 'inner-right'); + }; + Axis.prototype.getYAxisLabelPosition = function getYAxisLabelPosition() { + return this.getLabelPosition('y', this.owner.config.axis_rotated ? 'inner-right' : 'inner-top'); + }; + Axis.prototype.getY2AxisLabelPosition = function getY2AxisLabelPosition() { + return this.getLabelPosition('y2', this.owner.config.axis_rotated ? 'inner-right' : 'inner-top'); + }; + Axis.prototype.getLabelPositionById = function getLabelPositionById(id) { + return id === 'y2' + ? this.getY2AxisLabelPosition() + : id === 'y' + ? this.getYAxisLabelPosition() + : this.getXAxisLabelPosition(); + }; + Axis.prototype.textForXAxisLabel = function textForXAxisLabel() { + return this.getLabelText('x'); + }; + Axis.prototype.textForYAxisLabel = function textForYAxisLabel() { + return this.getLabelText('y'); + }; + Axis.prototype.textForY2AxisLabel = function textForY2AxisLabel() { + return this.getLabelText('y2'); + }; + Axis.prototype.xForAxisLabel = function xForAxisLabel(forHorizontal, position) { + var $$ = this.owner; + if (forHorizontal) { + return position.isLeft ? 0 : position.isCenter ? $$.width / 2 : $$.width; + } + else { + return position.isBottom + ? -$$.height + : position.isMiddle + ? -$$.height / 2 + : 0; + } + }; + Axis.prototype.dxForAxisLabel = function dxForAxisLabel(forHorizontal, position) { + if (forHorizontal) { + return position.isLeft ? '0.5em' : position.isRight ? '-0.5em' : '0'; + } + else { + return position.isTop ? '-0.5em' : position.isBottom ? '0.5em' : '0'; + } + }; + Axis.prototype.textAnchorForAxisLabel = function textAnchorForAxisLabel(forHorizontal, position) { + if (forHorizontal) { + return position.isLeft ? 'start' : position.isCenter ? 'middle' : 'end'; + } + else { + return position.isBottom ? 'start' : position.isMiddle ? 'middle' : 'end'; + } + }; + Axis.prototype.xForXAxisLabel = function xForXAxisLabel() { + return this.xForAxisLabel(!this.owner.config.axis_rotated, this.getXAxisLabelPosition()); + }; + Axis.prototype.xForYAxisLabel = function xForYAxisLabel() { + return this.xForAxisLabel(this.owner.config.axis_rotated, this.getYAxisLabelPosition()); + }; + Axis.prototype.xForY2AxisLabel = function xForY2AxisLabel() { + return this.xForAxisLabel(this.owner.config.axis_rotated, this.getY2AxisLabelPosition()); + }; + Axis.prototype.dxForXAxisLabel = function dxForXAxisLabel() { + return this.dxForAxisLabel(!this.owner.config.axis_rotated, this.getXAxisLabelPosition()); + }; + Axis.prototype.dxForYAxisLabel = function dxForYAxisLabel() { + return this.dxForAxisLabel(this.owner.config.axis_rotated, this.getYAxisLabelPosition()); + }; + Axis.prototype.dxForY2AxisLabel = function dxForY2AxisLabel() { + return this.dxForAxisLabel(this.owner.config.axis_rotated, this.getY2AxisLabelPosition()); + }; + Axis.prototype.dyForXAxisLabel = function dyForXAxisLabel() { + var $$ = this.owner, config = $$.config, position = this.getXAxisLabelPosition(); + if (config.axis_rotated) { + return position.isInner + ? '1.2em' + : -25 - ($$.config.axis_x_inner ? 0 : this.getMaxTickWidth('x')); + } + else { + return position.isInner ? '-0.5em' : $$.getHorizontalAxisHeight('x') - 10; + } + }; + Axis.prototype.dyForYAxisLabel = function dyForYAxisLabel() { + var $$ = this.owner, position = this.getYAxisLabelPosition(); + if ($$.config.axis_rotated) { + return position.isInner ? '-0.5em' : '3em'; + } + else { + return position.isInner + ? '1.2em' + : -10 - ($$.config.axis_y_inner ? 0 : this.getMaxTickWidth('y') + 10); + } + }; + Axis.prototype.dyForY2AxisLabel = function dyForY2AxisLabel() { + var $$ = this.owner, position = this.getY2AxisLabelPosition(); + if ($$.config.axis_rotated) { + return position.isInner ? '1.2em' : '-2.2em'; + } + else { + return position.isInner + ? '-0.5em' + : 15 + ($$.config.axis_y2_inner ? 0 : this.getMaxTickWidth('y2') + 15); + } + }; + Axis.prototype.textAnchorForXAxisLabel = function textAnchorForXAxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel(!$$.config.axis_rotated, this.getXAxisLabelPosition()); + }; + Axis.prototype.textAnchorForYAxisLabel = function textAnchorForYAxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel($$.config.axis_rotated, this.getYAxisLabelPosition()); + }; + Axis.prototype.textAnchorForY2AxisLabel = function textAnchorForY2AxisLabel() { + var $$ = this.owner; + return this.textAnchorForAxisLabel($$.config.axis_rotated, this.getY2AxisLabelPosition()); + }; + Axis.prototype.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) { + var $$ = this.owner, maxWidth = 0, targetsToShow, scale, axis, dummy, svg; + if (withoutRecompute && $$.currentMaxTickWidths[id]) { + return $$.currentMaxTickWidths[id]; + } + if ($$.svg) { + targetsToShow = $$.filterTargetsToShow($$.data.targets); + if (id === 'y') { + scale = $$.y.copy().domain($$.getYDomain(targetsToShow, 'y')); + axis = this.getYAxis(id, scale, $$.yOrient, $$.yAxisTickValues, false, true, true); + } + else if (id === 'y2') { + scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); + axis = this.getYAxis(id, scale, $$.y2Orient, $$.y2AxisTickValues, false, true, true); + } + else { + scale = $$.x.copy().domain($$.getXDomain(targetsToShow)); + axis = this.getXAxis(scale, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues, false, true, true); + this.updateXAxisTickValues(targetsToShow, axis); + } + dummy = $$.d3 + .select('body') + .append('div') + .classed('c3', true); + (svg = dummy + .append('svg') + .style('visibility', 'hidden') + .style('position', 'fixed') + .style('top', 0) + .style('left', 0)), + svg + .append('g') + .call(axis) + .each(function () { + $$.d3 + .select(this) + .selectAll('text') + .each(function () { + var box = getBBox(this); + if (maxWidth < box.width) { + maxWidth = box.width; + } + }); + dummy.remove(); + }); + } + $$.currentMaxTickWidths[id] = + maxWidth <= 0 ? $$.currentMaxTickWidths[id] : maxWidth; + return $$.currentMaxTickWidths[id]; + }; + Axis.prototype.updateLabels = function updateLabels(withTransition) { + var $$ = this.owner; + var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel), axisYLabel = $$.main.select('.' + CLASS.axisY + ' .' + CLASS.axisYLabel), axisY2Label = $$.main.select('.' + CLASS.axisY2 + ' .' + CLASS.axisY2Label); + (withTransition ? axisXLabel.transition() : axisXLabel) + .attr('x', this.xForXAxisLabel.bind(this)) + .attr('dx', this.dxForXAxisLabel.bind(this)) + .attr('dy', this.dyForXAxisLabel.bind(this)) + .text(this.textForXAxisLabel.bind(this)); + (withTransition ? axisYLabel.transition() : axisYLabel) + .attr('x', this.xForYAxisLabel.bind(this)) + .attr('dx', this.dxForYAxisLabel.bind(this)) + .attr('dy', this.dyForYAxisLabel.bind(this)) + .text(this.textForYAxisLabel.bind(this)); + (withTransition ? axisY2Label.transition() : axisY2Label) + .attr('x', this.xForY2AxisLabel.bind(this)) + .attr('dx', this.dxForY2AxisLabel.bind(this)) + .attr('dy', this.dyForY2AxisLabel.bind(this)) + .text(this.textForY2AxisLabel.bind(this)); + }; + Axis.prototype.getPadding = function getPadding(padding, key, defaultValue, domainLength) { + var p = typeof padding === 'number' ? padding : padding[key]; + if (!isValue(p)) { + return defaultValue; + } + if (padding.unit === 'ratio') { + return padding[key] * domainLength; + } + // assume padding is pixels if unit is not specified + return this.convertPixelsToAxisPadding(p, domainLength); + }; + Axis.prototype.convertPixelsToAxisPadding = function convertPixelsToAxisPadding(pixels, domainLength) { + var $$ = this.owner, length = $$.config.axis_rotated ? $$.width : $$.height; + return domainLength * (pixels / length); + }; + Axis.prototype.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) { + var tickValues = values, targetCount, start, end, count, interval, i, tickValue; + if (tickCount) { + targetCount = isFunction(tickCount) ? tickCount() : tickCount; + // compute ticks according to tickCount + if (targetCount === 1) { + tickValues = [values[0]]; + } + else if (targetCount === 2) { + tickValues = [values[0], values[values.length - 1]]; + } + else if (targetCount > 2) { + count = targetCount - 2; + start = values[0]; + end = values[values.length - 1]; + interval = (end - start) / (count + 1); + // re-construct unique values + tickValues = [start]; + for (i = 0; i < count; i++) { + tickValue = +start + interval * (i + 1); + tickValues.push(forTimeSeries ? new Date(tickValue) : tickValue); + } + tickValues.push(end); + } + } + if (!forTimeSeries) { + tickValues = tickValues.sort(function (a, b) { + return a - b; + }); + } + return tickValues; + }; + Axis.prototype.generateTransitions = function generateTransitions(duration) { + var $$ = this.owner, axes = $$.axes; + return { + axisX: duration ? axes.x.transition().duration(duration) : axes.x, + axisY: duration ? axes.y.transition().duration(duration) : axes.y, + axisY2: duration ? axes.y2.transition().duration(duration) : axes.y2, + axisSubX: duration ? axes.subx.transition().duration(duration) : axes.subx + }; + }; + Axis.prototype.redraw = function redraw(duration, isHidden) { + var $$ = this.owner, transition = duration ? $$.d3.transition().duration(duration) : null; + $$.axes.x.style('opacity', isHidden ? 0 : 1).call($$.xAxis, transition); + $$.axes.y.style('opacity', isHidden ? 0 : 1).call($$.yAxis, transition); + $$.axes.y2.style('opacity', isHidden ? 0 : 1).call($$.y2Axis, transition); + $$.axes.subx.style('opacity', isHidden ? 0 : 1).call($$.subXAxis, transition); + }; + + var c3 = { + version: '0.7.20', + chart: { + fn: Chart.prototype, + internal: { + fn: ChartInternal.prototype, + axis: { + fn: AxisClass.prototype, + internal: { + fn: AxisInternal.prototype + } + } + } + }, + generate: function (config) { + return new Chart(config); + } + }; + ChartInternal.prototype.beforeInit = function () { + // can do something + }; + ChartInternal.prototype.afterInit = function () { + // can do something + }; + ChartInternal.prototype.init = function () { + var $$ = this, config = $$.config; + $$.initParams(); + if (config.data_url) { + $$.convertUrlToData(config.data_url, config.data_mimeType, config.data_headers, config.data_keys, $$.initWithData); + } + else if (config.data_json) { + $$.initWithData($$.convertJsonToData(config.data_json, config.data_keys)); + } + else if (config.data_rows) { + $$.initWithData($$.convertRowsToData(config.data_rows)); + } + else if (config.data_columns) { + $$.initWithData($$.convertColumnsToData(config.data_columns)); + } + else { + throw Error('url or json or rows or columns is required.'); + } + }; + ChartInternal.prototype.initParams = function () { + var $$ = this, d3 = $$.d3, config = $$.config; + // MEMO: clipId needs to be unique because it conflicts when multiple charts exist + $$.clipId = 'c3-' + new Date().valueOf() + '-clip'; + $$.clipIdForXAxis = $$.clipId + '-xaxis'; + $$.clipIdForYAxis = $$.clipId + '-yaxis'; + $$.clipIdForGrid = $$.clipId + '-grid'; + $$.clipIdForSubchart = $$.clipId + '-subchart'; + $$.clipPath = $$.getClipPath($$.clipId); + $$.clipPathForXAxis = $$.getClipPath($$.clipIdForXAxis); + $$.clipPathForYAxis = $$.getClipPath($$.clipIdForYAxis); + $$.clipPathForGrid = $$.getClipPath($$.clipIdForGrid); + $$.clipPathForSubchart = $$.getClipPath($$.clipIdForSubchart); + $$.dragStart = null; + $$.dragging = false; + $$.flowing = false; + $$.cancelClick = false; + $$.mouseover = undefined; + $$.transiting = false; + $$.color = $$.generateColor(); + $$.levelColor = $$.generateLevelColor(); + $$.dataTimeParse = (config.data_xLocaltime ? d3.timeParse : d3.utcParse)($$.config.data_xFormat); + $$.axisTimeFormat = config.axis_x_localtime ? d3.timeFormat : d3.utcFormat; + $$.defaultAxisTimeFormat = function (date) { + if (date.getMilliseconds()) { + return d3.timeFormat('.%L')(date); + } + if (date.getSeconds()) { + return d3.timeFormat(':%S')(date); + } + if (date.getMinutes()) { + return d3.timeFormat('%I:%M')(date); + } + if (date.getHours()) { + return d3.timeFormat('%I %p')(date); + } + if (date.getDay() && date.getDate() !== 1) { + return d3.timeFormat('%-m/%-d')(date); + } + if (date.getDate() !== 1) { + return d3.timeFormat('%-m/%-d')(date); + } + if (date.getMonth()) { + return d3.timeFormat('%-m/%-d')(date); + } + return d3.timeFormat('%Y/%-m/%-d')(date); + }; + $$.hiddenTargetIds = []; + $$.hiddenLegendIds = []; + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; + $$.xOrient = config.axis_rotated + ? config.axis_x_inner + ? 'right' + : 'left' + : config.axis_x_inner + ? 'top' + : 'bottom'; + $$.yOrient = config.axis_rotated + ? config.axis_y_inner + ? 'top' + : 'bottom' + : config.axis_y_inner + ? 'right' + : 'left'; + $$.y2Orient = config.axis_rotated + ? config.axis_y2_inner + ? 'bottom' + : 'top' + : config.axis_y2_inner + ? 'left' + : 'right'; + $$.subXOrient = config.axis_rotated ? 'left' : 'bottom'; + $$.isLegendRight = config.legend_position === 'right'; + $$.isLegendInset = config.legend_position === 'inset'; + $$.isLegendTop = + config.legend_inset_anchor === 'top-left' || + config.legend_inset_anchor === 'top-right'; + $$.isLegendLeft = + config.legend_inset_anchor === 'top-left' || + config.legend_inset_anchor === 'bottom-left'; + $$.legendStep = 0; + $$.legendItemWidth = 0; + $$.legendItemHeight = 0; + $$.currentMaxTickWidths = { + x: 0, + y: 0, + y2: 0 + }; + $$.rotated_padding_left = 30; + $$.rotated_padding_right = config.axis_rotated && !config.axis_x_show ? 0 : 30; + $$.rotated_padding_top = 5; + $$.withoutFadeIn = {}; + $$.intervalForObserveInserted = undefined; + $$.axes.subx = d3.selectAll([]); // needs when excluding subchart.js + }; + ChartInternal.prototype.initChartElements = function () { + if (this.initBar) { + this.initBar(); + } + if (this.initLine) { + this.initLine(); + } + if (this.initArc) { + this.initArc(); + } + if (this.initGauge) { + this.initGauge(); + } + if (this.initText) { + this.initText(); + } + }; + ChartInternal.prototype.initWithData = function (data) { + var $$ = this, d3 = $$.d3, config = $$.config; + var defs, main, binding = true; + $$.axis = new AxisClass($$); + if (!config.bindto) { + $$.selectChart = d3.selectAll([]); + } + else if (typeof config.bindto.node === 'function') { + $$.selectChart = config.bindto; + } + else { + $$.selectChart = d3.select(config.bindto); + } + if ($$.selectChart.empty()) { + $$.selectChart = d3 + .select(document.createElement('div')) + .style('opacity', 0); + $$.observeInserted($$.selectChart); + binding = false; + } + $$.selectChart.html('').classed('c3', true); + // Init data as targets + $$.data.xs = {}; + $$.data.targets = $$.convertDataToTargets(data); + if (config.data_filter) { + $$.data.targets = $$.data.targets.filter(config.data_filter); + } + // Set targets to hide if needed + if (config.data_hide) { + $$.addHiddenTargetIds(config.data_hide === true + ? $$.mapToIds($$.data.targets) + : config.data_hide); + } + if (config.legend_hide) { + $$.addHiddenLegendIds(config.legend_hide === true + ? $$.mapToIds($$.data.targets) + : config.legend_hide); + } + if ($$.isStanfordGraphType()) { + $$.initStanfordData(); + } + // Init sizes and scales + $$.updateSizes(); + $$.updateScales(); + // Set domains for each scale + $$.x.domain(d3.extent($$.getXDomain($$.data.targets))); + $$.y.domain($$.getYDomain($$.data.targets, 'y')); + $$.y2.domain($$.getYDomain($$.data.targets, 'y2')); + $$.subX.domain($$.x.domain()); + $$.subY.domain($$.y.domain()); + $$.subY2.domain($$.y2.domain()); + // Save original x domain for zoom update + $$.orgXDomain = $$.x.domain(); + /*-- Basic Elements --*/ + // Define svgs + $$.svg = $$.selectChart + .append('svg') + .style('overflow', 'hidden') + .on('mouseenter', function () { + return config.onmouseover.call($$); + }) + .on('mouseleave', function () { + return config.onmouseout.call($$); + }); + if ($$.config.svg_classname) { + $$.svg.attr('class', $$.config.svg_classname); + } + // Define defs + defs = $$.svg.append('defs'); + $$.clipChart = $$.appendClip(defs, $$.clipId); + $$.clipXAxis = $$.appendClip(defs, $$.clipIdForXAxis); + $$.clipYAxis = $$.appendClip(defs, $$.clipIdForYAxis); + $$.clipGrid = $$.appendClip(defs, $$.clipIdForGrid); + $$.clipSubchart = $$.appendClip(defs, $$.clipIdForSubchart); + $$.updateSvgSize(); + // Define regions + main = $$.main = $$.svg.append('g').attr('transform', $$.getTranslate('main')); + if ($$.initPie) { + $$.initPie(); + } + if ($$.initDragZoom) { + $$.initDragZoom(); + } + if (config.subchart_show && $$.initSubchart) { + $$.initSubchart(); + } + if ($$.initTooltip) { + $$.initTooltip(); + } + if ($$.initLegend) { + $$.initLegend(); + } + if ($$.initTitle) { + $$.initTitle(); + } + if ($$.initZoom) { + $$.initZoom(); + } + if ($$.isStanfordGraphType()) { + $$.drawColorScale(); + } + // Update selection based on size and scale + // TODO: currently this must be called after initLegend because of update of sizes, but it should be done in initSubchart. + if (config.subchart_show && $$.initSubchartBrush) { + $$.initSubchartBrush(); + } + /*-- Main Region --*/ + // text when empty + main + .append('text') + .attr('class', CLASS.text + ' ' + CLASS.empty) + .attr('text-anchor', 'middle') // horizontal centering of text at x position in all browsers. + .attr('dominant-baseline', 'middle'); // vertical centering of text at y position in all browsers, except IE. + // Regions + $$.initRegion(); + // Grids + $$.initGrid(); + // Define g for chart area + main + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.chart); + // Grid lines + if (config.grid_lines_front) { + $$.initGridLines(); + } + $$.initStanfordElements(); + // Cover whole with rects for events + $$.initEventRect(); + // Define g for chart + $$.initChartElements(); + // Add Axis + $$.axis.init(); + // Set targets + $$.updateTargets($$.data.targets); + // Set default extent if defined + if (config.axis_x_selection) { + $$.brush.selectionAsValue($$.getDefaultSelection()); + } + // Draw with targets + if (binding) { + $$.updateDimension(); + $$.config.oninit.call($$); + $$.redraw({ + withTransition: false, + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransitionForAxis: false + }); + } + // Bind to resize event + $$.bindResize(); + // Bind to window focus event + $$.bindWindowFocus(); + // export element of the chart + $$.api.element = $$.selectChart.node(); + }; + ChartInternal.prototype.smoothLines = function (el, type) { + var $$ = this; + if (type === 'grid') { + el.each(function () { + var g = $$.d3.select(this), x1 = g.attr('x1'), x2 = g.attr('x2'), y1 = g.attr('y1'), y2 = g.attr('y2'); + g.attr({ + x1: Math.ceil(x1), + x2: Math.ceil(x2), + y1: Math.ceil(y1), + y2: Math.ceil(y2) + }); + }); + } + }; + ChartInternal.prototype.updateSizes = function () { + var $$ = this, config = $$.config; + var legendHeight = $$.legend ? $$.getLegendHeight() : 0, legendWidth = $$.legend ? $$.getLegendWidth() : 0, legendHeightForBottom = $$.isLegendRight || $$.isLegendInset ? 0 : legendHeight, hasArc = $$.hasArcType(), xAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x'), subchartXAxisHeight = config.axis_rotated || hasArc ? 0 : $$.getHorizontalAxisHeight('x', true), subchartHeight = config.subchart_show && !hasArc + ? config.subchart_size_height + subchartXAxisHeight + : 0; + $$.currentWidth = $$.getCurrentWidth(); + $$.currentHeight = $$.getCurrentHeight(); + // for main + $$.margin = config.axis_rotated + ? { + top: $$.getHorizontalAxisHeight('y2') + $$.getCurrentPaddingTop(), + right: hasArc ? 0 : $$.getCurrentPaddingRight(), + bottom: $$.getHorizontalAxisHeight('y') + + legendHeightForBottom + + $$.getCurrentPaddingBottom(), + left: subchartHeight + (hasArc ? 0 : $$.getCurrentPaddingLeft()) + } + : { + top: 4 + $$.getCurrentPaddingTop(), + right: hasArc ? 0 : $$.getCurrentPaddingRight(), + bottom: xAxisHeight + + subchartHeight + + legendHeightForBottom + + $$.getCurrentPaddingBottom(), + left: hasArc ? 0 : $$.getCurrentPaddingLeft() + }; + // for subchart + $$.margin2 = config.axis_rotated + ? { + top: $$.margin.top, + right: NaN, + bottom: 20 + legendHeightForBottom, + left: $$.rotated_padding_left + } + : { + top: $$.currentHeight - subchartHeight - legendHeightForBottom, + right: NaN, + bottom: subchartXAxisHeight + legendHeightForBottom, + left: $$.margin.left + }; + // for legend + $$.margin3 = { + top: 0, + right: NaN, + bottom: 0, + left: 0 + }; + if ($$.updateSizeForLegend) { + $$.updateSizeForLegend(legendHeight, legendWidth); + } + $$.width = $$.currentWidth - $$.margin.left - $$.margin.right; + $$.height = $$.currentHeight - $$.margin.top - $$.margin.bottom; + if ($$.width < 0) { + $$.width = 0; + } + if ($$.height < 0) { + $$.height = 0; + } + $$.width2 = config.axis_rotated + ? $$.margin.left - $$.rotated_padding_left - $$.rotated_padding_right + : $$.width; + $$.height2 = config.axis_rotated + ? $$.height + : $$.currentHeight - $$.margin2.top - $$.margin2.bottom; + if ($$.width2 < 0) { + $$.width2 = 0; + } + if ($$.height2 < 0) { + $$.height2 = 0; + } + // for arc + $$.arcWidth = $$.width - ($$.isLegendRight ? legendWidth + 10 : 0); + $$.arcHeight = $$.height - ($$.isLegendRight ? 0 : 10); + if ($$.hasType('gauge') && !config.gauge_fullCircle) { + $$.arcHeight += $$.height - $$.getGaugeLabelHeight(); + } + if ($$.updateRadius) { + $$.updateRadius(); + } + if ($$.isLegendRight && hasArc) { + $$.margin3.left = $$.arcWidth / 2 + $$.radiusExpanded * 1.1; + } + }; + ChartInternal.prototype.updateTargets = function (targets) { + var $$ = this, config = $$.config; + /*-- Main --*/ + //-- Text --// + $$.updateTargetsForText(targets); + //-- Bar --// + $$.updateTargetsForBar(targets); + //-- Line --// + $$.updateTargetsForLine(targets); + //-- Arc --// + if ($$.hasArcType() && $$.updateTargetsForArc) { + $$.updateTargetsForArc(targets); + } + /*-- Sub --*/ + if (config.subchart_show && $$.updateTargetsForSubchart) { + $$.updateTargetsForSubchart(targets); + } + // Fade-in each chart + $$.showTargets(); + }; + ChartInternal.prototype.showTargets = function () { + var $$ = this; + $$.svg + .selectAll('.' + CLASS.target) + .filter(function (d) { + return $$.isTargetToShow(d.id); + }) + .transition() + .duration($$.config.transition_duration) + .style('opacity', 1); + }; + ChartInternal.prototype.redraw = function (options, transitions) { + var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config; + var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType); + var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend, withEventRect, withDimension, withUpdateXAxis; + var hideAxis = $$.hasArcType(); + var drawArea, drawBar, drawLine, xForText, yForText; + var duration, durationForExit, durationForAxis; + var transitionsToWait, waitForDraw, flow, transition; + var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling, xDomainForZoom; + var xv = $$.xv.bind($$), cx, cy; + options = options || {}; + withY = getOption(options, 'withY', true); + withSubchart = getOption(options, 'withSubchart', true); + withTransition = getOption(options, 'withTransition', true); + withTransform = getOption(options, 'withTransform', false); + withUpdateXDomain = getOption(options, 'withUpdateXDomain', false); + withUpdateOrgXDomain = getOption(options, 'withUpdateOrgXDomain', false); + withTrimXDomain = getOption(options, 'withTrimXDomain', true); + withUpdateXAxis = getOption(options, 'withUpdateXAxis', withUpdateXDomain); + withLegend = getOption(options, 'withLegend', false); + withEventRect = getOption(options, 'withEventRect', true); + withDimension = getOption(options, 'withDimension', true); + withTransitionForExit = getOption(options, 'withTransitionForExit', withTransition); + withTransitionForAxis = getOption(options, 'withTransitionForAxis', withTransition); + duration = withTransition ? config.transition_duration : 0; + durationForExit = withTransitionForExit ? duration : 0; + durationForAxis = withTransitionForAxis ? duration : 0; + transitions = transitions || $$.axis.generateTransitions(durationForAxis); + // update legend and transform each g + if (withLegend && config.legend_show) { + $$.updateLegend($$.mapToIds($$.data.targets), options, transitions); + } + else if (withDimension) { + // need to update dimension (e.g. axis.y.tick.values) because y tick values should change + // no need to update axis in it because they will be updated in redraw() + $$.updateDimension(true); + } + // MEMO: needed for grids calculation + if ($$.isCategorized() && targetsToShow.length === 0) { + $$.x.domain([0, $$.axes.x.selectAll('.tick').size()]); + } + if (targetsToShow.length) { + $$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain); + if (!config.axis_x_tick_values) { + tickValues = $$.axis.updateXAxisTickValues(targetsToShow); + } + } + else { + $$.xAxis.tickValues([]); + $$.subXAxis.tickValues([]); + } + if (config.zoom_rescale && !options.flow) { + xDomainForZoom = $$.x.orgDomain(); + } + $$.y.domain($$.getYDomain(targetsToShow, 'y', xDomainForZoom)); + $$.y2.domain($$.getYDomain(targetsToShow, 'y2', xDomainForZoom)); + if (!config.axis_y_tick_values && config.axis_y_tick_count) { + $$.yAxis.tickValues($$.axis.generateTickValues($$.y.domain(), config.axis_y_tick_count)); + } + if (!config.axis_y2_tick_values && config.axis_y2_tick_count) { + $$.y2Axis.tickValues($$.axis.generateTickValues($$.y2.domain(), config.axis_y2_tick_count)); + } + // axes + $$.axis.redraw(durationForAxis, hideAxis); + // Update axis label + $$.axis.updateLabels(withTransition); + // show/hide if manual culling needed + if ((withUpdateXDomain || withUpdateXAxis) && targetsToShow.length) { + if (config.axis_x_tick_culling && tickValues) { + for (i = 1; i < tickValues.length; i++) { + if (tickValues.length / i < config.axis_x_tick_culling_max) { + intervalForCulling = i; + break; + } + } + $$.svg.selectAll('.' + CLASS.axisX + ' .tick text').each(function (e) { + var index = tickValues.indexOf(e); + if (index >= 0) { + d3.select(this).style('display', index % intervalForCulling ? 'none' : 'block'); + } + }); + } + else { + $$.svg + .selectAll('.' + CLASS.axisX + ' .tick text') + .style('display', 'block'); + } + } + // setup drawer - MEMO: these must be called after axis updated + drawArea = $$.generateDrawArea + ? $$.generateDrawArea(areaIndices, false) + : undefined; + drawBar = $$.generateDrawBar ? $$.generateDrawBar(barIndices) : undefined; + drawLine = $$.generateDrawLine + ? $$.generateDrawLine(lineIndices, false) + : undefined; + xForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, true); + yForText = $$.generateXYForText(areaIndices, barIndices, lineIndices, false); + // update circleY based on updated parameters + $$.updateCircleY(); + // generate circle x/y functions depending on updated params + cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$); + cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); + // Update sub domain + if (withY) { + $$.subY.domain($$.getYDomain(targetsToShow, 'y')); + $$.subY2.domain($$.getYDomain(targetsToShow, 'y2')); + } + // xgrid focus + $$.updateXgridFocus(); + // Data empty label positioning and text. + main + .select('text.' + CLASS.text + '.' + CLASS.empty) + .attr('x', $$.width / 2) + .attr('y', $$.height / 2) + .text(config.data_empty_label_text) + .transition() + .style('opacity', targetsToShow.length ? 0 : 1); + // event rect + if (withEventRect) { + $$.redrawEventRect(); + } + // grid + $$.updateGrid(duration); + $$.updateStanfordElements(duration); + // rect for regions + $$.updateRegion(duration); + // bars + $$.updateBar(durationForExit); + // lines, areas and circles + $$.updateLine(durationForExit); + $$.updateArea(durationForExit); + $$.updateCircle(cx, cy); + // text + if ($$.hasDataLabel()) { + $$.updateText(xForText, yForText, durationForExit); + } + // title + if ($$.redrawTitle) { + $$.redrawTitle(); + } + // arc + if ($$.redrawArc) { + $$.redrawArc(duration, durationForExit, withTransform); + } + // subchart + if (config.subchart_show && $$.redrawSubchart) { + $$.redrawSubchart(withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices); + } + if ($$.isStanfordGraphType()) { + $$.drawColorScale(); + } + // circles for select + main + .selectAll('.' + CLASS.selectedCircles) + .filter($$.isBarType.bind($$)) + .selectAll('circle') + .remove(); + if (options.flow) { + flow = $$.generateFlow({ + targets: targetsToShow, + flow: options.flow, + duration: options.flow.duration, + drawBar: drawBar, + drawLine: drawLine, + drawArea: drawArea, + cx: cx, + cy: cy, + xv: xv, + xForText: xForText, + yForText: yForText + }); + } + if (duration && $$.isTabVisible()) { + // Only use transition if tab visible. See #938. + // transition should be derived from one transition + transition = d3.transition().duration(duration); + transitionsToWait = []; + [ + $$.redrawBar(drawBar, true, transition), + $$.redrawLine(drawLine, true, transition), + $$.redrawArea(drawArea, true, transition), + $$.redrawCircle(cx, cy, true, transition), + $$.redrawText(xForText, yForText, options.flow, true, transition), + $$.redrawRegion(true, transition), + $$.redrawGrid(true, transition) + ].forEach(function (transitions) { + transitions.forEach(function (transition) { + transitionsToWait.push(transition); + }); + }); + // Wait for end of transitions to call flow and onrendered callback + waitForDraw = $$.generateWait(); + transitionsToWait.forEach(function (t) { + waitForDraw.add(t); + }); + waitForDraw(function () { + if (flow) { + flow(); + } + if (config.onrendered) { + config.onrendered.call($$); + } + }); + } + else { + $$.redrawBar(drawBar); + $$.redrawLine(drawLine); + $$.redrawArea(drawArea); + $$.redrawCircle(cx, cy); + $$.redrawText(xForText, yForText, options.flow); + $$.redrawRegion(); + $$.redrawGrid(); + if (flow) { + flow(); + } + if (config.onrendered) { + config.onrendered.call($$); + } + } + // update fadein condition + $$.mapToIds($$.data.targets).forEach(function (id) { + $$.withoutFadeIn[id] = true; + }); + }; + ChartInternal.prototype.updateAndRedraw = function (options) { + var $$ = this, config = $$.config, transitions; + options = options || {}; + // same with redraw + options.withTransition = getOption(options, 'withTransition', true); + options.withTransform = getOption(options, 'withTransform', false); + options.withLegend = getOption(options, 'withLegend', false); + // NOT same with redraw + options.withUpdateXDomain = getOption(options, 'withUpdateXDomain', true); + options.withUpdateOrgXDomain = getOption(options, 'withUpdateOrgXDomain', true); + options.withTransitionForExit = false; + options.withTransitionForTransform = getOption(options, 'withTransitionForTransform', options.withTransition); + // MEMO: this needs to be called before updateLegend and it means this ALWAYS needs to be called) + $$.updateSizes(); + // MEMO: called in updateLegend in redraw if withLegend + if (!(options.withLegend && config.legend_show)) { + transitions = $$.axis.generateTransitions(options.withTransitionForAxis ? config.transition_duration : 0); + // Update scales + $$.updateScales(); + $$.updateSvgSize(); + // Update g positions + $$.transformAll(options.withTransitionForTransform, transitions); + } + // Draw with new sizes & scales + $$.redraw(options, transitions); + }; + ChartInternal.prototype.redrawWithoutRescale = function () { + this.redraw({ + withY: false, + withSubchart: false, + withEventRect: false, + withTransitionForAxis: false + }); + }; + ChartInternal.prototype.isTimeSeries = function () { + return this.config.axis_x_type === 'timeseries'; + }; + ChartInternal.prototype.isCategorized = function () { + return this.config.axis_x_type.indexOf('categor') >= 0; + }; + ChartInternal.prototype.isCustomX = function () { + var $$ = this, config = $$.config; + return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)); + }; + ChartInternal.prototype.isTimeSeriesY = function () { + return this.config.axis_y_type === 'timeseries'; + }; + ChartInternal.prototype.getTranslate = function (target) { + var $$ = this, config = $$.config, x, y; + if (target === 'main') { + x = asHalfPixel($$.margin.left); + y = asHalfPixel($$.margin.top); + } + else if (target === 'context') { + x = asHalfPixel($$.margin2.left); + y = asHalfPixel($$.margin2.top); + } + else if (target === 'legend') { + x = $$.margin3.left; + y = $$.margin3.top; + } + else if (target === 'x') { + x = 0; + y = config.axis_rotated ? 0 : $$.height; + } + else if (target === 'y') { + x = 0; + y = config.axis_rotated ? $$.height : 0; + } + else if (target === 'y2') { + x = config.axis_rotated ? 0 : $$.width; + y = config.axis_rotated ? 1 : 0; + } + else if (target === 'subx') { + x = 0; + y = config.axis_rotated ? 0 : $$.height2; + } + else if (target === 'arc') { + x = $$.arcWidth / 2; + y = $$.arcHeight / 2 - ($$.hasType('gauge') ? 6 : 0); // to prevent wrong display of min and max label + } + return 'translate(' + x + ',' + y + ')'; + }; + ChartInternal.prototype.initialOpacity = function (d) { + return d.value !== null && this.withoutFadeIn[d.id] ? 1 : 0; + }; + ChartInternal.prototype.initialOpacityForCircle = function (d) { + return d.value !== null && this.withoutFadeIn[d.id] + ? this.opacityForCircle(d) + : 0; + }; + ChartInternal.prototype.opacityForCircle = function (d) { + var isPointShouldBeShown = isFunction(this.config.point_show) + ? this.config.point_show(d) + : this.config.point_show; + var opacity = isPointShouldBeShown || this.isStanfordType(d) ? 1 : 0; + return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0; + }; + ChartInternal.prototype.opacityForText = function () { + return this.hasDataLabel() ? 1 : 0; + }; + ChartInternal.prototype.xx = function (d) { + return d ? this.x(d.x) : null; + }; + ChartInternal.prototype.xvCustom = function (d, xyValue) { + var $$ = this, value = xyValue ? d[xyValue] : d.value; + if ($$.isTimeSeries()) { + value = $$.parseDate(d.value); + } + else if ($$.isCategorized() && typeof d.value === 'string') { + value = $$.config.axis_x_categories.indexOf(d.value); + } + return Math.ceil($$.x(value)); + }; + ChartInternal.prototype.yvCustom = function (d, xyValue) { + var $$ = this, yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y, value = xyValue ? d[xyValue] : d.value; + return Math.ceil(yScale(value)); + }; + ChartInternal.prototype.xv = function (d) { + var $$ = this, value = d.value; + if ($$.isTimeSeries()) { + value = $$.parseDate(d.value); + } + else if ($$.isCategorized() && typeof d.value === 'string') { + value = $$.config.axis_x_categories.indexOf(d.value); + } + return Math.ceil($$.x(value)); + }; + ChartInternal.prototype.yv = function (d) { + var $$ = this, yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y; + return Math.ceil(yScale(d.value)); + }; + ChartInternal.prototype.subxx = function (d) { + return d ? this.subX(d.x) : null; + }; + ChartInternal.prototype.transformMain = function (withTransition, transitions) { + var $$ = this, xAxis, yAxis, y2Axis; + if (transitions && transitions.axisX) { + xAxis = transitions.axisX; + } + else { + xAxis = $$.main.select('.' + CLASS.axisX); + if (withTransition) { + xAxis = xAxis.transition(); + } + } + if (transitions && transitions.axisY) { + yAxis = transitions.axisY; + } + else { + yAxis = $$.main.select('.' + CLASS.axisY); + if (withTransition) { + yAxis = yAxis.transition(); + } + } + if (transitions && transitions.axisY2) { + y2Axis = transitions.axisY2; + } + else { + y2Axis = $$.main.select('.' + CLASS.axisY2); + if (withTransition) { + y2Axis = y2Axis.transition(); + } + } + (withTransition ? $$.main.transition() : $$.main).attr('transform', $$.getTranslate('main')); + xAxis.attr('transform', $$.getTranslate('x')); + yAxis.attr('transform', $$.getTranslate('y')); + y2Axis.attr('transform', $$.getTranslate('y2')); + $$.main + .select('.' + CLASS.chartArcs) + .attr('transform', $$.getTranslate('arc')); + }; + ChartInternal.prototype.transformAll = function (withTransition, transitions) { + var $$ = this; + $$.transformMain(withTransition, transitions); + if ($$.config.subchart_show) { + $$.transformContext(withTransition, transitions); + } + if ($$.legend) { + $$.transformLegend(withTransition); + } + }; + ChartInternal.prototype.updateSvgSize = function () { + var $$ = this, brush = $$.svg.select("." + CLASS.brush + " .overlay"); + $$.svg.attr('width', $$.currentWidth).attr('height', $$.currentHeight); + $$.svg + .selectAll(['#' + $$.clipId, '#' + $$.clipIdForGrid]) + .select('rect') + .attr('width', $$.width) + .attr('height', $$.height); + $$.svg + .select('#' + $$.clipIdForXAxis) + .select('rect') + .attr('x', $$.getXAxisClipX.bind($$)) + .attr('y', $$.getXAxisClipY.bind($$)) + .attr('width', $$.getXAxisClipWidth.bind($$)) + .attr('height', $$.getXAxisClipHeight.bind($$)); + $$.svg + .select('#' + $$.clipIdForYAxis) + .select('rect') + .attr('x', $$.getYAxisClipX.bind($$)) + .attr('y', $$.getYAxisClipY.bind($$)) + .attr('width', $$.getYAxisClipWidth.bind($$)) + .attr('height', $$.getYAxisClipHeight.bind($$)); + $$.svg + .select('#' + $$.clipIdForSubchart) + .select('rect') + .attr('width', $$.width) + .attr('height', (brush.size() && brush.attr('height')) || 0); + // MEMO: parent div's height will be bigger than svg when + $$.selectChart.style('max-height', $$.currentHeight + 'px'); + }; + ChartInternal.prototype.updateDimension = function (withoutAxis) { + var $$ = this; + if (!withoutAxis) { + if ($$.config.axis_rotated) { + $$.axes.x.call($$.xAxis); + $$.axes.subx.call($$.subXAxis); + } + else { + $$.axes.y.call($$.yAxis); + $$.axes.y2.call($$.y2Axis); + } + } + $$.updateSizes(); + $$.updateScales(); + $$.updateSvgSize(); + $$.transformAll(false); + }; + ChartInternal.prototype.observeInserted = function (selection) { + var $$ = this, observer; + if (typeof MutationObserver === 'undefined') { + window.console.error('MutationObserver not defined.'); + return; + } + observer = new MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + if (mutation.type === 'childList' && mutation.previousSibling) { + observer.disconnect(); + // need to wait for completion of load because size calculation requires the actual sizes determined after that completion + $$.intervalForObserveInserted = window.setInterval(function () { + // parentNode will NOT be null when completed + if (selection.node().parentNode) { + window.clearInterval($$.intervalForObserveInserted); + $$.updateDimension(); + if ($$.brush) { + $$.brush.update(); + } + $$.config.oninit.call($$); + $$.redraw({ + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransition: false, + withTransitionForTransform: false, + withLegend: true + }); + selection.transition().style('opacity', 1); + } + }, 10); + } + }); + }); + observer.observe(selection.node(), { + attributes: true, + childList: true, + characterData: true + }); + }; + /** + * Binds handlers to the window resize event. + */ + ChartInternal.prototype.bindResize = function () { + var $$ = this, config = $$.config; + $$.resizeFunction = $$.generateResize(); // need to call .remove + $$.resizeFunction.add(function () { + config.onresize.call($$); + }); + if (config.resize_auto) { + $$.resizeFunction.add(function () { + if ($$.resizeTimeout !== undefined) { + window.clearTimeout($$.resizeTimeout); + } + $$.resizeTimeout = window.setTimeout(function () { + delete $$.resizeTimeout; + $$.updateAndRedraw({ + withUpdateXDomain: false, + withUpdateOrgXDomain: false, + withTransition: false, + withTransitionForTransform: false, + withLegend: true + }); + if ($$.brush) { + $$.brush.update(); + } + }, 100); + }); + } + $$.resizeFunction.add(function () { + config.onresized.call($$); + }); + $$.resizeIfElementDisplayed = function () { + // if element not displayed skip it + if ($$.api == null || !$$.api.element.offsetParent) { + return; + } + $$.resizeFunction(); + }; + window.addEventListener('resize', $$.resizeIfElementDisplayed, false); + }; + /** + * Binds handlers to the window focus event. + */ + ChartInternal.prototype.bindWindowFocus = function () { + var _this = this; + if (this.windowFocusHandler) { + // The handler is already set + return; + } + this.windowFocusHandler = function () { + _this.redraw(); + }; + window.addEventListener('focus', this.windowFocusHandler); + }; + /** + * Unbinds from the window focus event. + */ + ChartInternal.prototype.unbindWindowFocus = function () { + window.removeEventListener('focus', this.windowFocusHandler); + delete this.windowFocusHandler; + }; + ChartInternal.prototype.generateResize = function () { + var resizeFunctions = []; + function callResizeFunctions() { + resizeFunctions.forEach(function (f) { + f(); + }); + } + callResizeFunctions.add = function (f) { + resizeFunctions.push(f); + }; + callResizeFunctions.remove = function (f) { + for (var i = 0; i < resizeFunctions.length; i++) { + if (resizeFunctions[i] === f) { + resizeFunctions.splice(i, 1); + break; + } + } + }; + return callResizeFunctions; + }; + ChartInternal.prototype.endall = function (transition, callback) { + var n = 0; + transition + .each(function () { + ++n; + }) + .on('end', function () { + if (!--n) { + callback.apply(this, arguments); + } + }); + }; + ChartInternal.prototype.generateWait = function () { + var $$ = this; + var transitionsToWait = [], f = function (callback) { + var timer = setInterval(function () { + if (!$$.isTabVisible()) { + return; + } + var done = 0; + transitionsToWait.forEach(function (t) { + if (t.empty()) { + done += 1; + return; + } + try { + t.transition(); + } + catch (e) { + done += 1; + } + }); + if (done === transitionsToWait.length) { + clearInterval(timer); + if (callback) { + callback(); + } + } + }, 50); + }; + f.add = function (transition) { + transitionsToWait.push(transition); + }; + return f; + }; + ChartInternal.prototype.parseDate = function (date) { + var $$ = this, parsedDate; + if (date instanceof Date) { + parsedDate = date; + } + else if (typeof date === 'string') { + parsedDate = $$.dataTimeParse(date); + } + else if (typeof date === 'object') { + parsedDate = new Date(+date); + } + else if (typeof date === 'number' && !isNaN(date)) { + parsedDate = new Date(+date); + } + if (!parsedDate || isNaN(+parsedDate)) { + window.console.error("Failed to parse x '" + date + "' to Date object"); + } + return parsedDate; + }; + ChartInternal.prototype.isTabVisible = function () { + return !document.hidden; + }; + ChartInternal.prototype.getPathBox = getPathBox; + ChartInternal.prototype.CLASS = CLASS; + + /* jshint ignore:start */ + (function () { + if (!('SVGPathSeg' in window)) { + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg + window.SVGPathSeg = function (type, typeAsLetter, owningPathSegList) { + this.pathSegType = type; + this.pathSegTypeAsLetter = typeAsLetter; + this._owningPathSegList = owningPathSegList; + }; + window.SVGPathSeg.prototype.classname = 'SVGPathSeg'; + window.SVGPathSeg.PATHSEG_UNKNOWN = 0; + window.SVGPathSeg.PATHSEG_CLOSEPATH = 1; + window.SVGPathSeg.PATHSEG_MOVETO_ABS = 2; + window.SVGPathSeg.PATHSEG_MOVETO_REL = 3; + window.SVGPathSeg.PATHSEG_LINETO_ABS = 4; + window.SVGPathSeg.PATHSEG_LINETO_REL = 5; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9; + window.SVGPathSeg.PATHSEG_ARC_ABS = 10; + window.SVGPathSeg.PATHSEG_ARC_REL = 11; + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12; + window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13; + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14; + window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16; + window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18; + window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19; + // Notify owning PathSegList on any changes so they can be synchronized back to the path element. + window.SVGPathSeg.prototype._segmentChanged = function () { + if (this._owningPathSegList) + this._owningPathSegList.segmentChanged(this); + }; + window.SVGPathSegClosePath = function (owningPathSegList) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList); + }; + window.SVGPathSegClosePath.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegClosePath.prototype.toString = function () { + return '[object SVGPathSegClosePath]'; + }; + window.SVGPathSegClosePath.prototype._asPathString = function () { + return this.pathSegTypeAsLetter; + }; + window.SVGPathSegClosePath.prototype.clone = function () { + return new window.SVGPathSegClosePath(undefined); + }; + window.SVGPathSegMovetoAbs = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegMovetoAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegMovetoAbs.prototype.toString = function () { + return '[object SVGPathSegMovetoAbs]'; + }; + window.SVGPathSegMovetoAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegMovetoAbs.prototype.clone = function () { + return new window.SVGPathSegMovetoAbs(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegMovetoAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegMovetoRel = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegMovetoRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegMovetoRel.prototype.toString = function () { + return '[object SVGPathSegMovetoRel]'; + }; + window.SVGPathSegMovetoRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegMovetoRel.prototype.clone = function () { + return new window.SVGPathSegMovetoRel(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegMovetoRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegMovetoRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoAbs = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegLinetoAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoAbs.prototype.toString = function () { + return '[object SVGPathSegLinetoAbs]'; + }; + window.SVGPathSegLinetoAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegLinetoAbs.prototype.clone = function () { + return new window.SVGPathSegLinetoAbs(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegLinetoAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoRel = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegLinetoRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoRel.prototype.toString = function () { + return '[object SVGPathSegLinetoRel]'; + }; + window.SVGPathSegLinetoRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegLinetoRel.prototype.clone = function () { + return new window.SVGPathSegLinetoRel(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegLinetoRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegLinetoRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoCubicAbs = function (owningPathSegList, x, y, x1, y1, x2, y2) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoCubicAbs.prototype.toString = function () { + return '[object SVGPathSegCurvetoCubicAbs]'; + }; + window.SVGPathSegCurvetoCubicAbs.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoCubicAbs.prototype.clone = function () { + return new window.SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x1', { + get: function () { + return this._x1; + }, + set: function (x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y1', { + get: function () { + return this._y1; + }, + set: function (y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'x2', { + get: function () { + return this._x2; + }, + set: function (x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype, 'y2', { + get: function () { + return this._y2; + }, + set: function (y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoCubicRel = function (owningPathSegList, x, y, x1, y1, x2, y2) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoCubicRel.prototype.toString = function () { + return '[object SVGPathSegCurvetoCubicRel]'; + }; + window.SVGPathSegCurvetoCubicRel.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoCubicRel.prototype.clone = function () { + return new window.SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2); + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x1', { + get: function () { + return this._x1; + }, + set: function (x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y1', { + get: function () { + return this._y1; + }, + set: function (y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'x2', { + get: function () { + return this._x2; + }, + set: function (x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype, 'y2', { + get: function () { + return this._y2; + }, + set: function (y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoQuadraticAbs = function (owningPathSegList, x, y, x1, y1) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoQuadraticAbs.prototype.toString = function () { + return '[object SVGPathSegCurvetoQuadraticAbs]'; + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoQuadraticAbs.prototype.clone = function () { + return new window.SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1); + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'x1', { + get: function () { + return this._x1; + }, + set: function (x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype, 'y1', { + get: function () { + return this._y1; + }, + set: function (y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoQuadraticRel = function (owningPathSegList, x, y, x1, y1) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList); + this._x = x; + this._y = y; + this._x1 = x1; + this._y1 = y1; + }; + window.SVGPathSegCurvetoQuadraticRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoQuadraticRel.prototype.toString = function () { + return '[object SVGPathSegCurvetoQuadraticRel]'; + }; + window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x1 + + ' ' + + this._y1 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoQuadraticRel.prototype.clone = function () { + return new window.SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1); + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'x1', { + get: function () { + return this._x1; + }, + set: function (x1) { + this._x1 = x1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype, 'y1', { + get: function () { + return this._y1; + }, + set: function (y1) { + this._y1 = y1; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegArcAbs = function (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + }; + window.SVGPathSegArcAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegArcAbs.prototype.toString = function () { + return '[object SVGPathSegArcAbs]'; + }; + window.SVGPathSegArcAbs.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._r1 + + ' ' + + this._r2 + + ' ' + + this._angle + + ' ' + + (this._largeArcFlag ? '1' : '0') + + ' ' + + (this._sweepFlag ? '1' : '0') + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegArcAbs.prototype.clone = function () { + return new window.SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + }; + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'r1', { + get: function () { + return this._r1; + }, + set: function (r1) { + this._r1 = r1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'r2', { + get: function () { + return this._r2; + }, + set: function (r2) { + this._r2 = r2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'angle', { + get: function () { + return this._angle; + }, + set: function (angle) { + this._angle = angle; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'largeArcFlag', { + get: function () { + return this._largeArcFlag; + }, + set: function (largeArcFlag) { + this._largeArcFlag = largeArcFlag; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcAbs.prototype, 'sweepFlag', { + get: function () { + return this._sweepFlag; + }, + set: function (sweepFlag) { + this._sweepFlag = sweepFlag; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegArcRel = function (owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList); + this._x = x; + this._y = y; + this._r1 = r1; + this._r2 = r2; + this._angle = angle; + this._largeArcFlag = largeArcFlag; + this._sweepFlag = sweepFlag; + }; + window.SVGPathSegArcRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegArcRel.prototype.toString = function () { + return '[object SVGPathSegArcRel]'; + }; + window.SVGPathSegArcRel.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._r1 + + ' ' + + this._r2 + + ' ' + + this._angle + + ' ' + + (this._largeArcFlag ? '1' : '0') + + ' ' + + (this._sweepFlag ? '1' : '0') + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegArcRel.prototype.clone = function () { + return new window.SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag); + }; + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'r1', { + get: function () { + return this._r1; + }, + set: function (r1) { + this._r1 = r1; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'r2', { + get: function () { + return this._r2; + }, + set: function (r2) { + this._r2 = r2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'angle', { + get: function () { + return this._angle; + }, + set: function (angle) { + this._angle = angle; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'largeArcFlag', { + get: function () { + return this._largeArcFlag; + }, + set: function (largeArcFlag) { + this._largeArcFlag = largeArcFlag; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegArcRel.prototype, 'sweepFlag', { + get: function () { + return this._sweepFlag; + }, + set: function (sweepFlag) { + this._sweepFlag = sweepFlag; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoHorizontalAbs = function (owningPathSegList, x) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList); + this._x = x; + }; + window.SVGPathSegLinetoHorizontalAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoHorizontalAbs.prototype.toString = function () { + return '[object SVGPathSegLinetoHorizontalAbs]'; + }; + window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x; + }; + window.SVGPathSegLinetoHorizontalAbs.prototype.clone = function () { + return new window.SVGPathSegLinetoHorizontalAbs(undefined, this._x); + }; + Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoHorizontalRel = function (owningPathSegList, x) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList); + this._x = x; + }; + window.SVGPathSegLinetoHorizontalRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoHorizontalRel.prototype.toString = function () { + return '[object SVGPathSegLinetoHorizontalRel]'; + }; + window.SVGPathSegLinetoHorizontalRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x; + }; + window.SVGPathSegLinetoHorizontalRel.prototype.clone = function () { + return new window.SVGPathSegLinetoHorizontalRel(undefined, this._x); + }; + Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoVerticalAbs = function (owningPathSegList, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList); + this._y = y; + }; + window.SVGPathSegLinetoVerticalAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoVerticalAbs.prototype.toString = function () { + return '[object SVGPathSegLinetoVerticalAbs]'; + }; + window.SVGPathSegLinetoVerticalAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._y; + }; + window.SVGPathSegLinetoVerticalAbs.prototype.clone = function () { + return new window.SVGPathSegLinetoVerticalAbs(undefined, this._y); + }; + Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegLinetoVerticalRel = function (owningPathSegList, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList); + this._y = y; + }; + window.SVGPathSegLinetoVerticalRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegLinetoVerticalRel.prototype.toString = function () { + return '[object SVGPathSegLinetoVerticalRel]'; + }; + window.SVGPathSegLinetoVerticalRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._y; + }; + window.SVGPathSegLinetoVerticalRel.prototype.clone = function () { + return new window.SVGPathSegLinetoVerticalRel(undefined, this._y); + }; + Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoCubicSmoothAbs = function (owningPathSegList, x, y, x2, y2) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString = function () { + return '[object SVGPathSegCurvetoCubicSmoothAbs]'; + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone = function () { + return new window.SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2); + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, 'x2', { + get: function () { + return this._x2; + }, + set: function (x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype, 'y2', { + get: function () { + return this._y2; + }, + set: function (y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoCubicSmoothRel = function (owningPathSegList, x, y, x2, y2) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList); + this._x = x; + this._y = y; + this._x2 = x2; + this._y2 = y2; + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString = function () { + return '[object SVGPathSegCurvetoCubicSmoothRel]'; + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString = function () { + return (this.pathSegTypeAsLetter + + ' ' + + this._x2 + + ' ' + + this._y2 + + ' ' + + this._x + + ' ' + + this._y); + }; + window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone = function () { + return new window.SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2); + }; + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, 'x2', { + get: function () { + return this._x2; + }, + set: function (x2) { + this._x2 = x2; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype, 'y2', { + get: function () { + return this._y2; + }, + set: function (y2) { + this._y2 = y2; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoQuadraticSmoothAbs = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString = function () { + return '[object SVGPathSegCurvetoQuadraticSmoothAbs]'; + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone = function () { + return new window.SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + window.SVGPathSegCurvetoQuadraticSmoothRel = function (owningPathSegList, x, y) { + window.SVGPathSeg.call(this, window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList); + this._x = x; + this._y = y; + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype = Object.create(window.SVGPathSeg.prototype); + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString = function () { + return '[object SVGPathSegCurvetoQuadraticSmoothRel]'; + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString = function () { + return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y; + }; + window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone = function () { + return new window.SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y); + }; + Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, 'x', { + get: function () { + return this._x; + }, + set: function (x) { + this._x = x; + this._segmentChanged(); + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype, 'y', { + get: function () { + return this._y; + }, + set: function (y) { + this._y = y; + this._segmentChanged(); + }, + enumerable: true + }); + // Add createSVGPathSeg* functions to window.SVGPathElement. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-Interfacewindow.SVGPathElement. + window.SVGPathElement.prototype.createSVGPathSegClosePath = function () { + return new window.SVGPathSegClosePath(undefined); + }; + window.SVGPathElement.prototype.createSVGPathSegMovetoAbs = function (x, y) { + return new window.SVGPathSegMovetoAbs(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegMovetoRel = function (x, y) { + return new window.SVGPathSegMovetoRel(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoAbs = function (x, y) { + return new window.SVGPathSegLinetoAbs(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoRel = function (x, y) { + return new window.SVGPathSegLinetoRel(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function (x, y, x1, y1, x2, y2) { + return new window.SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function (x, y, x1, y1, x2, y2) { + return new window.SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function (x, y, x1, y1) { + return new window.SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function (x, y, x1, y1) { + return new window.SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1); + }; + window.SVGPathElement.prototype.createSVGPathSegArcAbs = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + return new window.SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + }; + window.SVGPathElement.prototype.createSVGPathSegArcRel = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) { + return new window.SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function (x) { + return new window.SVGPathSegLinetoHorizontalAbs(undefined, x); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function (x) { + return new window.SVGPathSegLinetoHorizontalRel(undefined, x); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function (y) { + return new window.SVGPathSegLinetoVerticalAbs(undefined, y); + }; + window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function (y) { + return new window.SVGPathSegLinetoVerticalRel(undefined, y); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function (x, y, x2, y2) { + return new window.SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function (x, y, x2, y2) { + return new window.SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function (x, y) { + return new window.SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y); + }; + window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function (x, y) { + return new window.SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y); + }; + if (!('getPathSegAtLength' in window.SVGPathElement.prototype)) { + // Add getPathSegAtLength to SVGPathElement. + // Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength + // This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm. + window.SVGPathElement.prototype.getPathSegAtLength = function (distance) { + if (distance === undefined || !isFinite(distance)) + throw 'Invalid arguments.'; + var measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + measurementElement.setAttribute('d', this.getAttribute('d')); + var lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; + // If the path is empty, return 0. + if (lastPathSegment <= 0) + return 0; + do { + measurementElement.pathSegList.removeItem(lastPathSegment); + if (distance > measurementElement.getTotalLength()) + break; + lastPathSegment--; + } while (lastPathSegment > 0); + return lastPathSegment; + }; + } + } + if (!('SVGPathSegList' in window)) { + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList + window.SVGPathSegList = function (pathElement) { + this._pathElement = pathElement; + this._list = this._parsePath(this._pathElement.getAttribute('d')); + // Use a MutationObserver to catch changes to the path's "d" attribute. + this._mutationObserverConfig = { + attributes: true, + attributeFilter: ['d'] + }; + this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this)); + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + }; + window.SVGPathSegList.prototype.classname = 'SVGPathSegList'; + Object.defineProperty(window.SVGPathSegList.prototype, 'numberOfItems', { + get: function () { + this._checkPathSynchronizedToList(); + return this._list.length; + }, + enumerable: true + }); + // Add the pathSegList accessors to window.SVGPathElement. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData + Object.defineProperty(window.SVGPathElement.prototype, 'pathSegList', { + get: function () { + if (!this._pathSegList) + this._pathSegList = new window.SVGPathSegList(this); + return this._pathSegList; + }, + enumerable: true + }); + // FIXME: The following are not implemented and simply return window.SVGPathElement.pathSegList. + Object.defineProperty(window.SVGPathElement.prototype, 'normalizedPathSegList', { + get: function () { + return this.pathSegList; + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathElement.prototype, 'animatedPathSegList', { + get: function () { + return this.pathSegList; + }, + enumerable: true + }); + Object.defineProperty(window.SVGPathElement.prototype, 'animatedNormalizedPathSegList', { + get: function () { + return this.pathSegList; + }, + enumerable: true + }); + // Process any pending mutations to the path element and update the list as needed. + // This should be the first call of all public functions and is needed because + // MutationObservers are not synchronous so we can have pending asynchronous mutations. + window.SVGPathSegList.prototype._checkPathSynchronizedToList = function () { + this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords()); + }; + window.SVGPathSegList.prototype._updateListFromPathMutations = function (mutationRecords) { + if (!this._pathElement) + return; + var hasPathMutations = false; + mutationRecords.forEach(function (record) { + if (record.attributeName == 'd') + hasPathMutations = true; + }); + if (hasPathMutations) + this._list = this._parsePath(this._pathElement.getAttribute('d')); + }; + // Serialize the list and update the path's 'd' attribute. + window.SVGPathSegList.prototype._writeListToPath = function () { + this._pathElementMutationObserver.disconnect(); + this._pathElement.setAttribute('d', window.SVGPathSegList._pathSegArrayAsString(this._list)); + this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig); + }; + // When a path segment changes the list needs to be synchronized back to the path element. + window.SVGPathSegList.prototype.segmentChanged = function (pathSeg) { + this._writeListToPath(); + }; + window.SVGPathSegList.prototype.clear = function () { + this._checkPathSynchronizedToList(); + this._list.forEach(function (pathSeg) { + pathSeg._owningPathSegList = null; + }); + this._list = []; + this._writeListToPath(); + }; + window.SVGPathSegList.prototype.initialize = function (newItem) { + this._checkPathSynchronizedToList(); + this._list = [newItem]; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem; + }; + window.SVGPathSegList.prototype._checkValidIndex = function (index) { + if (isNaN(index) || index < 0 || index >= this.numberOfItems) + throw 'INDEX_SIZE_ERR'; + }; + window.SVGPathSegList.prototype.getItem = function (index) { + this._checkPathSynchronizedToList(); + this._checkValidIndex(index); + return this._list[index]; + }; + window.SVGPathSegList.prototype.insertItemBefore = function (newItem, index) { + this._checkPathSynchronizedToList(); + // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list. + if (index > this.numberOfItems) + index = this.numberOfItems; + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.splice(index, 0, newItem); + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem; + }; + window.SVGPathSegList.prototype.replaceItem = function (newItem, index) { + this._checkPathSynchronizedToList(); + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._checkValidIndex(index); + this._list[index] = newItem; + newItem._owningPathSegList = this; + this._writeListToPath(); + return newItem; + }; + window.SVGPathSegList.prototype.removeItem = function (index) { + this._checkPathSynchronizedToList(); + this._checkValidIndex(index); + var item = this._list[index]; + this._list.splice(index, 1); + this._writeListToPath(); + return item; + }; + window.SVGPathSegList.prototype.appendItem = function (newItem) { + this._checkPathSynchronizedToList(); + if (newItem._owningPathSegList) { + // SVG2 spec says to make a copy. + newItem = newItem.clone(); + } + this._list.push(newItem); + newItem._owningPathSegList = this; + // TODO: Optimize this to just append to the existing attribute. + this._writeListToPath(); + return newItem; + }; + window.SVGPathSegList._pathSegArrayAsString = function (pathSegArray) { + var string = ''; + var first = true; + pathSegArray.forEach(function (pathSeg) { + if (first) { + first = false; + string += pathSeg._asPathString(); + } + else { + string += ' ' + pathSeg._asPathString(); + } + }); + return string; + }; + // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp. + window.SVGPathSegList.prototype._parsePath = function (string) { + if (!string || string.length == 0) + return []; + var owningPathSegList = this; + var Builder = function () { + this.pathSegList = []; + }; + Builder.prototype.appendSegment = function (pathSeg) { + this.pathSegList.push(pathSeg); + }; + var Source = function (string) { + this._string = string; + this._currentIndex = 0; + this._endIndex = this._string.length; + this._previousCommand = window.SVGPathSeg.PATHSEG_UNKNOWN; + this._skipOptionalSpaces(); + }; + Source.prototype._isCurrentSpace = function () { + var character = this._string[this._currentIndex]; + return (character <= ' ' && + (character == ' ' || + character == '\n' || + character == '\t' || + character == '\r' || + character == '\f')); + }; + Source.prototype._skipOptionalSpaces = function () { + while (this._currentIndex < this._endIndex && this._isCurrentSpace()) + this._currentIndex++; + return this._currentIndex < this._endIndex; + }; + Source.prototype._skipOptionalSpacesOrDelimiter = function () { + if (this._currentIndex < this._endIndex && + !this._isCurrentSpace() && + this._string.charAt(this._currentIndex) != ',') + return false; + if (this._skipOptionalSpaces()) { + if (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == ',') { + this._currentIndex++; + this._skipOptionalSpaces(); + } + } + return this._currentIndex < this._endIndex; + }; + Source.prototype.hasMoreData = function () { + return this._currentIndex < this._endIndex; + }; + Source.prototype.peekSegmentType = function () { + var lookahead = this._string[this._currentIndex]; + return this._pathSegTypeFromChar(lookahead); + }; + Source.prototype._pathSegTypeFromChar = function (lookahead) { + switch (lookahead) { + case 'Z': + case 'z': + return window.SVGPathSeg.PATHSEG_CLOSEPATH; + case 'M': + return window.SVGPathSeg.PATHSEG_MOVETO_ABS; + case 'm': + return window.SVGPathSeg.PATHSEG_MOVETO_REL; + case 'L': + return window.SVGPathSeg.PATHSEG_LINETO_ABS; + case 'l': + return window.SVGPathSeg.PATHSEG_LINETO_REL; + case 'C': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS; + case 'c': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL; + case 'Q': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS; + case 'q': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL; + case 'A': + return window.SVGPathSeg.PATHSEG_ARC_ABS; + case 'a': + return window.SVGPathSeg.PATHSEG_ARC_REL; + case 'H': + return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS; + case 'h': + return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL; + case 'V': + return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS; + case 'v': + return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL; + case 'S': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS; + case 's': + return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL; + case 'T': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS; + case 't': + return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL; + default: + return window.SVGPathSeg.PATHSEG_UNKNOWN; + } + }; + Source.prototype._nextCommandHelper = function (lookahead, previousCommand) { + // Check for remaining coordinates in the current command. + if ((lookahead == '+' || + lookahead == '-' || + lookahead == '.' || + (lookahead >= '0' && lookahead <= '9')) && + previousCommand != window.SVGPathSeg.PATHSEG_CLOSEPATH) { + if (previousCommand == window.SVGPathSeg.PATHSEG_MOVETO_ABS) + return window.SVGPathSeg.PATHSEG_LINETO_ABS; + if (previousCommand == window.SVGPathSeg.PATHSEG_MOVETO_REL) + return window.SVGPathSeg.PATHSEG_LINETO_REL; + return previousCommand; + } + return window.SVGPathSeg.PATHSEG_UNKNOWN; + }; + Source.prototype.initialCommandIsMoveTo = function () { + // If the path is empty it is still valid, so return true. + if (!this.hasMoreData()) + return true; + var command = this.peekSegmentType(); + // Path must start with moveTo. + return (command == window.SVGPathSeg.PATHSEG_MOVETO_ABS || + command == window.SVGPathSeg.PATHSEG_MOVETO_REL); + }; + // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp. + // Spec: http://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF + Source.prototype._parseNumber = function () { + var exponent = 0; + var integer = 0; + var frac = 1; + var decimal = 0; + var sign = 1; + var expsign = 1; + var startIndex = this._currentIndex; + this._skipOptionalSpaces(); + // Read the sign. + if (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '+') + this._currentIndex++; + else if (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '-') { + this._currentIndex++; + sign = -1; + } + if (this._currentIndex == this._endIndex || + ((this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9') && + this._string.charAt(this._currentIndex) != '.')) + // The first character of a number must be one of [0-9+-.]. + return undefined; + // Read the integer part, build right-to-left. + var startIntPartIndex = this._currentIndex; + while (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9') + this._currentIndex++; // Advance to first non-digit. + if (this._currentIndex != startIntPartIndex) { + var scanIntPartIndex = this._currentIndex - 1; + var multiplier = 1; + while (scanIntPartIndex >= startIntPartIndex) { + integer += + multiplier * (this._string.charAt(scanIntPartIndex--) - '0'); + multiplier *= 10; + } + } + // Read the decimals. + if (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) == '.') { + this._currentIndex++; + // There must be a least one digit following the . + if (this._currentIndex >= this._endIndex || + this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9') + return undefined; + while (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9') { + frac *= 10; + decimal += (this._string.charAt(this._currentIndex) - '0') / frac; + this._currentIndex += 1; + } + } + // Read the exponent part. + if (this._currentIndex != startIndex && + this._currentIndex + 1 < this._endIndex && + (this._string.charAt(this._currentIndex) == 'e' || + this._string.charAt(this._currentIndex) == 'E') && + this._string.charAt(this._currentIndex + 1) != 'x' && + this._string.charAt(this._currentIndex + 1) != 'm') { + this._currentIndex++; + // Read the sign of the exponent. + if (this._string.charAt(this._currentIndex) == '+') { + this._currentIndex++; + } + else if (this._string.charAt(this._currentIndex) == '-') { + this._currentIndex++; + expsign = -1; + } + // There must be an exponent. + if (this._currentIndex >= this._endIndex || + this._string.charAt(this._currentIndex) < '0' || + this._string.charAt(this._currentIndex) > '9') + return undefined; + while (this._currentIndex < this._endIndex && + this._string.charAt(this._currentIndex) >= '0' && + this._string.charAt(this._currentIndex) <= '9') { + exponent *= 10; + exponent += this._string.charAt(this._currentIndex) - '0'; + this._currentIndex++; + } + } + var number = integer + decimal; + number *= sign; + if (exponent) + number *= Math.pow(10, expsign * exponent); + if (startIndex == this._currentIndex) + return undefined; + this._skipOptionalSpacesOrDelimiter(); + return number; + }; + Source.prototype._parseArcFlag = function () { + if (this._currentIndex >= this._endIndex) + return undefined; + var flag = false; + var flagChar = this._string.charAt(this._currentIndex++); + if (flagChar == '0') + flag = false; + else if (flagChar == '1') + flag = true; + else + return undefined; + this._skipOptionalSpacesOrDelimiter(); + return flag; + }; + Source.prototype.parseSegment = function () { + var lookahead = this._string[this._currentIndex]; + var command = this._pathSegTypeFromChar(lookahead); + if (command == window.SVGPathSeg.PATHSEG_UNKNOWN) { + // Possibly an implicit command. Not allowed if this is the first command. + if (this._previousCommand == window.SVGPathSeg.PATHSEG_UNKNOWN) + return null; + command = this._nextCommandHelper(lookahead, this._previousCommand); + if (command == window.SVGPathSeg.PATHSEG_UNKNOWN) + return null; + } + else { + this._currentIndex++; + } + this._previousCommand = command; + switch (command) { + case window.SVGPathSeg.PATHSEG_MOVETO_REL: + return new window.SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_MOVETO_ABS: + return new window.SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_REL: + return new window.SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_ABS: + return new window.SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL: + return new window.SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS: + return new window.SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL: + return new window.SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber()); + case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS: + return new window.SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber()); + case window.SVGPathSeg.PATHSEG_CLOSEPATH: + this._skipOptionalSpaces(); + return new window.SVGPathSegClosePath(owningPathSegList); + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2); + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + var points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, points.x, points.y, points.x2, points.y2); + case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + var points = { + x2: this._parseNumber(), + y2: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, points.x, points.y, points.x2, points.y2); + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoQuadraticRel(owningPathSegList, points.x, points.y, points.x1, points.y1); + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegCurvetoQuadraticAbs(owningPathSegList, points.x, points.y, points.x1, points.y1); + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + return new window.SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + return new window.SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber()); + case window.SVGPathSeg.PATHSEG_ARC_REL: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegArcRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); + case window.SVGPathSeg.PATHSEG_ARC_ABS: + var points = { + x1: this._parseNumber(), + y1: this._parseNumber(), + arcAngle: this._parseNumber(), + arcLarge: this._parseArcFlag(), + arcSweep: this._parseArcFlag(), + x: this._parseNumber(), + y: this._parseNumber() + }; + return new window.SVGPathSegArcAbs(owningPathSegList, points.x, points.y, points.x1, points.y1, points.arcAngle, points.arcLarge, points.arcSweep); + default: + throw 'Unknown path seg type.'; + } + }; + var builder = new Builder(); + var source = new Source(string); + if (!source.initialCommandIsMoveTo()) + return []; + while (source.hasMoreData()) { + var pathSeg = source.parseSegment(); + if (!pathSeg) + return []; + builder.appendSegment(pathSeg); + } + return builder.pathSegList; + }; + } + })(); + // String.padEnd polyfill for IE11 + // + // https://github.com/uxitten/polyfill/blob/master/string.polyfill.js + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd + if (!String.prototype.padEnd) { + String.prototype.padEnd = function padEnd(targetLength, padString) { + targetLength = targetLength >> 0; //floor if number or convert non-number to 0; + padString = String(typeof padString !== 'undefined' ? padString : ' '); + if (this.length > targetLength) { + return String(this); + } + else { + targetLength = targetLength - this.length; + if (targetLength > padString.length) { + padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed + } + return String(this) + padString.slice(0, targetLength); + } + }; + } + // Object.assign polyfill for IE11 + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill + if (typeof Object.assign !== 'function') { + // Must be writable: true, enumerable: false, configurable: true + Object.defineProperty(Object, 'assign', { + value: function assign(target, varArgs) { + if (target === null || target === undefined) { + throw new TypeError('Cannot convert undefined or null to object'); + } + var to = Object(target); + for (var index = 1; index < arguments.length; index++) { + var nextSource = arguments[index]; + if (nextSource !== null && nextSource !== undefined) { + for (var nextKey in nextSource) { + // Avoid bugs when hasOwnProperty is shadowed + if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { + to[nextKey] = nextSource[nextKey]; + } + } + } + } + return to; + }, + writable: true, + configurable: true + }); + } + /* jshint ignore:end */ + + Chart.prototype.axis = function () { }; + Chart.prototype.axis.labels = function (labels) { + var $$ = this.internal; + if (arguments.length) { + Object.keys(labels).forEach(function (axisId) { + $$.axis.setLabelText(axisId, labels[axisId]); + }); + $$.axis.updateLabels(); + } + // TODO: return some values? + }; + Chart.prototype.axis.max = function (max) { + var $$ = this.internal, config = $$.config; + if (arguments.length) { + if (typeof max === 'object') { + if (isValue(max.x)) { + config.axis_x_max = max.x; + } + if (isValue(max.y)) { + config.axis_y_max = max.y; + } + if (isValue(max.y2)) { + config.axis_y2_max = max.y2; + } + } + else { + config.axis_y_max = config.axis_y2_max = max; + } + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + else { + return { + x: config.axis_x_max, + y: config.axis_y_max, + y2: config.axis_y2_max + }; + } + }; + Chart.prototype.axis.min = function (min) { + var $$ = this.internal, config = $$.config; + if (arguments.length) { + if (typeof min === 'object') { + if (isValue(min.x)) { + config.axis_x_min = min.x; + } + if (isValue(min.y)) { + config.axis_y_min = min.y; + } + if (isValue(min.y2)) { + config.axis_y2_min = min.y2; + } + } + else { + config.axis_y_min = config.axis_y2_min = min; + } + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + else { + return { + x: config.axis_x_min, + y: config.axis_y_min, + y2: config.axis_y2_min + }; + } + }; + Chart.prototype.axis.range = function (range) { + if (arguments.length) { + if (isDefined(range.max)) { + this.axis.max(range.max); + } + if (isDefined(range.min)) { + this.axis.min(range.min); + } + } + else { + return { + max: this.axis.max(), + min: this.axis.min() + }; + } + }; + Chart.prototype.axis.types = function (types) { + var $$ = this.internal; + if (types === undefined) { + return { + y: $$.config.axis_y_type, + y2: $$.config.axis_y2_type + }; + } + else { + if (isDefined(types.y)) { + $$.config.axis_y_type = types.y; + } + if (isDefined(types.y2)) { + $$.config.axis_y2_type = types.y2; + } + $$.updateScales(); + $$.redraw(); + } + }; + + Chart.prototype.category = function (i, category) { + var $$ = this.internal, config = $$.config; + if (arguments.length > 1) { + config.axis_x_categories[i] = category; + $$.redraw(); + } + return config.axis_x_categories[i]; + }; + Chart.prototype.categories = function (categories) { + var $$ = this.internal, config = $$.config; + if (!arguments.length) { + return config.axis_x_categories; + } + config.axis_x_categories = categories; + $$.redraw(); + return config.axis_x_categories; + }; + + Chart.prototype.resize = function (size) { + var $$ = this.internal, config = $$.config; + config.size_width = size ? size.width : null; + config.size_height = size ? size.height : null; + this.flush(); + }; + Chart.prototype.flush = function () { + var $$ = this.internal; + $$.updateAndRedraw({ + withLegend: true, + withTransition: false, + withTransitionForTransform: false + }); + }; + Chart.prototype.destroy = function () { + var $$ = this.internal; + window.clearInterval($$.intervalForObserveInserted); + if ($$.resizeTimeout !== undefined) { + window.clearTimeout($$.resizeTimeout); + } + window.removeEventListener('resize', $$.resizeIfElementDisplayed); + // Removes the inner resize functions + $$.resizeFunction.remove(); + // Unbinds from the window focus event + $$.unbindWindowFocus(); + $$.selectChart.classed('c3', false).html(''); + // MEMO: this is needed because the reference of some elements will not be released, then memory leak will happen. + Object.keys($$).forEach(function (key) { + $$[key] = null; + }); + return null; + }; + + // TODO: fix + Chart.prototype.color = function (id) { + var $$ = this.internal; + return $$.color(id); // more patterns + }; + + Chart.prototype.data = function (targetIds) { + var targets = this.internal.data.targets; + return typeof targetIds === 'undefined' + ? targets + : targets.filter(function (t) { + return [].concat(targetIds).indexOf(t.id) >= 0; + }); + }; + Chart.prototype.data.shown = function (targetIds) { + return this.internal.filterTargetsToShow(this.data(targetIds)); + }; + /** + * Get values of the data loaded in the chart. + * + * @param {String|Array} targetId This API returns the value of specified target. + * @param flat + * @return {Array} Data values + */ + Chart.prototype.data.values = function (targetId, flat) { + if (flat === void 0) { flat = true; } + var values = null; + if (targetId) { + var targets = this.data(targetId); + if (targets && isArray(targets)) { + values = targets.reduce(function (ret, v) { + var dataValue = v.values.map(function (d) { return d.value; }); + if (flat) { + ret = ret.concat(dataValue); + } + else { + ret.push(dataValue); + } + return ret; + }, []); + } + } + return values; + }; + Chart.prototype.data.names = function (names) { + this.internal.clearLegendItemTextBoxCache(); + return this.internal.updateDataAttributes('names', names); + }; + Chart.prototype.data.colors = function (colors) { + return this.internal.updateDataAttributes('colors', colors); + }; + Chart.prototype.data.axes = function (axes) { + return this.internal.updateDataAttributes('axes', axes); + }; + Chart.prototype.data.stackNormalized = function (normalized) { + if (normalized === undefined) { + return this.internal.isStackNormalized(); + } + this.internal.config.data_stack_normalize = !!normalized; + this.internal.redraw(); + }; + + Chart.prototype.donut = function () { }; + Chart.prototype.donut.padAngle = function (padAngle) { + if (padAngle === undefined) { + return this.internal.config.donut_padAngle; + } + this.internal.config.donut_padAngle = padAngle; + this.flush(); + }; + + Chart.prototype.flow = function (args) { + var $$ = this.internal, targets, data, notfoundIds = [], orgDataCount = $$.getMaxDataCount(), dataCount, domain, baseTarget, baseValue, length = 0, tail = 0, diff, to; + if (args.json) { + data = $$.convertJsonToData(args.json, args.keys); + } + else if (args.rows) { + data = $$.convertRowsToData(args.rows); + } + else if (args.columns) { + data = $$.convertColumnsToData(args.columns); + } + else { + return; + } + targets = $$.convertDataToTargets(data, true); + // Update/Add data + $$.data.targets.forEach(function (t) { + var found = false, i, j; + for (i = 0; i < targets.length; i++) { + if (t.id === targets[i].id) { + found = true; + if (t.values[t.values.length - 1]) { + tail = t.values[t.values.length - 1].index + 1; + } + length = targets[i].values.length; + for (j = 0; j < length; j++) { + targets[i].values[j].index = tail + j; + if (!$$.isTimeSeries()) { + targets[i].values[j].x = tail + j; + } + } + t.values = t.values.concat(targets[i].values); + targets.splice(i, 1); + break; + } + } + if (!found) { + notfoundIds.push(t.id); + } + }); + // Append null for not found targets + $$.data.targets.forEach(function (t) { + var i, j; + for (i = 0; i < notfoundIds.length; i++) { + if (t.id === notfoundIds[i]) { + tail = t.values[t.values.length - 1].index + 1; + for (j = 0; j < length; j++) { + t.values.push({ + id: t.id, + index: tail + j, + x: $$.isTimeSeries() ? $$.getOtherTargetX(tail + j) : tail + j, + value: null + }); + } + } + } + }); + // Generate null values for new target + if ($$.data.targets.length) { + targets.forEach(function (t) { + var i, missing = []; + for (i = $$.data.targets[0].values[0].index; i < tail; i++) { + missing.push({ + id: t.id, + index: i, + x: $$.isTimeSeries() ? $$.getOtherTargetX(i) : i, + value: null + }); + } + t.values.forEach(function (v) { + v.index += tail; + if (!$$.isTimeSeries()) { + v.x += tail; + } + }); + t.values = missing.concat(t.values); + }); + } + $$.data.targets = $$.data.targets.concat(targets); // add remained + // check data count because behavior needs to change when it's only one + dataCount = $$.getMaxDataCount(); + baseTarget = $$.data.targets[0]; + baseValue = baseTarget.values[0]; + // Update length to flow if needed + if (isDefined(args.to)) { + length = 0; + to = $$.isTimeSeries() ? $$.parseDate(args.to) : args.to; + baseTarget.values.forEach(function (v) { + if (v.x < to) { + length++; + } + }); + } + else if (isDefined(args.length)) { + length = args.length; + } + // If only one data, update the domain to flow from left edge of the chart + if (!orgDataCount) { + if ($$.isTimeSeries()) { + if (baseTarget.values.length > 1) { + diff = baseTarget.values[baseTarget.values.length - 1].x - baseValue.x; + } + else { + diff = baseValue.x - $$.getXDomain($$.data.targets)[0]; + } + } + else { + diff = 1; + } + domain = [baseValue.x - diff, baseValue.x]; + $$.updateXDomain(null, true, true, false, domain); + } + else if (orgDataCount === 1) { + if ($$.isTimeSeries()) { + diff = + (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2; + domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)]; + $$.updateXDomain(null, true, true, false, domain); + } + } + // Set targets + $$.updateTargets($$.data.targets); + // Redraw with new targets + $$.redraw({ + flow: { + index: baseValue.index, + length: length, + duration: isValue(args.duration) + ? args.duration + : $$.config.transition_duration, + done: args.done, + orgDataCount: orgDataCount + }, + withLegend: true, + withTransition: orgDataCount > 1, + withTrimXDomain: false, + withUpdateXAxis: true + }); + }; + ChartInternal.prototype.generateFlow = function (args) { + var $$ = this, config = $$.config, d3 = $$.d3; + return function () { + var targets = args.targets, flow = args.flow, drawBar = args.drawBar, drawLine = args.drawLine, drawArea = args.drawArea, cx = args.cx, cy = args.cy, xv = args.xv, xForText = args.xForText, yForText = args.yForText, duration = args.duration; + var translateX, scaleX = 1, transform, flowIndex = flow.index, flowLength = flow.length, flowStart = $$.getValueOnIndex($$.data.targets[0].values, flowIndex), flowEnd = $$.getValueOnIndex($$.data.targets[0].values, flowIndex + flowLength), orgDomain = $$.x.domain(), domain, durationForFlow = flow.duration || duration, done = flow.done || function () { }, wait = $$.generateWait(); + var xgrid, xgridLines, mainRegion, mainText, mainBar, mainLine, mainArea, mainCircle; + // set flag + $$.flowing = true; + // remove head data after rendered + $$.data.targets.forEach(function (d) { + d.values.splice(0, flowLength); + }); + // update x domain to generate axis elements for flow + domain = $$.updateXDomain(targets, true, true); + // update elements related to x scale + if ($$.updateXGrid) { + $$.updateXGrid(true); + } + xgrid = $$.xgrid || d3.selectAll([]); // xgrid needs to be obtained after updateXGrid + xgridLines = $$.xgridLines || d3.selectAll([]); + mainRegion = $$.mainRegion || d3.selectAll([]); + mainText = $$.mainText || d3.selectAll([]); + mainBar = $$.mainBar || d3.selectAll([]); + mainLine = $$.mainLine || d3.selectAll([]); + mainArea = $$.mainArea || d3.selectAll([]); + mainCircle = $$.mainCircle || d3.selectAll([]); + // generate transform to flow + if (!flow.orgDataCount) { + // if empty + if ($$.data.targets[0].values.length !== 1) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } + else { + if ($$.isTimeSeries()) { + flowStart = $$.getValueOnIndex($$.data.targets[0].values, 0); + flowEnd = $$.getValueOnIndex($$.data.targets[0].values, $$.data.targets[0].values.length - 1); + translateX = $$.x(flowStart.x) - $$.x(flowEnd.x); + } + else { + translateX = diffDomain(domain) / 2; + } + } + } + else if (flow.orgDataCount === 1 || + (flowStart && flowStart.x) === (flowEnd && flowEnd.x)) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } + else { + if ($$.isTimeSeries()) { + translateX = $$.x(orgDomain[0]) - $$.x(domain[0]); + } + else { + translateX = $$.x(flowStart.x) - $$.x(flowEnd.x); + } + } + scaleX = diffDomain(orgDomain) / diffDomain(domain); + transform = 'translate(' + translateX + ',0) scale(' + scaleX + ',1)'; + $$.hideXGridFocus(); + var flowTransition = d3 + .transition() + .ease(d3.easeLinear) + .duration(durationForFlow); + wait.add($$.xAxis($$.axes.x, flowTransition)); + wait.add(mainBar.transition(flowTransition).attr('transform', transform)); + wait.add(mainLine.transition(flowTransition).attr('transform', transform)); + wait.add(mainArea.transition(flowTransition).attr('transform', transform)); + wait.add(mainCircle.transition(flowTransition).attr('transform', transform)); + wait.add(mainText.transition(flowTransition).attr('transform', transform)); + wait.add(mainRegion + .filter($$.isRegionOnX) + .transition(flowTransition) + .attr('transform', transform)); + wait.add(xgrid.transition(flowTransition).attr('transform', transform)); + wait.add(xgridLines.transition(flowTransition).attr('transform', transform)); + wait(function () { + var i, shapes = [], texts = []; + // remove flowed elements + if (flowLength) { + for (i = 0; i < flowLength; i++) { + shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); + texts.push('.' + CLASS.text + '-' + (flowIndex + i)); + } + $$.svg + .selectAll('.' + CLASS.shapes) + .selectAll(shapes) + .remove(); + $$.svg + .selectAll('.' + CLASS.texts) + .selectAll(texts) + .remove(); + $$.svg.select('.' + CLASS.xgrid).remove(); + } + // draw again for removing flowed elements and reverting attr + xgrid + .attr('transform', null) + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', $$.xgridAttr.opacity); + xgridLines.attr('transform', null); + xgridLines + .select('line') + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv); + xgridLines + .select('text') + .attr('x', config.axis_rotated ? $$.width : 0) + .attr('y', xv); + mainBar.attr('transform', null).attr('d', drawBar); + mainLine.attr('transform', null).attr('d', drawLine); + mainArea.attr('transform', null).attr('d', drawArea); + mainCircle + .attr('transform', null) + .attr('cx', cx) + .attr('cy', cy); + mainText + .attr('transform', null) + .attr('x', xForText) + .attr('y', yForText) + .style('fill-opacity', $$.opacityForText.bind($$)); + mainRegion.attr('transform', null); + mainRegion + .filter($$.isRegionOnX) + .attr('x', $$.regionX.bind($$)) + .attr('width', $$.regionWidth.bind($$)); + // callback for end of flow + done(); + $$.flowing = false; + }); + }; + }; + + Chart.prototype.focus = function (targetIds) { + var $$ = this.internal, candidates; + targetIds = $$.mapToTargetIds(targetIds); + (candidates = $$.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)))), + this.revert(); + this.defocus(); + candidates.classed(CLASS.focused, true).classed(CLASS.defocused, false); + if ($$.hasArcType()) { + $$.expandArc(targetIds); + } + $$.toggleFocusLegend(targetIds, true); + $$.focusedTargetIds = targetIds; + $$.defocusedTargetIds = $$.defocusedTargetIds.filter(function (id) { + return targetIds.indexOf(id) < 0; + }); + }; + Chart.prototype.defocus = function (targetIds) { + var $$ = this.internal, candidates; + targetIds = $$.mapToTargetIds(targetIds); + (candidates = $$.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)))), + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, true); + if ($$.hasArcType()) { + $$.unexpandArc(targetIds); + } + $$.toggleFocusLegend(targetIds, false); + $$.focusedTargetIds = $$.focusedTargetIds.filter(function (id) { + return targetIds.indexOf(id) < 0; + }); + $$.defocusedTargetIds = targetIds; + }; + Chart.prototype.revert = function (targetIds) { + var $$ = this.internal, candidates; + targetIds = $$.mapToTargetIds(targetIds); + candidates = $$.svg.selectAll($$.selectorTargets(targetIds)); // should be for all targets + candidates.classed(CLASS.focused, false).classed(CLASS.defocused, false); + if ($$.hasArcType()) { + $$.unexpandArc(targetIds); + } + if ($$.config.legend_show) { + $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$))); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .filter(function () { + return $$.d3.select(this).classed(CLASS.legendItemFocused); + }) + .classed(CLASS.legendItemFocused, false); + } + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; + }; + + Chart.prototype.xgrids = function (grids) { + var $$ = this.internal, config = $$.config; + if (!grids) { + return config.grid_x_lines; + } + config.grid_x_lines = grids; + $$.redrawWithoutRescale(); + return config.grid_x_lines; + }; + Chart.prototype.xgrids.add = function (grids) { + var $$ = this.internal; + return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : [])); + }; + Chart.prototype.xgrids.remove = function (params) { + // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, true); + }; + Chart.prototype.ygrids = function (grids) { + var $$ = this.internal, config = $$.config; + if (!grids) { + return config.grid_y_lines; + } + config.grid_y_lines = grids; + $$.redrawWithoutRescale(); + return config.grid_y_lines; + }; + Chart.prototype.ygrids.add = function (grids) { + var $$ = this.internal; + return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : [])); + }; + Chart.prototype.ygrids.remove = function (params) { + // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, false); + }; + + Chart.prototype.groups = function (groups) { + var $$ = this.internal, config = $$.config; + if (isUndefined(groups)) { + return config.data_groups; + } + config.data_groups = groups; + $$.redraw(); + return config.data_groups; + }; + + Chart.prototype.legend = function () { }; + Chart.prototype.legend.show = function (targetIds) { + var $$ = this.internal; + $$.showLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({ withLegend: true }); + }; + Chart.prototype.legend.hide = function (targetIds) { + var $$ = this.internal; + $$.hideLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({ withLegend: false }); + }; + + Chart.prototype.load = function (args) { + var $$ = this.internal, config = $$.config; + // update xs if specified + if (args.xs) { + $$.addXs(args.xs); + } + // update names if exists + if ('names' in args) { + Chart.prototype.data.names.bind(this)(args.names); + } + // update classes if exists + if ('classes' in args) { + Object.keys(args.classes).forEach(function (id) { + config.data_classes[id] = args.classes[id]; + }); + } + // update categories if exists + if ('categories' in args && $$.isCategorized()) { + config.axis_x_categories = args.categories; + } + // update axes if exists + if ('axes' in args) { + Object.keys(args.axes).forEach(function (id) { + config.data_axes[id] = args.axes[id]; + }); + } + // update colors if exists + if ('colors' in args) { + Object.keys(args.colors).forEach(function (id) { + config.data_colors[id] = args.colors[id]; + }); + } + // use cache if exists + if ('cacheIds' in args && $$.hasCaches(args.cacheIds)) { + $$.load($$.getCaches(args.cacheIds), args.done); + return; + } + // unload if needed + if (args.unload) { + // TODO: do not unload if target will load (included in url/rows/columns) + $$.unload($$.mapToTargetIds(args.unload === true ? null : args.unload), function () { + $$.loadFromArgs(args); + }); + } + else { + $$.loadFromArgs(args); + } + }; + Chart.prototype.unload = function (args) { + var $$ = this.internal; + args = args || {}; + if (args instanceof Array) { + args = { ids: args }; + } + else if (typeof args === 'string') { + args = { ids: [args] }; + } + $$.unload($$.mapToTargetIds(args.ids), function () { + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + if (args.done) { + args.done(); + } + }); + }; + + Chart.prototype.pie = function () { }; + Chart.prototype.pie.padAngle = function (padAngle) { + if (padAngle === undefined) { + return this.internal.config.pie_padAngle; + } + this.internal.config.pie_padAngle = padAngle; + this.flush(); + }; + + Chart.prototype.regions = function (regions) { + var $$ = this.internal, config = $$.config; + if (!regions) { + return config.regions; + } + config.regions = regions; + $$.redrawWithoutRescale(); + return config.regions; + }; + Chart.prototype.regions.add = function (regions) { + var $$ = this.internal, config = $$.config; + if (!regions) { + return config.regions; + } + config.regions = config.regions.concat(regions); + $$.redrawWithoutRescale(); + return config.regions; + }; + Chart.prototype.regions.remove = function (options) { + var $$ = this.internal, config = $$.config, duration, classes, regions; + options = options || {}; + duration = getOption(options, 'duration', config.transition_duration); + classes = getOption(options, 'classes', [CLASS.region]); + regions = $$.main.select('.' + CLASS.regions).selectAll(classes.map(function (c) { + return '.' + c; + })); + (duration ? regions.transition().duration(duration) : regions) + .style('opacity', 0) + .remove(); + config.regions = config.regions.filter(function (region) { + var found = false; + if (!region['class']) { + return true; + } + region['class'].split(' ').forEach(function (c) { + if (classes.indexOf(c) >= 0) { + found = true; + } + }); + return !found; + }); + return config.regions; + }; + + Chart.prototype.selected = function (targetId) { + var $$ = this.internal, d3 = $$.d3; + return $$.main + .selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)) + .selectAll('.' + CLASS.shape) + .filter(function () { + return d3.select(this).classed(CLASS.SELECTED); + }) + .nodes() + .map(function (d) { + var data = d.__data__; + return data.data ? data.data : data; + }); + }; + Chart.prototype.select = function (ids, indices, resetOther) { + var $$ = this.internal, d3 = $$.d3, config = $$.config; + if (!config.data_selection_enabled) { + return; + } + $$.main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function (d, i) { + var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this, d).bind($$), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS.SELECTED); + // line/area selection not supported yet + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { + return; + } + if (isTargetId && isTargetIndex) { + if (config.data_selection_isselectable(d) && !isSelected) { + toggle(true, shape.classed(CLASS.SELECTED, true), d, i); + } + } + else if (isDefined(resetOther) && resetOther) { + if (isSelected) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + } + }); + }; + Chart.prototype.unselect = function (ids, indices) { + var $$ = this.internal, d3 = $$.d3, config = $$.config; + if (!config.data_selection_enabled) { + return; + } + $$.main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function (d, i) { + var shape = d3.select(this), id = d.data ? d.data.id : d.id, toggle = $$.getToggle(this, d).bind($$), isTargetId = config.data_selection_grouped || !ids || ids.indexOf(id) >= 0, isTargetIndex = !indices || indices.indexOf(i) >= 0, isSelected = shape.classed(CLASS.SELECTED); + // line/area selection not supported yet + if (shape.classed(CLASS.line) || shape.classed(CLASS.area)) { + return; + } + if (isTargetId && isTargetIndex) { + if (config.data_selection_isselectable(d)) { + if (isSelected) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + } + } + }); + }; + + Chart.prototype.show = function (targetIds, options) { + var $$ = this.internal, targets; + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + $$.removeHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + targets + .transition() + .style('display', isIE() ? 'block' : 'initial', 'important') + .style('opacity', 1, 'important') + .call($$.endall, function () { + targets.style('opacity', null).style('opacity', 1); + }); + if (options.withLegend) { + $$.showLegend(targetIds); + } + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + }; + Chart.prototype.hide = function (targetIds, options) { + var $$ = this.internal, targets; + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + $$.addHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + targets + .transition() + .style('opacity', 0, 'important') + .call($$.endall, function () { + targets.style('opacity', null).style('opacity', 0); + targets.style('display', 'none'); + }); + if (options.withLegend) { + $$.hideLegend(targetIds); + } + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + }; + Chart.prototype.toggle = function (targetIds, options) { + var that = this, $$ = this.internal; + $$.mapToTargetIds(targetIds).forEach(function (targetId) { + $$.isTargetToShow(targetId) + ? that.hide(targetId, options) + : that.show(targetId, options); + }); + }; + + Chart.prototype.subchart = function () { }; + Chart.prototype.subchart.isShown = function () { + var $$ = this.internal; + return $$.config.subchart_show; + }; + Chart.prototype.subchart.show = function () { + var $$ = this.internal; + if ($$.config.subchart_show) { + return; + } + $$.config.subchart_show = true; + // insert DOM + $$.initSubchart(); + // update dimensions with sub chart now visible + $$.updateDimension(); + // insert brush (depends on sizes previously updated) + $$.initSubchartBrush(); + // attach data + $$.updateTargetsForSubchart($$.getTargets()); + // reset fade-in state + $$.mapToIds($$.data.targets).forEach(function (id) { + $$.withoutFadeIn[id] = false; + }); + // redraw chart ! + $$.updateAndRedraw(); + // update visible targets ! + $$.showTargets(); + }; + Chart.prototype.subchart.hide = function () { + var $$ = this.internal; + if (!$$.config.subchart_show) { + return; + } + $$.config.subchart_show = false; + // remove DOM + $$.removeSubchart(); + // re-render chart + $$.redraw(); + }; + + Chart.prototype.tooltip = function () { }; + Chart.prototype.tooltip.show = function (args) { + var $$ = this.internal, targets, data, mouse = {}; + // determine mouse position on the chart + if (args.mouse) { + mouse = args.mouse; + } + else { + // determine focus data + if (args.data) { + data = args.data; + } + else if (typeof args.x !== 'undefined') { + if (args.id) { + targets = $$.data.targets.filter(function (t) { + return t.id === args.id; + }); + } + else { + targets = $$.data.targets; + } + data = $$.filterByX(targets, args.x).slice(0, 1)[0]; + } + mouse = data ? $$.getMousePosition(data) : null; + } + // emulate mouse events to show + $$.dispatchEvent('mousemove', mouse); + $$.config.tooltip_onshow.call($$, data); + }; + Chart.prototype.tooltip.hide = function () { + // TODO: get target data by checking the state of focus + this.internal.dispatchEvent('mouseout', 0); + this.internal.config.tooltip_onhide.call(this); + }; + + Chart.prototype.transform = function (type, targetIds) { + var $$ = this.internal, options = ['pie', 'donut'].indexOf(type) >= 0 ? { withTransform: true } : null; + $$.transformTo(targetIds, type, options); + }; + ChartInternal.prototype.transformTo = function (targetIds, type, optionsForRedraw) { + var $$ = this, withTransitionForAxis = !$$.hasArcType(), options = optionsForRedraw || { + withTransitionForAxis: withTransitionForAxis + }; + options.withTransitionForTransform = false; + $$.transiting = false; + $$.setTargetType(targetIds, type); + $$.updateTargets($$.data.targets); // this is needed when transforming to arc + $$.updateAndRedraw(options); + }; + + Chart.prototype.x = function (x) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetX($$.data.targets, x); + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + return $$.data.xs; + }; + Chart.prototype.xs = function (xs) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetXs($$.data.targets, xs); + $$.redraw({ withUpdateOrgXDomain: true, withUpdateXDomain: true }); + } + return $$.data.xs; + }; + + Chart.prototype.zoom = function (domain) { + var $$ = this.internal; + if (domain) { + if ($$.isTimeSeries()) { + domain = domain.map(function (x) { + return $$.parseDate(x); + }); + } + if ($$.config.subchart_show) { + $$.brush.selectionAsValue(domain, true); + } + else { + $$.updateXDomain(null, true, false, false, domain); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } + $$.config.zoom_onzoom.call(this, $$.x.orgDomain()); + return domain; + } + else { + return $$.x.domain(); + } + }; + Chart.prototype.zoom.enable = function (enabled) { + var $$ = this.internal; + $$.config.zoom_enabled = enabled; + $$.updateAndRedraw(); + }; + Chart.prototype.unzoom = function () { + var $$ = this.internal; + if ($$.config.subchart_show) { + $$.brush.clear(); + } + else { + $$.updateXDomain(null, true, false, false, $$.subX.domain()); + $$.redraw({ withY: $$.config.zoom_rescale, withSubchart: false }); + } + }; + Chart.prototype.zoom.max = function (max) { + var $$ = this.internal, config = $$.config, d3 = $$.d3; + if (max === 0 || max) { + config.zoom_x_max = d3.max([$$.orgXDomain[1], max]); + } + else { + return config.zoom_x_max; + } + }; + Chart.prototype.zoom.min = function (min) { + var $$ = this.internal, config = $$.config, d3 = $$.d3; + if (min === 0 || min) { + config.zoom_x_min = d3.min([$$.orgXDomain[0], min]); + } + else { + return config.zoom_x_min; + } + }; + Chart.prototype.zoom.range = function (range) { + if (arguments.length) { + if (isDefined(range.max)) { + this.domain.max(range.max); + } + if (isDefined(range.min)) { + this.domain.min(range.min); + } + } + else { + return { + max: this.domain.max(), + min: this.domain.min() + }; + } + }; + + ChartInternal.prototype.initPie = function () { + var $$ = this, d3 = $$.d3; + $$.pie = d3 + .pie() + .padAngle(this.getPadAngle.bind(this)) + .value(function (d) { + return d.values.reduce(function (a, b) { + return a + b.value; + }, 0); + }); + var orderFct = $$.getOrderFunction(); + // we need to reverse the returned order if asc or desc to have the slice in expected order. + if (orderFct && ($$.isOrderAsc() || $$.isOrderDesc())) { + var defaultSort_1 = orderFct; + orderFct = function (t1, t2) { return defaultSort_1(t1, t2) * -1; }; + } + $$.pie.sort(orderFct || null); + }; + ChartInternal.prototype.updateRadius = function () { + var $$ = this, config = $$.config, w = config.gauge_width || config.donut_width, gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length * + $$.config.gauge_arcs_minWidth; + $$.radiusExpanded = + (Math.min($$.arcWidth, $$.arcHeight) / 2) * ($$.hasType('gauge') ? 0.85 : 1); + $$.radius = $$.radiusExpanded * 0.95; + $$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6; + $$.innerRadius = + $$.hasType('donut') || $$.hasType('gauge') + ? $$.radius * $$.innerRadiusRatio + : 0; + $$.gaugeArcWidth = w + ? w + : gaugeArcWidth <= $$.radius - $$.innerRadius + ? $$.radius - $$.innerRadius + : gaugeArcWidth <= $$.radius + ? gaugeArcWidth + : $$.radius; + }; + ChartInternal.prototype.getPadAngle = function () { + if (this.hasType('pie')) { + return this.config.pie_padAngle || 0; + } + else if (this.hasType('donut')) { + return this.config.donut_padAngle || 0; + } + else { + return 0; + } + }; + ChartInternal.prototype.updateArc = function () { + var $$ = this; + $$.svgArc = $$.getSvgArc(); + $$.svgArcExpanded = $$.getSvgArcExpanded(); + $$.svgArcExpandedSub = $$.getSvgArcExpanded(0.98); + }; + ChartInternal.prototype.updateAngle = function (d) { + var $$ = this, config = $$.config, found = false, index = 0, gMin, gMax, gTic, gValue; + if (!config) { + return null; + } + $$.pie($$.filterTargetsToShow($$.data.targets)).forEach(function (t) { + if (!found && t.data.id === d.data.id) { + found = true; + d = t; + d.index = index; + } + index++; + }); + if (isNaN(d.startAngle)) { + d.startAngle = 0; + } + if (isNaN(d.endAngle)) { + d.endAngle = d.startAngle; + } + if ($$.isGaugeType(d.data)) { + gMin = config.gauge_min; + gMax = config.gauge_max; + gTic = (Math.PI * (config.gauge_fullCircle ? 2 : 1)) / (gMax - gMin); + gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : gMax - gMin; + d.startAngle = config.gauge_startingAngle; + d.endAngle = d.startAngle + gTic * gValue; + } + return found ? d : null; + }; + ChartInternal.prototype.getSvgArc = function () { + var $$ = this, hasGaugeType = $$.hasType('gauge'), singleArcWidth = $$.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length, arc = $$.d3 + .arc() + .outerRadius(function (d) { + return hasGaugeType ? $$.radius - singleArcWidth * d.index : $$.radius; + }) + .innerRadius(function (d) { + return hasGaugeType + ? $$.radius - singleArcWidth * (d.index + 1) + : $$.innerRadius; + }), newArc = function (d, withoutUpdate) { + var updated; + if (withoutUpdate) { + return arc(d); + } // for interpolate + updated = $$.updateAngle(d); + return updated ? arc(updated) : 'M 0 0'; + }; + newArc.centroid = arc.centroid; + return newArc; + }; + ChartInternal.prototype.getSvgArcExpanded = function (rate) { + rate = rate || 1; + var $$ = this, hasGaugeType = $$.hasType('gauge'), singleArcWidth = $$.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length, expandWidth = Math.min($$.radiusExpanded * rate - $$.radius, singleArcWidth * 0.8 - (1 - rate) * 100), arc = $$.d3 + .arc() + .outerRadius(function (d) { + return hasGaugeType + ? $$.radius - singleArcWidth * d.index + expandWidth + : $$.radiusExpanded * rate; + }) + .innerRadius(function (d) { + return hasGaugeType + ? $$.radius - singleArcWidth * (d.index + 1) + : $$.innerRadius; + }); + return function (d) { + var updated = $$.updateAngle(d); + return updated ? arc(updated) : 'M 0 0'; + }; + }; + ChartInternal.prototype.getArc = function (d, withoutUpdate, force) { + return force || this.isArcType(d.data) + ? this.svgArc(d, withoutUpdate) + : 'M 0 0'; + }; + ChartInternal.prototype.transformForArcLabel = function (d) { + var $$ = this, config = $$.config, updated = $$.updateAngle(d), c, x, y, h, ratio, translate = '', hasGauge = $$.hasType('gauge'); + if (updated && !hasGauge) { + c = this.svgArc.centroid(updated); + x = isNaN(c[0]) ? 0 : c[0]; + y = isNaN(c[1]) ? 0 : c[1]; + h = Math.sqrt(x * x + y * y); + if ($$.hasType('donut') && config.donut_label_ratio) { + ratio = isFunction(config.donut_label_ratio) + ? config.donut_label_ratio(d, $$.radius, h) + : config.donut_label_ratio; + } + else if ($$.hasType('pie') && config.pie_label_ratio) { + ratio = isFunction(config.pie_label_ratio) + ? config.pie_label_ratio(d, $$.radius, h) + : config.pie_label_ratio; + } + else { + ratio = + $$.radius && h + ? ((36 / $$.radius > 0.375 ? 1.175 - 36 / $$.radius : 0.8) * + $$.radius) / + h + : 0; + } + translate = 'translate(' + x * ratio + ',' + y * ratio + ')'; + } + else if (updated && + hasGauge && + $$.filterTargetsToShow($$.data.targets).length > 1) { + var y1 = Math.sin(updated.endAngle - Math.PI / 2); + x = Math.cos(updated.endAngle - Math.PI / 2) * ($$.radiusExpanded + 25); + y = y1 * ($$.radiusExpanded + 15 - Math.abs(y1 * 10)) + 3; + translate = 'translate(' + x + ',' + y + ')'; + } + return translate; + }; + /** + * @deprecated Use `getRatio('arc', d)` instead. + */ + ChartInternal.prototype.getArcRatio = function (d) { + return this.getRatio('arc', d); + }; + ChartInternal.prototype.convertToArcData = function (d) { + return this.addName({ + id: d.data.id, + value: d.value, + ratio: this.getRatio('arc', d), + index: d.index + }); + }; + ChartInternal.prototype.textForArcLabel = function (d) { + var $$ = this, updated, value, ratio, id, format; + if (!$$.shouldShowArcLabel()) { + return ''; + } + updated = $$.updateAngle(d); + value = updated ? updated.value : null; + ratio = $$.getRatio('arc', updated); + id = d.data.id; + if (!$$.hasType('gauge') && !$$.meetsArcLabelThreshold(ratio)) { + return ''; + } + format = $$.getArcLabelFormat(); + return format + ? format(value, ratio, id) + : $$.defaultArcValueFormat(value, ratio); + }; + ChartInternal.prototype.textForGaugeMinMax = function (value, isMax) { + var $$ = this, format = $$.getGaugeLabelExtents(); + return format ? format(value, isMax) : value; + }; + ChartInternal.prototype.expandArc = function (targetIds) { + var $$ = this, interval; + // MEMO: avoid to cancel transition + if ($$.transiting) { + interval = window.setInterval(function () { + if (!$$.transiting) { + window.clearInterval(interval); + if ($$.legend.selectAll('.c3-legend-item-focused').size() > 0) { + $$.expandArc(targetIds); + } + } + }, 10); + return; + } + targetIds = $$.mapToTargetIds(targetIds); + $$.svg + .selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)) + .each(function (d) { + if (!$$.shouldExpand(d.data.id)) { + return; + } + $$.d3 + .select(this) + .selectAll('path') + .transition() + .duration($$.expandDuration(d.data.id)) + .attr('d', $$.svgArcExpanded) + .transition() + .duration($$.expandDuration(d.data.id) * 2) + .attr('d', $$.svgArcExpandedSub) + .each(function (d) { + if ($$.isDonutType(d.data)) ; + }); + }); + }; + ChartInternal.prototype.unexpandArc = function (targetIds) { + var $$ = this; + if ($$.transiting) { + return; + } + targetIds = $$.mapToTargetIds(targetIds); + $$.svg + .selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)) + .selectAll('path') + .transition() + .duration(function (d) { + return $$.expandDuration(d.data.id); + }) + .attr('d', $$.svgArc); + $$.svg.selectAll('.' + CLASS.arc); + }; + ChartInternal.prototype.expandDuration = function (id) { + var $$ = this, config = $$.config; + if ($$.isDonutType(id)) { + return config.donut_expand_duration; + } + else if ($$.isGaugeType(id)) { + return config.gauge_expand_duration; + } + else if ($$.isPieType(id)) { + return config.pie_expand_duration; + } + else { + return 50; + } + }; + ChartInternal.prototype.shouldExpand = function (id) { + var $$ = this, config = $$.config; + return (($$.isDonutType(id) && config.donut_expand) || + ($$.isGaugeType(id) && config.gauge_expand) || + ($$.isPieType(id) && config.pie_expand)); + }; + ChartInternal.prototype.shouldShowArcLabel = function () { + var $$ = this, config = $$.config, shouldShow = true; + if ($$.hasType('donut')) { + shouldShow = config.donut_label_show; + } + else if ($$.hasType('pie')) { + shouldShow = config.pie_label_show; + } + // when gauge, always true + return shouldShow; + }; + ChartInternal.prototype.meetsArcLabelThreshold = function (ratio) { + var $$ = this, config = $$.config, threshold = $$.hasType('donut') + ? config.donut_label_threshold + : config.pie_label_threshold; + return ratio >= threshold; + }; + ChartInternal.prototype.getArcLabelFormat = function () { + var $$ = this, config = $$.config, format = config.pie_label_format; + if ($$.hasType('gauge')) { + format = config.gauge_label_format; + } + else if ($$.hasType('donut')) { + format = config.donut_label_format; + } + return format; + }; + ChartInternal.prototype.getGaugeLabelExtents = function () { + var $$ = this, config = $$.config; + return config.gauge_label_extents; + }; + ChartInternal.prototype.getArcTitle = function () { + var $$ = this; + return $$.hasType('donut') ? $$.config.donut_title : ''; + }; + ChartInternal.prototype.updateTargetsForArc = function (targets) { + var $$ = this, main = $$.main, mainPies, mainPieEnter, classChartArc = $$.classChartArc.bind($$), classArcs = $$.classArcs.bind($$), classFocus = $$.classFocus.bind($$); + mainPies = main + .select('.' + CLASS.chartArcs) + .selectAll('.' + CLASS.chartArc) + .data($$.pie(targets)) + .attr('class', function (d) { + return classChartArc(d) + classFocus(d.data); + }); + mainPieEnter = mainPies + .enter() + .append('g') + .attr('class', classChartArc); + mainPieEnter.append('g').attr('class', classArcs); + mainPieEnter + .append('text') + .attr('dy', $$.hasType('gauge') ? '-.1em' : '.35em') + .style('opacity', 0) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + // MEMO: can not keep same color..., but not bad to update color in redraw + //mainPieUpdate.exit().remove(); + }; + ChartInternal.prototype.initArc = function () { + var $$ = this; + $$.arcs = $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartArcs) + .attr('transform', $$.getTranslate('arc')); + $$.arcs + .append('text') + .attr('class', CLASS.chartArcsTitle) + .style('text-anchor', 'middle') + .text($$.getArcTitle()); + }; + ChartInternal.prototype.redrawArc = function (duration, durationForExit, withTransform) { + var $$ = this, d3 = $$.d3, config = $$.config, main = $$.main, arcs, mainArc, arcLabelLines, mainArcLabelLine, hasGaugeType = $$.hasType('gauge'); + arcs = main + .selectAll('.' + CLASS.arcs) + .selectAll('.' + CLASS.arc) + .data($$.arcData.bind($$)); + mainArc = arcs + .enter() + .append('path') + .attr('class', $$.classArc.bind($$)) + .style('fill', function (d) { + return $$.color(d.data); + }) + .style('cursor', function (d) { + return config.interaction_enabled && config.data_selection_isselectable(d) + ? 'pointer' + : null; + }) + .each(function (d) { + if ($$.isGaugeType(d.data)) { + d.startAngle = d.endAngle = config.gauge_startingAngle; + } + this._current = d; + }) + .merge(arcs); + if (hasGaugeType) { + arcLabelLines = main + .selectAll('.' + CLASS.arcs) + .selectAll('.' + CLASS.arcLabelLine) + .data($$.arcData.bind($$)); + mainArcLabelLine = arcLabelLines + .enter() + .append('rect') + .attr('class', function (d) { + return (CLASS.arcLabelLine + + ' ' + + CLASS.target + + ' ' + + CLASS.target + + '-' + + d.data.id); + }) + .merge(arcLabelLines); + if ($$.filterTargetsToShow($$.data.targets).length === 1) { + mainArcLabelLine.style('display', 'none'); + } + else { + mainArcLabelLine + .style('fill', function (d) { + return $$.levelColor + ? $$.levelColor(d.data.values.reduce(function (total, item) { + return total + item.value; + }, 0)) + : $$.color(d.data); + }) + .style('display', config.gauge_labelLine_show ? '' : 'none') + .each(function (d) { + var lineLength = 0, lineThickness = 2, x = 0, y = 0, transform = ''; + if ($$.hiddenTargetIds.indexOf(d.data.id) < 0) { + var updated = $$.updateAngle(d), innerLineLength = ($$.gaugeArcWidth / + $$.filterTargetsToShow($$.data.targets).length) * + (updated.index + 1), lineAngle = updated.endAngle - Math.PI / 2, arcInnerRadius = $$.radius - innerLineLength, linePositioningAngle = lineAngle - (arcInnerRadius === 0 ? 0 : 1 / arcInnerRadius); + lineLength = $$.radiusExpanded - $$.radius + innerLineLength; + x = Math.cos(linePositioningAngle) * arcInnerRadius; + y = Math.sin(linePositioningAngle) * arcInnerRadius; + transform = + 'rotate(' + + (lineAngle * 180) / Math.PI + + ', ' + + x + + ', ' + + y + + ')'; + } + d3.select(this) + .attr('x', x) + .attr('y', y) + .attr('width', lineLength) + .attr('height', lineThickness) + .attr('transform', transform) + .style('stroke-dasharray', '0, ' + (lineLength + lineThickness) + ', 0'); + }); + } + } + mainArc + .attr('transform', function (d) { + return !$$.isGaugeType(d.data) && withTransform ? 'scale(0)' : ''; + }) + .on('mouseover', config.interaction_enabled + ? function (d) { + var updated, arcData; + if ($$.transiting) { + // skip while transiting + return; + } + updated = $$.updateAngle(d); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.expandArc(updated.data.id); + $$.api.focus(updated.data.id); + $$.toggleFocusLegend(updated.data.id, true); + $$.config.data_onmouseover(arcData, this); + } + } + : null) + .on('mousemove', config.interaction_enabled + ? function (d) { + var updated = $$.updateAngle(d), arcData, selectedData; + if (updated) { + (arcData = $$.convertToArcData(updated)), + (selectedData = [arcData]); + $$.showTooltip(selectedData, this); + } + } + : null) + .on('mouseout', config.interaction_enabled + ? function (d) { + var updated, arcData; + if ($$.transiting) { + // skip while transiting + return; + } + updated = $$.updateAngle(d); + if (updated) { + arcData = $$.convertToArcData(updated); + // transitions + $$.unexpandArc(updated.data.id); + $$.api.revert(); + $$.revertLegend(); + $$.hideTooltip(); + $$.config.data_onmouseout(arcData, this); + } + } + : null) + .on('click', config.interaction_enabled + ? function (d, i) { + var updated = $$.updateAngle(d), arcData; + if (updated) { + arcData = $$.convertToArcData(updated); + if ($$.toggleShape) { + $$.toggleShape(this, arcData, i); + } + $$.config.data_onclick.call($$.api, arcData, this); + } + } + : null) + .each(function () { + $$.transiting = true; + }) + .transition() + .duration(duration) + .attrTween('d', function (d) { + var updated = $$.updateAngle(d), interpolate; + if (!updated) { + return function () { + return 'M 0 0'; + }; + } + // if (this._current === d) { + // this._current = { + // startAngle: Math.PI*2, + // endAngle: Math.PI*2, + // }; + // } + if (isNaN(this._current.startAngle)) { + this._current.startAngle = 0; + } + if (isNaN(this._current.endAngle)) { + this._current.endAngle = this._current.startAngle; + } + interpolate = d3.interpolate(this._current, updated); + this._current = interpolate(0); + return function (t) { + // prevents crashing the charts once in transition and chart.destroy() has been called + if ($$.config === null) { + return 'M 0 0'; + } + var interpolated = interpolate(t); + interpolated.data = d.data; // data.id will be updated by interporator + return $$.getArc(interpolated, true); + }; + }) + .attr('transform', withTransform ? 'scale(1)' : '') + .style('fill', function (d) { + return $$.levelColor + ? $$.levelColor(d.data.values.reduce(function (total, item) { + return total + item.value; + }, 0)) + : $$.color(d.data.id); + }) // Where gauge reading color would receive customization. + .call($$.endall, function () { + $$.transiting = false; + }); + arcs + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + main + .selectAll('.' + CLASS.chartArc) + .select('text') + .style('opacity', 0) + .attr('class', function (d) { + return $$.isGaugeType(d.data) ? CLASS.gaugeValue : ''; + }) + .text($$.textForArcLabel.bind($$)) + .attr('transform', $$.transformForArcLabel.bind($$)) + .style('font-size', function (d) { + return $$.isGaugeType(d.data) && + $$.filterTargetsToShow($$.data.targets).length === 1 + ? Math.round($$.radius / 5) + 'px' + : ''; + }) + .transition() + .duration(duration) + .style('opacity', function (d) { + return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? 1 : 0; + }); + main + .select('.' + CLASS.chartArcsTitle) + .style('opacity', $$.hasType('donut') || hasGaugeType ? 1 : 0); + if (hasGaugeType) { + var index_1 = 0; + var backgroundArc = $$.arcs + .select('g.' + CLASS.chartArcsBackground) + .selectAll('path.' + CLASS.chartArcsBackground) + .data($$.data.targets); + backgroundArc + .enter() + .append('path') + .attr('class', function (d, i) { + return CLASS.chartArcsBackground + ' ' + CLASS.chartArcsBackground + '-' + i; + }) + .merge(backgroundArc) + .attr('d', function (d1) { + if ($$.hiddenTargetIds.indexOf(d1.id) >= 0) { + return 'M 0 0'; + } + var d = { + data: [{ value: config.gauge_max }], + startAngle: config.gauge_startingAngle, + endAngle: -1 * + config.gauge_startingAngle * + (config.gauge_fullCircle ? Math.PI : 1), + index: index_1++ + }; + return $$.getArc(d, true, true); + }); + backgroundArc.exit().remove(); + $$.arcs + .select('.' + CLASS.chartArcsGaugeUnit) + .attr('dy', '.75em') + .text(config.gauge_label_show ? config.gauge_units : ''); + $$.arcs + .select('.' + CLASS.chartArcsGaugeMin) + .attr('dx', -1 * + ($$.innerRadius + + ($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2)) + + 'px') + .attr('dy', '1.2em') + .text(config.gauge_label_show + ? $$.textForGaugeMinMax(config.gauge_min, false) + : ''); + $$.arcs + .select('.' + CLASS.chartArcsGaugeMax) + .attr('dx', $$.innerRadius + + ($$.radius - $$.innerRadius) / (config.gauge_fullCircle ? 1 : 2) + + 'px') + .attr('dy', '1.2em') + .text(config.gauge_label_show + ? $$.textForGaugeMinMax(config.gauge_max, true) + : ''); + } + }; + ChartInternal.prototype.initGauge = function () { + var arcs = this.arcs; + if (this.hasType('gauge')) { + arcs.append('g').attr('class', CLASS.chartArcsBackground); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeUnit) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeMin) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + arcs + .append('text') + .attr('class', CLASS.chartArcsGaugeMax) + .style('text-anchor', 'middle') + .style('pointer-events', 'none'); + } + }; + ChartInternal.prototype.getGaugeLabelHeight = function () { + return this.config.gauge_label_show ? 20 : 0; + }; + + /** + * Store value into cache + * + * @param key + * @param value + */ + ChartInternal.prototype.addToCache = function (key, value) { + this.cache["$" + key] = value; + }; + /** + * Returns a cached value or undefined + * + * @param key + * @return {*} + */ + ChartInternal.prototype.getFromCache = function (key) { + return this.cache["$" + key]; + }; + /** + * Reset cached data + */ + ChartInternal.prototype.resetCache = function () { + var _this = this; + Object.keys(this.cache) + .filter(function (key) { return /^\$/.test(key); }) + .forEach(function (key) { + delete _this.cache[key]; + }); + }; + // Old API that stores Targets + ChartInternal.prototype.hasCaches = function (ids) { + for (var i = 0; i < ids.length; i++) { + if (!(ids[i] in this.cache)) { + return false; + } + } + return true; + }; + ChartInternal.prototype.addCache = function (id, target) { + this.cache[id] = this.cloneTarget(target); + }; + ChartInternal.prototype.getCaches = function (ids) { + var targets = [], i; + for (i = 0; i < ids.length; i++) { + if (ids[i] in this.cache) { + targets.push(this.cloneTarget(this.cache[ids[i]])); + } + } + return targets; + }; + + ChartInternal.prototype.categoryName = function (i) { + var config = this.config; + return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i; + }; + + ChartInternal.prototype.generateTargetClass = function (targetId) { + return targetId || targetId === 0 ? ('-' + targetId).replace(/\s/g, '-') : ''; + }; + ChartInternal.prototype.generateClass = function (prefix, targetId) { + return ' ' + prefix + ' ' + prefix + this.generateTargetClass(targetId); + }; + ChartInternal.prototype.classText = function (d) { + return this.generateClass(CLASS.text, d.index); + }; + ChartInternal.prototype.classTexts = function (d) { + return this.generateClass(CLASS.texts, d.id); + }; + ChartInternal.prototype.classShape = function (d) { + return this.generateClass(CLASS.shape, d.index); + }; + ChartInternal.prototype.classShapes = function (d) { + return this.generateClass(CLASS.shapes, d.id); + }; + ChartInternal.prototype.classLine = function (d) { + return this.classShape(d) + this.generateClass(CLASS.line, d.id); + }; + ChartInternal.prototype.classLines = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.lines, d.id); + }; + ChartInternal.prototype.classCircle = function (d) { + return this.classShape(d) + this.generateClass(CLASS.circle, d.index); + }; + ChartInternal.prototype.classCircles = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.circles, d.id); + }; + ChartInternal.prototype.classBar = function (d) { + return this.classShape(d) + this.generateClass(CLASS.bar, d.index); + }; + ChartInternal.prototype.classBars = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.bars, d.id); + }; + ChartInternal.prototype.classArc = function (d) { + return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id); + }; + ChartInternal.prototype.classArcs = function (d) { + return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id); + }; + ChartInternal.prototype.classArea = function (d) { + return this.classShape(d) + this.generateClass(CLASS.area, d.id); + }; + ChartInternal.prototype.classAreas = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.areas, d.id); + }; + ChartInternal.prototype.classRegion = function (d, i) { + return (this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d['class'] : '')); + }; + ChartInternal.prototype.classEvent = function (d) { + return this.generateClass(CLASS.eventRect, d.index); + }; + ChartInternal.prototype.classTarget = function (id) { + var $$ = this; + var additionalClassSuffix = $$.config.data_classes[id], additionalClass = ''; + if (additionalClassSuffix) { + additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; + } + return $$.generateClass(CLASS.target, id) + additionalClass; + }; + ChartInternal.prototype.classFocus = function (d) { + return this.classFocused(d) + this.classDefocused(d); + }; + ChartInternal.prototype.classFocused = function (d) { + return ' ' + (this.focusedTargetIds.indexOf(d.id) >= 0 ? CLASS.focused : ''); + }; + ChartInternal.prototype.classDefocused = function (d) { + return (' ' + (this.defocusedTargetIds.indexOf(d.id) >= 0 ? CLASS.defocused : '')); + }; + ChartInternal.prototype.classChartText = function (d) { + return CLASS.chartText + this.classTarget(d.id); + }; + ChartInternal.prototype.classChartLine = function (d) { + return CLASS.chartLine + this.classTarget(d.id); + }; + ChartInternal.prototype.classChartBar = function (d) { + return CLASS.chartBar + this.classTarget(d.id); + }; + ChartInternal.prototype.classChartArc = function (d) { + return CLASS.chartArc + this.classTarget(d.data.id); + }; + ChartInternal.prototype.getTargetSelectorSuffix = function (targetId) { + var targetClass = this.generateTargetClass(targetId); + if (window.CSS && window.CSS.escape) { + return window.CSS.escape(targetClass); + } + // fallback on imperfect method for old browsers (does not handles unicode) + return targetClass.replace(/([?!@#$%^&*()=+,.<>'":;\[\]\/|~`{}\\])/g, '\\$1'); + }; + ChartInternal.prototype.selectorTarget = function (id, prefix) { + return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id); + }; + ChartInternal.prototype.selectorTargets = function (ids, prefix) { + var $$ = this; + ids = ids || []; + return ids.length + ? ids.map(function (id) { + return $$.selectorTarget(id, prefix); + }) + : null; + }; + ChartInternal.prototype.selectorLegend = function (id) { + return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id); + }; + ChartInternal.prototype.selectorLegends = function (ids) { + var $$ = this; + return ids && ids.length + ? ids.map(function (id) { + return $$.selectorLegend(id); + }) + : null; + }; + + ChartInternal.prototype.getClipPath = function (id) { + return 'url(' + (isIE(9) ? '' : document.URL.split('#')[0]) + '#' + id + ')'; + }; + ChartInternal.prototype.appendClip = function (parent, id) { + return parent + .append('clipPath') + .attr('id', id) + .append('rect'); + }; + ChartInternal.prototype.getAxisClipX = function (forHorizontal) { + // axis line width + padding for left + var left = Math.max(30, this.margin.left); + return forHorizontal ? -(1 + left) : -(left - 1); + }; + ChartInternal.prototype.getAxisClipY = function (forHorizontal) { + return forHorizontal ? -20 : -this.margin.top; + }; + ChartInternal.prototype.getXAxisClipX = function () { + var $$ = this; + return $$.getAxisClipX(!$$.config.axis_rotated); + }; + ChartInternal.prototype.getXAxisClipY = function () { + var $$ = this; + return $$.getAxisClipY(!$$.config.axis_rotated); + }; + ChartInternal.prototype.getYAxisClipX = function () { + var $$ = this; + return $$.config.axis_y_inner ? -1 : $$.getAxisClipX($$.config.axis_rotated); + }; + ChartInternal.prototype.getYAxisClipY = function () { + var $$ = this; + return $$.getAxisClipY($$.config.axis_rotated); + }; + ChartInternal.prototype.getAxisClipWidth = function (forHorizontal) { + var $$ = this, left = Math.max(30, $$.margin.left), right = Math.max(30, $$.margin.right); + // width + axis line width + padding for left/right + return forHorizontal ? $$.width + 2 + left + right : $$.margin.left + 20; + }; + ChartInternal.prototype.getAxisClipHeight = function (forHorizontal) { + // less than 20 is not enough to show the axis label 'outer' without legend + return ((forHorizontal ? this.margin.bottom : this.margin.top + this.height) + 20); + }; + ChartInternal.prototype.getXAxisClipWidth = function () { + var $$ = this; + return $$.getAxisClipWidth(!$$.config.axis_rotated); + }; + ChartInternal.prototype.getXAxisClipHeight = function () { + var $$ = this; + return $$.getAxisClipHeight(!$$.config.axis_rotated); + }; + ChartInternal.prototype.getYAxisClipWidth = function () { + var $$ = this; + return ($$.getAxisClipWidth($$.config.axis_rotated) + + ($$.config.axis_y_inner ? 20 : 0)); + }; + ChartInternal.prototype.getYAxisClipHeight = function () { + var $$ = this; + return $$.getAxisClipHeight($$.config.axis_rotated); + }; + + ChartInternal.prototype.generateColor = function () { + var $$ = this, config = $$.config, d3 = $$.d3, colors = config.data_colors, pattern = notEmpty(config.color_pattern) + ? config.color_pattern + : d3.schemeCategory10, callback = config.data_color, ids = []; + return function (d) { + var id = d.id || (d.data && d.data.id) || d, color; + // if callback function is provided + if (colors[id] instanceof Function) { + color = colors[id](d); + } + // if specified, choose that color + else if (colors[id]) { + color = colors[id]; + } + // if not specified, choose from pattern + else { + if (ids.indexOf(id) < 0) { + ids.push(id); + } + color = pattern[ids.indexOf(id) % pattern.length]; + colors[id] = color; + } + return callback instanceof Function ? callback(color, d) : color; + }; + }; + ChartInternal.prototype.generateLevelColor = function () { + var $$ = this, config = $$.config, colors = config.color_pattern, threshold = config.color_threshold, asValue = threshold.unit === 'value', values = threshold.values && threshold.values.length ? threshold.values : [], max = threshold.max || 100; + return notEmpty(threshold) && notEmpty(colors) + ? function (value) { + var i, v, color = colors[colors.length - 1]; + for (i = 0; i < values.length; i++) { + v = asValue ? value : (value * 100) / max; + if (v < values[i]) { + color = colors[i]; + break; + } + } + return color; + } + : null; + }; + + ChartInternal.prototype.getDefaultConfig = function () { + var config = { + bindto: '#chart', + svg_classname: undefined, + size_width: undefined, + size_height: undefined, + padding_left: undefined, + padding_right: undefined, + padding_top: undefined, + padding_bottom: undefined, + resize_auto: true, + zoom_enabled: false, + zoom_initialRange: undefined, + zoom_type: 'scroll', + zoom_disableDefaultBehavior: false, + zoom_privileged: false, + zoom_rescale: false, + zoom_onzoom: function () { }, + zoom_onzoomstart: function () { }, + zoom_onzoomend: function () { }, + zoom_x_min: undefined, + zoom_x_max: undefined, + interaction_brighten: true, + interaction_enabled: true, + onmouseover: function () { }, + onmouseout: function () { }, + onresize: function () { }, + onresized: function () { }, + oninit: function () { }, + onrendered: function () { }, + transition_duration: 350, + data_epochs: 'epochs', + data_x: undefined, + data_xs: {}, + data_xFormat: '%Y-%m-%d', + data_xLocaltime: true, + data_xSort: true, + data_idConverter: function (id) { + return id; + }, + data_names: {}, + data_classes: {}, + data_groups: [], + data_axes: {}, + data_type: undefined, + data_types: {}, + data_labels: {}, + data_order: 'desc', + data_regions: {}, + data_color: undefined, + data_colors: {}, + data_hide: false, + data_filter: undefined, + data_selection_enabled: false, + data_selection_grouped: false, + data_selection_isselectable: function () { + return true; + }, + data_selection_multiple: true, + data_selection_draggable: false, + data_stack_normalize: false, + data_onclick: function () { }, + data_onmouseover: function () { }, + data_onmouseout: function () { }, + data_onselected: function () { }, + data_onunselected: function () { }, + data_url: undefined, + data_headers: undefined, + data_json: undefined, + data_rows: undefined, + data_columns: undefined, + data_mimeType: undefined, + data_keys: undefined, + // configuration for no plot-able data supplied. + data_empty_label_text: '', + // subchart + subchart_show: false, + subchart_size_height: 60, + subchart_axis_x_show: true, + subchart_onbrush: function () { }, + // color + color_pattern: [], + color_threshold: {}, + // legend + legend_show: true, + legend_hide: false, + legend_position: 'bottom', + legend_inset_anchor: 'top-left', + legend_inset_x: 10, + legend_inset_y: 0, + legend_inset_step: undefined, + legend_item_onclick: undefined, + legend_item_onmouseover: undefined, + legend_item_onmouseout: undefined, + legend_equally: false, + legend_padding: 0, + legend_item_tile_width: 10, + legend_item_tile_height: 10, + // axis + axis_rotated: false, + axis_x_show: true, + axis_x_type: 'indexed', + axis_x_localtime: true, + axis_x_categories: [], + axis_x_tick_centered: false, + axis_x_tick_format: undefined, + axis_x_tick_culling: {}, + axis_x_tick_culling_max: 10, + axis_x_tick_count: undefined, + axis_x_tick_fit: true, + axis_x_tick_values: null, + axis_x_tick_rotate: 0, + axis_x_tick_outer: true, + axis_x_tick_multiline: true, + axis_x_tick_multilineMax: 0, + axis_x_tick_width: null, + axis_x_max: undefined, + axis_x_min: undefined, + axis_x_padding: {}, + axis_x_height: undefined, + axis_x_selection: undefined, + axis_x_label: {}, + axis_x_inner: undefined, + axis_y_show: true, + axis_y_type: 'linear', + axis_y_max: undefined, + axis_y_min: undefined, + axis_y_inverted: false, + axis_y_center: undefined, + axis_y_inner: undefined, + axis_y_label: {}, + axis_y_tick_format: undefined, + axis_y_tick_outer: true, + axis_y_tick_values: null, + axis_y_tick_rotate: 0, + axis_y_tick_count: undefined, + axis_y_tick_time_type: undefined, + axis_y_tick_time_interval: undefined, + axis_y_padding: {}, + axis_y_default: undefined, + axis_y2_show: false, + axis_y2_type: 'linear', + axis_y2_max: undefined, + axis_y2_min: undefined, + axis_y2_inverted: false, + axis_y2_center: undefined, + axis_y2_inner: undefined, + axis_y2_label: {}, + axis_y2_tick_format: undefined, + axis_y2_tick_outer: true, + axis_y2_tick_values: null, + axis_y2_tick_count: undefined, + axis_y2_padding: {}, + axis_y2_default: undefined, + // grid + grid_x_show: false, + grid_x_type: 'tick', + grid_x_lines: [], + grid_y_show: false, + // not used + // grid_y_type: 'tick', + grid_y_lines: [], + grid_y_ticks: 10, + grid_focus_show: true, + grid_lines_front: true, + // point - point of each data + point_show: true, + point_r: 2.5, + point_sensitivity: 10, + point_focus_expand_enabled: true, + point_focus_expand_r: undefined, + point_select_r: undefined, + // line + line_connectNull: false, + line_step_type: 'step', + // bar + bar_width: undefined, + bar_width_ratio: 0.6, + bar_width_max: undefined, + bar_zerobased: true, + bar_space: 0, + // area + area_zerobased: true, + area_above: false, + // pie + pie_label_show: true, + pie_label_format: undefined, + pie_label_threshold: 0.05, + pie_label_ratio: undefined, + pie_expand: {}, + pie_expand_duration: 50, + pie_padAngle: 0, + // gauge + gauge_fullCircle: false, + gauge_label_show: true, + gauge_labelLine_show: true, + gauge_label_format: undefined, + gauge_min: 0, + gauge_max: 100, + gauge_startingAngle: (-1 * Math.PI) / 2, + gauge_label_extents: undefined, + gauge_units: undefined, + gauge_width: undefined, + gauge_arcs_minWidth: 5, + gauge_expand: {}, + gauge_expand_duration: 50, + // donut + donut_label_show: true, + donut_label_format: undefined, + donut_label_threshold: 0.05, + donut_label_ratio: undefined, + donut_width: undefined, + donut_title: '', + donut_expand: {}, + donut_expand_duration: 50, + donut_padAngle: 0, + // spline + spline_interpolation_type: 'cardinal', + // stanford + stanford_lines: [], + stanford_regions: [], + stanford_texts: [], + stanford_scaleMin: undefined, + stanford_scaleMax: undefined, + stanford_scaleWidth: undefined, + stanford_scaleFormat: undefined, + stanford_scaleValues: undefined, + stanford_colors: undefined, + stanford_padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + // region - region to change style + regions: [], + // tooltip - show when mouseover on each data + tooltip_show: true, + tooltip_grouped: true, + tooltip_order: undefined, + tooltip_format_title: undefined, + tooltip_format_name: undefined, + tooltip_format_value: undefined, + tooltip_horizontal: undefined, + tooltip_position: undefined, + tooltip_contents: function (d, defaultTitleFormat, defaultValueFormat, color) { + return this.getTooltipContent + ? this.getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color) + : ''; + }, + tooltip_init_show: false, + tooltip_init_x: 0, + tooltip_init_position: { top: '0px', left: '50px' }, + tooltip_onshow: function () { }, + tooltip_onhide: function () { }, + // title + title_text: undefined, + title_padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + }, + title_position: 'top-center' + }; + Object.keys(this.additionalConfig).forEach(function (key) { + config[key] = this.additionalConfig[key]; + }, this); + return config; + }; + ChartInternal.prototype.additionalConfig = {}; + ChartInternal.prototype.loadConfig = function (config) { + var this_config = this.config, target, keys, read; + function find() { + var key = keys.shift(); + // console.log("key =>", key, ", target =>", target); + if (key && target && typeof target === 'object' && key in target) { + target = target[key]; + return find(); + } + else if (!key) { + return target; + } + else { + return undefined; + } + } + Object.keys(this_config).forEach(function (key) { + target = config; + keys = key.split('_'); + read = find(); + // console.log("CONFIG : ", key, read); + if (isDefined(read)) { + this_config[key] = read; + } + }); + }; + + ChartInternal.prototype.convertUrlToData = function (url, mimeType, headers, keys, done) { + var $$ = this, type = mimeType ? mimeType : 'csv', f, converter; + if (type === 'json') { + f = $$.d3.json; + converter = $$.convertJsonToData; + } + else if (type === 'tsv') { + f = $$.d3.tsv; + converter = $$.convertXsvToData; + } + else { + f = $$.d3.csv; + converter = $$.convertXsvToData; + } + f(url, headers) + .then(function (data) { + done.call($$, converter.call($$, data, keys)); + }) + .catch(function (error) { + throw error; + }); + }; + ChartInternal.prototype.convertXsvToData = function (xsv) { + var keys = xsv.columns, rows = xsv; + if (rows.length === 0) { + return { + keys: keys, + rows: [keys.reduce(function (row, key) { + var _a; + return Object.assign(row, (_a = {}, _a[key] = null, _a)); + }, {})] + }; + } + else { + // [].concat() is to convert result into a plain array otherwise + // test is not happy because rows have properties. + return { keys: keys, rows: [].concat(xsv) }; + } + }; + ChartInternal.prototype.convertJsonToData = function (json, keys) { + var $$ = this, new_rows = [], targetKeys, data; + if (keys) { + // when keys specified, json would be an array that includes objects + if (keys.x) { + targetKeys = keys.value.concat(keys.x); + $$.config.data_x = keys.x; + } + else { + targetKeys = keys.value; + } + new_rows.push(targetKeys); + json.forEach(function (o) { + var new_row = []; + targetKeys.forEach(function (key) { + // convert undefined to null because undefined data will be removed in convertDataToTargets() + var v = $$.findValueInJson(o, key); + if (isUndefined(v)) { + v = null; + } + new_row.push(v); + }); + new_rows.push(new_row); + }); + data = $$.convertRowsToData(new_rows); + } + else { + Object.keys(json).forEach(function (key) { + new_rows.push([key].concat(json[key])); + }); + data = $$.convertColumnsToData(new_rows); + } + return data; + }; + /** + * Finds value from the given nested object by the given path. + * If it's not found, then this returns undefined. + * @param {Object} object the object + * @param {string} path the path + */ + ChartInternal.prototype.findValueInJson = function (object, path) { + if (path in object) { + // If object has a key that contains . or [], return the key's value + // instead of searching for an inner object. + // See https://github.com/c3js/c3/issues/1691 for details. + return object[path]; + } + path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties (replace [] with .) + path = path.replace(/^\./, ''); // strip a leading dot + var pathArray = path.split('.'); + for (var i = 0; i < pathArray.length; ++i) { + var k = pathArray[i]; + if (k in object) { + object = object[k]; + } + else { + return; + } + } + return object; + }; + /** + * Converts the rows to normalized data. + * @param {any[][]} rows The row data + * @return {Object} + */ + ChartInternal.prototype.convertRowsToData = function (rows) { + var newRows = []; + var keys = rows[0]; + for (var i = 1; i < rows.length; i++) { + var newRow = {}; + for (var j = 0; j < rows[i].length; j++) { + if (isUndefined(rows[i][j])) { + throw new Error('Source data is missing a component at (' + i + ',' + j + ')!'); + } + newRow[keys[j]] = rows[i][j]; + } + newRows.push(newRow); + } + return { keys: keys, rows: newRows }; + }; + /** + * Converts the columns to normalized data. + * @param {any[][]} columns The column data + * @return {Object} + */ + ChartInternal.prototype.convertColumnsToData = function (columns) { + var newRows = []; + var keys = []; + for (var i = 0; i < columns.length; i++) { + var key = columns[i][0]; + for (var j = 1; j < columns[i].length; j++) { + if (isUndefined(newRows[j - 1])) { + newRows[j - 1] = {}; + } + if (isUndefined(columns[i][j])) { + throw new Error('Source data is missing a component at (' + i + ',' + j + ')!'); + } + newRows[j - 1][key] = columns[i][j]; + } + keys.push(key); + } + return { keys: keys, rows: newRows }; + }; + /** + * Converts the data format into the target format. + * @param {!Object} data + * @param {!Array} data.keys Ordered list of target IDs. + * @param {!Array} data.rows Rows of data to convert. + * @param {boolean} appendXs True to append to $$.data.xs, False to replace. + * @return {!Array} + */ + ChartInternal.prototype.convertDataToTargets = function (data, appendXs) { + var $$ = this, config = $$.config, targets, ids, xs, keys, epochs; + // handles format where keys are not orderly provided + if (isArray(data)) { + keys = Object.keys(data[0]); + } + else { + keys = data.keys; + data = data.rows; + } + xs = keys.filter($$.isX, $$); + if (!$$.isStanfordGraphType()) { + ids = keys.filter($$.isNotX, $$); + } + else { + epochs = keys.filter($$.isEpochs, $$); + ids = keys.filter($$.isNotXAndNotEpochs, $$); + if (xs.length !== 1 || epochs.length !== 1 || ids.length !== 1) { + throw new Error("You must define the 'x' key name and the 'epochs' for Stanford Diagrams"); + } + } + // save x for update data by load when custom x and c3.x API + ids.forEach(function (id) { + var xKey = $$.getXKey(id); + if ($$.isCustomX() || $$.isTimeSeries()) { + // if included in input data + if (xs.indexOf(xKey) >= 0) { + $$.data.xs[id] = (appendXs && $$.data.xs[id] + ? $$.data.xs[id] + : []).concat(data + .map(function (d) { + return d[xKey]; + }) + .filter(isValue) + .map(function (rawX, i) { + return $$.generateTargetX(rawX, id, i); + })); + } + // if not included in input data, find from preloaded data of other id's x + else if (config.data_x) { + $$.data.xs[id] = $$.getOtherTargetXs(); + } + // if not included in input data, find from preloaded data + else if (notEmpty(config.data_xs)) { + $$.data.xs[id] = $$.getXValuesOfXKey(xKey, $$.data.targets); + } + // MEMO: if no x included, use same x of current will be used + } + else { + $$.data.xs[id] = data.map(function (d, i) { + return i; + }); + } + }); + // check x is defined + ids.forEach(function (id) { + if (!$$.data.xs[id]) { + throw new Error('x is not defined for id = "' + id + '".'); + } + }); + // convert to target + targets = ids.map(function (id, index) { + var convertedId = config.data_idConverter(id); + return { + id: convertedId, + id_org: id, + values: data + .map(function (d, i) { + var xKey = $$.getXKey(id), rawX = d[xKey], value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null, x, returnData; + // use x as categories if custom x and categorized + if ($$.isCustomX() && $$.isCategorized() && !isUndefined(rawX)) { + if (index === 0 && i === 0) { + config.axis_x_categories = []; + } + x = config.axis_x_categories.indexOf(rawX); + if (x === -1) { + x = config.axis_x_categories.length; + config.axis_x_categories.push(rawX); + } + } + else { + x = $$.generateTargetX(rawX, id, i); + } + // mark as x = undefined if value is undefined and filter to remove after mapped + if (isUndefined(d[id]) || $$.data.xs[id].length <= i) { + x = undefined; + } + returnData = { x: x, value: value, id: convertedId }; + if ($$.isStanfordGraphType()) { + returnData.epochs = d[epochs]; + } + return returnData; + }) + .filter(function (v) { + return isDefined(v.x); + }) + }; + }); + // finish targets + targets.forEach(function (t) { + var i; + // sort values by its x + if (config.data_xSort) { + t.values = t.values.sort(function (v1, v2) { + var x1 = v1.x || v1.x === 0 ? v1.x : Infinity, x2 = v2.x || v2.x === 0 ? v2.x : Infinity; + return x1 - x2; + }); + } + // indexing each value + i = 0; + t.values.forEach(function (v) { + v.index = i++; + }); + // this needs to be sorted because its index and value.index is identical + $$.data.xs[t.id].sort(function (v1, v2) { + return v1 - v2; + }); + }); + // cache information about values + $$.hasNegativeValue = $$.hasNegativeValueInTargets(targets); + $$.hasPositiveValue = $$.hasPositiveValueInTargets(targets); + // set target types + if (config.data_type) { + $$.setTargetType($$.mapToIds(targets).filter(function (id) { + return !(id in config.data_types); + }), config.data_type); + } + // cache as original id keyed + targets.forEach(function (d) { + $$.addCache(d.id_org, d); + }); + return targets; + }; + + ChartInternal.prototype.isEpochs = function (key) { + var $$ = this, config = $$.config; + return config.data_epochs && key === config.data_epochs; + }; + ChartInternal.prototype.isX = function (key) { + var $$ = this, config = $$.config; + return ((config.data_x && key === config.data_x) || + (notEmpty(config.data_xs) && hasValue(config.data_xs, key))); + }; + ChartInternal.prototype.isNotX = function (key) { + return !this.isX(key); + }; + ChartInternal.prototype.isNotXAndNotEpochs = function (key) { + return !this.isX(key) && !this.isEpochs(key); + }; + /** + * Returns whether the normalized stack option is enabled or not. + * + * To be enabled it must also have data.groups defined. + * + * @return {boolean} + */ + ChartInternal.prototype.isStackNormalized = function () { + return this.config.data_stack_normalize && this.config.data_groups.length > 0; + }; + /** + * Returns whether the axis is normalized or not. + * + * An axis is normalized as long as one of its associated target + * is normalized. + * + * @param axisId Axis ID (y or y2) + * @return {Boolean} + */ + ChartInternal.prototype.isAxisNormalized = function (axisId) { + var $$ = this; + if (!$$.isStackNormalized()) { + // shortcut + return false; + } + return $$.data.targets + .filter(function (target) { return $$.axis.getId(target.id) === axisId; }) + .some(function (target) { return $$.isTargetNormalized(target.id); }); + }; + /** + * Returns whether the values for this target ID is normalized or not. + * + * To be normalized the option needs to be enabled and target needs + * to be defined in `data.groups`. + * + * @param targetId ID of the target + * @return {Boolean} True if the target is normalized, false otherwise. + */ + ChartInternal.prototype.isTargetNormalized = function (targetId) { + var $$ = this; + return ($$.isStackNormalized() && + $$.config.data_groups.some(function (group) { return group.includes(targetId); })); + }; + ChartInternal.prototype.getXKey = function (id) { + var $$ = this, config = $$.config; + return config.data_x + ? config.data_x + : notEmpty(config.data_xs) + ? config.data_xs[id] + : null; + }; + /** + * Get sum of visible data per index for given axis. + * + * Expect axisId to be either 'y' or 'y2'. + * + * @private + * @param axisId Compute sum for data associated to given axis. + * @return {Array} + */ + ChartInternal.prototype.getTotalPerIndex = function (axisId) { + var $$ = this; + if (!$$.isStackNormalized()) { + return null; + } + var cached = $$.getFromCache('getTotalPerIndex'); + if (cached !== undefined) { + return cached[axisId]; + } + var sum = { y: [], y2: [] }; + $$.data.targets + // keep only target that are normalized + .filter(function (target) { return $$.isTargetNormalized(target.id); }) + // keep only target that are visible + .filter(function (target) { return $$.isTargetToShow(target.id); }) + // compute sum per axis + .forEach(function (target) { + var sumByAxis = sum[$$.axis.getId(target.id)]; + target.values.forEach(function (v, i) { + if (!sumByAxis[i]) { + sumByAxis[i] = 0; + } + sumByAxis[i] += isNumber(v.value) ? v.value : 0; + }); + }); + $$.addToCache('getTotalPerIndex', sum); + return sum[axisId]; + }; + /** + * Get sum of visible data. + * + * Should be used for normalised data only since all values + * are expected to be positive. + * + * @private + * @return {Number} + */ + ChartInternal.prototype.getTotalDataSum = function () { + var $$ = this; + var cached = $$.getFromCache('getTotalDataSum'); + if (cached !== undefined) { + return cached; + } + var totalDataSum = flattenArray($$.data.targets + .filter(function (target) { return $$.isTargetToShow(target.id); }) + .map(function (target) { return target.values; })) + .map(function (d) { return d.value; }) + .reduce(function (p, c) { return p + c; }, 0); + $$.addToCache('getTotalDataSum', totalDataSum); + return totalDataSum; + }; + ChartInternal.prototype.getXValuesOfXKey = function (key, targets) { + var $$ = this, xValues, ids = targets && notEmpty(targets) ? $$.mapToIds(targets) : []; + ids.forEach(function (id) { + if ($$.getXKey(id) === key) { + xValues = $$.data.xs[id]; + } + }); + return xValues; + }; + ChartInternal.prototype.getXValue = function (id, i) { + var $$ = this; + return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) + ? $$.data.xs[id][i] + : i; + }; + ChartInternal.prototype.getOtherTargetXs = function () { + var $$ = this, idsForX = Object.keys($$.data.xs); + return idsForX.length ? $$.data.xs[idsForX[0]] : null; + }; + ChartInternal.prototype.getOtherTargetX = function (index) { + var xs = this.getOtherTargetXs(); + return xs && index < xs.length ? xs[index] : null; + }; + ChartInternal.prototype.addXs = function (xs) { + var $$ = this; + Object.keys(xs).forEach(function (id) { + $$.config.data_xs[id] = xs[id]; + }); + }; + ChartInternal.prototype.addName = function (data) { + var $$ = this, name; + if (data) { + name = $$.config.data_names[data.id]; + data.name = name !== undefined ? name : data.id; + } + return data; + }; + ChartInternal.prototype.getValueOnIndex = function (values, index) { + var valueOnIndex = values.filter(function (v) { + return v.index === index; + }); + return valueOnIndex.length ? valueOnIndex[0] : null; + }; + ChartInternal.prototype.updateTargetX = function (targets, x) { + var $$ = this; + targets.forEach(function (t) { + t.values.forEach(function (v, i) { + v.x = $$.generateTargetX(x[i], t.id, i); + }); + $$.data.xs[t.id] = x; + }); + }; + ChartInternal.prototype.updateTargetXs = function (targets, xs) { + var $$ = this; + targets.forEach(function (t) { + if (xs[t.id]) { + $$.updateTargetX([t], xs[t.id]); + } + }); + }; + ChartInternal.prototype.generateTargetX = function (rawX, id, index) { + var $$ = this, x; + if ($$.isTimeSeries()) { + x = rawX ? $$.parseDate(rawX) : $$.parseDate($$.getXValue(id, index)); + } + else if ($$.isCustomX() && !$$.isCategorized()) { + x = isValue(rawX) ? +rawX : $$.getXValue(id, index); + } + else { + x = index; + } + return x; + }; + ChartInternal.prototype.cloneTarget = function (target) { + return { + id: target.id, + id_org: target.id_org, + values: target.values.map(function (d) { + return { + x: d.x, + value: d.value, + id: d.id + }; + }) + }; + }; + ChartInternal.prototype.getMaxDataCount = function () { + var $$ = this; + return $$.d3.max($$.data.targets, function (t) { + return t.values.length; + }); + }; + ChartInternal.prototype.mapToIds = function (targets) { + return targets.map(function (d) { + return d.id; + }); + }; + ChartInternal.prototype.mapToTargetIds = function (ids) { + var $$ = this; + return ids ? [].concat(ids) : $$.mapToIds($$.data.targets); + }; + ChartInternal.prototype.hasTarget = function (targets, id) { + var ids = this.mapToIds(targets), i; + for (i = 0; i < ids.length; i++) { + if (ids[i] === id) { + return true; + } + } + return false; + }; + ChartInternal.prototype.isTargetToShow = function (targetId) { + return this.hiddenTargetIds.indexOf(targetId) < 0; + }; + ChartInternal.prototype.isLegendToShow = function (targetId) { + return this.hiddenLegendIds.indexOf(targetId) < 0; + }; + /** + * Returns only visible targets. + * + * This is the same as calling {@link filterTargetsToShow} on $$.data.targets. + * + * @return {Array} + */ + ChartInternal.prototype.getTargetsToShow = function () { + var $$ = this; + return $$.filterTargetsToShow($$.data.targets); + }; + ChartInternal.prototype.filterTargetsToShow = function (targets) { + var $$ = this; + return targets.filter(function (t) { + return $$.isTargetToShow(t.id); + }); + }; + /** + * @return {Array} Returns all the targets attached to the chart, visible or not + */ + ChartInternal.prototype.getTargets = function () { + var $$ = this; + return $$.data.targets; + }; + ChartInternal.prototype.mapTargetsToUniqueXs = function (targets) { + var $$ = this; + var xs = $$.d3 + .set($$.d3.merge(targets.map(function (t) { + return t.values.map(function (v) { + return +v.x; + }); + }))) + .values(); + xs = $$.isTimeSeries() + ? xs.map(function (x) { + return new Date(+x); + }) + : xs.map(function (x) { + return +x; + }); + return xs.sort(function (a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; + }); + }; + ChartInternal.prototype.addHiddenTargetIds = function (targetIds) { + targetIds = targetIds instanceof Array ? targetIds : new Array(targetIds); + for (var i = 0; i < targetIds.length; i++) { + if (this.hiddenTargetIds.indexOf(targetIds[i]) < 0) { + this.hiddenTargetIds = this.hiddenTargetIds.concat(targetIds[i]); + } + } + this.resetCache(); + }; + ChartInternal.prototype.removeHiddenTargetIds = function (targetIds) { + this.hiddenTargetIds = this.hiddenTargetIds.filter(function (id) { + return targetIds.indexOf(id) < 0; + }); + this.resetCache(); + }; + ChartInternal.prototype.addHiddenLegendIds = function (targetIds) { + targetIds = targetIds instanceof Array ? targetIds : new Array(targetIds); + for (var i = 0; i < targetIds.length; i++) { + if (this.hiddenLegendIds.indexOf(targetIds[i]) < 0) { + this.hiddenLegendIds = this.hiddenLegendIds.concat(targetIds[i]); + } + } + }; + ChartInternal.prototype.removeHiddenLegendIds = function (targetIds) { + this.hiddenLegendIds = this.hiddenLegendIds.filter(function (id) { + return targetIds.indexOf(id) < 0; + }); + }; + ChartInternal.prototype.getValuesAsIdKeyed = function (targets) { + var ys = {}; + targets.forEach(function (t) { + ys[t.id] = []; + t.values.forEach(function (v) { + ys[t.id].push(v.value); + }); + }); + return ys; + }; + ChartInternal.prototype.checkValueInTargets = function (targets, checker) { + var ids = Object.keys(targets), i, j, values; + for (i = 0; i < ids.length; i++) { + values = targets[ids[i]].values; + for (j = 0; j < values.length; j++) { + if (checker(values[j].value)) { + return true; + } + } + } + return false; + }; + ChartInternal.prototype.hasNegativeValueInTargets = function (targets) { + return this.checkValueInTargets(targets, function (v) { + return v < 0; + }); + }; + ChartInternal.prototype.hasPositiveValueInTargets = function (targets) { + return this.checkValueInTargets(targets, function (v) { + return v > 0; + }); + }; + ChartInternal.prototype.isOrderDesc = function () { + var config = this.config; + return (typeof config.data_order === 'string' && + config.data_order.toLowerCase() === 'desc'); + }; + ChartInternal.prototype.isOrderAsc = function () { + var config = this.config; + return (typeof config.data_order === 'string' && + config.data_order.toLowerCase() === 'asc'); + }; + ChartInternal.prototype.getOrderFunction = function () { + var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc(); + if (orderAsc || orderDesc) { + var reducer = function (p, c) { + return p + Math.abs(c.value); + }; + return function (t1, t2) { + var t1Sum = t1.values.reduce(reducer, 0), t2Sum = t2.values.reduce(reducer, 0); + return orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum; + }; + } + else if (isFunction(config.data_order)) { + return config.data_order; + } + else if (isArray(config.data_order)) { + var order = config.data_order; + return function (t1, t2) { + return order.indexOf(t1.id) - order.indexOf(t2.id); + }; + } + }; + ChartInternal.prototype.orderTargets = function (targets) { + var fct = this.getOrderFunction(); + if (fct) { + targets.sort(fct); + } + return targets; + }; + /** + * Returns all the values from the given targets at the given index. + * + * @param {Array} targets + * @param {Number} index + * @return {Array} + */ + ChartInternal.prototype.filterByIndex = function (targets, index) { + return this.d3.merge(targets.map(function (t) { return t.values.filter(function (v) { return v.index === index; }); })); + }; + ChartInternal.prototype.filterByX = function (targets, x) { + return this.d3 + .merge(targets.map(function (t) { + return t.values; + })) + .filter(function (v) { + return v.x - x === 0; + }); + }; + ChartInternal.prototype.filterRemoveNull = function (data) { + return data.filter(function (d) { + return isValue(d.value); + }); + }; + ChartInternal.prototype.filterByXDomain = function (targets, xDomain) { + return targets.map(function (t) { + return { + id: t.id, + id_org: t.id_org, + values: t.values.filter(function (v) { + return xDomain[0] <= v.x && v.x <= xDomain[1]; + }) + }; + }); + }; + ChartInternal.prototype.hasDataLabel = function () { + var config = this.config; + if (typeof config.data_labels === 'boolean' && config.data_labels) { + return true; + } + else if (typeof config.data_labels === 'object' && + notEmpty(config.data_labels)) { + return true; + } + return false; + }; + ChartInternal.prototype.getDataLabelLength = function (min, max, key) { + var $$ = this, lengths = [0, 0], paddingCoef = 1.3; + $$.selectChart + .select('svg') + .selectAll('.dummy') + .data([min, max]) + .enter() + .append('text') + .text(function (d) { + return $$.dataLabelFormat(d.id)(d); + }) + .each(function (d, i) { + lengths[i] = getBBox(this)[key] * paddingCoef; + }) + .remove(); + return lengths; + }; + /** + * Returns true if the given data point is not arc type, otherwise false. + * @param {Object} d The data point + * @return {boolean} + */ + ChartInternal.prototype.isNoneArc = function (d) { + return this.hasTarget(this.data.targets, d.id); + }; + /** + * Returns true if the given data point is arc type, otherwise false. + * @param {Object} d The data point + * @return {boolean} + */ + ChartInternal.prototype.isArc = function (d) { + return 'data' in d && this.hasTarget(this.data.targets, d.data.id); + }; + /** + * Find the closest point from the given pos among the given targets or + * undefined if none satisfies conditions. + * + * @param {Array} targets + * @param {Array} pos An [x,y] coordinate + * @return {Object|undefined} + */ + ChartInternal.prototype.findClosestFromTargets = function (targets, pos) { + var $$ = this; + // for each target, find the closest point + var candidates = targets + .map(function (t) { + return $$.findClosest(t.values, pos, $$.config.tooltip_horizontal + ? $$.horizontalDistance.bind($$) + : $$.dist.bind($$), $$.config.point_sensitivity); + }) + .filter(function (v) { return v; }); + // returns the closest of candidates + if (candidates.length === 0) { + return undefined; + } + else if (candidates.length === 1) { + return candidates[0]; + } + else { + return $$.findClosest(candidates, pos, $$.dist.bind($$)); + } + }; + /** + * Find the closest point from the x value or undefined if none satisfies conditions. + * + * @param {Array} targets + * @param {Array} x A value on X axis + * @return {Object|undefined} + */ + ChartInternal.prototype.findClosestFromTargetsByX = function (targets, x) { + var closest; + var diff; + targets.forEach(function (t) { + t.values.forEach(function (d) { + var newDiff = Math.abs(x - d.x); + if (diff === undefined || newDiff < diff) { + closest = d; + diff = newDiff; + } + }); + }); + return closest; + }; + /** + * Using given compute distance method, returns the closest data point from the + * given position. + * + * Giving optionally a minimum distance to satisfy. + * + * @param {Array} dataPoints List of DataPoints + * @param {Array} pos An [x,y] coordinate + * @param {Function} computeDist Function to compute distance between 2 points + * @param {Number} minDist Minimal distance to satisfy + * @return {Object|undefined} Closest data point + */ + ChartInternal.prototype.findClosest = function (dataPoints, pos, computeDist, minDist) { + if (minDist === void 0) { minDist = Infinity; } + var $$ = this; + var closest; + // find closest bar + dataPoints + .filter(function (v) { return v && $$.isBarType(v.id); }) + .forEach(function (v) { + if (!closest) { + var shape = $$.main + .select('.' + + CLASS.bars + + $$.getTargetSelectorSuffix(v.id) + + ' .' + + CLASS.bar + + '-' + + v.index) + .node(); + if ($$.isWithinBar(pos, shape)) { + closest = v; + } + } + }); + // find closest point from non-bar + dataPoints + .filter(function (v) { return v && !$$.isBarType(v.id); }) + .forEach(function (v) { + var d = computeDist(v, pos); + if (d < minDist) { + minDist = d; + closest = v; + } + }); + return closest; + }; + ChartInternal.prototype.dist = function (data, pos) { + var $$ = this, config = $$.config, xIndex = config.axis_rotated ? 1 : 0, yIndex = config.axis_rotated ? 0 : 1, y = $$.circleY(data, data.index), x = $$.x(data.x); + return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2)); + }; + ChartInternal.prototype.horizontalDistance = function (data, pos) { + var $$ = this, config = $$.config, xIndex = config.axis_rotated ? 1 : 0, x = $$.x(data.x); + return Math.abs(x - pos[xIndex]); + }; + ChartInternal.prototype.convertValuesToStep = function (values) { + var converted = [].concat(values), i; + if (!this.isCategorized()) { + return values; + } + for (i = values.length + 1; 0 < i; i--) { + converted[i] = converted[i - 1]; + } + converted[0] = { + x: converted[0].x - 1, + value: converted[0].value, + id: converted[0].id + }; + converted[values.length + 1] = { + x: converted[values.length].x + 1, + value: converted[values.length].value, + id: converted[values.length].id + }; + return converted; + }; + /** + * Get ratio value + * + * @param {String} type Ratio for given type + * @param {Object} d Data value object + * @param {Boolean} asPercent Convert the return as percent or not + * @return {Number} Ratio value + * @private + */ + ChartInternal.prototype.getRatio = function (type, d, asPercent) { + if (asPercent === void 0) { asPercent = false; } + var $$ = this; + var api = $$.api; + var ratio = 0; + if (d && api.data.shown.call(api).length) { + ratio = d.ratio || d.value; + if (type === 'arc') { + if ($$.hasType('gauge')) { + ratio = + (d.endAngle - d.startAngle) / + (Math.PI * ($$.config.gauge_fullCircle ? 2 : 1)); + } + else { + var total = $$.getTotalDataSum(); + ratio = d.value / total; + } + } + else if (type === 'index') { + var total = $$.getTotalPerIndex($$.axis.getId(d.id)); + d.ratio = + isNumber(d.value) && total && total[d.index] > 0 + ? d.value / total[d.index] + : 0; + ratio = d.ratio; + } + } + return asPercent && ratio ? ratio * 100 : ratio; + }; + ChartInternal.prototype.updateDataAttributes = function (name, attrs) { + var $$ = this, config = $$.config, current = config['data_' + name]; + if (typeof attrs === 'undefined') { + return current; + } + Object.keys(attrs).forEach(function (id) { + current[id] = attrs[id]; + }); + $$.redraw({ + withLegend: true + }); + return current; + }; + + ChartInternal.prototype.load = function (targets, args) { + var $$ = this; + if (targets) { + // filter loading targets if needed + if (args.filter) { + targets = targets.filter(args.filter); + } + // set type if args.types || args.type specified + if (args.type || args.types) { + targets.forEach(function (t) { + var type = args.types && args.types[t.id] ? args.types[t.id] : args.type; + $$.setTargetType(t.id, type); + }); + } + // Update/Add data + $$.data.targets.forEach(function (d) { + for (var i = 0; i < targets.length; i++) { + if (d.id === targets[i].id) { + d.values = targets[i].values; + targets.splice(i, 1); + break; + } + } + }); + $$.data.targets = $$.data.targets.concat(targets); // add remained + } + // Set targets + $$.updateTargets($$.data.targets); + // Redraw with new targets + $$.redraw({ + withUpdateOrgXDomain: true, + withUpdateXDomain: true, + withLegend: true + }); + if (args.done) { + args.done(); + } + }; + ChartInternal.prototype.loadFromArgs = function (args) { + var $$ = this; + $$.resetCache(); + if (args.data) { + $$.load($$.convertDataToTargets(args.data), args); + } + else if (args.url) { + $$.convertUrlToData(args.url, args.mimeType, args.headers, args.keys, function (data) { + $$.load($$.convertDataToTargets(data), args); + }); + } + else if (args.json) { + $$.load($$.convertDataToTargets($$.convertJsonToData(args.json, args.keys)), args); + } + else if (args.rows) { + $$.load($$.convertDataToTargets($$.convertRowsToData(args.rows)), args); + } + else if (args.columns) { + $$.load($$.convertDataToTargets($$.convertColumnsToData(args.columns)), args); + } + else { + $$.load(null, args); + } + }; + ChartInternal.prototype.unload = function (targetIds, done) { + var $$ = this; + $$.resetCache(); + if (!done) { + done = function () { }; + } + // filter existing target + targetIds = targetIds.filter(function (id) { + return $$.hasTarget($$.data.targets, id); + }); + // If no target, call done and return + if (!targetIds || targetIds.length === 0) { + done(); + return; + } + $$.svg + .selectAll(targetIds.map(function (id) { + return $$.selectorTarget(id); + })) + .transition() + .style('opacity', 0) + .remove() + .call($$.endall, done); + targetIds.forEach(function (id) { + // Reset fadein for future load + $$.withoutFadeIn[id] = false; + // Remove target's elements + if ($$.legend) { + $$.legend + .selectAll('.' + CLASS.legendItem + $$.getTargetSelectorSuffix(id)) + .remove(); + } + // Remove target + $$.data.targets = $$.data.targets.filter(function (t) { + return t.id !== id; + }); + }); + }; + + ChartInternal.prototype.getYDomainMin = function (targets) { + var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasNegativeValue; + if (config.data_groups.length > 0) { + hasNegativeValue = $$.hasNegativeValueInTargets(targets); + for (j = 0; j < config.data_groups.length; j++) { + // Determine baseId + idsInGroup = config.data_groups[j].filter(function (id) { + return ids.indexOf(id) >= 0; + }); + if (idsInGroup.length === 0) { + continue; + } + baseId = idsInGroup[0]; + // Consider negative values + if (hasNegativeValue && ys[baseId]) { + ys[baseId].forEach(function (v, i) { + ys[baseId][i] = v < 0 ? v : 0; + }); + } + // Compute min + for (k = 1; k < idsInGroup.length; k++) { + id = idsInGroup[k]; + if (!ys[id]) { + continue; + } + ys[id].forEach(function (v, i) { + if ($$.axis.getId(id) === $$.axis.getId(baseId) && + ys[baseId] && + !(hasNegativeValue && +v > 0)) { + ys[baseId][i] += +v; + } + }); + } + } + } + return $$.d3.min(Object.keys(ys).map(function (key) { + return $$.d3.min(ys[key]); + })); + }; + ChartInternal.prototype.getYDomainMax = function (targets) { + var $$ = this, config = $$.config, ids = $$.mapToIds(targets), ys = $$.getValuesAsIdKeyed(targets), j, k, baseId, idsInGroup, id, hasPositiveValue; + if (config.data_groups.length > 0) { + hasPositiveValue = $$.hasPositiveValueInTargets(targets); + for (j = 0; j < config.data_groups.length; j++) { + // Determine baseId + idsInGroup = config.data_groups[j].filter(function (id) { + return ids.indexOf(id) >= 0; + }); + if (idsInGroup.length === 0) { + continue; + } + baseId = idsInGroup[0]; + // Consider positive values + if (hasPositiveValue && ys[baseId]) { + ys[baseId].forEach(function (v, i) { + ys[baseId][i] = v > 0 ? v : 0; + }); + } + // Compute max + for (k = 1; k < idsInGroup.length; k++) { + id = idsInGroup[k]; + if (!ys[id]) { + continue; + } + ys[id].forEach(function (v, i) { + if ($$.axis.getId(id) === $$.axis.getId(baseId) && + ys[baseId] && + !(hasPositiveValue && +v < 0)) { + ys[baseId][i] += +v; + } + }); + } + } + } + return $$.d3.max(Object.keys(ys).map(function (key) { + return $$.d3.max(ys[key]); + })); + }; + ChartInternal.prototype.getYDomain = function (targets, axisId, xDomain) { + var $$ = this, config = $$.config; + if ($$.isAxisNormalized(axisId)) { + return [0, 100]; + } + var targetsByAxisId = targets.filter(function (t) { + return $$.axis.getId(t.id) === axisId; + }), yTargets = xDomain + ? $$.filterByXDomain(targetsByAxisId, xDomain) + : targetsByAxisId, yMin = axisId === 'y2' ? config.axis_y2_min : config.axis_y_min, yMax = axisId === 'y2' ? config.axis_y2_max : config.axis_y_max, yDomainMin = $$.getYDomainMin(yTargets), yDomainMax = $$.getYDomainMax(yTargets), domain, domainLength, padding_top, padding_bottom, center = axisId === 'y2' ? config.axis_y2_center : config.axis_y_center, yDomainAbs, lengths, diff, ratio, isAllPositive, isAllNegative, isZeroBased = ($$.hasType('bar', yTargets) && config.bar_zerobased) || + ($$.hasType('area', yTargets) && config.area_zerobased), isInverted = axisId === 'y2' ? config.axis_y2_inverted : config.axis_y_inverted, showHorizontalDataLabel = $$.hasDataLabel() && config.axis_rotated, showVerticalDataLabel = $$.hasDataLabel() && !config.axis_rotated; + // MEMO: avoid inverting domain unexpectedly + yDomainMin = isValue(yMin) + ? yMin + : isValue(yMax) + ? yDomainMin < yMax + ? yDomainMin + : yMax - 10 + : yDomainMin; + yDomainMax = isValue(yMax) + ? yMax + : isValue(yMin) + ? yMin < yDomainMax + ? yDomainMax + : yMin + 10 + : yDomainMax; + if (yTargets.length === 0) { + // use current domain if target of axisId is none + return axisId === 'y2' ? $$.y2.domain() : $$.y.domain(); + } + if (isNaN(yDomainMin)) { + // set minimum to zero when not number + yDomainMin = 0; + } + if (isNaN(yDomainMax)) { + // set maximum to have same value as yDomainMin + yDomainMax = yDomainMin; + } + if (yDomainMin === yDomainMax) { + yDomainMin < 0 ? (yDomainMax = 0) : (yDomainMin = 0); + } + isAllPositive = yDomainMin >= 0 && yDomainMax >= 0; + isAllNegative = yDomainMin <= 0 && yDomainMax <= 0; + // Cancel zerobased if axis_*_min / axis_*_max specified + if ((isValue(yMin) && isAllPositive) || (isValue(yMax) && isAllNegative)) { + isZeroBased = false; + } + // Bar/Area chart should be 0-based if all positive|negative + if (isZeroBased) { + if (isAllPositive) { + yDomainMin = 0; + } + if (isAllNegative) { + yDomainMax = 0; + } + } + domainLength = Math.abs(yDomainMax - yDomainMin); + padding_top = padding_bottom = domainLength * 0.1; + if (typeof center !== 'undefined') { + yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax)); + yDomainMax = center + yDomainAbs; + yDomainMin = center - yDomainAbs; + } + // add padding for data label + if (showHorizontalDataLabel) { + lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'width'); + diff = diffDomain($$.y.range()); + ratio = [lengths[0] / diff, lengths[1] / diff]; + padding_top += domainLength * (ratio[1] / (1 - ratio[0] - ratio[1])); + padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1])); + } + else if (showVerticalDataLabel) { + lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, 'height'); + var pixelsToAxisPadding = $$.getY(config["axis_" + axisId + "_type"], + // input domain as pixels + [0, config.axis_rotated ? $$.width : $$.height], + // output range as axis padding + [0, domainLength]); + padding_top += pixelsToAxisPadding(lengths[1]); + padding_bottom += pixelsToAxisPadding(lengths[0]); + } + if (axisId === 'y' && notEmpty(config.axis_y_padding)) { + padding_top = $$.axis.getPadding(config.axis_y_padding, 'top', padding_top, domainLength); + padding_bottom = $$.axis.getPadding(config.axis_y_padding, 'bottom', padding_bottom, domainLength); + } + if (axisId === 'y2' && notEmpty(config.axis_y2_padding)) { + padding_top = $$.axis.getPadding(config.axis_y2_padding, 'top', padding_top, domainLength); + padding_bottom = $$.axis.getPadding(config.axis_y2_padding, 'bottom', padding_bottom, domainLength); + } + // Bar/Area chart should be 0-based if all positive|negative + if (isZeroBased) { + if (isAllPositive) { + padding_bottom = yDomainMin; + } + if (isAllNegative) { + padding_top = -yDomainMax; + } + } + domain = [yDomainMin - padding_bottom, yDomainMax + padding_top]; + return isInverted ? domain.reverse() : domain; + }; + ChartInternal.prototype.getXDomainMin = function (targets) { + var $$ = this, config = $$.config; + return isDefined(config.axis_x_min) + ? $$.isTimeSeries() + ? this.parseDate(config.axis_x_min) + : config.axis_x_min + : $$.d3.min(targets, function (t) { + return $$.d3.min(t.values, function (v) { + return v.x; + }); + }); + }; + ChartInternal.prototype.getXDomainMax = function (targets) { + var $$ = this, config = $$.config; + return isDefined(config.axis_x_max) + ? $$.isTimeSeries() + ? this.parseDate(config.axis_x_max) + : config.axis_x_max + : $$.d3.max(targets, function (t) { + return $$.d3.max(t.values, function (v) { + return v.x; + }); + }); + }; + ChartInternal.prototype.getXDomainPadding = function (domain) { + var $$ = this, config = $$.config, diff = domain[1] - domain[0], maxDataCount, padding, paddingLeft, paddingRight; + if ($$.isCategorized()) { + padding = 0; + } + else if ($$.hasType('bar')) { + maxDataCount = $$.getMaxDataCount(); + padding = maxDataCount > 1 ? diff / (maxDataCount - 1) / 2 : 0.5; + } + else { + padding = diff * 0.01; + } + if (typeof config.axis_x_padding === 'object' && + notEmpty(config.axis_x_padding)) { + paddingLeft = isValue(config.axis_x_padding.left) + ? config.axis_x_padding.left + : padding; + paddingRight = isValue(config.axis_x_padding.right) + ? config.axis_x_padding.right + : padding; + } + else if (typeof config.axis_x_padding === 'number') { + paddingLeft = paddingRight = config.axis_x_padding; + } + else { + paddingLeft = paddingRight = padding; + } + return { left: paddingLeft, right: paddingRight }; + }; + ChartInternal.prototype.getXDomain = function (targets) { + var $$ = this, xDomain = [$$.getXDomainMin(targets), $$.getXDomainMax(targets)], firstX = xDomain[0], lastX = xDomain[1], padding = $$.getXDomainPadding(xDomain), min = 0, max = 0; + // show center of x domain if min and max are the same + if (firstX - lastX === 0 && !$$.isCategorized()) { + if ($$.isTimeSeries()) { + firstX = new Date(firstX.getTime() * 0.5); + lastX = new Date(lastX.getTime() * 1.5); + } + else { + firstX = firstX === 0 ? 1 : firstX * 0.5; + lastX = lastX === 0 ? -1 : lastX * 1.5; + } + } + if (firstX || firstX === 0) { + min = $$.isTimeSeries() + ? new Date(firstX.getTime() - padding.left) + : firstX - padding.left; + } + if (lastX || lastX === 0) { + max = $$.isTimeSeries() + ? new Date(lastX.getTime() + padding.right) + : lastX + padding.right; + } + return [min, max]; + }; + ChartInternal.prototype.updateXDomain = function (targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) { + var $$ = this, config = $$.config; + if (withUpdateOrgXDomain) { + $$.x.domain(domain ? domain : $$.d3.extent($$.getXDomain(targets))); + $$.orgXDomain = $$.x.domain(); + if (config.zoom_enabled) { + $$.zoom.update(); + } + $$.subX.domain($$.x.domain()); + if ($$.brush) { + $$.brush.updateScale($$.subX); + } + } + if (withUpdateXDomain) { + $$.x.domain(domain + ? domain + : !$$.brush || $$.brush.empty() + ? $$.orgXDomain + : $$.brush.selectionAsValue()); + } + // Trim domain when too big by zoom mousemove event + if (withTrim) { + $$.x.domain($$.trimXDomain($$.x.orgDomain())); + } + return $$.x.domain(); + }; + ChartInternal.prototype.trimXDomain = function (domain) { + var zoomDomain = this.getZoomDomain(), min = zoomDomain[0], max = zoomDomain[1]; + if (domain[0] <= min) { + domain[1] = +domain[1] + (min - domain[0]); + domain[0] = min; + } + if (max <= domain[1]) { + domain[0] = +domain[0] - (domain[1] - max); + domain[1] = max; + } + return domain; + }; + + ChartInternal.prototype.drag = function (mouse) { + var $$ = this, config = $$.config, main = $$.main, d3 = $$.d3; + var sx, sy, mx, my, minX, maxX, minY, maxY; + if ($$.hasArcType()) { + return; + } + if (!config.data_selection_enabled) { + return; + } // do nothing if not selectable + if (!config.data_selection_multiple) { + return; + } // skip when single selection because drag is used for multiple selection + sx = $$.dragStart[0]; + sy = $$.dragStart[1]; + mx = mouse[0]; + my = mouse[1]; + minX = Math.min(sx, mx); + maxX = Math.max(sx, mx); + minY = config.data_selection_grouped ? $$.margin.top : Math.min(sy, my); + maxY = config.data_selection_grouped ? $$.height : Math.max(sy, my); + main + .select('.' + CLASS.dragarea) + .attr('x', minX) + .attr('y', minY) + .attr('width', maxX - minX) + .attr('height', maxY - minY); + // TODO: binary search when multiple xs + main + .selectAll('.' + CLASS.shapes) + .selectAll('.' + CLASS.shape) + .each(function (d, i) { + if (!config.data_selection_isselectable(d)) { + return; + } + var shape = d3.select(this), isSelected = shape.classed(CLASS.SELECTED), isIncluded = shape.classed(CLASS.INCLUDED), _x, _y, _w, _h, toggle, isWithin = false, box; + if (shape.classed(CLASS.circle)) { + _x = shape.attr('cx') * 1; + _y = shape.attr('cy') * 1; + toggle = $$.togglePoint; + isWithin = minX < _x && _x < maxX && minY < _y && _y < maxY; + } + else if (shape.classed(CLASS.bar)) { + box = getPathBox(this); + _x = box.x; + _y = box.y; + _w = box.width; + _h = box.height; + toggle = $$.togglePath; + isWithin = + !(maxX < _x || _x + _w < minX) && !(maxY < _y || _y + _h < minY); + } + else { + // line/area selection not supported yet + return; + } + if (isWithin ^ isIncluded) { + shape.classed(CLASS.INCLUDED, !isIncluded); + // TODO: included/unincluded callback here + shape.classed(CLASS.SELECTED, !isSelected); + toggle.call($$, !isSelected, shape, d, i); + } + }); + }; + ChartInternal.prototype.dragstart = function (mouse) { + var $$ = this, config = $$.config; + if ($$.hasArcType()) { + return; + } + if (!config.data_selection_enabled) { + return; + } // do nothing if not selectable + $$.dragStart = mouse; + $$.main + .select('.' + CLASS.chart) + .append('rect') + .attr('class', CLASS.dragarea) + .style('opacity', 0.1); + $$.dragging = true; + }; + ChartInternal.prototype.dragend = function () { + var $$ = this, config = $$.config; + if ($$.hasArcType()) { + return; + } + if (!config.data_selection_enabled) { + return; + } // do nothing if not selectable + $$.main + .select('.' + CLASS.dragarea) + .transition() + .duration(100) + .style('opacity', 0) + .remove(); + $$.main.selectAll('.' + CLASS.shape).classed(CLASS.INCLUDED, false); + $$.dragging = false; + }; + + ChartInternal.prototype.getYFormat = function (forArc) { + var $$ = this, formatForY = forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.yFormat, formatForY2 = forArc && !$$.hasType('gauge') ? $$.defaultArcValueFormat : $$.y2Format; + return function (v, ratio, id) { + var format = $$.axis.getId(id) === 'y2' ? formatForY2 : formatForY; + return format.call($$, v, ratio); + }; + }; + ChartInternal.prototype.yFormat = function (v) { + var $$ = this, config = $$.config, format = config.axis_y_tick_format + ? config.axis_y_tick_format + : $$.defaultValueFormat; + return format(v); + }; + ChartInternal.prototype.y2Format = function (v) { + var $$ = this, config = $$.config, format = config.axis_y2_tick_format + ? config.axis_y2_tick_format + : $$.defaultValueFormat; + return format(v); + }; + ChartInternal.prototype.defaultValueFormat = function (v) { + return isValue(v) ? +v : ''; + }; + ChartInternal.prototype.defaultArcValueFormat = function (v, ratio) { + return (ratio * 100).toFixed(1) + '%'; + }; + ChartInternal.prototype.dataLabelFormat = function (targetId) { + var $$ = this, data_labels = $$.config.data_labels, format, defaultFormat = function (v) { + return isValue(v) ? +v : ''; + }; + // find format according to axis id + if (typeof data_labels.format === 'function') { + format = data_labels.format; + } + else if (typeof data_labels.format === 'object') { + if (data_labels.format[targetId]) { + format = + data_labels.format[targetId] === true + ? defaultFormat + : data_labels.format[targetId]; + } + else { + format = function () { + return ''; + }; + } + } + else { + format = defaultFormat; + } + return format; + }; + + ChartInternal.prototype.initGrid = function () { + var $$ = this, config = $$.config, d3 = $$.d3; + $$.grid = $$.main + .append('g') + .attr('clip-path', $$.clipPathForGrid) + .attr('class', CLASS.grid); + if (config.grid_x_show) { + $$.grid.append('g').attr('class', CLASS.xgrids); + } + if (config.grid_y_show) { + $$.grid.append('g').attr('class', CLASS.ygrids); + } + if (config.grid_focus_show) { + $$.grid + .append('g') + .attr('class', CLASS.xgridFocus) + .append('line') + .attr('class', CLASS.xgridFocus); + } + $$.xgrid = d3.selectAll([]); + if (!config.grid_lines_front) { + $$.initGridLines(); + } + }; + ChartInternal.prototype.initGridLines = function () { + var $$ = this, d3 = $$.d3; + $$.gridLines = $$.main + .append('g') + .attr('clip-path', $$.clipPathForGrid) + .attr('class', CLASS.grid + ' ' + CLASS.gridLines); + $$.gridLines.append('g').attr('class', CLASS.xgridLines); + $$.gridLines.append('g').attr('class', CLASS.ygridLines); + $$.xgridLines = d3.selectAll([]); + }; + ChartInternal.prototype.updateXGrid = function (withoutUpdate) { + var $$ = this, config = $$.config, d3 = $$.d3, xgridData = $$.generateGridData(config.grid_x_type, $$.x), tickOffset = $$.isCategorized() ? $$.xAxis.tickOffset() : 0; + $$.xgridAttr = config.axis_rotated + ? { + x1: 0, + x2: $$.width, + y1: function (d) { + return $$.x(d) - tickOffset; + }, + y2: function (d) { + return $$.x(d) - tickOffset; + } + } + : { + x1: function (d) { + return $$.x(d) + tickOffset; + }, + x2: function (d) { + return $$.x(d) + tickOffset; + }, + y1: 0, + y2: $$.height + }; + $$.xgridAttr.opacity = function () { + var pos = +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1'); + return pos === (config.axis_rotated ? $$.height : 0) ? 0 : 1; + }; + var xgrid = $$.main + .select('.' + CLASS.xgrids) + .selectAll('.' + CLASS.xgrid) + .data(xgridData); + var xgridEnter = xgrid + .enter() + .append('line') + .attr('class', CLASS.xgrid) + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', 0); + $$.xgrid = xgridEnter.merge(xgrid); + if (!withoutUpdate) { + $$.xgrid + .attr('x1', $$.xgridAttr.x1) + .attr('x2', $$.xgridAttr.x2) + .attr('y1', $$.xgridAttr.y1) + .attr('y2', $$.xgridAttr.y2) + .style('opacity', $$.xgridAttr.opacity); + } + xgrid.exit().remove(); + }; + ChartInternal.prototype.updateYGrid = function () { + var $$ = this, config = $$.config, gridValues = $$.yAxis.tickValues() || $$.y.ticks(config.grid_y_ticks); + var ygrid = $$.main + .select('.' + CLASS.ygrids) + .selectAll('.' + CLASS.ygrid) + .data(gridValues); + var ygridEnter = ygrid + .enter() + .append('line') + // TODO: x1, x2, y1, y2, opacity need to be set here maybe + .attr('class', CLASS.ygrid); + $$.ygrid = ygridEnter.merge(ygrid); + $$.ygrid + .attr('x1', config.axis_rotated ? $$.y : 0) + .attr('x2', config.axis_rotated ? $$.y : $$.width) + .attr('y1', config.axis_rotated ? 0 : $$.y) + .attr('y2', config.axis_rotated ? $$.height : $$.y); + ygrid.exit().remove(); + $$.smoothLines($$.ygrid, 'grid'); + }; + ChartInternal.prototype.gridTextAnchor = function (d) { + return d.position ? d.position : 'end'; + }; + ChartInternal.prototype.gridTextDx = function (d) { + return d.position === 'start' ? 4 : d.position === 'middle' ? 0 : -4; + }; + ChartInternal.prototype.xGridTextX = function (d) { + return d.position === 'start' + ? -this.height + : d.position === 'middle' + ? -this.height / 2 + : 0; + }; + ChartInternal.prototype.yGridTextX = function (d) { + return d.position === 'start' + ? 0 + : d.position === 'middle' + ? this.width / 2 + : this.width; + }; + ChartInternal.prototype.updateGrid = function (duration) { + var $$ = this, main = $$.main, config = $$.config, xgridLine, xgridLineEnter, ygridLine, ygridLineEnter, xv = $$.xv.bind($$), yv = $$.yv.bind($$), xGridTextX = $$.xGridTextX.bind($$), yGridTextX = $$.yGridTextX.bind($$); + // hide if arc type + $$.grid.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + main.select('line.' + CLASS.xgridFocus).style('visibility', 'hidden'); + if (config.grid_x_show) { + $$.updateXGrid(); + } + xgridLine = main + .select('.' + CLASS.xgridLines) + .selectAll('.' + CLASS.xgridLine) + .data(config.grid_x_lines); + // enter + xgridLineEnter = xgridLine + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.xgridLine + (d['class'] ? ' ' + d['class'] : ''); + }); + xgridLineEnter + .append('line') + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv) + .attr('y1', config.axis_rotated ? xv : 0) + .attr('y2', config.axis_rotated ? xv : $$.height) + .style('opacity', 0); + xgridLineEnter + .append('text') + .attr('text-anchor', $$.gridTextAnchor) + .attr('transform', config.axis_rotated ? '' : 'rotate(-90)') + .attr('x', config.axis_rotated ? yGridTextX : xGridTextX) + .attr('y', xv) + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style('opacity', 0); + // udpate + $$.xgridLines = xgridLineEnter.merge(xgridLine); + // done in d3.transition() of the end of this function + // exit + xgridLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + // Y-Grid + if (config.grid_y_show) { + $$.updateYGrid(); + } + ygridLine = main + .select('.' + CLASS.ygridLines) + .selectAll('.' + CLASS.ygridLine) + .data(config.grid_y_lines); + // enter + ygridLineEnter = ygridLine + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.ygridLine + (d['class'] ? ' ' + d['class'] : ''); + }); + ygridLineEnter + .append('line') + .attr('x1', config.axis_rotated ? yv : 0) + .attr('x2', config.axis_rotated ? yv : $$.width) + .attr('y1', config.axis_rotated ? 0 : yv) + .attr('y2', config.axis_rotated ? $$.height : yv) + .style('opacity', 0); + ygridLineEnter + .append('text') + .attr('text-anchor', $$.gridTextAnchor) + .attr('transform', config.axis_rotated ? 'rotate(-90)' : '') + .attr('x', config.axis_rotated ? xGridTextX : yGridTextX) + .attr('y', yv) + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style('opacity', 0); + // update + $$.ygridLines = ygridLineEnter.merge(ygridLine); + $$.ygridLines + .select('line') + .transition() + .duration(duration) + .attr('x1', config.axis_rotated ? yv : 0) + .attr('x2', config.axis_rotated ? yv : $$.width) + .attr('y1', config.axis_rotated ? 0 : yv) + .attr('y2', config.axis_rotated ? $$.height : yv) + .style('opacity', 1); + $$.ygridLines + .select('text') + .transition() + .duration(duration) + .attr('x', config.axis_rotated ? $$.xGridTextX.bind($$) : $$.yGridTextX.bind($$)) + .attr('y', yv) + .text(function (d) { + return d.text; + }) + .style('opacity', 1); + // exit + ygridLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + }; + ChartInternal.prototype.redrawGrid = function (withTransition, transition) { + var $$ = this, config = $$.config, xv = $$.xv.bind($$), lines = $$.xgridLines.select('line'), texts = $$.xgridLines.select('text'); + return [ + (withTransition ? lines.transition(transition) : lines) + .attr('x1', config.axis_rotated ? 0 : xv) + .attr('x2', config.axis_rotated ? $$.width : xv) + .attr('y1', config.axis_rotated ? xv : 0) + .attr('y2', config.axis_rotated ? xv : $$.height) + .style('opacity', 1), + (withTransition ? texts.transition(transition) : texts) + .attr('x', config.axis_rotated ? $$.yGridTextX.bind($$) : $$.xGridTextX.bind($$)) + .attr('y', xv) + .text(function (d) { + return d.text; + }) + .style('opacity', 1) + ]; + }; + ChartInternal.prototype.showXGridFocus = function (selectedData) { + var $$ = this, config = $$.config, dataToShow = selectedData.filter(function (d) { + return d && isValue(d.value); + }), focusEl = $$.main.selectAll('line.' + CLASS.xgridFocus), xx = $$.xx.bind($$); + if (!config.tooltip_show) { + return; + } + // Hide when stanford plot exists + if ($$.hasType('stanford') || $$.hasArcType()) { + return; + } + focusEl + .style('visibility', 'visible') + .data([dataToShow[0]]) + .attr(config.axis_rotated ? 'y1' : 'x1', xx) + .attr(config.axis_rotated ? 'y2' : 'x2', xx); + $$.smoothLines(focusEl, 'grid'); + }; + ChartInternal.prototype.hideXGridFocus = function () { + this.main.select('line.' + CLASS.xgridFocus).style('visibility', 'hidden'); + }; + ChartInternal.prototype.updateXgridFocus = function () { + var $$ = this, config = $$.config; + $$.main + .select('line.' + CLASS.xgridFocus) + .attr('x1', config.axis_rotated ? 0 : -10) + .attr('x2', config.axis_rotated ? $$.width : -10) + .attr('y1', config.axis_rotated ? -10 : 0) + .attr('y2', config.axis_rotated ? -10 : $$.height); + }; + ChartInternal.prototype.generateGridData = function (type, scale) { + var $$ = this, gridData = [], xDomain, firstYear, lastYear, i, tickNum = $$.main + .select('.' + CLASS.axisX) + .selectAll('.tick') + .size(); + if (type === 'year') { + xDomain = $$.getXDomain(); + firstYear = xDomain[0].getFullYear(); + lastYear = xDomain[1].getFullYear(); + for (i = firstYear; i <= lastYear; i++) { + gridData.push(new Date(i + '-01-01 00:00:00')); + } + } + else { + gridData = scale.ticks(10); + if (gridData.length > tickNum) { + // use only int + gridData = gridData.filter(function (d) { + return ('' + d).indexOf('.') < 0; + }); + } + } + return gridData; + }; + ChartInternal.prototype.getGridFilterToRemove = function (params) { + return params + ? function (line) { + var found = false; + [].concat(params).forEach(function (param) { + if (('value' in param && line.value === param.value) || + ('class' in param && line['class'] === param['class'])) { + found = true; + } + }); + return found; + } + : function () { + return true; + }; + }; + ChartInternal.prototype.removeGridLines = function (params, forX) { + var $$ = this, config = $$.config, toRemove = $$.getGridFilterToRemove(params), toShow = function (line) { + return !toRemove(line); + }, classLines = forX ? CLASS.xgridLines : CLASS.ygridLines, classLine = forX ? CLASS.xgridLine : CLASS.ygridLine; + $$.main + .select('.' + classLines) + .selectAll('.' + classLine) + .filter(toRemove) + .transition() + .duration(config.transition_duration) + .style('opacity', 0) + .remove(); + if (forX) { + config.grid_x_lines = config.grid_x_lines.filter(toShow); + } + else { + config.grid_y_lines = config.grid_y_lines.filter(toShow); + } + }; + + ChartInternal.prototype.initEventRect = function () { + var $$ = this, config = $$.config; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.eventRects) + .style('fill-opacity', 0); + $$.eventRect = $$.main + .select('.' + CLASS.eventRects) + .append('rect') + .attr('class', CLASS.eventRect); + // event rect handle zoom event as well + if (config.zoom_enabled && $$.zoom) { + $$.eventRect.call($$.zoom).on('dblclick.zoom', null); + if (config.zoom_initialRange) { + // WORKAROUND: Add transition to apply transform immediately when no subchart + $$.eventRect + .transition() + .duration(0) + .call($$.zoom.transform, $$.zoomTransform(config.zoom_initialRange)); + } + } + }; + ChartInternal.prototype.redrawEventRect = function () { + var $$ = this, d3 = $$.d3, config = $$.config; + function mouseout() { + $$.svg.select('.' + CLASS.eventRect).style('cursor', null); + $$.hideXGridFocus(); + $$.hideTooltip(); + $$.unexpandCircles(); + $$.unexpandBars(); + } + var isHoveringDataPoint = function (mouse, closest) { + return closest && + ($$.isBarType(closest.id) || + $$.dist(closest, mouse) < config.point_sensitivity); + }; + var withName = function (d) { return (d ? $$.addName(Object.assign({}, d)) : null); }; + // rects for mouseover + $$.main + .select('.' + CLASS.eventRects) + .style('cursor', config.zoom_enabled + ? config.axis_rotated + ? 'ns-resize' + : 'ew-resize' + : null); + $$.eventRect + .attr('x', 0) + .attr('y', 0) + .attr('width', $$.width) + .attr('height', $$.height) + .on('mouseout', config.interaction_enabled + ? function () { + if (!config) { + return; + } // chart is destroyed + if ($$.hasArcType()) { + return; + } + if ($$.mouseover) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + mouseout(); + } + : null) + .on('mousemove', config.interaction_enabled + ? function () { + // do nothing when dragging + if ($$.dragging) { + return; + } + var targetsToShow = $$.getTargetsToShow(); + // do nothing if arc type + if ($$.hasArcType(targetsToShow)) { + return; + } + var mouse = d3.mouse(this); + var closest = withName($$.findClosestFromTargets(targetsToShow, mouse)); + var isMouseCloseToDataPoint = isHoveringDataPoint(mouse, closest); + // ensure onmouseout is always called if mousemove switch between 2 targets + if ($$.mouseover && + (!closest || + closest.id !== $$.mouseover.id || + closest.index !== $$.mouseover.index)) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + if (closest && !$$.mouseover) { + config.data_onmouseover.call($$.api, closest); + $$.mouseover = closest; + } + // show cursor as pointer if we're hovering a data point close enough + $$.svg + .select('.' + CLASS.eventRect) + .style('cursor', isMouseCloseToDataPoint ? 'pointer' : null); + // if tooltip not grouped, we want to display only data from closest data point + var showSingleDataPoint = !config.tooltip_grouped || $$.hasType('stanford', targetsToShow); + // find data to highlight + var selectedData; + if (showSingleDataPoint) { + if (closest) { + selectedData = [closest]; + } + } + else { + var closestByX = void 0; + if (closest) { + // reuse closest value + closestByX = closest; + } + else { + // try to find the closest value by X values from the mouse position + var mouseX = config.axis_rotated ? mouse[1] : mouse[0]; + closestByX = $$.findClosestFromTargetsByX(targetsToShow, $$.x.invert(mouseX)); + } + // highlight all data for this 'x' value + if (closestByX) { + selectedData = $$.filterByX(targetsToShow, closestByX.x); + } + } + // ensure we have data to show + if (!selectedData || selectedData.length === 0) { + return mouseout(); + } + // inject names for each point + selectedData = selectedData.map(withName); + // show tooltip + $$.showTooltip(selectedData, this); + // expand points + if (config.point_focus_expand_enabled) { + $$.unexpandCircles(); + selectedData.forEach(function (d) { + $$.expandCircles(d.index, d.id, false); + }); + } + // expand bars + $$.unexpandBars(); + selectedData.forEach(function (d) { + $$.expandBars(d.index, d.id, false); + }); + // Show xgrid focus line + $$.showXGridFocus(selectedData); + } + : null) + .on('click', config.interaction_enabled + ? function () { + var targetsToShow = $$.getTargetsToShow(); + if ($$.hasArcType(targetsToShow)) { + return; + } + var mouse = d3.mouse(this); + var closest = withName($$.findClosestFromTargets(targetsToShow, mouse)); + if (!isHoveringDataPoint(mouse, closest)) { + return; + } + // select if selection enabled + var sameXData; + if (!config.data_selection_grouped || $$.isStanfordType(closest)) { + sameXData = [closest]; + } + else { + sameXData = $$.filterByX(targetsToShow, closest.x); + } + // toggle selected state + sameXData.forEach(function (d) { + $$.main + .selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.shape + '-' + d.index) + .each(function () { + if (config.data_selection_grouped || + $$.isWithinShape(this, d)) { + $$.toggleShape(this, d, d.index); + } + }); + }); + // call data_onclick on the closest data point + if (closest) { + var shape = $$.main + .selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(closest.id)) + .select('.' + CLASS.shape + '-' + closest.index); + config.data_onclick.call($$.api, closest, shape.node()); + } + } + : null) + .call(config.interaction_enabled && config.data_selection_draggable && $$.drag + ? d3 + .drag() + .on('drag', function () { + $$.drag(d3.mouse(this)); + }) + .on('start', function () { + $$.dragstart(d3.mouse(this)); + }) + .on('end', function () { + $$.dragend(); + }) + : function () { }); + }; + ChartInternal.prototype.getMousePosition = function (data) { + var $$ = this; + return [$$.x(data.x), $$.getYScale(data.id)(data.value)]; + }; + ChartInternal.prototype.dispatchEvent = function (type, mouse) { + var $$ = this, selector = '.' + CLASS.eventRect, eventRect = $$.main.select(selector).node(), box = eventRect.getBoundingClientRect(), x = box.left + (mouse ? mouse[0] : 0), y = box.top + (mouse ? mouse[1] : 0), event = document.createEvent('MouseEvents'); + event.initMouseEvent(type, true, true, window, 0, x, y, x, y, false, false, false, false, 0, null); + eventRect.dispatchEvent(event); + }; + + ChartInternal.prototype.initLegend = function () { + var $$ = this; + $$.legendItemTextBox = {}; + $$.legendHasRendered = false; + $$.legend = $$.svg.append('g').attr('transform', $$.getTranslate('legend')); + if (!$$.config.legend_show) { + $$.legend.style('visibility', 'hidden'); + $$.hiddenLegendIds = $$.mapToIds($$.data.targets); + return; + } + // MEMO: call here to update legend box and tranlate for all + // MEMO: translate will be updated by this, so transform not needed in updateLegend() + $$.updateLegendWithDefaults(); + }; + ChartInternal.prototype.updateLegendWithDefaults = function () { + var $$ = this; + $$.updateLegend($$.mapToIds($$.data.targets), { + withTransform: false, + withTransitionForTransform: false, + withTransition: false + }); + }; + ChartInternal.prototype.updateSizeForLegend = function (legendHeight, legendWidth) { + var $$ = this, config = $$.config, insetLegendPosition = { + top: $$.isLegendTop + ? $$.getCurrentPaddingTop() + config.legend_inset_y + 5.5 + : $$.currentHeight - + legendHeight - + $$.getCurrentPaddingBottom() - + config.legend_inset_y, + left: $$.isLegendLeft + ? $$.getCurrentPaddingLeft() + config.legend_inset_x + 0.5 + : $$.currentWidth - + legendWidth - + $$.getCurrentPaddingRight() - + config.legend_inset_x + + 0.5 + }; + $$.margin3 = { + top: $$.isLegendRight + ? 0 + : $$.isLegendInset + ? insetLegendPosition.top + : $$.currentHeight - legendHeight, + right: NaN, + bottom: 0, + left: $$.isLegendRight + ? $$.currentWidth - legendWidth + : $$.isLegendInset + ? insetLegendPosition.left + : 0 + }; + }; + ChartInternal.prototype.transformLegend = function (withTransition) { + var $$ = this; + (withTransition ? $$.legend.transition() : $$.legend).attr('transform', $$.getTranslate('legend')); + }; + ChartInternal.prototype.updateLegendStep = function (step) { + this.legendStep = step; + }; + ChartInternal.prototype.updateLegendItemWidth = function (w) { + this.legendItemWidth = w; + }; + ChartInternal.prototype.updateLegendItemHeight = function (h) { + this.legendItemHeight = h; + }; + ChartInternal.prototype.getLegendWidth = function () { + var $$ = this; + return $$.config.legend_show + ? $$.isLegendRight || $$.isLegendInset + ? $$.legendItemWidth * ($$.legendStep + 1) + : $$.currentWidth + : 0; + }; + ChartInternal.prototype.getLegendHeight = function () { + var $$ = this, h = 0; + if ($$.config.legend_show) { + if ($$.isLegendRight) { + h = $$.currentHeight; + } + else { + h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1); + } + } + return h; + }; + ChartInternal.prototype.opacityForLegend = function (legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 1; + }; + ChartInternal.prototype.opacityForUnfocusedLegend = function (legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 0.3; + }; + ChartInternal.prototype.toggleFocusLegend = function (targetIds, focus) { + var $$ = this; + targetIds = $$.mapToTargetIds(targetIds); + $$.legend + .selectAll('.' + CLASS.legendItem) + .filter(function (id) { + return targetIds.indexOf(id) >= 0; + }) + .classed(CLASS.legendItemFocused, focus) + .transition() + .duration(100) + .style('opacity', function () { + var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend; + return opacity.call($$, $$.d3.select(this)); + }); + }; + ChartInternal.prototype.revertLegend = function () { + var $$ = this, d3 = $$.d3; + $$.legend + .selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemFocused, false) + .transition() + .duration(100) + .style('opacity', function () { + return $$.opacityForLegend(d3.select(this)); + }); + }; + ChartInternal.prototype.showLegend = function (targetIds) { + var $$ = this, config = $$.config; + if (!config.legend_show) { + config.legend_show = true; + $$.legend.style('visibility', 'visible'); + if (!$$.legendHasRendered) { + $$.updateLegendWithDefaults(); + } + } + $$.removeHiddenLegendIds(targetIds); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .style('visibility', 'visible') + .transition() + .style('opacity', function () { + return $$.opacityForLegend($$.d3.select(this)); + }); + }; + ChartInternal.prototype.hideLegend = function (targetIds) { + var $$ = this, config = $$.config; + if (config.legend_show && isEmpty(targetIds)) { + config.legend_show = false; + $$.legend.style('visibility', 'hidden'); + } + $$.addHiddenLegendIds(targetIds); + $$.legend + .selectAll($$.selectorLegends(targetIds)) + .style('opacity', 0) + .style('visibility', 'hidden'); + }; + ChartInternal.prototype.clearLegendItemTextBoxCache = function () { + this.legendItemTextBox = {}; + }; + ChartInternal.prototype.updateLegend = function (targetIds, options, transitions) { + var $$ = this, config = $$.config; + var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect, x1ForLegendTile, x2ForLegendTile, yForLegendTile; + var paddingTop = 4, paddingRight = 10, maxWidth = 0, maxHeight = 0, posMin = 10, tileWidth = config.legend_item_tile_width + 5; + var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; + var withTransition, withTransitionForTransform; + var texts, rects, tiles, background; + // Skip elements when their name is set to null + targetIds = targetIds.filter(function (id) { + return !isDefined(config.data_names[id]) || config.data_names[id] !== null; + }); + options = options || {}; + withTransition = getOption(options, 'withTransition', true); + withTransitionForTransform = getOption(options, 'withTransitionForTransform', true); + function getTextBox(textElement, id) { + if (!$$.legendItemTextBox[id]) { + $$.legendItemTextBox[id] = $$.getTextRect(textElement.textContent, CLASS.legendItem, textElement); + } + return $$.legendItemTextBox[id]; + } + function updatePositions(textElement, id, index) { + var reset = index === 0, isLast = index === targetIds.length - 1, box = getTextBox(textElement, id), itemWidth = box.width + + tileWidth + + (isLast && !($$.isLegendRight || $$.isLegendInset) ? 0 : paddingRight) + + config.legend_padding, itemHeight = box.height + paddingTop, itemLength = $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth, areaLength = $$.isLegendRight || $$.isLegendInset + ? $$.getLegendHeight() + : $$.getLegendWidth(), margin, maxLength; + // MEMO: care about condifion of step, totalLength + function updateValues(id, withoutStep) { + if (!withoutStep) { + margin = (areaLength - totalLength - itemLength) / 2; + if (margin < posMin) { + margin = (areaLength - itemLength) / 2; + totalLength = 0; + step++; + } + } + steps[id] = step; + margins[step] = $$.isLegendInset ? 10 : margin; + offsets[id] = totalLength; + totalLength += itemLength; + } + if (reset) { + totalLength = 0; + step = 0; + maxWidth = 0; + maxHeight = 0; + } + if (config.legend_show && !$$.isLegendToShow(id)) { + widths[id] = heights[id] = steps[id] = offsets[id] = 0; + return; + } + widths[id] = itemWidth; + heights[id] = itemHeight; + if (!maxWidth || itemWidth >= maxWidth) { + maxWidth = itemWidth; + } + if (!maxHeight || itemHeight >= maxHeight) { + maxHeight = itemHeight; + } + maxLength = $$.isLegendRight || $$.isLegendInset ? maxHeight : maxWidth; + if (config.legend_equally) { + Object.keys(widths).forEach(function (id) { + widths[id] = maxWidth; + }); + Object.keys(heights).forEach(function (id) { + heights[id] = maxHeight; + }); + margin = (areaLength - maxLength * targetIds.length) / 2; + if (margin < posMin) { + totalLength = 0; + step = 0; + targetIds.forEach(function (id) { + updateValues(id); + }); + } + else { + updateValues(id, true); + } + } + else { + updateValues(id); + } + } + if ($$.isLegendInset) { + step = config.legend_inset_step + ? config.legend_inset_step + : targetIds.length; + $$.updateLegendStep(step); + } + if ($$.isLegendRight) { + xForLegend = function (id) { + return maxWidth * steps[id]; + }; + yForLegend = function (id) { + return margins[steps[id]] + offsets[id]; + }; + } + else if ($$.isLegendInset) { + xForLegend = function (id) { + return maxWidth * steps[id] + 10; + }; + yForLegend = function (id) { + return margins[steps[id]] + offsets[id]; + }; + } + else { + xForLegend = function (id) { + return margins[steps[id]] + offsets[id]; + }; + yForLegend = function (id) { + return maxHeight * steps[id]; + }; + } + xForLegendText = function (id, i) { + return xForLegend(id, i) + 4 + config.legend_item_tile_width; + }; + yForLegendText = function (id, i) { + return yForLegend(id, i) + 9; + }; + xForLegendRect = function (id, i) { + return xForLegend(id, i); + }; + yForLegendRect = function (id, i) { + return yForLegend(id, i) - 5; + }; + x1ForLegendTile = function (id, i) { + return xForLegend(id, i) - 2; + }; + x2ForLegendTile = function (id, i) { + return xForLegend(id, i) - 2 + config.legend_item_tile_width; + }; + yForLegendTile = function (id, i) { + return yForLegend(id, i) + 4; + }; + // Define g for legend area + l = $$.legend + .selectAll('.' + CLASS.legendItem) + .data(targetIds) + .enter() + .append('g') + .attr('class', function (id) { + return $$.generateClass(CLASS.legendItem, id); + }) + .style('visibility', function (id) { + return $$.isLegendToShow(id) ? 'visible' : 'hidden'; + }) + .style('cursor', function () { + return config.interaction_enabled ? 'pointer' : 'auto'; + }) + .on('click', config.interaction_enabled + ? function (id) { + if (config.legend_item_onclick) { + config.legend_item_onclick.call($$, id); + } + else { + if ($$.d3.event.altKey) { + $$.api.hide(); + $$.api.show(id); + } + else { + $$.api.toggle(id); + $$.isTargetToShow(id) ? $$.api.focus(id) : $$.api.revert(); + } + } + } + : null) + .on('mouseover', config.interaction_enabled + ? function (id) { + if (config.legend_item_onmouseover) { + config.legend_item_onmouseover.call($$, id); + } + else { + $$.d3.select(this).classed(CLASS.legendItemFocused, true); + if (!$$.transiting && $$.isTargetToShow(id)) { + $$.api.focus(id); + } + } + } + : null) + .on('mouseout', config.interaction_enabled + ? function (id) { + if (config.legend_item_onmouseout) { + config.legend_item_onmouseout.call($$, id); + } + else { + $$.d3.select(this).classed(CLASS.legendItemFocused, false); + $$.api.revert(); + } + } + : null); + l.append('text') + .text(function (id) { + return isDefined(config.data_names[id]) ? config.data_names[id] : id; + }) + .each(function (id, i) { + updatePositions(this, id, i); + }) + .style('pointer-events', 'none') + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendText); + l.append('rect') + .attr('class', CLASS.legendItemEvent) + .style('fill-opacity', 0) + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendRect : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendRect); + l.append('line') + .attr('class', CLASS.legendItemTile) + .style('stroke', $$.color) + .style('pointer-events', 'none') + .attr('x1', $$.isLegendRight || $$.isLegendInset ? x1ForLegendTile : -200) + .attr('y1', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) + .attr('x2', $$.isLegendRight || $$.isLegendInset ? x2ForLegendTile : -200) + .attr('y2', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegendTile) + .attr('stroke-width', config.legend_item_tile_height); + // Set background for inset legend + background = $$.legend.select('.' + CLASS.legendBackground + ' rect'); + if ($$.isLegendInset && maxWidth > 0 && background.size() === 0) { + background = $$.legend + .insert('g', '.' + CLASS.legendItem) + .attr('class', CLASS.legendBackground) + .append('rect'); + } + texts = $$.legend + .selectAll('text') + .data(targetIds) + .text(function (id) { + return isDefined(config.data_names[id]) ? config.data_names[id] : id; + }) // MEMO: needed for update + .each(function (id, i) { + updatePositions(this, id, i); + }); + (withTransition ? texts.transition() : texts) + .attr('x', xForLegendText) + .attr('y', yForLegendText); + rects = $$.legend.selectAll('rect.' + CLASS.legendItemEvent).data(targetIds); + (withTransition ? rects.transition() : rects) + .attr('width', function (id) { + return widths[id]; + }) + .attr('height', function (id) { + return heights[id]; + }) + .attr('x', xForLegendRect) + .attr('y', yForLegendRect); + tiles = $$.legend.selectAll('line.' + CLASS.legendItemTile).data(targetIds); + (withTransition ? tiles.transition() : tiles) + .style('stroke', $$.levelColor + ? function (id) { + return $$.levelColor($$.cache[id].values.reduce(function (total, item) { + return total + item.value; + }, 0)); + } + : $$.color) + .attr('x1', x1ForLegendTile) + .attr('y1', yForLegendTile) + .attr('x2', x2ForLegendTile) + .attr('y2', yForLegendTile); + if (background) { + (withTransition ? background.transition() : background) + .attr('height', $$.getLegendHeight() - 12) + .attr('width', maxWidth * (step + 1) + 10); + } + // toggle legend state + $$.legend + .selectAll('.' + CLASS.legendItem) + .classed(CLASS.legendItemHidden, function (id) { + return !$$.isTargetToShow(id); + }); + // Update all to reflect change of legend + $$.updateLegendItemWidth(maxWidth); + $$.updateLegendItemHeight(maxHeight); + $$.updateLegendStep(step); + // Update size and scale + $$.updateSizes(); + $$.updateScales(); + $$.updateSvgSize(); + // Update g positions + $$.transformAll(withTransitionForTransform, transitions); + $$.legendHasRendered = true; + }; + + ChartInternal.prototype.initRegion = function () { + var $$ = this; + $$.region = $$.main + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.regions); + }; + ChartInternal.prototype.updateRegion = function (duration) { + var $$ = this, config = $$.config; + // hide if arc type + $$.region.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + var mainRegion = $$.main + .select('.' + CLASS.regions) + .selectAll('.' + CLASS.region) + .data(config.regions); + var g = mainRegion.enter().append('g'); + g.append('rect') + .attr('x', $$.regionX.bind($$)) + .attr('y', $$.regionY.bind($$)) + .attr('width', $$.regionWidth.bind($$)) + .attr('height', $$.regionHeight.bind($$)) + .style('fill-opacity', function (d) { + return isValue(d.opacity) ? d.opacity : 0.1; + }); + g.append('text').text($$.labelRegion.bind($$)); + $$.mainRegion = g.merge(mainRegion).attr('class', $$.classRegion.bind($$)); + mainRegion + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + }; + ChartInternal.prototype.redrawRegion = function (withTransition, transition) { + var $$ = this, regions = $$.mainRegion, regionLabels = $$.mainRegion.selectAll('text'); + return [ + (withTransition ? regions.transition(transition) : regions) + .attr('x', $$.regionX.bind($$)) + .attr('y', $$.regionY.bind($$)) + .attr('width', $$.regionWidth.bind($$)) + .attr('height', $$.regionHeight.bind($$)) + .style('fill-opacity', function (d) { + return isValue(d.opacity) ? d.opacity : 0.1; + }), + (withTransition ? regionLabels.transition(transition) : regionLabels) + .attr('x', $$.labelOffsetX.bind($$)) + .attr('y', $$.labelOffsetY.bind($$)) + .attr('transform', $$.labelTransform.bind($$)) + .attr('style', 'text-anchor: left;') + ]; + }; + ChartInternal.prototype.regionX = function (d) { + var $$ = this, config = $$.config, xPos, yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + xPos = config.axis_rotated ? ('start' in d ? yScale(d.start) : 0) : 0; + } + else { + xPos = config.axis_rotated + ? 0 + : 'start' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) + : 0; + } + return xPos; + }; + ChartInternal.prototype.regionY = function (d) { + var $$ = this, config = $$.config, yPos, yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + yPos = config.axis_rotated ? 0 : 'end' in d ? yScale(d.end) : 0; + } + else { + yPos = config.axis_rotated + ? 'start' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.start) : d.start) + : 0 + : 0; + } + return yPos; + }; + ChartInternal.prototype.regionWidth = function (d) { + var $$ = this, config = $$.config, start = $$.regionX(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + end = config.axis_rotated + ? 'end' in d + ? yScale(d.end) + : $$.width + : $$.width; + } + else { + end = config.axis_rotated + ? $$.width + : 'end' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) + : $$.width; + } + return end < start ? 0 : end - start; + }; + ChartInternal.prototype.regionHeight = function (d) { + var $$ = this, config = $$.config, start = this.regionY(d), end, yScale = d.axis === 'y' ? $$.y : $$.y2; + if (d.axis === 'y' || d.axis === 'y2') { + end = config.axis_rotated + ? $$.height + : 'start' in d + ? yScale(d.start) + : $$.height; + } + else { + end = config.axis_rotated + ? 'end' in d + ? $$.x($$.isTimeSeries() ? $$.parseDate(d.end) : d.end) + : $$.height + : $$.height; + } + return end < start ? 0 : end - start; + }; + ChartInternal.prototype.isRegionOnX = function (d) { + return !d.axis || d.axis === 'x'; + }; + ChartInternal.prototype.labelRegion = function (d) { + return 'label' in d ? d.label : ''; + }; + ChartInternal.prototype.labelTransform = function (d) { + return 'vertical' in d && d.vertical ? 'rotate(90)' : ''; + }; + ChartInternal.prototype.labelOffsetX = function (d) { + var paddingX = 'paddingX' in d ? d.paddingX : 3; + var paddingY = 'paddingY' in d ? d.paddingY : 3; + return 'vertical' in d && d.vertical + ? this.regionY(d) + paddingY + : this.regionX(d) + paddingX; + }; + ChartInternal.prototype.labelOffsetY = function (d) { + var paddingX = 'paddingX' in d ? d.paddingX : 3; + var paddingY = 'paddingY' in d ? d.paddingY : 3; + return 'vertical' in d && d.vertical + ? -(this.regionX(d) + paddingX) + : this.regionY(d) + 10 + paddingY; + }; + + function c3LogScale(d3, linearScale, logScale) { + var PROJECTION = [0.01, 10]; + if (!linearScale) { + linearScale = d3.scaleLinear(); + linearScale.range(PROJECTION); + } + if (!logScale) { + logScale = d3.scaleLog(); + logScale.domain(PROJECTION); + logScale.nice(); + } + // copied from https://github.com/compute-io/logspace + function logspace(a, b, len) { + var arr, end, tmp, d; + if (arguments.length < 3) { + len = 10; + } + else { + if (len === 0) { + return []; + } + } + // Calculate the increment: + end = len - 1; + d = (b - a) / end; + // Build the output array... + arr = new Array(len); + tmp = a; + arr[0] = Math.pow(10, tmp); + for (var i = 1; i < end; i++) { + tmp += d; + arr[i] = Math.pow(10, tmp); + } + arr[end] = Math.pow(10, b); + return arr; + } + function scale(x) { + return logScale(linearScale(x)); + } + scale.domain = function (x) { + if (!arguments.length) { + return linearScale.domain(); + } + linearScale.domain(x); + return scale; + }; + scale.range = function (x) { + if (!arguments.length) { + return logScale.range(); + } + logScale.range(x); + return scale; + }; + scale.ticks = function (m) { + return logspace(-2, 1, m || 10).map(function (v) { + return linearScale.invert(v); + }); + }; + scale.copy = function () { + return c3LogScale(d3, linearScale.copy(), logScale.copy()); + }; + return scale; + } + ChartInternal.prototype.getScale = function (min, max, forTimeseries) { + return (forTimeseries ? this.d3.scaleTime() : this.d3.scaleLinear()).range([ + min, + max + ]); + }; + ChartInternal.prototype.getX = function (min, max, domain, offset) { + var $$ = this, scale = $$.getScale(min, max, $$.isTimeSeries()), _scale = domain ? scale.domain(domain) : scale, key; + // Define customized scale if categorized axis + if ($$.isCategorized()) { + offset = + offset || + function () { + return 0; + }; + scale = function (d, raw) { + var v = _scale(d) + offset(d); + return raw ? v : Math.ceil(v); + }; + } + else { + scale = function (d, raw) { + var v = _scale(d); + return raw ? v : Math.ceil(v); + }; + } + // define functions + for (key in _scale) { + scale[key] = _scale[key]; + } + scale.orgDomain = function () { + return _scale.domain(); + }; + // define custom domain() for categorized axis + if ($$.isCategorized()) { + scale.domain = function (domain) { + if (!arguments.length) { + domain = this.orgDomain(); + return [domain[0], domain[1] + 1]; + } + _scale.domain(domain); + return scale; + }; + } + return scale; + }; + /** + * Creates and configures a D3 scale instance for the given type. + * + * By defaults it returns a Linear scale. + * + * @param {String} type Type of d3-scale to create. Type can be 'linear', 'time', 'timeseries' or 'log'. + * @param {Array} domain The scale domain such as [from, to] + * @param {Array} range The scale's range such as [from, to] + * + * @return A d3-scale instance + */ + ChartInternal.prototype.getY = function (type, domain, range) { + var scale; + if (type === 'timeseries' || type === 'time') { + scale = this.d3.scaleTime(); + } + else if (type === 'log') { + scale = c3LogScale(this.d3); + } + else if (type === 'linear' || type === undefined) { + scale = this.d3.scaleLinear(); + } + else { + throw new Error("Invalid Y axis type: \"" + type + "\""); + } + if (domain) { + scale.domain(domain); + } + if (range) { + scale.range(range); + } + return scale; + }; + ChartInternal.prototype.getYScale = function (id) { + return this.axis.getId(id) === 'y2' ? this.y2 : this.y; + }; + ChartInternal.prototype.getSubYScale = function (id) { + return this.axis.getId(id) === 'y2' ? this.subY2 : this.subY; + }; + ChartInternal.prototype.updateScales = function () { + var $$ = this, config = $$.config, forInit = !$$.x; + // update edges + $$.xMin = config.axis_rotated ? 1 : 0; + $$.xMax = config.axis_rotated ? $$.height : $$.width; + $$.yMin = config.axis_rotated ? 0 : $$.height; + $$.yMax = config.axis_rotated ? $$.width : 1; + $$.subXMin = $$.xMin; + $$.subXMax = $$.xMax; + $$.subYMin = config.axis_rotated ? 0 : $$.height2; + $$.subYMax = config.axis_rotated ? $$.width2 : 1; + // update scales + $$.x = $$.getX($$.xMin, $$.xMax, forInit ? undefined : $$.x.orgDomain(), function () { + return $$.xAxis.tickOffset(); + }); + $$.y = $$.getY(config.axis_y_type, forInit ? config.axis_y_default : $$.y.domain(), [$$.yMin, $$.yMax]); + $$.y2 = $$.getY(config.axis_y2_type, forInit ? config.axis_y2_default : $$.y2.domain(), [$$.yMin, $$.yMax]); + $$.subX = $$.getX($$.xMin, $$.xMax, $$.orgXDomain, function (d) { + return d % 1 ? 0 : $$.subXAxis.tickOffset(); + }); + $$.subY = $$.getY(config.axis_y_type, forInit ? config.axis_y_default : $$.subY.domain(), [$$.subYMin, $$.subYMax]); + $$.subY2 = $$.getY(config.axis_y2_type, forInit ? config.axis_y2_default : $$.subY2.domain(), [$$.subYMin, $$.subYMax]); + // update axes + $$.xAxisTickFormat = $$.axis.getXAxisTickFormat(); + $$.xAxisTickValues = $$.axis.getXAxisTickValues(); + $$.yAxisTickValues = $$.axis.getYAxisTickValues(); + $$.y2AxisTickValues = $$.axis.getY2AxisTickValues(); + $$.xAxis = $$.axis.getXAxis($$.x, $$.xOrient, $$.xAxisTickFormat, $$.xAxisTickValues, config.axis_x_tick_outer); + $$.subXAxis = $$.axis.getXAxis($$.subX, $$.subXOrient, $$.xAxisTickFormat, $$.xAxisTickValues, config.axis_x_tick_outer); + $$.yAxis = $$.axis.getYAxis('y', $$.y, $$.yOrient, $$.yAxisTickValues, config.axis_y_tick_outer); + $$.y2Axis = $$.axis.getYAxis('y2', $$.y2, $$.y2Orient, $$.y2AxisTickValues, config.axis_y2_tick_outer); + // Set initialized scales to brush and zoom + if (!forInit) { + if ($$.brush) { + $$.brush.updateScale($$.subX); + } + } + // update for arc + if ($$.updateArc) { + $$.updateArc(); + } + }; + + ChartInternal.prototype.selectPoint = function (target, d, i) { + var $$ = this, config = $$.config, cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$), cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$), r = $$.pointSelectR.bind($$); + config.data_onselected.call($$.api, d, target.node()); + // add selected-circle on low layer g + $$.main + .select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.selectedCircle + '-' + i) + .data([d]) + .enter() + .append('circle') + .attr('class', function () { + return $$.generateClass(CLASS.selectedCircle, i); + }) + .attr('cx', cx) + .attr('cy', cy) + .attr('stroke', function () { + return $$.color(d); + }) + .attr('r', function (d) { + return $$.pointSelectR(d) * 1.4; + }) + .transition() + .duration(100) + .attr('r', r); + }; + ChartInternal.prototype.unselectPoint = function (target, d, i) { + var $$ = this; + $$.config.data_onunselected.call($$.api, d, target.node()); + // remove selected-circle from low layer g + $$.main + .select('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(d.id)) + .selectAll('.' + CLASS.selectedCircle + '-' + i) + .transition() + .duration(100) + .attr('r', 0) + .remove(); + }; + ChartInternal.prototype.togglePoint = function (selected, target, d, i) { + selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i); + }; + ChartInternal.prototype.selectPath = function (target, d) { + var $$ = this; + $$.config.data_onselected.call($$, d, target.node()); + if ($$.config.interaction_brighten) { + target + .transition() + .duration(100) + .style('fill', function () { + return $$.d3.rgb($$.color(d)).brighter(0.75); + }); + } + }; + ChartInternal.prototype.unselectPath = function (target, d) { + var $$ = this; + $$.config.data_onunselected.call($$, d, target.node()); + if ($$.config.interaction_brighten) { + target + .transition() + .duration(100) + .style('fill', function () { + return $$.color(d); + }); + } + }; + ChartInternal.prototype.togglePath = function (selected, target, d, i) { + selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i); + }; + ChartInternal.prototype.getToggle = function (that, d) { + var $$ = this, toggle; + if (that.nodeName === 'circle') { + if ($$.isStepType(d)) { + // circle is hidden in step chart, so treat as within the click area + toggle = function () { }; // TODO: how to select step chart? + } + else { + toggle = $$.togglePoint; + } + } + else if (that.nodeName === 'path') { + toggle = $$.togglePath; + } + return toggle; + }; + ChartInternal.prototype.toggleShape = function (that, d, i) { + var $$ = this, d3 = $$.d3, config = $$.config, shape = d3.select(that), isSelected = shape.classed(CLASS.SELECTED), toggle = $$.getToggle(that, d).bind($$); + if (config.data_selection_enabled && config.data_selection_isselectable(d)) { + if (!config.data_selection_multiple) { + $$.main + .selectAll('.' + + CLASS.shapes + + (config.data_selection_grouped + ? $$.getTargetSelectorSuffix(d.id) + : '')) + .selectAll('.' + CLASS.shape) + .each(function (d, i) { + var shape = d3.select(this); + if (shape.classed(CLASS.SELECTED)) { + toggle(false, shape.classed(CLASS.SELECTED, false), d, i); + } + }); + } + shape.classed(CLASS.SELECTED, !isSelected); + toggle(!isSelected, shape, d, i); + } + }; + + ChartInternal.prototype.initBar = function () { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartBars); + }; + ChartInternal.prototype.updateTargetsForBar = function (targets) { + var $$ = this, config = $$.config, mainBars, mainBarEnter, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$), classFocus = $$.classFocus.bind($$); + mainBars = $$.main + .select('.' + CLASS.chartBars) + .selectAll('.' + CLASS.chartBar) + .data(targets) + .attr('class', function (d) { + return classChartBar(d) + classFocus(d); + }); + mainBarEnter = mainBars + .enter() + .append('g') + .attr('class', classChartBar) + .style('pointer-events', 'none'); + // Bars for each data + mainBarEnter + .append('g') + .attr('class', classBars) + .style('cursor', function (d) { + return config.data_selection_isselectable(d) ? 'pointer' : null; + }); + }; + ChartInternal.prototype.updateBar = function (durationForExit) { + var $$ = this, barData = $$.barData.bind($$), classBar = $$.classBar.bind($$), initialOpacity = $$.initialOpacity.bind($$), color = function (d) { + return $$.color(d.id); + }; + var mainBar = $$.main + .selectAll('.' + CLASS.bars) + .selectAll('.' + CLASS.bar) + .data(barData); + var mainBarEnter = mainBar + .enter() + .append('path') + .attr('class', classBar) + .style('stroke', color) + .style('fill', color); + $$.mainBar = mainBarEnter.merge(mainBar).style('opacity', initialOpacity); + mainBar + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); + }; + ChartInternal.prototype.redrawBar = function (drawBar, withTransition, transition) { + var $$ = this; + return [ + (withTransition ? this.mainBar.transition(transition) : this.mainBar) + .attr('d', drawBar) + .style('stroke', this.color) + .style('fill', this.color) + .style('opacity', function (d) { return ($$.isTargetToShow(d.id) ? 1 : 0); }) + ]; + }; + ChartInternal.prototype.getBarW = function (axis, barTargetsNum) { + var $$ = this, config = $$.config, w = typeof config.bar_width === 'number' + ? config.bar_width + : barTargetsNum + ? (axis.tickInterval() * config.bar_width_ratio) / barTargetsNum + : 0; + return config.bar_width_max && w > config.bar_width_max + ? config.bar_width_max + : w; + }; + ChartInternal.prototype.getBars = function (i, id) { + var $$ = this; + return (id + ? $$.main.selectAll('.' + CLASS.bars + $$.getTargetSelectorSuffix(id)) + : $$.main).selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')); + }; + ChartInternal.prototype.expandBars = function (i, id, reset) { + var $$ = this; + if (reset) { + $$.unexpandBars(); + } + $$.getBars(i, id).classed(CLASS.EXPANDED, true); + }; + ChartInternal.prototype.unexpandBars = function (i) { + var $$ = this; + $$.getBars(i).classed(CLASS.EXPANDED, false); + }; + ChartInternal.prototype.generateDrawBar = function (barIndices, isSub) { + var $$ = this, config = $$.config, getPoints = $$.generateGetBarPoints(barIndices, isSub); + return function (d, i) { + // 4 points that make a bar + var points = getPoints(d, i); + // switch points if axis is rotated, not applicable for sub chart + var indexX = config.axis_rotated ? 1 : 0; + var indexY = config.axis_rotated ? 0 : 1; + var path = 'M ' + + points[0][indexX] + + ',' + + points[0][indexY] + + ' ' + + 'L' + + points[1][indexX] + + ',' + + points[1][indexY] + + ' ' + + 'L' + + points[2][indexX] + + ',' + + points[2][indexY] + + ' ' + + 'L' + + points[3][indexX] + + ',' + + points[3][indexY] + + ' ' + + 'z'; + return path; + }; + }; + ChartInternal.prototype.generateGetBarPoints = function (barIndices, isSub) { + var $$ = this, axis = isSub ? $$.subXAxis : $$.xAxis, barTargetsNum = barIndices.__max__ + 1, barW = $$.getBarW(axis, barTargetsNum), barX = $$.getShapeX(barW, barTargetsNum, barIndices, !!isSub), barY = $$.getShapeY(!!isSub), barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub), barSpaceOffset = barW * ($$.config.bar_space / 2), yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function (d, i) { + var y0 = yScale.call($$, d.id)(0), offset = barOffset(d, i) || y0, // offset is for stacked bar chart + posX = barX(d), posY = barY(d); + // fix posY not to overflow opposite quadrant + if ($$.config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + posY -= y0 - offset; + // 4 points that make a bar + return [ + [posX + barSpaceOffset, offset], + [posX + barSpaceOffset, posY], + [posX + barW - barSpaceOffset, posY], + [posX + barW - barSpaceOffset, offset] + ]; + }; + }; + /** + * Returns whether the data point is within the given bar shape. + * + * @param mouse + * @param barShape + * @return {boolean} + */ + ChartInternal.prototype.isWithinBar = function (mouse, barShape) { + return isWithinBox(mouse, getBBox(barShape), 2); + }; + + ChartInternal.prototype.getShapeIndices = function (typeFilter) { + var $$ = this, config = $$.config, indices = {}, i = 0, j, k; + $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)).forEach(function (d) { + for (j = 0; j < config.data_groups.length; j++) { + if (config.data_groups[j].indexOf(d.id) < 0) { + continue; + } + for (k = 0; k < config.data_groups[j].length; k++) { + if (config.data_groups[j][k] in indices) { + indices[d.id] = indices[config.data_groups[j][k]]; + break; + } + } + } + if (isUndefined(indices[d.id])) { + indices[d.id] = i++; + } + }); + indices.__max__ = i - 1; + return indices; + }; + ChartInternal.prototype.getShapeX = function (offset, targetsNum, indices, isSub) { + var $$ = this, scale = isSub ? $$.subX : $$.x; + return function (d) { + var index = d.id in indices ? indices[d.id] : 0; + return d.x || d.x === 0 ? scale(d.x) - offset * (targetsNum / 2 - index) : 0; + }; + }; + ChartInternal.prototype.getShapeY = function (isSub) { + var $$ = this; + return function (d) { + var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id); + return scale($$.isTargetNormalized(d.id) ? $$.getRatio('index', d, true) : d.value); + }; + }; + ChartInternal.prototype.getShapeOffset = function (typeFilter, indices, isSub) { + var $$ = this, targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))), targetIds = targets.map(function (t) { + return t.id; + }); + return function (d, i) { + var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id), y0 = scale(0), offset = y0; + targets.forEach(function (t) { + var rowValues = $$.isStepType(d) + ? $$.convertValuesToStep(t.values) + : t.values; + var isTargetNormalized = $$.isTargetNormalized(d.id); + var values = rowValues.map(function (v) { + return isTargetNormalized ? $$.getRatio('index', v, true) : v.value; + }); + if (t.id === d.id || indices[t.id] !== indices[d.id]) { + return; + } + if (targetIds.indexOf(t.id) < targetIds.indexOf(d.id)) { + // check if the x values line up + if (isUndefined(rowValues[i]) || +rowValues[i].x !== +d.x) { + // "+" for timeseries + // if not, try to find the value that does line up + i = -1; + rowValues.forEach(function (v, j) { + var x1 = v.x.constructor === Date ? +v.x : v.x; + var x2 = d.x.constructor === Date ? +d.x : d.x; + if (x1 === x2) { + i = j; + } + }); + } + if (i in rowValues && rowValues[i].value * d.value >= 0) { + offset += scale(values[i]) - y0; + } + } + }); + return offset; + }; + }; + ChartInternal.prototype.isWithinShape = function (that, d) { + var $$ = this, shape = $$.d3.select(that), isWithin; + if (!$$.isTargetToShow(d.id)) { + isWithin = false; + } + else if (that.nodeName === 'circle') { + isWithin = $$.isStepType(d) + ? $$.isWithinStep(that, $$.getYScale(d.id)(d.value)) + : $$.isWithinCircle(that, $$.pointSelectR(d) * 1.5); + } + else if (that.nodeName === 'path') { + isWithin = shape.classed(CLASS.bar) + ? $$.isWithinBar($$.d3.mouse(that), that) + : true; + } + return isWithin; + }; + ChartInternal.prototype.getInterpolate = function (d) { + var $$ = this, d3 = $$.d3, types = { + linear: d3.curveLinear, + 'linear-closed': d3.curveLinearClosed, + basis: d3.curveBasis, + 'basis-open': d3.curveBasisOpen, + 'basis-closed': d3.curveBasisClosed, + bundle: d3.curveBundle, + cardinal: d3.curveCardinal, + 'cardinal-open': d3.curveCardinalOpen, + 'cardinal-closed': d3.curveCardinalClosed, + monotone: d3.curveMonotoneX, + step: d3.curveStep, + 'step-before': d3.curveStepBefore, + 'step-after': d3.curveStepAfter + }, type; + if ($$.isSplineType(d)) { + type = types[$$.config.spline_interpolation_type] || types.cardinal; + } + else if ($$.isStepType(d)) { + type = types[$$.config.line_step_type]; + } + else { + type = types.linear; + } + return type; + }; + + ChartInternal.prototype.initLine = function () { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartLines); + }; + ChartInternal.prototype.updateTargetsForLine = function (targets) { + var $$ = this, config = $$.config, mainLines, mainLineEnter, classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$), classCircles = $$.classCircles.bind($$), classFocus = $$.classFocus.bind($$); + mainLines = $$.main + .select('.' + CLASS.chartLines) + .selectAll('.' + CLASS.chartLine) + .data(targets) + .attr('class', function (d) { + return classChartLine(d) + classFocus(d); + }); + mainLineEnter = mainLines + .enter() + .append('g') + .attr('class', classChartLine) + .style('opacity', 0) + .style('pointer-events', 'none'); + // Lines for each data + mainLineEnter.append('g').attr('class', classLines); + // Areas + mainLineEnter.append('g').attr('class', classAreas); + // Circles for each data point on lines + mainLineEnter.append('g').attr('class', function (d) { + return $$.generateClass(CLASS.selectedCircles, d.id); + }); + mainLineEnter + .append('g') + .attr('class', classCircles) + .style('cursor', function (d) { + return config.data_selection_isselectable(d) ? 'pointer' : null; + }); + // Update date for selected circles + targets.forEach(function (t) { + $$.main + .selectAll('.' + CLASS.selectedCircles + $$.getTargetSelectorSuffix(t.id)) + .selectAll('.' + CLASS.selectedCircle) + .each(function (d) { + d.value = t.values[d.index].value; + }); + }); + // MEMO: can not keep same color... + //mainLineUpdate.exit().remove(); + }; + ChartInternal.prototype.updateLine = function (durationForExit) { + var $$ = this; + var mainLine = $$.main + .selectAll('.' + CLASS.lines) + .selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + var mainLineEnter = mainLine + .enter() + .append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + $$.mainLine = mainLineEnter + .merge(mainLine) + .style('opacity', $$.initialOpacity.bind($$)) + .style('shape-rendering', function (d) { + return $$.isStepType(d) ? 'crispEdges' : ''; + }) + .attr('transform', null); + mainLine + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); + }; + ChartInternal.prototype.redrawLine = function (drawLine, withTransition, transition) { + return [ + (withTransition ? this.mainLine.transition(transition) : this.mainLine) + .attr('d', drawLine) + .style('stroke', this.color) + .style('opacity', 1) + ]; + }; + ChartInternal.prototype.generateDrawLine = function (lineIndices, isSub) { + var $$ = this, config = $$.config, line = $$.d3.line(), getPoints = $$.generateGetLinePoints(lineIndices, isSub), yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { + return (isSub ? $$.subxx : $$.xx).call($$, d); + }, yValue = function (d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[0][1] + : yScaleGetter.call($$, d.id)(d.value); + }; + line = config.axis_rotated + ? line.x(yValue).y(xValue) + : line.x(xValue).y(yValue); + if (!config.line_connectNull) { + line = line.defined(function (d) { + return d.value != null; + }); + } + return function (d) { + var values = config.line_connectNull + ? $$.filterRemoveNull(d.values) + : d.values, x = isSub ? $$.subX : $$.x, y = yScaleGetter.call($$, d.id), x0 = 0, y0 = 0, path; + if ($$.isLineType(d)) { + if (config.data_regions[d.id]) { + path = $$.lineWithRegions(values, x, y, config.data_regions[d.id]); + } + else { + if ($$.isStepType(d)) { + values = $$.convertValuesToStep(values); + } + path = line.curve($$.getInterpolate(d))(values); + } + } + else { + if (values[0]) { + x0 = x(values[0].x); + y0 = y(values[0].value); + } + path = config.axis_rotated ? 'M ' + y0 + ' ' + x0 : 'M ' + x0 + ' ' + y0; + } + return path ? path : 'M 0 0'; + }; + }; + ChartInternal.prototype.generateGetLinePoints = function (lineIndices, isSub) { + // partial duplication of generateGetBarPoints + var $$ = this, config = $$.config, lineTargetsNum = lineIndices.__max__ + 1, x = $$.getShapeX(0, lineTargetsNum, lineIndices, !!isSub), y = $$.getShapeY(!!isSub), lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, !!isSub), yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function (d, i) { + var y0 = yScale.call($$, d.id)(0), offset = lineOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), posY = y(d); + // fix posY not to overflow opposite quadrant + if (config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + // 1 point that marks the line position + return [ + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)] // needed for compatibility + ]; + }; + }; + ChartInternal.prototype.lineWithRegions = function (d, x, y, _regions) { + var $$ = this, config = $$.config, prev = -1, i, j, s = 'M', sWithRegion, xp, yp, dx, dy, dd, diff, diffx2, xOffset = $$.isCategorized() ? 0.5 : 0, xValue, yValue, regions = []; + function isWithinRegions(x, regions) { + var i; + for (i = 0; i < regions.length; i++) { + if (regions[i].start < x && x <= regions[i].end) { + return true; + } + } + return false; + } + // Check start/end of regions + if (isDefined(_regions)) { + for (i = 0; i < _regions.length; i++) { + regions[i] = {}; + if (isUndefined(_regions[i].start)) { + regions[i].start = d[0].x; + } + else { + regions[i].start = $$.isTimeSeries() + ? $$.parseDate(_regions[i].start) + : _regions[i].start; + } + if (isUndefined(_regions[i].end)) { + regions[i].end = d[d.length - 1].x; + } + else { + regions[i].end = $$.isTimeSeries() + ? $$.parseDate(_regions[i].end) + : _regions[i].end; + } + } + } + // Set scales + xValue = config.axis_rotated + ? function (d) { + return y(d.value); + } + : function (d) { + return x(d.x); + }; + yValue = config.axis_rotated + ? function (d) { + return x(d.x); + } + : function (d) { + return y(d.value); + }; + // Define svg generator function for region + function generateM(points) { + return ('M' + + points[0][0] + + ' ' + + points[0][1] + + ' ' + + points[1][0] + + ' ' + + points[1][1]); + } + if ($$.isTimeSeries()) { + sWithRegion = function (d0, d1, j, diff) { + var x0 = d0.x.getTime(), x_diff = d1.x - d0.x, xv0 = new Date(x0 + x_diff * j), xv1 = new Date(x0 + x_diff * (j + diff)), points; + if (config.axis_rotated) { + points = [ + [y(yp(j)), x(xv0)], + [y(yp(j + diff)), x(xv1)] + ]; + } + else { + points = [ + [x(xv0), y(yp(j))], + [x(xv1), y(yp(j + diff))] + ]; + } + return generateM(points); + }; + } + else { + sWithRegion = function (d0, d1, j, diff) { + var points; + if (config.axis_rotated) { + points = [ + [y(yp(j), true), x(xp(j))], + [y(yp(j + diff), true), x(xp(j + diff))] + ]; + } + else { + points = [ + [x(xp(j), true), y(yp(j))], + [x(xp(j + diff), true), y(yp(j + diff))] + ]; + } + return generateM(points); + }; + } + // Generate + for (i = 0; i < d.length; i++) { + // Draw as normal + if (isUndefined(regions) || !isWithinRegions(d[i].x, regions)) { + s += ' ' + xValue(d[i]) + ' ' + yValue(d[i]); + } + // Draw with region // TODO: Fix for horizotal charts + else { + xp = $$.getScale(d[i - 1].x + xOffset, d[i].x + xOffset, $$.isTimeSeries()); + yp = $$.getScale(d[i - 1].value, d[i].value); + dx = x(d[i].x) - x(d[i - 1].x); + dy = y(d[i].value) - y(d[i - 1].value); + dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); + diff = 2 / dd; + diffx2 = diff * 2; + for (j = diff; j <= 1; j += diffx2) { + s += sWithRegion(d[i - 1], d[i], j, diff); + } + } + prev = d[i].x; + } + return s; + }; + ChartInternal.prototype.updateArea = function (durationForExit) { + var $$ = this, d3 = $$.d3; + var mainArea = $$.main + .selectAll('.' + CLASS.areas) + .selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + var mainAreaEnter = mainArea + .enter() + .append('path') + .attr('class', $$.classArea.bind($$)) + .style('fill', $$.color) + .style('opacity', function () { + $$.orgAreaOpacity = +d3.select(this).style('opacity'); + return 0; + }); + $$.mainArea = mainAreaEnter + .merge(mainArea) + .style('opacity', $$.orgAreaOpacity); + mainArea + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0); + }; + ChartInternal.prototype.redrawArea = function (drawArea, withTransition, transition) { + return [ + (withTransition ? this.mainArea.transition(transition) : this.mainArea) + .attr('d', drawArea) + .style('fill', this.color) + .style('opacity', this.orgAreaOpacity) + ]; + }; + ChartInternal.prototype.generateDrawArea = function (areaIndices, isSub) { + var $$ = this, config = $$.config, area = $$.d3.area(), getPoints = $$.generateGetAreaPoints(areaIndices, isSub), yScaleGetter = isSub ? $$.getSubYScale : $$.getYScale, xValue = function (d) { + return (isSub ? $$.subxx : $$.xx).call($$, d); + }, value0 = function (d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[0][1] + : yScaleGetter.call($$, d.id)($$.getAreaBaseValue(d.id)); + }, value1 = function (d, i) { + return config.data_groups.length > 0 + ? getPoints(d, i)[1][1] + : yScaleGetter.call($$, d.id)(d.value); + }; + area = config.axis_rotated + ? area + .x0(value0) + .x1(value1) + .y(xValue) + : area + .x(xValue) + .y0(config.area_above ? 0 : value0) + .y1(value1); + if (!config.line_connectNull) { + area = area.defined(function (d) { + return d.value !== null; + }); + } + return function (d) { + var values = config.line_connectNull + ? $$.filterRemoveNull(d.values) + : d.values, x0 = 0, y0 = 0, path; + if ($$.isAreaType(d)) { + if ($$.isStepType(d)) { + values = $$.convertValuesToStep(values); + } + path = area.curve($$.getInterpolate(d))(values); + } + else { + if (values[0]) { + x0 = $$.x(values[0].x); + y0 = $$.getYScale(d.id)(values[0].value); + } + path = config.axis_rotated ? 'M ' + y0 + ' ' + x0 : 'M ' + x0 + ' ' + y0; + } + return path ? path : 'M 0 0'; + }; + }; + ChartInternal.prototype.getAreaBaseValue = function () { + return 0; + }; + ChartInternal.prototype.generateGetAreaPoints = function (areaIndices, isSub) { + // partial duplication of generateGetBarPoints + var $$ = this, config = $$.config, areaTargetsNum = areaIndices.__max__ + 1, x = $$.getShapeX(0, areaTargetsNum, areaIndices, !!isSub), y = $$.getShapeY(!!isSub), areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, !!isSub), yScale = isSub ? $$.getSubYScale : $$.getYScale; + return function (d, i) { + var y0 = yScale.call($$, d.id)(0), offset = areaOffset(d, i) || y0, // offset is for stacked area chart + posX = x(d), posY = y(d); + // fix posY not to overflow opposite quadrant + if (config.axis_rotated) { + if ((0 < d.value && posY < y0) || (d.value < 0 && y0 < posY)) { + posY = y0; + } + } + // 1 point that marks the area position + return [ + [posX, offset], + [posX, posY - (y0 - offset)], + [posX, posY - (y0 - offset)], + [posX, offset] // needed for compatibility + ]; + }; + }; + ChartInternal.prototype.updateCircle = function (cx, cy) { + var $$ = this; + var mainCircle = $$.main + .selectAll('.' + CLASS.circles) + .selectAll('.' + CLASS.circle) + .data($$.lineOrScatterOrStanfordData.bind($$)); + var mainCircleEnter = mainCircle + .enter() + .append('circle') + .attr('shape-rendering', $$.isStanfordGraphType() ? 'crispEdges' : '') + .attr('class', $$.classCircle.bind($$)) + .attr('cx', cx) + .attr('cy', cy) + .attr('r', $$.pointR.bind($$)) + .style('color', $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color); + $$.mainCircle = mainCircleEnter + .merge(mainCircle) + .style('opacity', $$.isStanfordGraphType() ? 1 : $$.initialOpacityForCircle.bind($$)); + mainCircle.exit().style('opacity', 0); + }; + ChartInternal.prototype.redrawCircle = function (cx, cy, withTransition, transition) { + var $$ = this, selectedCircles = $$.main.selectAll('.' + CLASS.selectedCircle); + return [ + (withTransition ? $$.mainCircle.transition(transition) : $$.mainCircle) + .style('opacity', this.opacityForCircle.bind($$)) + .style('color', $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color) + .attr('cx', cx) + .attr('cy', cy), + (withTransition ? selectedCircles.transition(transition) : selectedCircles) + .attr('cx', cx) + .attr('cy', cy) + ]; + }; + ChartInternal.prototype.circleX = function (d) { + return d.x || d.x === 0 ? this.x(d.x) : null; + }; + ChartInternal.prototype.updateCircleY = function () { + var $$ = this, lineIndices, getPoints; + if ($$.config.data_groups.length > 0) { + (lineIndices = $$.getShapeIndices($$.isLineType)), + (getPoints = $$.generateGetLinePoints(lineIndices)); + $$.circleY = function (d, i) { + return getPoints(d, i)[0][1]; + }; + } + else { + $$.circleY = function (d) { + return $$.getYScale(d.id)(d.value); + }; + } + }; + ChartInternal.prototype.getCircles = function (i, id) { + var $$ = this; + return (id + ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) + : $$.main).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')); + }; + ChartInternal.prototype.expandCircles = function (i, id, reset) { + var $$ = this, r = $$.pointExpandedR.bind($$); + if (reset) { + $$.unexpandCircles(); + } + $$.getCircles(i, id) + .classed(CLASS.EXPANDED, true) + .attr('r', r); + }; + ChartInternal.prototype.unexpandCircles = function (i) { + var $$ = this, r = $$.pointR.bind($$); + $$.getCircles(i) + .filter(function () { + return $$.d3.select(this).classed(CLASS.EXPANDED); + }) + .classed(CLASS.EXPANDED, false) + .attr('r', r); + }; + ChartInternal.prototype.pointR = function (d) { + var $$ = this, config = $$.config; + return $$.isStepType(d) + ? 0 + : isFunction(config.point_r) + ? config.point_r(d) + : config.point_r; + }; + ChartInternal.prototype.pointExpandedR = function (d) { + var $$ = this, config = $$.config; + if (config.point_focus_expand_enabled) { + return isFunction(config.point_focus_expand_r) + ? config.point_focus_expand_r(d) + : config.point_focus_expand_r + ? config.point_focus_expand_r + : $$.pointR(d) * 1.75; + } + else { + return $$.pointR(d); + } + }; + ChartInternal.prototype.pointSelectR = function (d) { + var $$ = this, config = $$.config; + return isFunction(config.point_select_r) + ? config.point_select_r(d) + : config.point_select_r + ? config.point_select_r + : $$.pointR(d) * 4; + }; + ChartInternal.prototype.isWithinCircle = function (that, r) { + var d3 = this.d3, mouse = d3.mouse(that), d3_this = d3.select(that), cx = +d3_this.attr('cx'), cy = +d3_this.attr('cy'); + return Math.sqrt(Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)) < r; + }; + ChartInternal.prototype.isWithinStep = function (that, y) { + return Math.abs(y - this.d3.mouse(that)[1]) < 30; + }; + + ChartInternal.prototype.getCurrentWidth = function () { + var $$ = this, config = $$.config; + return config.size_width ? config.size_width : $$.getParentWidth(); + }; + ChartInternal.prototype.getCurrentHeight = function () { + var $$ = this, config = $$.config, h = config.size_height ? config.size_height : $$.getParentHeight(); + return h > 0 + ? h + : 320 / ($$.hasType('gauge') && !config.gauge_fullCircle ? 2 : 1); + }; + ChartInternal.prototype.getCurrentPaddingTop = function () { + var $$ = this, config = $$.config, padding = isValue(config.padding_top) ? config.padding_top : 0; + if ($$.title && $$.title.node()) { + padding += $$.getTitlePadding(); + } + return padding; + }; + ChartInternal.prototype.getCurrentPaddingBottom = function () { + var config = this.config; + return isValue(config.padding_bottom) ? config.padding_bottom : 0; + }; + ChartInternal.prototype.getCurrentPaddingLeft = function (withoutRecompute) { + var $$ = this, config = $$.config; + if (isValue(config.padding_left)) { + return config.padding_left; + } + else if (config.axis_rotated) { + return !config.axis_x_show || config.axis_x_inner + ? 1 + : Math.max(ceil10($$.getAxisWidthByAxisId('x', withoutRecompute)), 40); + } + else if (!config.axis_y_show || config.axis_y_inner) { + // && !config.axis_rotated + return $$.axis.getYAxisLabelPosition().isOuter ? 30 : 1; + } + else { + return ceil10($$.getAxisWidthByAxisId('y', withoutRecompute)); + } + }; + ChartInternal.prototype.getCurrentPaddingRight = function () { + var $$ = this, config = $$.config, padding = 0, defaultPadding = 10, legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0; + if (isValue(config.padding_right)) { + padding = config.padding_right + 1; // 1 is needed not to hide tick line + } + else if (config.axis_rotated) { + padding = defaultPadding + legendWidthOnRight; + } + else if (!config.axis_y2_show || config.axis_y2_inner) { + // && !config.axis_rotated + padding = + 2 + + legendWidthOnRight + + ($$.axis.getY2AxisLabelPosition().isOuter ? 20 : 0); + } + else { + padding = ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight; + } + if ($$.colorScale && $$.colorScale.node()) { + padding += $$.getColorScalePadding(); + } + return padding; + }; + ChartInternal.prototype.getParentRectValue = function (key) { + var parent = this.selectChart.node(), v; + while (parent && parent.tagName !== 'BODY') { + try { + v = parent.getBoundingClientRect()[key]; + } + catch (e) { + if (key === 'width') { + // In IE in certain cases getBoundingClientRect + // will cause an "unspecified error" + v = parent.offsetWidth; + } + } + if (v) { + break; + } + parent = parent.parentNode; + } + return v; + }; + ChartInternal.prototype.getParentWidth = function () { + return this.getParentRectValue('width'); + }; + ChartInternal.prototype.getParentHeight = function () { + var h = this.selectChart.style('height'); + return h.indexOf('px') > 0 ? +h.replace('px', '') : 0; + }; + ChartInternal.prototype.getSvgLeft = function (withoutRecompute) { + var $$ = this, config = $$.config, hasLeftAxisRect = config.axis_rotated || (!config.axis_rotated && !config.axis_y_inner), leftAxisClass = config.axis_rotated ? CLASS.axisX : CLASS.axisY, leftAxis = $$.main.select('.' + leftAxisClass).node(), svgRect = leftAxis && hasLeftAxisRect + ? leftAxis.getBoundingClientRect() + : { right: 0 }, chartRect = $$.selectChart.node().getBoundingClientRect(), hasArc = $$.hasArcType(), svgLeft = svgRect.right - + chartRect.left - + (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute)); + return svgLeft > 0 ? svgLeft : 0; + }; + ChartInternal.prototype.getAxisWidthByAxisId = function (id, withoutRecompute) { + var $$ = this, position = $$.axis.getLabelPositionById(id); + return ($$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40)); + }; + ChartInternal.prototype.getHorizontalAxisHeight = function (axisId, isSubchart) { + var $$ = this, config = $$.config, h = 30; + if (axisId === 'x' && !(isDefined(isSubchart) && isSubchart ? config.subchart_axis_x_show : config.axis_x_show)) { + return 8; + } + if (axisId === 'x' && config.axis_x_height) { + return config.axis_x_height; + } + if (axisId === 'y' && !config.axis_y_show) { + return config.legend_show && !$$.isLegendRight && !$$.isLegendInset ? 10 : 1; + } + if (axisId === 'y2' && !config.axis_y2_show) { + return $$.rotated_padding_top; + } + // Calculate x axis height when tick rotated + if (axisId === 'x' && !config.axis_rotated && config.axis_x_tick_rotate) { + h = + 30 + + $$.axis.getMaxTickWidth(axisId) * + Math.cos((Math.PI * (90 - Math.abs(config.axis_x_tick_rotate))) / 180); + } + // Calculate y axis height when tick rotated + if (axisId === 'y' && config.axis_rotated && config.axis_y_tick_rotate) { + h = + 30 + + $$.axis.getMaxTickWidth(axisId) * + Math.cos((Math.PI * (90 - Math.abs(config.axis_y_tick_rotate))) / 180); + } + return (h + + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + + (axisId === 'y2' ? -10 : 0)); + }; + + ChartInternal.prototype.initBrush = function (scale) { + var $$ = this, d3 = $$.d3; + // TODO: dynamically change brushY/brushX according to axis_rotated. + $$.brush = ($$.config.axis_rotated ? d3.brushY() : d3.brushX()) + .on('brush', function () { + var event = d3.event.sourceEvent; + if (event && event.type === 'zoom') { + return; + } + $$.redrawForBrush(); + }) + .on('end', function () { + var event = d3.event.sourceEvent; + if (event && event.type === 'zoom') { + return; + } + if ($$.brush.empty() && event && event.type !== 'end') { + $$.brush.clear(); + } + }); + $$.brush.updateExtent = function () { + var range = this.scale.range(), extent; + if ($$.config.axis_rotated) { + extent = [ + [0, range[0]], + [$$.width2, range[1]] + ]; + } + else { + extent = [ + [range[0], 0], + [range[1], $$.height2] + ]; + } + this.extent(extent); + return this; + }; + $$.brush.updateScale = function (scale) { + this.scale = scale; + return this; + }; + $$.brush.update = function (scale) { + this.updateScale(scale || $$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call(this); + }; + $$.brush.clear = function () { + $$.context.select('.' + CLASS.brush).call($$.brush.move, null); + }; + $$.brush.selection = function () { + return d3.brushSelection($$.context.select('.' + CLASS.brush).node()); + }; + $$.brush.selectionAsValue = function (selectionAsValue, withTransition) { + var selection, brush; + if (selectionAsValue) { + if ($$.context) { + selection = [ + this.scale(selectionAsValue[0]), + this.scale(selectionAsValue[1]) + ]; + brush = $$.context.select('.' + CLASS.brush); + if (withTransition) { + brush = brush.transition(); + } + $$.brush.move(brush, selection); + } + return []; + } + selection = $$.brush.selection() || [0, 0]; + return [this.scale.invert(selection[0]), this.scale.invert(selection[1])]; + }; + $$.brush.empty = function () { + var selection = $$.brush.selection(); + return !selection || selection[0] === selection[1]; + }; + return $$.brush.updateScale(scale); + }; + ChartInternal.prototype.initSubchart = function () { + var $$ = this, config = $$.config, context = ($$.context = $$.svg + .append('g') + .attr('transform', $$.getTranslate('context'))); + // set style + context.style('visibility', 'visible'); + // Define g for chart area + context + .append('g') + .attr('clip-path', $$.clipPathForSubchart) + .attr('class', CLASS.chart); + // Define g for bar chart area + context + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartBars); + // Define g for line chart area + context + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartLines); + // Add extent rect for Brush + context + .append('g') + .attr('clip-path', $$.clipPath) + .attr('class', CLASS.brush); + // ATTENTION: This must be called AFTER chart added + // Add Axis + $$.axes.subx = context + .append('g') + .attr('class', CLASS.axisX) + .attr('transform', $$.getTranslate('subx')) + .attr('clip-path', config.axis_rotated ? '' : $$.clipPathForXAxis) + .style('visibility', config.subchart_axis_x_show ? 'visible' : 'hidden'); + }; + ChartInternal.prototype.initSubchartBrush = function () { + var $$ = this; + // Add extent rect for Brush + $$.initBrush($$.subX).updateExtent(); + $$.context.select('.' + CLASS.brush).call($$.brush); + }; + ChartInternal.prototype.updateTargetsForSubchart = function (targets) { + var $$ = this, context = $$.context, config = $$.config, contextLineEnter, contextLine, contextBarEnter, contextBar, classChartBar = $$.classChartBar.bind($$), classBars = $$.classBars.bind($$), classChartLine = $$.classChartLine.bind($$), classLines = $$.classLines.bind($$), classAreas = $$.classAreas.bind($$); + //-- Bar --// + contextBar = context + .select('.' + CLASS.chartBars) + .selectAll('.' + CLASS.chartBar) + .data(targets); + contextBarEnter = contextBar + .enter() + .append('g') + .style('opacity', 0); + contextBarEnter.merge(contextBar).attr('class', classChartBar); + // Bars for each data + contextBarEnter.append('g').attr('class', classBars); + //-- Line --// + contextLine = context + .select('.' + CLASS.chartLines) + .selectAll('.' + CLASS.chartLine) + .data(targets); + contextLineEnter = contextLine + .enter() + .append('g') + .style('opacity', 0); + contextLineEnter.merge(contextLine).attr('class', classChartLine); + // Lines for each data + contextLineEnter.append('g').attr('class', classLines); + // Area + contextLineEnter.append('g').attr('class', classAreas); + //-- Brush --// + context + .selectAll('.' + CLASS.brush + ' rect') + .attr(config.axis_rotated ? 'width' : 'height', config.axis_rotated ? $$.width2 : $$.height2); + }; + ChartInternal.prototype.updateBarForSubchart = function (durationForExit) { + var $$ = this; + var contextBar = $$.context + .selectAll('.' + CLASS.bars) + .selectAll('.' + CLASS.bar) + .data($$.barData.bind($$)); + var contextBarEnter = contextBar + .enter() + .append('path') + .attr('class', $$.classBar.bind($$)) + .style('stroke', 'none') + .style('fill', $$.color); + contextBar + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextBar = contextBarEnter + .merge(contextBar) + .style('opacity', $$.initialOpacity.bind($$)); + }; + ChartInternal.prototype.redrawBarForSubchart = function (drawBarOnSub, withTransition, duration) { + (withTransition + ? this.contextBar.transition(Math.random().toString()).duration(duration) + : this.contextBar) + .attr('d', drawBarOnSub) + .style('opacity', 1); + }; + ChartInternal.prototype.updateLineForSubchart = function (durationForExit) { + var $$ = this; + var contextLine = $$.context + .selectAll('.' + CLASS.lines) + .selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + var contextLineEnter = contextLine + .enter() + .append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + contextLine + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextLine = contextLineEnter + .merge(contextLine) + .style('opacity', $$.initialOpacity.bind($$)); + }; + ChartInternal.prototype.redrawLineForSubchart = function (drawLineOnSub, withTransition, duration) { + (withTransition + ? this.contextLine.transition(Math.random().toString()).duration(duration) + : this.contextLine) + .attr('d', drawLineOnSub) + .style('opacity', 1); + }; + ChartInternal.prototype.updateAreaForSubchart = function (durationForExit) { + var $$ = this, d3 = $$.d3; + var contextArea = $$.context + .selectAll('.' + CLASS.areas) + .selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + var contextAreaEnter = contextArea + .enter() + .append('path') + .attr('class', $$.classArea.bind($$)) + .style('fill', $$.color) + .style('opacity', function () { + $$.orgAreaOpacity = +d3.select(this).style('opacity'); + return 0; + }); + contextArea + .exit() + .transition() + .duration(durationForExit) + .style('opacity', 0) + .remove(); + $$.contextArea = contextAreaEnter.merge(contextArea).style('opacity', 0); + }; + ChartInternal.prototype.redrawAreaForSubchart = function (drawAreaOnSub, withTransition, duration) { + (withTransition + ? this.contextArea.transition(Math.random().toString()).duration(duration) + : this.contextArea) + .attr('d', drawAreaOnSub) + .style('fill', this.color) + .style('opacity', this.orgAreaOpacity); + }; + ChartInternal.prototype.redrawSubchart = function (withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices) { + var $$ = this, d3 = $$.d3, drawAreaOnSub, drawBarOnSub, drawLineOnSub; + // reflect main chart to extent on subchart if zoomed + if (d3.event && d3.event.type === 'zoom') { + $$.brush.selectionAsValue($$.x.orgDomain()); + } + // update subchart elements if needed + if (withSubchart) { + // extent rect + if (!$$.brush.empty()) { + $$.brush.selectionAsValue($$.x.orgDomain()); + } + // setup drawer - MEMO: this must be called after axis updated + drawAreaOnSub = $$.generateDrawArea(areaIndices, true); + drawBarOnSub = $$.generateDrawBar(barIndices, true); + drawLineOnSub = $$.generateDrawLine(lineIndices, true); + $$.updateBarForSubchart(duration); + $$.updateLineForSubchart(duration); + $$.updateAreaForSubchart(duration); + $$.redrawBarForSubchart(drawBarOnSub, duration, duration); + $$.redrawLineForSubchart(drawLineOnSub, duration, duration); + $$.redrawAreaForSubchart(drawAreaOnSub, duration, duration); + } + }; + ChartInternal.prototype.redrawForBrush = function () { + var $$ = this, x = $$.x, d3 = $$.d3, s; + $$.redraw({ + withTransition: false, + withY: $$.config.zoom_rescale, + withSubchart: false, + withUpdateXDomain: true, + withEventRect: false, + withDimension: false + }); + // update zoom transation binded to event rect + s = d3.event.selection || $$.brush.scale.range(); + $$.main + .select('.' + CLASS.eventRect) + .call($$.zoom.transform, d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0)); + $$.config.subchart_onbrush.call($$.api, x.orgDomain()); + }; + ChartInternal.prototype.transformContext = function (withTransition, transitions) { + var $$ = this, subXAxis; + if (transitions && transitions.axisSubX) { + subXAxis = transitions.axisSubX; + } + else { + subXAxis = $$.context.select('.' + CLASS.axisX); + if (withTransition) { + subXAxis = subXAxis.transition(); + } + } + $$.context.attr('transform', $$.getTranslate('context')); + subXAxis.attr('transform', $$.getTranslate('subx')); + }; + ChartInternal.prototype.getDefaultSelection = function () { + var $$ = this, config = $$.config, selection = isFunction(config.axis_x_selection) + ? config.axis_x_selection($$.getXDomain($$.data.targets)) + : config.axis_x_selection; + if ($$.isTimeSeries()) { + selection = [$$.parseDate(selection[0]), $$.parseDate(selection[1])]; + } + return selection; + }; + ChartInternal.prototype.removeSubchart = function () { + var $$ = this; + $$.brush = null; + $$.context.remove(); + $$.context = null; + }; + + ChartInternal.prototype.initText = function () { + var $$ = this; + $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.chartTexts); + $$.mainText = $$.d3.selectAll([]); + }; + ChartInternal.prototype.updateTargetsForText = function (targets) { + var $$ = this, classChartText = $$.classChartText.bind($$), classTexts = $$.classTexts.bind($$), classFocus = $$.classFocus.bind($$); + var mainText = $$.main + .select('.' + CLASS.chartTexts) + .selectAll('.' + CLASS.chartText) + .data(targets); + var mainTextEnter = mainText + .enter() + .append('g') + .attr('class', classChartText) + .style('opacity', 0) + .style('pointer-events', 'none'); + mainTextEnter.append('g').attr('class', classTexts); + mainTextEnter.merge(mainText).attr('class', function (d) { + return classChartText(d) + classFocus(d); + }); + }; + ChartInternal.prototype.updateText = function (xForText, yForText, durationForExit) { + var $$ = this, config = $$.config, barOrLineData = $$.barOrLineData.bind($$), classText = $$.classText.bind($$); + var mainText = $$.main + .selectAll('.' + CLASS.texts) + .selectAll('.' + CLASS.text) + .data(barOrLineData); + var mainTextEnter = mainText + .enter() + .append('text') + .attr('class', classText) + .attr('text-anchor', function (d) { + return config.axis_rotated ? (d.value < 0 ? 'end' : 'start') : 'middle'; + }) + .style('stroke', 'none') + .attr('x', xForText) + .attr('y', yForText) + .style('fill', function (d) { + return $$.color(d); + }) + .style('fill-opacity', 0); + $$.mainText = mainTextEnter.merge(mainText).text(function (d, i, j) { + return $$.dataLabelFormat(d.id)(d.value, d.id, i, j); + }); + mainText + .exit() + .transition() + .duration(durationForExit) + .style('fill-opacity', 0) + .remove(); + }; + ChartInternal.prototype.redrawText = function (xForText, yForText, forFlow, withTransition, transition) { + return [ + (withTransition ? this.mainText.transition(transition) : this.mainText) + .attr('x', xForText) + .attr('y', yForText) + .style('fill', this.color) + .style('fill-opacity', forFlow ? 0 : this.opacityForText.bind(this)) + ]; + }; + ChartInternal.prototype.getTextRect = function (text, cls, element) { + var dummy = this.d3 + .select('body') + .append('div') + .classed('c3', true), svg = dummy + .append('svg') + .style('visibility', 'hidden') + .style('position', 'fixed') + .style('top', 0) + .style('left', 0), font = this.d3.select(element).style('font'), rect; + svg + .selectAll('.dummy') + .data([text]) + .enter() + .append('text') + .classed(cls ? cls : '', true) + .style('font', font) + .text(text) + .each(function () { + rect = getBBox(this); + }); + dummy.remove(); + return rect; + }; + ChartInternal.prototype.generateXYForText = function (areaIndices, barIndices, lineIndices, forX) { + var $$ = this, getAreaPoints = $$.generateGetAreaPoints(areaIndices, false), getBarPoints = $$.generateGetBarPoints(barIndices, false), getLinePoints = $$.generateGetLinePoints(lineIndices, false), getter = forX ? $$.getXForText : $$.getYForText; + return function (d, i) { + var getPoints = $$.isAreaType(d) + ? getAreaPoints + : $$.isBarType(d) + ? getBarPoints + : getLinePoints; + return getter.call($$, getPoints(d, i), d, this); + }; + }; + ChartInternal.prototype.getXForText = function (points, d, textElement) { + var $$ = this, box = getBBox(textElement), xPos, padding; + if ($$.config.axis_rotated) { + padding = $$.isBarType(d) ? 4 : 6; + xPos = points[2][1] + padding * (d.value < 0 ? -1 : 1); + } + else { + xPos = $$.hasType('bar') ? (points[2][0] + points[0][0]) / 2 : points[0][0]; + } + // show labels regardless of the domain if value is null + if (d.value === null) { + if (xPos > $$.width) { + xPos = $$.width - box.width; + } + else if (xPos < 0) { + xPos = 4; + } + } + return xPos; + }; + ChartInternal.prototype.getYForText = function (points, d, textElement) { + var $$ = this, box = getBBox(textElement), yPos; + if ($$.config.axis_rotated) { + yPos = (points[0][0] + points[2][0] + box.height * 0.6) / 2; + } + else { + yPos = points[2][1]; + if (d.value < 0 || (d.value === 0 && !$$.hasPositiveValue)) { + yPos += box.height; + if ($$.isBarType(d) && $$.isSafari()) { + yPos -= 3; + } + else if (!$$.isBarType(d) && $$.isChrome()) { + yPos += 3; + } + } + else { + yPos += $$.isBarType(d) ? -3 : -6; + } + } + // show labels regardless of the domain if value is null + if (d.value === null && !$$.config.axis_rotated) { + if (yPos < box.height) { + yPos = box.height; + } + else if (yPos > this.height) { + yPos = this.height - 4; + } + } + return yPos; + }; + + ChartInternal.prototype.initTitle = function () { + var $$ = this; + $$.title = $$.svg + .append('text') + .text($$.config.title_text) + .attr('class', $$.CLASS.title); + }; + ChartInternal.prototype.redrawTitle = function () { + var $$ = this; + $$.title.attr('x', $$.xForTitle.bind($$)).attr('y', $$.yForTitle.bind($$)); + }; + ChartInternal.prototype.xForTitle = function () { + var $$ = this, config = $$.config, position = config.title_position || 'left', x; + if (position.indexOf('right') >= 0) { + x = + $$.currentWidth - + $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()).width - + config.title_padding.right; + } + else if (position.indexOf('center') >= 0) { + x = Math.max(($$.currentWidth - + $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()).width) / + 2, 0); + } + else { + // left + x = config.title_padding.left; + } + return x; + }; + ChartInternal.prototype.yForTitle = function () { + var $$ = this; + return ($$.config.title_padding.top + + $$.getTextRect($$.title.node().textContent, $$.CLASS.title, $$.title.node()) + .height); + }; + ChartInternal.prototype.getTitlePadding = function () { + var $$ = this; + return $$.yForTitle() + $$.config.title_padding.bottom; + }; + + function powerOfTen(d) { + return d / Math.pow(10, Math.ceil(Math.log(d) / Math.LN10 - 1e-12)) === 1; + } + ChartInternal.prototype.drawColorScale = function () { + var $$ = this, d3 = $$.d3, config = $$.config, target = $$.data.targets[0], barWidth, barHeight, axis, points, legendAxis, axisScale, inverseScale, height; + barWidth = !isNaN(config.stanford_scaleWidth) + ? config.stanford_scaleWidth + : 20; + barHeight = 5; + if (barHeight < 0 || barWidth < 0) { + throw Error("Colorscale's barheight and barwidth must be greater than 0."); + } + height = + $$.height - config.stanford_padding.bottom - config.stanford_padding.top; + points = d3.range(config.stanford_padding.bottom, height, barHeight); + inverseScale = d3 + .scaleSequential(target.colors) + .domain([points[points.length - 1], points[0]]); + if ($$.colorScale) { + $$.colorScale.remove(); + } + $$.colorScale = $$.svg + .append('g') + .attr('width', 50) + .attr('height', height) + .attr('class', CLASS.colorScale); + $$.colorScale + .append('g') + .attr('transform', "translate(0, " + config.stanford_padding.top + ")") + .selectAll('bars') + .data(points) + .enter() + .append('rect') + .attr('y', function (d, i) { return i * barHeight; }) + .attr('x', 0) + .attr('width', barWidth) + .attr('height', barHeight) + .attr('fill', function (d) { + return inverseScale(d); + }); + // Legend Axis + axisScale = d3 + .scaleLog() + .domain([target.minEpochs, target.maxEpochs]) + .range([ + points[0] + + config.stanford_padding.top + + points[points.length - 1] + + barHeight - + 1, + points[0] + config.stanford_padding.top + ]); + legendAxis = d3.axisRight(axisScale); + if (config.stanford_scaleFormat === 'pow10') { + legendAxis.tickValues([1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]); + } + else if (isFunction(config.stanford_scaleFormat)) { + legendAxis.tickFormat(config.stanford_scaleFormat); + } + else { + legendAxis.tickFormat(d3.format('d')); + } + if (isFunction(config.stanford_scaleValues)) { + legendAxis.tickValues(config.stanford_scaleValues(target.minEpochs, target.maxEpochs)); + } + // Draw Axis + axis = $$.colorScale + .append('g') + .attr('class', 'legend axis') + .attr('transform', "translate(" + barWidth + ",0)") + .call(legendAxis); + if (config.stanford_scaleFormat === 'pow10') { + axis + .selectAll('.tick text') + .text(null) + .filter(powerOfTen) + .text(10) + .append('tspan') + .attr('dy', '-.7em') // https://bl.ocks.org/mbostock/6738229 + .text(function (d) { + return Math.round(Math.log(d) / Math.LN10); + }); + } + $$.colorScale.attr('transform', "translate(" + ($$.currentWidth - $$.xForColorScale()) + ", 0)"); + }; + ChartInternal.prototype.xForColorScale = function () { + var $$ = this; + return $$.config.stanford_padding.right + getBBox($$.colorScale.node()).width; + }; + ChartInternal.prototype.getColorScalePadding = function () { + var $$ = this; + return $$.xForColorScale() + $$.config.stanford_padding.left + 20; + }; + + ChartInternal.prototype.isStanfordGraphType = function () { + var $$ = this; + return $$.config.data_type === 'stanford'; + }; + ChartInternal.prototype.initStanfordData = function () { + var $$ = this, d3 = $$.d3, config = $$.config, target = $$.data.targets[0], epochs, maxEpochs, minEpochs; + // Make larger values appear on top + target.values.sort(compareEpochs); + // Get array of epochs + epochs = target.values.map(function (a) { return a.epochs; }); + minEpochs = !isNaN(config.stanford_scaleMin) + ? config.stanford_scaleMin + : d3.min(epochs); + maxEpochs = !isNaN(config.stanford_scaleMax) + ? config.stanford_scaleMax + : d3.max(epochs); + if (minEpochs > maxEpochs) { + throw Error('Number of minEpochs has to be smaller than maxEpochs'); + } + target.colors = isFunction(config.stanford_colors) + ? config.stanford_colors + : d3.interpolateHslLong(d3.hsl(250, 1, 0.5), d3.hsl(0, 1, 0.5)); + target.colorscale = d3 + .scaleSequentialLog(target.colors) + .domain([minEpochs, maxEpochs]); + target.minEpochs = minEpochs; + target.maxEpochs = maxEpochs; + }; + ChartInternal.prototype.getStanfordPointColor = function (d) { + var $$ = this, target = $$.data.targets[0]; + return target.colorscale(d.epochs); + }; + // http://jsfiddle.net/Xotic750/KtzLq/ + ChartInternal.prototype.getCentroid = function (points) { + var area = getRegionArea(points); + var x = 0, y = 0, i, j, f, point1, point2; + for (i = 0, j = points.length - 1; i < points.length; j = i, i += 1) { + point1 = points[i]; + point2 = points[j]; + f = point1.x * point2.y - point2.x * point1.y; + x += (point1.x + point2.x) * f; + y += (point1.y + point2.y) * f; + } + f = area * 6; + return { + x: x / f, + y: y / f + }; + }; + ChartInternal.prototype.getStanfordTooltipTitle = function (d) { + var $$ = this, labelX = $$.axis.getLabelText('x'), labelY = $$.axis.getLabelText('y'); + return "\n " + (labelX ? sanitise(labelX) : 'x') + "" + d.x + "\n " + (labelY ? sanitise(labelY) : 'y') + "" + d.value + "\n "; + }; + ChartInternal.prototype.countEpochsInRegion = function (region) { + var $$ = this, target = $$.data.targets[0], total, count; + total = target.values.reduce(function (accumulator, currentValue) { return accumulator + Number(currentValue.epochs); }, 0); + count = target.values.reduce(function (accumulator, currentValue) { + if (pointInRegion(currentValue, region)) { + return accumulator + Number(currentValue.epochs); + } + return accumulator; + }, 0); + return { + value: count, + percentage: count !== 0 ? ((count / total) * 100).toFixed(1) : 0 + }; + }; + var getRegionArea = function (points) { + // thanks to: https://stackoverflow.com/questions/16282330/find-centerpoint-of-polygon-in-javascript + var area = 0, i, j, point1, point2; + for (i = 0, j = points.length - 1; i < points.length; j = i, i += 1) { + point1 = points[i]; + point2 = points[j]; + area += point1.x * point2.y; + area -= point1.y * point2.x; + } + area /= 2; + return area; + }; + var pointInRegion = function (point, region) { + // thanks to: http://bl.ocks.org/bycoffe/5575904 + // ray-casting algorithm based on + // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html + var xi, yi, yj, xj, intersect, x = point.x, y = point.value, inside = false; + for (var i = 0, j = region.length - 1; i < region.length; j = i++) { + xi = region[i].x; + yi = region[i].y; + xj = region[j].x; + yj = region[j].y; + intersect = yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi; + if (intersect) { + inside = !inside; + } + } + return inside; + }; + var compareEpochs = function (a, b) { + if (a.epochs < b.epochs) { + return -1; + } + if (a.epochs > b.epochs) { + return 1; + } + return 0; + }; + + ChartInternal.prototype.initStanfordElements = function () { + var $$ = this; + // Avoid blocking eventRect + $$.stanfordElements = $$.main + .select('.' + CLASS.chart) + .append('g') + .attr('class', CLASS.stanfordElements); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordLines); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordTexts); + $$.stanfordElements.append('g').attr('class', CLASS.stanfordRegions); + }; + ChartInternal.prototype.updateStanfordElements = function (duration) { + var $$ = this, main = $$.main, config = $$.config, stanfordLine, stanfordLineEnter, stanfordRegion, stanfordRegionEnter, stanfordText, stanfordTextEnter, xvCustom = $$.xvCustom.bind($$), yvCustom = $$.yvCustom.bind($$), countPointsInRegion = $$.countEpochsInRegion.bind($$); + // Stanford-Lines + stanfordLine = main + .select('.' + CLASS.stanfordLines) + .style('shape-rendering', 'geometricprecision') + .selectAll('.' + CLASS.stanfordLine) + .data(config.stanford_lines); + // enter + stanfordLineEnter = stanfordLine + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.stanfordLine + (d['class'] ? ' ' + d['class'] : ''); + }); + stanfordLineEnter + .append('line') + .attr('x1', function (d) { + return config.axis_rotated ? yvCustom(d, 'value_y1') : xvCustom(d, 'value_x1'); + }) + .attr('x2', function (d) { + return config.axis_rotated ? yvCustom(d, 'value_y2') : xvCustom(d, 'value_x2'); + }) + .attr('y1', function (d) { + return config.axis_rotated ? xvCustom(d, 'value_x1') : yvCustom(d, 'value_y1'); + }) + .attr('y2', function (d) { + return config.axis_rotated ? xvCustom(d, 'value_x2') : yvCustom(d, 'value_y2'); + }) + .style('opacity', 0); + // update + $$.stanfordLines = stanfordLineEnter.merge(stanfordLine); + $$.stanfordLines + .select('line') + .transition() + .duration(duration) + .attr('x1', function (d) { + return config.axis_rotated ? yvCustom(d, 'value_y1') : xvCustom(d, 'value_x1'); + }) + .attr('x2', function (d) { + return config.axis_rotated ? yvCustom(d, 'value_y2') : xvCustom(d, 'value_x2'); + }) + .attr('y1', function (d) { + return config.axis_rotated ? xvCustom(d, 'value_x1') : yvCustom(d, 'value_y1'); + }) + .attr('y2', function (d) { + return config.axis_rotated ? xvCustom(d, 'value_x2') : yvCustom(d, 'value_y2'); + }) + .style('opacity', 1); + // exit + stanfordLine + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + // Stanford-Text + stanfordText = main + .select('.' + CLASS.stanfordTexts) + .selectAll('.' + CLASS.stanfordText) + .data(config.stanford_texts); + // enter + stanfordTextEnter = stanfordText + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.stanfordText + (d['class'] ? ' ' + d['class'] : ''); + }); + stanfordTextEnter + .append('text') + .attr('x', function (d) { return (config.axis_rotated ? yvCustom(d, 'y') : xvCustom(d, 'x')); }) + .attr('y', function (d) { return (config.axis_rotated ? xvCustom(d, 'x') : yvCustom(d, 'y')); }) + .style('opacity', 0); + // update + $$.stanfordTexts = stanfordTextEnter.merge(stanfordText); + $$.stanfordTexts + .select('text') + .transition() + .duration(duration) + .attr('x', function (d) { return (config.axis_rotated ? yvCustom(d, 'y') : xvCustom(d, 'x')); }) + .attr('y', function (d) { return (config.axis_rotated ? xvCustom(d, 'x') : yvCustom(d, 'y')); }) + .text(function (d) { + return d.content; + }) + .style('opacity', 1); + // exit + stanfordText + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + // Stanford-Regions + stanfordRegion = main + .select('.' + CLASS.stanfordRegions) + .selectAll('.' + CLASS.stanfordRegion) + .data(config.stanford_regions); + // enter + stanfordRegionEnter = stanfordRegion + .enter() + .append('g') + .attr('class', function (d) { + return CLASS.stanfordRegion + (d['class'] ? ' ' + d['class'] : ''); + }); + stanfordRegionEnter + .append('polygon') + .attr('points', function (d) { + return d.points + .map(function (value) { + return [ + config.axis_rotated ? yvCustom(value, 'y') : xvCustom(value, 'x'), + config.axis_rotated ? xvCustom(value, 'x') : yvCustom(value, 'y') + ].join(','); + }) + .join(' '); + }) + .style('opacity', 0); + stanfordRegionEnter + .append('text') + .attr('x', function (d) { return $$.getCentroid(d.points).x; }) + .attr('y', function (d) { return $$.getCentroid(d.points).y; }) + .style('opacity', 0); + // update + $$.stanfordRegions = stanfordRegionEnter.merge(stanfordRegion); + $$.stanfordRegions + .select('polygon') + .transition() + .duration(duration) + .attr('points', function (d) { + return d.points + .map(function (value) { + return [ + config.axis_rotated ? yvCustom(value, 'y') : xvCustom(value, 'x'), + config.axis_rotated ? xvCustom(value, 'x') : yvCustom(value, 'y') + ].join(','); + }) + .join(' '); + }) + .style('opacity', function (d) { + return d.opacity ? d.opacity : 0.2; + }); + $$.stanfordRegions + .select('text') + .transition() + .duration(duration) + .attr('x', function (d) { + return config.axis_rotated + ? yvCustom($$.getCentroid(d.points), 'y') + : xvCustom($$.getCentroid(d.points), 'x'); + }) + .attr('y', function (d) { + return config.axis_rotated + ? xvCustom($$.getCentroid(d.points), 'x') + : yvCustom($$.getCentroid(d.points), 'y'); + }) + .text(function (d) { + if (d.text) { + var value, percentage, temp; + if ($$.isStanfordGraphType()) { + temp = countPointsInRegion(d.points); + value = temp.value; + percentage = temp.percentage; + } + return d.text(value, percentage); + } + return ''; + }) + .attr('text-anchor', 'middle') + .attr('dominant-baseline', 'middle') + .style('opacity', 1); + // exit + stanfordRegion + .exit() + .transition() + .duration(duration) + .style('opacity', 0) + .remove(); + }; + + ChartInternal.prototype.initTooltip = function () { + var $$ = this, config = $$.config, i; + $$.tooltip = $$.selectChart + .style('position', 'relative') + .append('div') + .attr('class', CLASS.tooltipContainer) + .style('position', 'absolute') + .style('pointer-events', 'none') + .style('display', 'none'); + // Show tooltip if needed + if (config.tooltip_init_show) { + if ($$.isTimeSeries() && isString(config.tooltip_init_x)) { + config.tooltip_init_x = $$.parseDate(config.tooltip_init_x); + for (i = 0; i < $$.data.targets[0].values.length; i++) { + if ($$.data.targets[0].values[i].x - config.tooltip_init_x === 0) { + break; + } + } + config.tooltip_init_x = i; + } + $$.tooltip.html(config.tooltip_contents.call($$, $$.data.targets.map(function (d) { + return $$.addName(d.values[config.tooltip_init_x]); + }), $$.axis.getXAxisTickFormat(), $$.getYFormat($$.hasArcType()), $$.color)); + $$.tooltip + .style('top', config.tooltip_init_position.top) + .style('left', config.tooltip_init_position.left) + .style('display', 'block'); + } + }; + ChartInternal.prototype.getTooltipSortFunction = function () { + var $$ = this, config = $$.config; + if (config.data_groups.length === 0 || config.tooltip_order !== undefined) { + // if data are not grouped or if an order is specified + // for the tooltip values we sort them by their values + var order = config.tooltip_order; + if (order === undefined) { + order = config.data_order; + } + var valueOf = function (obj) { + return obj ? obj.value : null; + }; + // if data are not grouped, we sort them by their value + if (isString(order) && order.toLowerCase() === 'asc') { + return function (a, b) { + return valueOf(a) - valueOf(b); + }; + } + else if (isString(order) && order.toLowerCase() === 'desc') { + return function (a, b) { + return valueOf(b) - valueOf(a); + }; + } + else if (isFunction(order)) { + // if the function is from data_order we need + // to wrap the returned function in order to format + // the sorted value to the expected format + var sortFunction = order; + if (config.tooltip_order === undefined) { + sortFunction = function (a, b) { + return order(a + ? { + id: a.id, + values: [a] + } + : null, b + ? { + id: b.id, + values: [b] + } + : null); + }; + } + return sortFunction; + } + else if (isArray(order)) { + return function (a, b) { + return order.indexOf(a.id) - order.indexOf(b.id); + }; + } + } + else { + // if data are grouped, we follow the order of grouped targets + var ids = $$.orderTargets($$.data.targets).map(function (i) { + return i.id; + }); + // if it was either asc or desc we need to invert the order + // returned by orderTargets + if ($$.isOrderAsc() || $$.isOrderDesc()) { + ids = ids.reverse(); + } + return function (a, b) { + return ids.indexOf(a.id) - ids.indexOf(b.id); + }; + } + }; + ChartInternal.prototype.getTooltipContent = function (d, defaultTitleFormat, defaultValueFormat, color) { + var $$ = this, config = $$.config, titleFormat = config.tooltip_format_title || defaultTitleFormat, nameFormat = config.tooltip_format_name || + function (name) { + return name; + }, text, i, title, value, name, bgcolor; + var valueFormat = config.tooltip_format_value; + if (!valueFormat) { + valueFormat = $$.isTargetNormalized(d.id) + ? function (v, ratio) { return (ratio * 100).toFixed(2) + "%"; } + : defaultValueFormat; + } + var tooltipSortFunction = this.getTooltipSortFunction(); + if (tooltipSortFunction) { + d.sort(tooltipSortFunction); + } + for (i = 0; i < d.length; i++) { + if (!(d[i] && (d[i].value || d[i].value === 0))) { + continue; + } + if ($$.isStanfordGraphType()) { + // Custom tooltip for stanford plots + if (!text) { + title = $$.getStanfordTooltipTitle(d[i]); + text = "" + title; + } + bgcolor = $$.getStanfordPointColor(d[i]); + name = sanitise(config.data_epochs); // Epochs key name + value = d[i].epochs; + } + else { + // Regular tooltip + if (!text) { + title = sanitise(titleFormat ? titleFormat(d[i].x, d[i].index) : d[i].x); + text = + "
" + + (title || title === 0 + ? "' + : ''); + } + value = sanitise(valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index, d)); + if (value !== undefined) { + // Skip elements when their name is set to null + if (d[i].name === null) { + continue; + } + name = sanitise(nameFormat(d[i].name, d[i].ratio, d[i].id, d[i].index)); + bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); + } + } + if (value !== undefined) { + text += + ""; + text += + "'; + text += "'; + text += ''; + } + } + return text + '
" + title + '
" + + name + + '" + value + '
'; + }; + ChartInternal.prototype.tooltipPosition = function (dataToShow, tWidth, tHeight, element) { + var $$ = this, config = $$.config, d3 = $$.d3; + var svgLeft, tooltipLeft, tooltipRight, tooltipTop, chartRight; + var forArc = $$.hasArcType(), mouse = d3.mouse(element); + // Determin tooltip position + if (forArc) { + tooltipLeft = + ($$.width - ($$.isLegendRight ? $$.getLegendWidth() : 0)) / 2 + mouse[0]; + tooltipTop = + ($$.hasType('gauge') ? $$.height : $$.height / 2) + mouse[1] + 20; + } + else { + svgLeft = $$.getSvgLeft(true); + if (config.axis_rotated) { + tooltipLeft = svgLeft + mouse[0] + 100; + tooltipRight = tooltipLeft + tWidth; + chartRight = $$.currentWidth - $$.getCurrentPaddingRight(); + tooltipTop = $$.x(dataToShow[0].x) + 20; + } + else { + tooltipLeft = + svgLeft + $$.getCurrentPaddingLeft(true) + $$.x(dataToShow[0].x) + 20; + tooltipRight = tooltipLeft + tWidth; + chartRight = svgLeft + $$.currentWidth - $$.getCurrentPaddingRight(); + tooltipTop = mouse[1] + 15; + } + if (tooltipRight > chartRight) { + // 20 is needed for Firefox to keep tooltip width + tooltipLeft -= tooltipRight - chartRight + 20; + } + if (tooltipTop + tHeight > $$.currentHeight) { + tooltipTop -= tHeight + 30; + } + } + if (tooltipTop < 0) { + tooltipTop = 0; + } + return { + top: tooltipTop, + left: tooltipLeft + }; + }; + ChartInternal.prototype.showTooltip = function (selectedData, element) { + var $$ = this, config = $$.config; + var tWidth, tHeight, position; + var forArc = $$.hasArcType(), dataToShow = selectedData.filter(function (d) { + return d && isValue(d.value); + }), positionFunction = config.tooltip_position || ChartInternal.prototype.tooltipPosition; + if (dataToShow.length === 0 || !config.tooltip_show) { + $$.hideTooltip(); + return; + } + $$.tooltip + .html(config.tooltip_contents.call($$, selectedData, $$.axis.getXAxisTickFormat(), $$.getYFormat(forArc), $$.color)) + .style('display', 'block'); + // Get tooltip dimensions + tWidth = $$.tooltip.property('offsetWidth'); + tHeight = $$.tooltip.property('offsetHeight'); + position = positionFunction.call(this, dataToShow, tWidth, tHeight, element); + // Set tooltip + $$.tooltip + .style('top', position.top + 'px') + .style('left', position.left + 'px'); + }; + ChartInternal.prototype.hideTooltip = function () { + this.tooltip.style('display', 'none'); + }; + + ChartInternal.prototype.setTargetType = function (targetIds, type) { + var $$ = this, config = $$.config; + $$.mapToTargetIds(targetIds).forEach(function (id) { + $$.withoutFadeIn[id] = type === config.data_types[id]; + config.data_types[id] = type; + }); + if (!targetIds) { + config.data_type = type; + } + }; + ChartInternal.prototype.hasType = function (type, targets) { + var $$ = this, types = $$.config.data_types, has = false; + targets = targets || $$.data.targets; + if (targets && targets.length) { + targets.forEach(function (target) { + var t = types[target.id]; + if ((t && t.indexOf(type) >= 0) || (!t && type === 'line')) { + has = true; + } + }); + } + else if (Object.keys(types).length) { + Object.keys(types).forEach(function (id) { + if (types[id] === type) { + has = true; + } + }); + } + else { + has = $$.config.data_type === type; + } + return has; + }; + ChartInternal.prototype.hasArcType = function (targets) { + return (this.hasType('pie', targets) || + this.hasType('donut', targets) || + this.hasType('gauge', targets)); + }; + ChartInternal.prototype.isLineType = function (d) { + var config = this.config, id = isString(d) ? d : d.id; + return (!config.data_types[id] || + ['line', 'spline', 'area', 'area-spline', 'step', 'area-step'].indexOf(config.data_types[id]) >= 0); + }; + ChartInternal.prototype.isStepType = function (d) { + var id = isString(d) ? d : d.id; + return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0; + }; + ChartInternal.prototype.isSplineType = function (d) { + var id = isString(d) ? d : d.id; + return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0; + }; + ChartInternal.prototype.isAreaType = function (d) { + var id = isString(d) ? d : d.id; + return (['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= + 0); + }; + ChartInternal.prototype.isBarType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'bar'; + }; + ChartInternal.prototype.isScatterType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'scatter'; + }; + ChartInternal.prototype.isStanfordType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'stanford'; + }; + ChartInternal.prototype.isPieType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'pie'; + }; + ChartInternal.prototype.isGaugeType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'gauge'; + }; + ChartInternal.prototype.isDonutType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'donut'; + }; + ChartInternal.prototype.isArcType = function (d) { + return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d); + }; + ChartInternal.prototype.lineData = function (d) { + return this.isLineType(d) ? [d] : []; + }; + ChartInternal.prototype.arcData = function (d) { + return this.isArcType(d.data) ? [d] : []; + }; + /* not used + function scatterData(d) { + return isScatterType(d) ? d.values : []; + } + */ + ChartInternal.prototype.barData = function (d) { + return this.isBarType(d) ? d.values : []; + }; + ChartInternal.prototype.lineOrScatterOrStanfordData = function (d) { + return this.isLineType(d) || this.isScatterType(d) || this.isStanfordType(d) + ? d.values + : []; + }; + ChartInternal.prototype.barOrLineData = function (d) { + return this.isBarType(d) || this.isLineType(d) ? d.values : []; + }; + + ChartInternal.prototype.isSafari = function () { + var ua = window.navigator.userAgent; + return ua.indexOf('Safari') >= 0 && ua.indexOf('Chrome') < 0; + }; + ChartInternal.prototype.isChrome = function () { + var ua = window.navigator.userAgent; + return ua.indexOf('Chrome') >= 0; + }; + + ChartInternal.prototype.initZoom = function () { + var $$ = this, d3 = $$.d3, config = $$.config, startEvent; + $$.zoom = d3 + .zoom() + .on('start', function () { + if (config.zoom_type !== 'scroll') { + return; + } + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return; + } + startEvent = e; + config.zoom_onzoomstart.call($$.api, e); + }) + .on('zoom', function () { + if (config.zoom_type !== 'scroll') { + return; + } + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return; + } + $$.redrawForZoom(); + config.zoom_onzoom.call($$.api, $$.x.orgDomain()); + }) + .on('end', function () { + if (config.zoom_type !== 'scroll') { + return; + } + var e = d3.event.sourceEvent; + if (e && e.type === 'brush') { + return; + } + // if click, do nothing. otherwise, click interaction will be canceled. + if (e && + startEvent.clientX === e.clientX && + startEvent.clientY === e.clientY) { + return; + } + config.zoom_onzoomend.call($$.api, $$.x.orgDomain()); + }); + $$.zoom.updateDomain = function () { + if (d3.event && d3.event.transform) { + if (config.axis_rotated && config.zoom_type === 'scroll' && d3.event.sourceEvent.type === 'mousemove') { + // we're moving the mouse in a rotated chart with zoom = "scroll", so we need rescaleY (i.e. vertical) + $$.x.domain(d3.event.transform.rescaleY($$.subX).domain()); + } + else { + $$.x.domain(d3.event.transform.rescaleX($$.subX).domain()); + } + } + return this; + }; + $$.zoom.updateExtent = function () { + this.scaleExtent([1, Infinity]) + .translateExtent([ + [0, 0], + [$$.width, $$.height] + ]) + .extent([ + [0, 0], + [$$.width, $$.height] + ]); + return this; + }; + $$.zoom.update = function () { + return this.updateExtent().updateDomain(); + }; + return $$.zoom.updateExtent(); + }; + ChartInternal.prototype.zoomTransform = function (range) { + var $$ = this, s = [$$.x(range[0]), $$.x(range[1])]; + return $$.d3.zoomIdentity.scale($$.width / (s[1] - s[0])).translate(-s[0], 0); + }; + ChartInternal.prototype.initDragZoom = function () { + var $$ = this; + var d3 = $$.d3; + var config = $$.config; + var context = ($$.context = $$.svg); + var brushXPos = $$.margin.left + 20.5; + var brushYPos = $$.margin.top + 0.5; + if (!(config.zoom_type === 'drag' && config.zoom_enabled)) { + return; + } + var getZoomedDomain = function (selection) { + return selection && selection.map(function (x) { return $$.x.invert(x); }); + }; + var brush = ($$.dragZoomBrush = d3 + .brushX() + .on('start', function () { + $$.api.unzoom(); + $$.svg.select('.' + CLASS.dragZoom).classed('disabled', false); + config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent); + }) + .on('brush', function () { + config.zoom_onzoom.call($$.api, getZoomedDomain(d3.event.selection)); + }) + .on('end', function () { + if (d3.event.selection == null) { + return; + } + var zoomedDomain = getZoomedDomain(d3.event.selection); + if (!config.zoom_disableDefaultBehavior) { + $$.api.zoom(zoomedDomain); + } + $$.svg.select('.' + CLASS.dragZoom).classed('disabled', true); + config.zoom_onzoomend.call($$.api, zoomedDomain); + })); + context + .append('g') + .classed(CLASS.dragZoom, true) + .attr('clip-path', $$.clipPath) + .attr('transform', 'translate(' + brushXPos + ',' + brushYPos + ')') + .call(brush); + }; + ChartInternal.prototype.getZoomDomain = function () { + var $$ = this, config = $$.config, d3 = $$.d3, min = d3.min([$$.orgXDomain[0], config.zoom_x_min]), max = d3.max([$$.orgXDomain[1], config.zoom_x_max]); + return [min, max]; + }; + ChartInternal.prototype.redrawForZoom = function () { + var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x; + if (!config.zoom_enabled) { + return; + } + if ($$.filterTargetsToShow($$.data.targets).length === 0) { + return; + } + zoom.update(); + if (config.zoom_disableDefaultBehavior) { + return; + } + if ($$.isCategorized() && x.orgDomain()[0] === $$.orgXDomain[0]) { + x.domain([$$.orgXDomain[0] - 1e-10, x.orgDomain()[1]]); + } + $$.redraw({ + withTransition: false, + withY: config.zoom_rescale, + withSubchart: false, + withEventRect: false, + withDimension: false + }); + if (d3.event.sourceEvent && d3.event.sourceEvent.type === 'mousemove') { + $$.cancelClick = true; + } + }; + + return c3; + +}))); diff --git a/server/static/server/c3/docs/js/c3.min.js b/server/static/server/c3/docs/js/c3.min.js new file mode 100644 index 0000000..dc30669 --- /dev/null +++ b/server/static/server/c3/docs/js/c3.min.js @@ -0,0 +1,2 @@ +/* @license C3.js v0.7.20 | (c) C3 Team and other contributors | http://c3js.org/ */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).c3=e()}(this,function(){"use strict";function l(t){var e=this;e.d3=window.d3?window.d3:"undefined"!=typeof require?require("d3"):void 0,e.api=t,e.config=e.getDefaultConfig(),e.data={},e.cache={},e.axes={}}function n(t){this.internal=new l(this),this.internal.loadConfig(t),this.internal.beforeInit(t),this.internal.init(),this.internal.afterInit(t),function e(i,n,r){Object.keys(i).forEach(function(t){n[t]=i[t].bind(r),0/g,">"):t}function c(t){var e=function(t){void 0===t&&(t=window.navigator.userAgent);var e=t.indexOf("MSIE ");return 0e.getTotalLength())break;i--}while(0=this.numberOfItems)throw"INDEX_SIZE_ERR"},window.SVGPathSegList.prototype.getItem=function(t){return this._checkPathSynchronizedToList(),this._checkValidIndex(t),this._list[t]},window.SVGPathSegList.prototype.insertItemBefore=function(t,e){return this._checkPathSynchronizedToList(),e>this.numberOfItems&&(e=this.numberOfItems),t._owningPathSegList&&(t=t.clone()),this._list.splice(e,0,t),(t._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList.prototype.replaceItem=function(t,e){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._checkValidIndex(e),((this._list[e]=t)._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList.prototype.removeItem=function(t){this._checkPathSynchronizedToList(),this._checkValidIndex(t);var e=this._list[t];return this._list.splice(t,1),this._writeListToPath(),e},window.SVGPathSegList.prototype.appendItem=function(t){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._list.push(t),(t._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList._pathSegArrayAsString=function(t){var e="",i=!0;return t.forEach(function(t){i?(i=!1,e+=t._asPathString()):e+=" "+t._asPathString()}),e},window.SVGPathSegList.prototype._parsePath=function(t){if(!t||0==t.length)return[];function e(){this.pathSegList=[]}var n=this;e.prototype.appendSegment=function(t){this.pathSegList.push(t)};function i(t){this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=window.SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}i.prototype._isCurrentSpace=function(){var t=this._string[this._currentIndex];return t<=" "&&(" "==t||"\n"==t||"\t"==t||"\r"==t||"\f"==t)},i.prototype._skipOptionalSpaces=function(){for(;this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||"9"=this._endIndex||this._string.charAt(this._currentIndex)<"0"||"9"=this._endIndex)){var t=!1,e=this._string.charAt(this._currentIndex++);if("0"==e)t=!1;else{if("1"!=e)return;t=!0}return this._skipOptionalSpacesOrDelimiter(),t}},i.prototype.parseSegment=function(){var t=this._string[this._currentIndex],e=this._pathSegTypeFromChar(t);if(e==window.SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==window.SVGPathSeg.PATHSEG_UNKNOWN)return null;if((e=this._nextCommandHelper(t,this._previousCommand))==window.SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=e){case window.SVGPathSeg.PATHSEG_MOVETO_REL:return new window.SVGPathSegMovetoRel(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_MOVETO_ABS:return new window.SVGPathSegMovetoAbs(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_REL:return new window.SVGPathSegLinetoRel(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_ABS:return new window.SVGPathSegLinetoAbs(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new window.SVGPathSegLinetoHorizontalRel(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new window.SVGPathSegLinetoHorizontalAbs(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new window.SVGPathSegLinetoVerticalRel(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new window.SVGPathSegLinetoVerticalAbs(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new window.SVGPathSegClosePath(n);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicRel(n,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicAbs(n,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicSmoothRel(n,i.x,i.y,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:i={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoCubicSmoothAbs(n,i.x,i.y,i.x2,i.y2);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:i={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoQuadraticRel(n,i.x,i.y,i.x1,i.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:i={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegCurvetoQuadraticAbs(n,i.x,i.y,i.x1,i.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new window.SVGPathSegCurvetoQuadraticSmoothRel(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new window.SVGPathSegCurvetoQuadraticSmoothAbs(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_ARC_REL:i={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcRel(n,i.x,i.y,i.x1,i.y1,i.arcAngle,i.arcLarge,i.arcSweep);case window.SVGPathSeg.PATHSEG_ARC_ABS:i={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new window.SVGPathSegArcAbs(n,i.x,i.y,i.x1,i.y1,i.arcAngle,i.arcLarge,i.arcSweep);default:throw"Unknown path seg type."}};var r=new e,a=new i(t);if(!a.initialCommandIsMoveTo())return[];for(;a.hasMoreData();){var o=a.parseSegment();if(!o)return[];r.appendSegment(o)}return r.pathSegList}),String.prototype.padEnd||(String.prototype.padEnd=function(t,e){return t>>=0,e=String(void 0!==e?e:" "),this.length>t?String(this):((t-=this.length)>e.length&&(e+=e.repeat(t/e.length)),String(this)+e.slice(0,t))}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),n=1;n'":;\[\]\/|~`{}\\])/g,"\\$1")},l.prototype.selectorTarget=function(t,e){return(e||"")+"."+Y.target+this.getTargetSelectorSuffix(t)},l.prototype.selectorTargets=function(t,e){var i=this;return(t=t||[]).length?t.map(function(t){return i.selectorTarget(t,e)}):null},l.prototype.selectorLegend=function(t){return"."+Y.legendItem+this.getTargetSelectorSuffix(t)},l.prototype.selectorLegends=function(t){var e=this;return t&&t.length?t.map(function(t){return e.selectorLegend(t)}):null},l.prototype.getClipPath=function(t){return"url("+(c(9)?"":document.URL.split("#")[0])+"#"+t+")"},l.prototype.appendClip=function(t,e){return t.append("clipPath").attr("id",e).append("rect")},l.prototype.getAxisClipX=function(t){var e=Math.max(30,this.margin.left);return t?-(1+e):-(e-1)},l.prototype.getAxisClipY=function(t){return t?-20:-this.margin.top},l.prototype.getXAxisClipX=function(){return this.getAxisClipX(!this.config.axis_rotated)},l.prototype.getXAxisClipY=function(){return this.getAxisClipY(!this.config.axis_rotated)},l.prototype.getYAxisClipX=function(){return this.config.axis_y_inner?-1:this.getAxisClipX(this.config.axis_rotated)},l.prototype.getYAxisClipY=function(){return this.getAxisClipY(this.config.axis_rotated)},l.prototype.getAxisClipWidth=function(t){var e=Math.max(30,this.margin.left),i=Math.max(30,this.margin.right);return t?this.width+2+e+i:this.margin.left+20},l.prototype.getAxisClipHeight=function(t){return(t?this.margin.bottom:this.margin.top+this.height)+20},l.prototype.getXAxisClipWidth=function(){return this.getAxisClipWidth(!this.config.axis_rotated)},l.prototype.getXAxisClipHeight=function(){return this.getAxisClipHeight(!this.config.axis_rotated)},l.prototype.getYAxisClipWidth=function(){return this.getAxisClipWidth(this.config.axis_rotated)+(this.config.axis_y_inner?20:0)},l.prototype.getYAxisClipHeight=function(){return this.getAxisClipHeight(this.config.axis_rotated)},l.prototype.generateColor=function(){var t=this.config,e=this.d3,n=t.data_colors,r=L(t.color_pattern)?t.color_pattern:e.schemeCategory10,a=t.data_color,o=[];return function(t){var e,i=t.id||t.data&&t.data.id||t;return n[i]instanceof Function?e=n[i](t):n[i]?e=n[i]:(o.indexOf(i)<0&&o.push(i),e=r[o.indexOf(i)%r.length],n[i]=e),a instanceof Function?a(e,t):e}},l.prototype.generateLevelColor=function(){var t=this.config,n=t.color_pattern,e=t.color_threshold,r="value"===e.unit,a=e.values&&e.values.length?e.values:[],o=e.max||100;return L(e)&&L(n)?function(t){for(var e=n[n.length-1],i=0;is&&(o=o.filter(function(t){return(""+t).indexOf(".")<0}));return o},l.prototype.getGridFilterToRemove=function(t){return t?function(e){var i=!1;return[].concat(t).forEach(function(t){("value"in t&&e.value===t.value||"class"in t&&e.class===t.class)&&(i=!0)}),i}:function(){return!0}},l.prototype.removeGridLines=function(t,e){function i(t){return!r(t)}var n=this.config,r=this.getGridFilterToRemove(t),a=e?Y.xgridLines:Y.ygridLines,o=e?Y.xgridLine:Y.ygridLine;this.main.select("."+a).selectAll("."+o).filter(r).transition().duration(n.transition_duration).style("opacity",0).remove(),e?n.grid_x_lines=n.grid_x_lines.filter(i):n.grid_y_lines=n.grid_y_lines.filter(i)},l.prototype.initEventRect=function(){var t=this,e=t.config;t.main.select("."+Y.chart).append("g").attr("class",Y.eventRects).style("fill-opacity",0),t.eventRect=t.main.select("."+Y.eventRects).append("rect").attr("class",Y.eventRect),e.zoom_enabled&&t.zoom&&(t.eventRect.call(t.zoom).on("dblclick.zoom",null),e.zoom_initialRange&&t.eventRect.transition().duration(0).call(t.zoom.transform,t.zoomTransform(e.zoom_initialRange)))},l.prototype.redrawEventRect=function(){var s=this,c=s.d3,d=s.config;function l(){s.svg.select("."+Y.eventRect).style("cursor",null),s.hideXGridFocus(),s.hideTooltip(),s.unexpandCircles(),s.unexpandBars()}function u(t,e){return e&&(s.isBarType(e.id)||s.dist(e,t)i.bar_width_max?i.bar_width_max:n},l.prototype.getBars=function(t,e){return(e?this.main.selectAll("."+Y.bars+this.getTargetSelectorSuffix(e)):this.main).selectAll("."+Y.bar+(C(t)?"-"+t:""))},l.prototype.expandBars=function(t,e,i){i&&this.unexpandBars(),this.getBars(t,e).classed(Y.EXPANDED,!0)},l.prototype.unexpandBars=function(t){this.getBars(t).classed(Y.EXPANDED,!1)},l.prototype.generateDrawBar=function(t,e){var a=this.config,o=this.generateGetBarPoints(t,e);return function(t,e){var i=o(t,e),n=a.axis_rotated?1:0,r=a.axis_rotated?0:1;return"M "+i[0][n]+","+i[0][r]+" L"+i[1][n]+","+i[1][r]+" L"+i[2][n]+","+i[2][r]+" L"+i[3][n]+","+i[3][r]+" z"}},l.prototype.generateGetBarPoints=function(t,e){var o=this,i=e?o.subXAxis:o.xAxis,n=t.__max__+1,s=o.getBarW(i,n),c=o.getShapeX(s,n,t,!!e),d=o.getShapeY(!!e),l=o.getShapeOffset(o.isBarType,t,!!e),u=s*(o.config.bar_space/2),h=e?o.getSubYScale:o.getYScale;return function(t,e){var i=h.call(o,t.id)(0),n=l(t,e)||i,r=c(t),a=d(t);return o.config.axis_rotated&&(0r.width?o=r.width-a.width:o<0&&(o=4)),o},l.prototype.getYForText=function(t,e,i){var n,r=this,a=d(i);return r.config.axis_rotated?n=(t[0][0]+t[2][0]+.6*a.height)/2:(n=t[2][1],e.value<0||0===e.value&&!r.hasPositiveValue?(n+=a.height,r.isBarType(e)&&r.isSafari()?n-=3:!r.isBarType(e)&&r.isChrome()&&(n+=3)):n+=r.isBarType(e)?-3:-6),null!==e.value||r.config.axis_rotated||(nthis.height&&(n=this.height-4)),n},l.prototype.initTitle=function(){this.title=this.svg.append("text").text(this.config.title_text).attr("class",this.CLASS.title)},l.prototype.redrawTitle=function(){var t=this;t.title.attr("x",t.xForTitle.bind(t)).attr("y",t.yForTitle.bind(t))},l.prototype.xForTitle=function(){var t=this,e=t.config,i=e.title_position||"left",n=0<=i.indexOf("right")?t.currentWidth-t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).width-e.title_padding.right:0<=i.indexOf("center")?Math.max((t.currentWidth-t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).width)/2,0):e.title_padding.left;return n},l.prototype.yForTitle=function(){var t=this;return t.config.title_padding.top+t.getTextRect(t.title.node().textContent,t.CLASS.title,t.title.node()).height},l.prototype.getTitlePadding=function(){return this.yForTitle()+this.config.title_padding.bottom},l.prototype.drawColorScale=function(){var t,e,i,n,r,a,o=this,s=o.d3,c=o.config,d=o.data.targets[0],l=isNaN(c.stanford_scaleWidth)?20:c.stanford_scaleWidth;if(l<0)throw Error("Colorscale's barheight and barwidth must be greater than 0.");a=o.height-c.stanford_padding.bottom-c.stanford_padding.top,e=s.range(c.stanford_padding.bottom,a,5),r=s.scaleSequential(d.colors).domain([e[e.length-1],e[0]]),o.colorScale&&o.colorScale.remove(),o.colorScale=o.svg.append("g").attr("width",50).attr("height",a).attr("class",Y.colorScale),o.colorScale.append("g").attr("transform","translate(0, "+c.stanford_padding.top+")").selectAll("bars").data(e).enter().append("rect").attr("y",function(t,e){return 5*e}).attr("x",0).attr("width",l).attr("height",5).attr("fill",function(t){return r(t)}),n=s.scaleLog().domain([d.minEpochs,d.maxEpochs]).range([e[0]+c.stanford_padding.top+e[e.length-1]+5-1,e[0]+c.stanford_padding.top]),i=s.axisRight(n),"pow10"===c.stanford_scaleFormat?i.tickValues([1,10,100,1e3,1e4,1e5,1e6,1e7]):h(c.stanford_scaleFormat)?i.tickFormat(c.stanford_scaleFormat):i.tickFormat(s.format("d")),h(c.stanford_scaleValues)&&i.tickValues(c.stanford_scaleValues(d.minEpochs,d.maxEpochs)),t=o.colorScale.append("g").attr("class","legend axis").attr("transform","translate("+l+",0)").call(i),"pow10"===c.stanford_scaleFormat&&t.selectAll(".tick text").text(null).filter(x).text(10).append("tspan").attr("dy","-.7em").text(function(t){return Math.round(Math.log(t)/Math.LN10)}),o.colorScale.attr("transform","translate("+(o.currentWidth-o.xForColorScale())+", 0)")},l.prototype.xForColorScale=function(){return this.config.stanford_padding.right+d(this.colorScale.node()).width},l.prototype.getColorScalePadding=function(){return this.xForColorScale()+this.config.stanford_padding.left+20},l.prototype.isStanfordGraphType=function(){return"stanford"===this.config.data_type},l.prototype.initStanfordData=function(){var t,e,i,n=this.d3,r=this.config,a=this.data.targets[0];if(a.values.sort(v),t=a.values.map(function(t){return t.epochs}),i=isNaN(r.stanford_scaleMin)?n.min(t):r.stanford_scaleMin,(e=isNaN(r.stanford_scaleMax)?n.max(t):r.stanford_scaleMax)"+(e?_(e):"x")+""+t.x+"\n "+(i?_(i):"y")+""+t.value+"\n "},l.prototype.countEpochsInRegion=function(i){var t=this.data.targets[0],e=t.values.reduce(function(t,e){return t+Number(e.epochs)},0),n=t.values.reduce(function(t,e){return S(e,i)?t+Number(e.epochs):t},0);return{value:n,percentage:0!==n?(n/e*100).toFixed(1):0}};var y=function(t){for(var e,i,n=0,r=0,a=t.length-1;re.epochs?1:0};return l.prototype.initStanfordElements=function(){var t=this;t.stanfordElements=t.main.select("."+Y.chart).append("g").attr("class",Y.stanfordElements),t.stanfordElements.append("g").attr("class",Y.stanfordLines),t.stanfordElements.append("g").attr("class",Y.stanfordTexts),t.stanfordElements.append("g").attr("class",Y.stanfordRegions)},l.prototype.updateStanfordElements=function(t){var e,i,n,r,a=this,o=a.main,s=a.config,c=a.xvCustom.bind(a),d=a.yvCustom.bind(a),l=a.countEpochsInRegion.bind(a),u=o.select("."+Y.stanfordLines).style("shape-rendering","geometricprecision").selectAll("."+Y.stanfordLine).data(s.stanford_lines),h=u.enter().append("g").attr("class",function(t){return Y.stanfordLine+(t.class?" "+t.class:"")});h.append("line").attr("x1",function(t){return s.axis_rotated?d(t,"value_y1"):c(t,"value_x1")}).attr("x2",function(t){return s.axis_rotated?d(t,"value_y2"):c(t,"value_x2")}).attr("y1",function(t){return s.axis_rotated?c(t,"value_x1"):d(t,"value_y1")}).attr("y2",function(t){return s.axis_rotated?c(t,"value_x2"):d(t,"value_y2")}).style("opacity",0),a.stanfordLines=h.merge(u),a.stanfordLines.select("line").transition().duration(t).attr("x1",function(t){return s.axis_rotated?d(t,"value_y1"):c(t,"value_x1")}).attr("x2",function(t){return s.axis_rotated?d(t,"value_y2"):c(t,"value_x2")}).attr("y1",function(t){return s.axis_rotated?c(t,"value_x1"):d(t,"value_y1")}).attr("y2",function(t){return s.axis_rotated?c(t,"value_x2"):d(t,"value_y2")}).style("opacity",1),u.exit().transition().duration(t).style("opacity",0).remove(),(r=(n=o.select("."+Y.stanfordTexts).selectAll("."+Y.stanfordText).data(s.stanford_texts)).enter().append("g").attr("class",function(t){return Y.stanfordText+(t.class?" "+t.class:"")})).append("text").attr("x",function(t){return s.axis_rotated?d(t,"y"):c(t,"x")}).attr("y",function(t){return s.axis_rotated?c(t,"x"):d(t,"y")}).style("opacity",0),a.stanfordTexts=r.merge(n),a.stanfordTexts.select("text").transition().duration(t).attr("x",function(t){return s.axis_rotated?d(t,"y"):c(t,"x")}).attr("y",function(t){return s.axis_rotated?c(t,"x"):d(t,"y")}).text(function(t){return t.content}).style("opacity",1),n.exit().transition().duration(t).style("opacity",0).remove(),(i=(e=o.select("."+Y.stanfordRegions).selectAll("."+Y.stanfordRegion).data(s.stanford_regions)).enter().append("g").attr("class",function(t){return Y.stanfordRegion+(t.class?" "+t.class:"")})).append("polygon").attr("points",function(t){return t.points.map(function(t){return[s.axis_rotated?d(t,"y"):c(t,"x"),s.axis_rotated?c(t,"x"):d(t,"y")].join(",")}).join(" ")}).style("opacity",0),i.append("text").attr("x",function(t){return a.getCentroid(t.points).x}).attr("y",function(t){return a.getCentroid(t.points).y}).style("opacity",0),a.stanfordRegions=i.merge(e),a.stanfordRegions.select("polygon").transition().duration(t).attr("points",function(t){return t.points.map(function(t){return[s.axis_rotated?d(t,"y"):c(t,"x"),s.axis_rotated?c(t,"x"):d(t,"y")].join(",")}).join(" ")}).style("opacity",function(t){return t.opacity?t.opacity:.2}),a.stanfordRegions.select("text").transition().duration(t).attr("x",function(t){return s.axis_rotated?d(a.getCentroid(t.points),"y"):c(a.getCentroid(t.points),"x")}).attr("y",function(t){return s.axis_rotated?c(a.getCentroid(t.points),"x"):d(a.getCentroid(t.points),"y")}).text(function(t){var e,i,n;return t.text?(a.isStanfordGraphType()&&(e=(n=l(t.points)).value,i=n.percentage),t.text(e,i)):""}).attr("text-anchor","middle").attr("dominant-baseline","middle").style("opacity",1),e.exit().transition().duration(t).style("opacity",0).remove()},l.prototype.initTooltip=function(){var t,e=this,i=e.config;if(e.tooltip=e.selectChart.style("position","relative").append("div").attr("class",Y.tooltipContainer).style("position","absolute").style("pointer-events","none").style("display","none"),i.tooltip_init_show){if(e.isTimeSeries()&&g(i.tooltip_init_x)){for(i.tooltip_init_x=e.parseDate(i.tooltip_init_x),t=0;t"+o),d=l.getStanfordPointColor(t[a]),c=_(u.data_epochs),s=t[a].epochs;else if(r||(o=_(h?h(t[a].x,t[a].index):t[a].x),r=""+(o||0===o?"":"")),void 0!==(s=_(p(t[a].value,t[a].ratio,t[a].id,t[a].index,t)))){if(null===t[a].name)continue;c=_(g(t[a].name,t[a].ratio,t[a].id,t[a].index)),d=l.levelColor?l.levelColor(t[a].value):n(t[a].id)}void 0!==s&&(r+="",r+="",r+="",r+="")}return r+"
"+o+"
"+c+""+s+"
"},l.prototype.tooltipPosition=function(t,e,i,n){var r,a,o,s,c,d=this,l=d.config,u=d.d3,h=d.hasArcType(),g=u.mouse(n);return h?(a=(d.width-(d.isLegendRight?d.getLegendWidth():0))/2+g[0],s=(d.hasType("gauge")?d.height:d.height/2)+g[1]+20):(r=d.getSvgLeft(!0),s=l.axis_rotated?(o=(a=r+g[0]+100)+e,c=d.currentWidth-d.getCurrentPaddingRight(),d.x(t[0].x)+20):(o=(a=r+d.getCurrentPaddingLeft(!0)+d.x(t[0].x)+20)+e,c=r+d.currentWidth-d.getCurrentPaddingRight(),g[1]+15),cd.currentHeight&&(s-=i+30)),s<0&&(s=0),{top:s,left:a}},l.prototype.showTooltip=function(t,e){var i,n,r,a=this,o=a.config,s=a.hasArcType(),c=t.filter(function(t){return t&&C(t.value)}),d=o.tooltip_position||l.prototype.tooltipPosition;0!==c.length&&o.tooltip_show?(a.tooltip.html(o.tooltip_contents.call(a,t,a.axis.getXAxisTickFormat(),a.getYFormat(s),a.color)).style("display","block"),i=a.tooltip.property("offsetWidth"),n=a.tooltip.property("offsetHeight"),r=d.call(this,c,i,n,e),a.tooltip.style("top",r.top+"px").style("left",r.left+"px")):a.hideTooltip()},l.prototype.hideTooltip=function(){this.tooltip.style("display","none")},l.prototype.setTargetType=function(t,e){var i=this,n=i.config;i.mapToTargetIds(t).forEach(function(t){i.withoutFadeIn[t]=e===n.data_types[t],n.data_types[t]=e}),t||(n.data_type=e)},l.prototype.hasType=function(i,t){var n=this.config.data_types,r=!1;return(t=t||this.data.targets)&&t.length?t.forEach(function(t){var e=n[t.id];(e&&0<=e.indexOf(i)||!e&&"line"===i)&&(r=!0)}):Object.keys(n).length?Object.keys(n).forEach(function(t){n[t]===i&&(r=!0)}):r=this.config.data_type===i,r},l.prototype.hasArcType=function(t){return this.hasType("pie",t)||this.hasType("donut",t)||this.hasType("gauge",t)},l.prototype.isLineType=function(t){var e=this.config,i=g(t)?t:t.id;return!e.data_types[i]||0<=["line","spline","area","area-spline","step","area-step"].indexOf(e.data_types[i])},l.prototype.isStepType=function(t){var e=g(t)?t:t.id;return 0<=["step","area-step"].indexOf(this.config.data_types[e])},l.prototype.isSplineType=function(t){var e=g(t)?t:t.id;return 0<=["spline","area-spline"].indexOf(this.config.data_types[e])},l.prototype.isAreaType=function(t){var e=g(t)?t:t.id;return 0<=["area","area-spline","area-step"].indexOf(this.config.data_types[e])},l.prototype.isBarType=function(t){var e=g(t)?t:t.id;return"bar"===this.config.data_types[e]},l.prototype.isScatterType=function(t){var e=g(t)?t:t.id;return"scatter"===this.config.data_types[e]},l.prototype.isStanfordType=function(t){var e=g(t)?t:t.id;return"stanford"===this.config.data_types[e]},l.prototype.isPieType=function(t){var e=g(t)?t:t.id;return"pie"===this.config.data_types[e]},l.prototype.isGaugeType=function(t){var e=g(t)?t:t.id;return"gauge"===this.config.data_types[e]},l.prototype.isDonutType=function(t){var e=g(t)?t:t.id;return"donut"===this.config.data_types[e]},l.prototype.isArcType=function(t){return this.isPieType(t)||this.isDonutType(t)||this.isGaugeType(t)},l.prototype.lineData=function(t){return this.isLineType(t)?[t]:[]},l.prototype.arcData=function(t){return this.isArcType(t.data)?[t]:[]},l.prototype.barData=function(t){return this.isBarType(t)?t.values:[]},l.prototype.lineOrScatterOrStanfordData=function(t){return this.isLineType(t)||this.isScatterType(t)||this.isStanfordType(t)?t.values:[]},l.prototype.barOrLineData=function(t){return this.isBarType(t)||this.isLineType(t)?t.values:[]},l.prototype.isSafari=function(){var t=window.navigator.userAgent;return 0<=t.indexOf("Safari")&&t.indexOf("Chrome")<0},l.prototype.isChrome=function(){return 0<=window.navigator.userAgent.indexOf("Chrome")},l.prototype.initZoom=function(){var e,i=this,n=i.d3,r=i.config;return i.zoom=n.zoom().on("start",function(){var t;"scroll"===r.zoom_type&&((t=n.event.sourceEvent)&&"brush"===t.type||(e=t,r.zoom_onzoomstart.call(i.api,t)))}).on("zoom",function(){var t;"scroll"===r.zoom_type&&((t=n.event.sourceEvent)&&"brush"===t.type||(i.redrawForZoom(),r.zoom_onzoom.call(i.api,i.x.orgDomain())))}).on("end",function(){var t;"scroll"===r.zoom_type&&((t=n.event.sourceEvent)&&"brush"===t.type||t&&e.clientX===t.clientX&&e.clientY===t.clientY||r.zoom_onzoomend.call(i.api,i.x.orgDomain()))}),i.zoom.updateDomain=function(){return n.event&&n.event.transform&&(r.axis_rotated&&"scroll"===r.zoom_type&&"mousemove"===n.event.sourceEvent.type?i.x.domain(n.event.transform.rescaleY(i.subX).domain()):i.x.domain(n.event.transform.rescaleX(i.subX).domain())),this},i.zoom.updateExtent=function(){return this.scaleExtent([1,1/0]).translateExtent([[0,0],[i.width,i.height]]).extent([[0,0],[i.width,i.height]]),this},i.zoom.update=function(){return this.updateExtent().updateDomain()},i.zoom.updateExtent()},l.prototype.zoomTransform=function(t){var e=[this.x(t[0]),this.x(t[1])];return this.d3.zoomIdentity.scale(this.width/(e[1]-e[0])).translate(-e[0],0)},l.prototype.initDragZoom=function(){var e,t,i=this,n=i.d3,r=i.config,a=i.context=i.svg,o=i.margin.left+20.5,s=i.margin.top+.5;"drag"===r.zoom_type&&r.zoom_enabled&&(e=function(t){return t&&t.map(function(t){return i.x.invert(t)})},t=i.dragZoomBrush=n.brushX().on("start",function(){i.api.unzoom(),i.svg.select("."+Y.dragZoom).classed("disabled",!1),r.zoom_onzoomstart.call(i.api,n.event.sourceEvent)}).on("brush",function(){r.zoom_onzoom.call(i.api,e(n.event.selection))}).on("end",function(){var t;null!=n.event.selection&&(t=e(n.event.selection),r.zoom_disableDefaultBehavior||i.api.zoom(t),i.svg.select("."+Y.dragZoom).classed("disabled",!0),r.zoom_onzoomend.call(i.api,t))}),a.append("g").classed(Y.dragZoom,!0).attr("clip-path",i.clipPath).attr("transform","translate("+o+","+s+")").call(t))},l.prototype.getZoomDomain=function(){var t=this.config,e=this.d3;return[e.min([this.orgXDomain[0],t.zoom_x_min]),e.max([this.orgXDomain[1],t.zoom_x_max])]},l.prototype.redrawForZoom=function(){var t=this,e=t.d3,i=t.config,n=t.zoom,r=t.x;i.zoom_enabled&&0!==t.filterTargetsToShow(t.data.targets).length&&(n.update(),i.zoom_disableDefaultBehavior||(t.isCategorized()&&r.orgDomain()[0]===t.orgXDomain[0]&&r.domain([t.orgXDomain[0]-1e-10,r.orgDomain()[1]]),t.redraw({withTransition:!1,withY:i.zoom_rescale,withSubchart:!1,withEventRect:!1,withDimension:!1}),e.event.sourceEvent&&"mousemove"===e.event.sourceEvent.type&&(t.cancelClick=!0)))},i}); \ No newline at end of file diff --git a/server/static/server/c3/docs/js/d3-5.8.2.min.js b/server/static/server/c3/docs/js/d3-5.8.2.min.js new file mode 100644 index 0000000..009d7ba --- /dev/null +++ b/server/static/server/c3/docs/js/d3-5.8.2.min.js @@ -0,0 +1,2 @@ +// https://d3js.org v5.8.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.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 A(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 S(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 k(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 T(t){if(!(i=t.length))return[];for(var n=-1,e=k(t,E),r=new Array(e);++n=0&&(n=t.slice(e+1),t=t.slice(0,e)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})),a=-1,u=o.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++a0)for(var e,r,i=new Array(e),o=0;o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),V.hasOwnProperty(n)?{space:V[n],local:t}:t}function W(t){var n=$(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 Z(){}function Q(t){return null==t?Z:function(){return this.querySelector(t)}}function J(){return[]}function K(t){return null==t?J:function(){return this.querySelectorAll(t)}}function tt(t){return function(){return this.matches(t)}}function nt(t){return new Array(t.length)}function et(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}et.prototype={constructor:et,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 rt="$";function it(t,n,e,r,i,o){for(var a,u=0,c=n.length,f=o.length;un?1:t>=n?0:NaN}function ut(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function ct(t,n){return t.style.getPropertyValue(n)||ut(t).getComputedStyle(t,null).getPropertyValue(n)}function ft(t){return t.trim().split(/^|\s+/)}function st(t){return t.classList||new lt(t)}function lt(t){this._node=t,this._names=ft(t.getAttribute("class")||"")}function ht(t,n){for(var e=st(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 wt={};(t.event=null,"undefined"!=typeof document)&&("onmouseenter"in document.documentElement||(wt={mouseenter:"mouseover",mouseleave:"mouseout"}));function Mt(t,n,e){return t=Nt(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function Nt(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=x&&(x=m+1);!(b=y[x])&&++x=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=at);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)):ct(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=ft(t+"");if(arguments.length<2){for(var r=st(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):(n=rn.exec(t))?dn(parseInt(n[1],16)):(n=on.exec(t))?new yn(n[1],n[2],n[3],1):(n=an.exec(t))?new yn(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=un.exec(t))?pn(n[1],n[2],n[3],n[4]):(n=cn.exec(t))?pn(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=fn.exec(t))?bn(n[1],n[2]/100,n[3]/100,1):(n=sn.exec(t))?bn(n[1],n[2]/100,n[3]/100,n[4]):ln.hasOwnProperty(t)?dn(ln[t]):"transparent"===t?new yn(NaN,NaN,NaN,0):null}function dn(t){return new yn(t>>16&255,t>>8&255,255&t,1)}function pn(t,n,e,r){return r<=0&&(t=n=e=NaN),new yn(t,n,e,r)}function vn(t){return t instanceof Jt||(t=hn(t)),t?new yn((t=t.rgb()).r,t.g,t.b,t.opacity):new yn}function gn(t,n,e,r){return 1===arguments.length?vn(t):new yn(t,n,e,null==r?1:r)}function yn(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function _n(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function bn(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new xn(t,n,e,r)}function mn(t,n,e,r){return 1===arguments.length?function(t){if(t instanceof xn)return new xn(t.h,t.s,t.l,t.opacity);if(t instanceof Jt||(t=hn(t)),!t)return new xn;if(t instanceof xn)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 xn(a,u,c,t.opacity)}(t):new xn(t,n,e,null==r?1:r)}function xn(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function wn(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}Zt(Jt,hn,{displayable:function(){return this.rgb().displayable()},hex:function(){return this.rgb().hex()},toString:function(){return this.rgb()+""}}),Zt(yn,gn,Qt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new yn(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new yn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},hex:function(){return"#"+_n(this.r)+_n(this.g)+_n(this.b)},toString:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}})),Zt(xn,mn,Qt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new xn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new xn(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 yn(wn(t>=240?t-240:t+120,i,r),wn(t,i,r),wn(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}}));var Mn=Math.PI/180,Nn=180/Math.PI,An=.96422,Sn=1,kn=.82521,Tn=4/29,En=6/29,Cn=3*En*En,Pn=En*En*En;function zn(t){if(t instanceof qn)return new qn(t.l,t.a,t.b,t.opacity);if(t instanceof Fn){if(isNaN(t.h))return new qn(t.l,0,0,t.opacity);var n=t.h*Mn;return new qn(t.l,Math.cos(n)*t.c,Math.sin(n)*t.c,t.opacity)}t instanceof yn||(t=vn(t));var e,r,i=On(t.r),o=On(t.g),a=On(t.b),u=Dn((.2225045*i+.7168786*o+.0606169*a)/Sn);return i===o&&o===a?e=r=u:(e=Dn((.4360747*i+.3850649*o+.1430804*a)/An),r=Dn((.0139322*i+.0971045*o+.7141733*a)/kn)),new qn(116*u-16,500*(e-u),200*(u-r),t.opacity)}function Rn(t,n,e,r){return 1===arguments.length?zn(t):new qn(t,n,e,null==r?1:r)}function qn(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function Dn(t){return t>Pn?Math.pow(t,1/3):t/Cn+Tn}function Ln(t){return t>En?t*t*t:Cn*(t-Tn)}function Un(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function On(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Yn(t){if(t instanceof Fn)return new Fn(t.h,t.c,t.l,t.opacity);if(t instanceof qn||(t=zn(t)),0===t.a&&0===t.b)return new Fn(NaN,0,t.l,t.opacity);var n=Math.atan2(t.b,t.a)*Nn;return new Fn(n<0?n+360:n,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function Bn(t,n,e,r){return 1===arguments.length?Yn(t):new Fn(t,n,e,null==r?1:r)}function Fn(t,n,e,r){this.h=+t,this.c=+n,this.l=+e,this.opacity=+r}Zt(qn,Rn,Qt(Jt,{brighter:function(t){return new qn(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new qn(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,n=isNaN(this.a)?t:t+this.a/500,e=isNaN(this.b)?t:t-this.b/200;return new yn(Un(3.1338561*(n=An*Ln(n))-1.6168667*(t=Sn*Ln(t))-.4906146*(e=kn*Ln(e))),Un(-.9787684*n+1.9161415*t+.033454*e),Un(.0719453*n-.2289914*t+1.4052427*e),this.opacity)}})),Zt(Fn,Bn,Qt(Jt,{brighter:function(t){return new Fn(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new Fn(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return zn(this).rgb()}}));var In=-.14861,Hn=1.78277,jn=-.29227,Xn=-.90649,Gn=1.97294,Vn=Gn*Xn,$n=Gn*Hn,Wn=Hn*jn-Xn*In;function Zn(t,n,e,r){return 1===arguments.length?function(t){if(t instanceof Qn)return new Qn(t.h,t.s,t.l,t.opacity);t instanceof yn||(t=vn(t));var n=t.r/255,e=t.g/255,r=t.b/255,i=(Wn*r+Vn*n-$n*e)/(Wn+Vn-$n),o=r-i,a=(Gn*(e-i)-jn*o)/Xn,u=Math.sqrt(a*a+o*o)/(Gn*i*(1-i)),c=u?Math.atan2(a,o)*Nn-120:NaN;return new Qn(c<0?c+360:c,u,i,t.opacity)}(t):new Qn(t,n,e,null==r?1:r)}function Qn(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function Jn(t,n,e,r,i){var o=t*t,a=o*t;return((1-3*t+3*o-a)*n+(4-6*o+3*a)*e+(1+3*t+3*o-3*a)*r+a*i)/6}function Kn(t){var n=t.length-1;return function(e){var r=e<=0?e=0:e>=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):ne(isNaN(t)?n:t)}function ie(t){return 1==(t=+t)?oe: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):ne(isNaN(n)?e:n)}}function oe(t,n){var e=n-t;return e?ee(t,e):ne(isNaN(t)?n:t)}Zt(Qn,Zn,Qt(Jt,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new Qn(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new Qn(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*Mn,n=+this.l,e=isNaN(this.s)?0:this.s*n*(1-n),r=Math.cos(t),i=Math.sin(t);return new yn(255*(n+e*(In*r+Hn*i)),255*(n+e*(jn*r+Xn*i)),255*(n+e*(Gn*r)),this.opacity)}}));var ae=function t(n){var e=ie(n);function r(t,n){var r=e((t=gn(t)).r,(n=gn(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=oe(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 ue(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:he(e,r)})),o=ve.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:he(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:he(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:he(t,e)},{i:u-2,x:he(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;--Ge}function ar(){Qe=(Ze=Ke.now())+Je,Ge=Ve=0;try{or()}finally{Ge=0,function(){var t,n,e=je,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:je=n);Xe=t,cr(r)}(),Qe=0}}function ur(){var t=Ke.now(),n=t-Ze;n>We&&(Je-=n,Ze=t)}function cr(t){Ge||(Ve&&(Ve=clearTimeout(Ve)),t-Qe>24?(t<1/0&&(Ve=setTimeout(ar,t-Ke.now()-Je)),$e&&($e=clearInterval($e))):($e||(Ze=Ke.now(),$e=setInterval(ur,We)),Ge=1,tr(ar)))}function fr(t,n,e){var r=new rr;return n=null==n?0:+n,r.restart(function(e){r.stop(),t(e+n)},n,e),r}rr.prototype=ir.prototype={constructor:rr,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?nr():+e)+(null==n?0:+n),this._next||Xe===this||(Xe?Xe._next=this:je=this,Xe=this),this._call=t,this._time=e,cr()},stop:function(){this._call&&(this._call=null,this._time=1/0,cr())}};var sr=I("start","end","cancel","interrupt"),lr=[],hr=0,dr=1,pr=2,vr=3,gr=4,yr=5,_r=6;function br(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!==dr)return u();for(f in i)if((h=i[f]).name===e.name){if(h.state===vr)return fr(o);h.state===gr?(h.state=_r,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[f]):+fhr)throw new Error("too late; already scheduled");return e}function xr(t,n){var e=wr(t,n);if(e.state>vr)throw new Error("too late; already running");return e}function wr(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Mr(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>pr&&e.state=0&&(t=t.slice(0,n)),!t||"start"===t})}(n)?mr:xr;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=$(t),r="transform"===e?Te:Ar;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,Nr(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=$(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(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(e))}}(t,i)),e}return i._value=n,i})(r,n))},style:function(t,n,e){var r="transform"==(t+="")?ke:Ar;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=ct(this,t),a=(this.style.removeProperty(t),ct(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,kr(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=ct(this,t),u=e(this),c=u+"";return null==u&&(this.style.removeProperty(t),c=u=ct(this,t)),a===c?null:a===r&&c===i?o:(i=c,o=n(r=a,u))}}(t,r,Nr(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var c=xr(this,t),f=c.on,s=null==c.value[a]?o||(o=kr(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=ct(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(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}}(Nr(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},remove:function(){return this.on("end.remove",(t=this._id,function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}));var t},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=wr(this.node(),e).tween,o=0,a=i.length;o0&&(r=o-p),M<0?h=d-v:M>0&&(a=u-v),x=vi,L.attr("cursor",xi.selection),Y());break;default:return}di()},!0).on("keyup.brush",function(){switch(t.event.keyCode){case 16:P&&(y=_=P=!1,Y());break;case 18:x===yi&&(w<0?s=l:w>0&&(r=o),M<0?h=d:M>0&&(a=u),x=gi,Y());break;case 32:x===vi&&(t.event.altKey?(w&&(s=l-p*w,r=o+p*w),M&&(h=d-v*M,a=u+v*M),x=yi):(w<0?s=l:w>0&&(r=o),M<0?h=d:M>0&&(a=u),x=gi),L.attr("cursor",xi[m]),Y());break;default:return}di()},!0).on("mousemove.brush",O,!0).on("mouseup.brush",B,!0);It(t.event.view)}hi(),Mr(b),c.call(b),q.start()}function O(){var t=Ot(b);!P||y||_||(Math.abs(t[0]-R[0])>Math.abs(t[1]-R[1])?_=!0:y=!0),R=t,g=!0,di(),Y()}function Y(){var t;switch(p=R[0]-z[0],v=R[1]-z[1],x){case vi:case pi:w&&(p=Math.max(k-r,Math.min(E-s,p)),o=r+p,l=s+p),M&&(v=Math.max(T-a,Math.min(C-h,v)),u=a+v,d=h+v);break;case gi:w<0?(p=Math.max(k-r,Math.min(E-r,p)),o=r+p,l=s):w>0&&(p=Math.max(k-s,Math.min(E-s,p)),o=r,l=s+p),M<0?(v=Math.max(T-a,Math.min(C-a,v)),u=a+v,d=h):M>0&&(v=Math.max(T-h,Math.min(C-h,v)),u=a,d=h+v);break;case yi:w&&(o=Math.max(k,Math.min(E,r-p*w)),l=Math.max(k,Math.min(E,s+p*w))),M&&(u=Math.max(T,Math.min(C,a-v*M)),d=Math.max(T,Math.min(C,h+v*M)))}l1e-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((Bi-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;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%Fi+Fi),l>Ii?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>=Bi)+","+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 Zi(){}function Qi(t,n){var e=new Zi;if(t instanceof Zi)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 so(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 lo(){}var ho=[[],[[[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 po(){var t=1,n=1,e=M,r=u;function i(t){var n=e(t);if(Array.isArray(n))n=n.slice().sort(ao);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,ho[f<<1].forEach(p);for(;++o=r,ho[c|f<<1].forEach(p);ho[f<<0].forEach(p);for(;++u=r,s=e[u*t]>=r,ho[f<<1|s<<2].forEach(p);++o=r,l=s,s=e[u*t+o+1]>=r,ho[c|f<<1|s<<2|l<<3].forEach(p);ho[f|s<<3].forEach(p)}o=-1,s=e[u*t]>=r,ho[s<<2].forEach(p);for(;++o=r,ho[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]}}ho[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)?uo(oo.call(t)):uo(t),i):e},i.smooth=function(t){return arguments.length?(r=t?u:lo,i):r===u},i}function vo(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 go(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 yo(t){return t[0]}function _o(t){return t[1]}function bo(){return 1}var mo={},xo={},wo=34,Mo=10,No=13;function Ao(t){return new Function("d","return {"+t.map(function(t,n){return JSON.stringify(t)+": d["+n+"]"}).join(",")+"}")}function So(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 xo;if(f)return f=!1,mo;var n,r,i=a;if(t.charCodeAt(i)===wo){for(;a++=o?c=!0:(r=t.charCodeAt(a++))===Mo?f=!0:r===No&&(f=!0,t.charCodeAt(a)===Mo&&++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 Jo(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function Ko(t){return t[0]}function ta(t){return t[1]}function na(t,n,e){var r=new ea(null==n?Ko:n,null==e?ta:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function ea(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 ra(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var ia=na.prototype=ea.prototype;function oa(t){return t.x+t.vx}function aa(t){return t.y+t.vy}function ua(t){return t.index}function ca(t,n){var e=t.get(n);if(!e)throw new Error("missing: "+n);return e}function fa(t){return t.x}function sa(t){return t.y}ia.copy=function(){var t,n,e=new ea(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=ra(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]=ra(n));return e},ia.add=function(t){var n=+this._x.call(null,t),e=+this._y.call(null,t);return Qo(this.cover(n,e),n,e,t)},ia.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));for(st||t>i||r>n||n>o))return this;var a,u,c=i-e,f=this._root;switch(u=(n<(r+o)/2)<<1|t<(e+i)/2){case 0:do{(a=new Array(4))[u]=f,f=a}while(o=r+(c*=2),t>(i=e+c)||n>o);break;case 1:do{(a=new Array(4))[u]=f,f=a}while(o=r+(c*=2),(e=i-c)>t||n>o);break;case 2:do{(a=new Array(4))[u]=f,f=a}while(r=o-(c*=2),t>(i=e+c)||r>n);break;case 3:do{(a=new Array(4))[u]=f,f=a}while(r=o-(c*=2),(e=i-c)>t||r>n)}this._root&&this._root.length&&(this._root=f)}return this._x0=e,this._y0=r,this._x1=i,this._y1=o,this},ia.data=function(){var t=[];return this.visit(function(n){if(!n.length)do{t.push(n.data)}while(n=n.next)}),t},ia.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},ia.find=function(t,n,e){var r,i,o,a,u,c,f,s=this._x0,l=this._y0,h=this._x1,d=this._y1,p=[],v=this._root;for(v&&p.push(new Jo(v,s,l,h,d)),null==e?e=1/0:(s=t-e,l=n-e,h=t+e,d=n+e,e*=e);c=p.pop();)if(!(!(v=c.node)||(i=c.x0)>h||(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)},ia.removeAll=function(t){for(var n=0,e=t.length;n1?r[0]+r.slice(2):r,+t.slice(e+1)]}function pa(t){return(t=da(Math.abs(t)))?t[1]:NaN}var va,ga=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ya(t){return new _a(t)}function _a(t){if(!(n=ga.exec(t)))throw new Error("invalid format: "+t);var n;this.fill=n[1]||" ",this.align=n[2]||">",this.sign=n[3]||"-",this.symbol=n[4]||"",this.zero=!!n[5],this.width=n[6]&&+n[6],this.comma=!!n[7],this.precision=n[8]&&+n[8].slice(1),this.trim=!!n[9],this.type=n[10]||""}function ba(t,n){var e=da(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")}ya.prototype=_a.prototype,_a.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var ma={"%":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 ba(100*t,n)},r:ba,s:function(t,n){var e=da(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(va=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")+da(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 xa(t){return t}var wa,Ma=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Na(t){var n,e,r=t.grouping&&t.thousands?(n=t.grouping,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)}):xa,i=t.currency,o=t.decimal,a=t.numerals?function(t){return function(n){return n.replace(/[0-9]/g,function(n){return t[+n]})}}(t.numerals):xa,u=t.percent||"%";function c(t){var n=(t=ya(t)).fill,e=t.align,c=t.sign,f=t.symbol,s=t.zero,l=t.width,h=t.comma,d=t.precision,p=t.trim,v=t.type;"n"===v?(h=!0,v="g"):ma[v]||(null==d&&(d=12),p=!0,v="g"),(s||"0"===n&&"="===e)&&(s=!0,n="0",e="=");var g="$"===f?i[0]:"#"===f&&/[boxX]/.test(v)?"0"+v.toLowerCase():"",y="$"===f?i[1]:/[%p]/.test(v)?u:"",_=ma[v],b=/[defgprs%]/.test(v);function m(t){var i,u,f,m=g,x=y;if("c"===v)x=_(t)+x,t="";else{var w=(t=+t)<0;if(t=_(Math.abs(t),d),p&&(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)),w&&0==+t&&(w=!1),m=(w?"("===c?c:"-":"-"===c||"("===c?"":c)+m,x=("s"===v?Ma[8+va/3]:"")+x+(w&&"("===c?")":""),b)for(i=-1,u=t.length;++i(f=t.charCodeAt(i))||f>57){x=(46===f?o+t.slice(i+1):t.slice(i))+x,t=t.slice(0,i);break}}h&&!s&&(t=r(t,1/0));var M=m.length+t.length+x.length,N=M>1)+m+t+x+N.slice(M);break;default:t=N+m+t+x}return a(t)}return d=null==d?6:/[gprs]/.test(v)?Math.max(1,Math.min(21,d)):Math.max(0,Math.min(20,d)),m.toString=function(){return t+""},m}return{format:c,formatPrefix:function(t,n){var e=c(((t=ya(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(pa(n)/3))),i=Math.pow(10,-r),o=Ma[8+r/3];return function(t){return e(i*t)+o}}}}function Aa(n){return wa=Na(n),t.format=wa.format,t.formatPrefix=wa.formatPrefix,wa}function Sa(t){return Math.max(0,-pa(Math.abs(t)))}function ka(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(pa(n)/3)))-pa(Math.abs(t)))}function Ta(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,pa(n)-pa(t))+1}function Ea(){return new Ca}function Ca(){this.reset()}Aa({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),Ca.prototype={constructor:Ca,reset:function(){this.s=this.t=0},add:function(t){za(Pa,t,this.t),za(this,Pa.s,this.s),this.s?this.t+=Pa.t:this.s=Pa.t},valueOf:function(){return this.s}};var Pa=new Ca;function za(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var Ra=1e-6,qa=1e-12,Da=Math.PI,La=Da/2,Ua=Da/4,Oa=2*Da,Ya=180/Da,Ba=Da/180,Fa=Math.abs,Ia=Math.atan,Ha=Math.atan2,ja=Math.cos,Xa=Math.ceil,Ga=Math.exp,Va=Math.log,$a=Math.pow,Wa=Math.sin,Za=Math.sign||function(t){return t>0?1:t<0?-1:0},Qa=Math.sqrt,Ja=Math.tan;function Ka(t){return t>1?0:t<-1?Da:Math.acos(t)}function tu(t){return t>1?La:t<-1?-La:Math.asin(t)}function nu(t){return(t=Wa(t/2))*t}function eu(){}function ru(t,n){t&&ou.hasOwnProperty(t.type)&&ou[t.type](t,n)}var iu={Feature:function(t,n){ru(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=ja(n=(n*=Ba)/2+Ua),a=Wa(n),u=du*a,c=hu*o+u*ja(i),f=u*r*Wa(i);pu.add(Ha(f,c)),lu=t,hu=o,du=a}function xu(t){return[Ha(t[1],t[0]),tu(t[2])]}function wu(t){var n=t[0],e=t[1],r=ja(e);return[r*ja(n),r*Wa(n),Wa(e)]}function Mu(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Nu(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 Au(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Su(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function ku(t){var n=Qa(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var Tu,Eu,Cu,Pu,zu,Ru,qu,Du,Lu,Uu,Ou,Yu,Bu,Fu,Iu,Hu,ju,Xu,Gu,Vu,$u,Wu,Zu,Qu,Ju,Ku,tc=Ea(),nc={point:ec,lineStart:ic,lineEnd:oc,polygonStart:function(){nc.point=ac,nc.lineStart=uc,nc.lineEnd=cc,tc.reset(),gu.polygonStart()},polygonEnd:function(){gu.polygonEnd(),nc.point=ec,nc.lineStart=ic,nc.lineEnd=oc,pu<0?(Tu=-(Cu=180),Eu=-(Pu=90)):tc>Ra?Pu=90:tc<-Ra&&(Eu=-90),Uu[0]=Tu,Uu[1]=Cu}};function ec(t,n){Lu.push(Uu=[Tu=t,Cu=t]),nPu&&(Pu=n)}function rc(t,n){var e=wu([t*Ba,n*Ba]);if(Du){var r=Nu(Du,e),i=Nu([r[1],-r[0],0],r);ku(i),i=xu(i);var o,a=t-zu,u=a>0?1:-1,c=i[0]*Ya*u,f=Fa(a)>180;f^(u*zuPu&&(Pu=o):f^(u*zu<(c=(c+360)%360-180)&&cPu&&(Pu=n)),f?tfc(Tu,Cu)&&(Cu=t):fc(t,Cu)>fc(Tu,Cu)&&(Tu=t):Cu>=Tu?(tCu&&(Cu=t)):t>zu?fc(Tu,t)>fc(Tu,Cu)&&(Cu=t):fc(t,Cu)>fc(Tu,Cu)&&(Tu=t)}else Lu.push(Uu=[Tu=t,Cu=t]);nPu&&(Pu=n),Du=e,zu=t}function ic(){nc.point=rc}function oc(){Uu[0]=Tu,Uu[1]=Cu,nc.point=ec,Du=null}function ac(t,n){if(Du){var e=t-zu;tc.add(Fa(e)>180?e+(e>0?360:-360):e)}else Ru=t,qu=n;gu.point(t,n),rc(t,n)}function uc(){gu.lineStart()}function cc(){ac(Ru,qu),gu.lineEnd(),Fa(tc)>Ra&&(Tu=-(Cu=180)),Uu[0]=Tu,Uu[1]=Cu,Du=null}function fc(t,n){return(n-=t)<0?n+360:n}function sc(t,n){return t[0]-n[0]}function lc(t,n){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nDa?t+Math.round(-t/Oa)*Oa:t,n]}function Sc(t,n,e){return(t%=Oa)?n||e?Nc(Tc(t),Ec(n,e)):Tc(t):n||e?Ec(n,e):Ac}function kc(t){return function(n,e){return[(n+=t)>Da?n-Oa:n<-Da?n+Oa:n,e]}}function Tc(t){var n=kc(t);return n.invert=kc(-t),n}function Ec(t,n){var e=ja(t),r=Wa(t),i=ja(n),o=Wa(n);function a(t,n){var a=ja(n),u=ja(t)*a,c=Wa(t)*a,f=Wa(n),s=f*e+u*r;return[Ha(c*i-s*o,u*e-f*r),tu(s*i+c*o)]}return a.invert=function(t,n){var a=ja(n),u=ja(t)*a,c=Wa(t)*a,f=Wa(n),s=f*i-c*o;return[Ha(c*i+f*o,u*e+s*r),tu(s*e-u*r)]},a}function Cc(t){function n(n){return(n=t(n[0]*Ba,n[1]*Ba))[0]*=Ya,n[1]*=Ya,n}return t=Sc(t[0]*Ba,t[1]*Ba,t.length>2?t[2]*Ba:0),n.invert=function(n){return(n=t.invert(n[0]*Ba,n[1]*Ba))[0]*=Ya,n[1]*=Ya,n},n}function Pc(t,n,e,r,i,o){if(e){var a=ja(n),u=Wa(n),c=r*e;null==i?(i=n+r*Oa,o=n-c/2):(i=zc(a,i),o=zc(a,o),(r>0?io)&&(i+=r*Oa));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 qc(t,n){return Fa(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 Uc(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r=0?1:-1,A=N*M,S=A>Da,k=v*x;if(Oc.add(Ha(k*N*Wa(A),g*w+k*ja(A))),a+=S?M+N*Oa:M,S^d>=e^b>=e){var T=Nu(wu(h),wu(_));ku(T);var E=Nu(o,T);ku(E);var C=(S^M>=0?-1:1)*tu(E[2]);(r>C||r===C&&(T[0]||T[1]))&&(u+=S^M>=0?1:-1)}}return(a<-Ra||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(Fc))}return h}}function Fc(t){return t.length>1}function Ic(t,n){return((t=t.x)[0]<0?t[1]-La-Ra:La-t[1])-((n=n.x)[0]<0?n[1]-La-Ra:La-n[1])}var Hc=Bc(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?Da:-Da,c=Fa(o-e);Fa(c-Da)0?La:-La),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&c>=Da&&(Fa(e-i)Ra?Ia((Wa(n)*(o=ja(r))*Wa(e)-Wa(r)*(i=ja(n))*Wa(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*La,r.point(-Da,i),r.point(0,i),r.point(Da,i),r.point(Da,0),r.point(Da,-i),r.point(0,-i),r.point(-Da,-i),r.point(-Da,0),r.point(-Da,i);else if(Fa(t[0]-n[0])>Ra){var o=t[0]0,i=Fa(n)>Ra;function o(t,e){return ja(t)*ja(e)>n}function a(t,e,r){var i=[1,0,0],o=Nu(wu(t),wu(e)),a=Mu(o,o),u=o[0],c=a-u*u;if(!c)return!r&&t;var f=n*a/c,s=-n*u/c,l=Nu(i,o),h=Su(i,f);Au(h,Su(o,s));var d=l,p=Mu(h,d),v=Mu(d,d),g=p*p-v*(Mu(h,h)-1);if(!(g<0)){var y=Qa(g),_=Su(d,(-p-y)/v);if(Au(_,h),_=xu(_),!r)return _;var b,m=t[0],x=e[0],w=t[1],M=e[1];x0^_[1]<(Fa(_[0]-m)Da^(m<=_[0]&&_[0]<=x)){var S=Su(d,(-p+y)/v);return Au(S,h),[_,xu(S)]}}}function u(n,e){var i=r?t:Da-t,o=0;return n<-i?o|=1:n>i&&(o|=2),e<-i?o|=4:e>i&&(o|=8),o}return Bc(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?Da:-Da),h):0;if(!n&&(f=c=v)&&t.lineStart(),v!==c&&(!(d=a(n,p))||qc(n,d)||qc(p,d))&&(p[0]+=Ra,p[1]+=Ra,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&&qc(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){Pc(o,t,e,i,n,r)},r?[0,-t]:[-Da,t-Da])}var Xc=1e9,Gc=-Xc;function Vc(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 Fa(r[0]-t)0?0:3:Fa(r[0]-e)0?2:1:Fa(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=Rc(),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=S(c)).length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&Lc(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(Gc,Math.min(Xc,p)),v=Math.max(Gc,Math.min(Xc,v))],m=[o=Math.max(Gc,Math.min(Xc,o)),a=Math.max(Gc,Math.min(Xc,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 $c,Wc,Zc,Qc=Ea(),Jc={sphere:eu,point:eu,lineStart:function(){Jc.point=tf,Jc.lineEnd=Kc},lineEnd:eu,polygonStart:eu,polygonEnd:eu};function Kc(){Jc.point=Jc.lineEnd=eu}function tf(t,n){$c=t*=Ba,Wc=Wa(n*=Ba),Zc=ja(n),Jc.point=nf}function nf(t,n){t*=Ba;var e=Wa(n*=Ba),r=ja(n),i=Fa(t-$c),o=ja(i),a=r*Wa(i),u=Zc*e-Wc*r*o,c=Wc*e+Zc*r*o;Qc.add(Ha(Qa(a*a+u*u),c)),$c=t,Wc=e,Zc=r}function ef(t){return Qc.reset(),cu(t,Jc),+Qc}var rf=[null,null],of={type:"LineString",coordinates:rf};function af(t,n){return rf[0]=t,rf[1]=n,ef(of)}var uf={Feature:function(t,n){return ff(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++rRa}).map(c)).concat(g(Xa(o/d)*d,i,d).filter(function(t){return Fa(t%v)>Ra}).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=vf(o,i,90),f=gf(n,t,y),s=vf(u,a,90),l=gf(r,e,y),_):y},_.extentMajor([[-180,-90+Ra],[180,90-Ra]]).extentMinor([[-180,-80-Ra],[180,80+Ra]])}function _f(t){return t}var bf,mf,xf,wf,Mf=Ea(),Nf=Ea(),Af={point:eu,lineStart:eu,lineEnd:eu,polygonStart:function(){Af.lineStart=Sf,Af.lineEnd=Ef},polygonEnd:function(){Af.lineStart=Af.lineEnd=Af.point=eu,Mf.add(Fa(Nf)),Nf.reset()},result:function(){var t=Mf/2;return Mf.reset(),t}};function Sf(){Af.point=kf}function kf(t,n){Af.point=Tf,bf=xf=t,mf=wf=n}function Tf(t,n){Nf.add(wf*t-xf*n),xf=t,wf=n}function Ef(){Tf(bf,mf)}var Cf=1/0,Pf=Cf,zf=-Cf,Rf=zf,qf={point:function(t,n){tzf&&(zf=t);nRf&&(Rf=n)},lineStart:eu,lineEnd:eu,polygonStart:eu,polygonEnd:eu,result:function(){var t=[[Cf,Pf],[zf,Rf]];return zf=Rf=-(Pf=Cf=1/0),t}};var Df,Lf,Uf,Of,Yf=0,Bf=0,Ff=0,If=0,Hf=0,jf=0,Xf=0,Gf=0,Vf=0,$f={point:Wf,lineStart:Zf,lineEnd:Kf,polygonStart:function(){$f.lineStart=ts,$f.lineEnd=ns},polygonEnd:function(){$f.point=Wf,$f.lineStart=Zf,$f.lineEnd=Kf},result:function(){var t=Vf?[Xf/Vf,Gf/Vf]:jf?[If/jf,Hf/jf]:Ff?[Yf/Ff,Bf/Ff]:[NaN,NaN];return Yf=Bf=Ff=If=Hf=jf=Xf=Gf=Vf=0,t}};function Wf(t,n){Yf+=t,Bf+=n,++Ff}function Zf(){$f.point=Qf}function Qf(t,n){$f.point=Jf,Wf(Uf=t,Of=n)}function Jf(t,n){var e=t-Uf,r=n-Of,i=Qa(e*e+r*r);If+=i*(Uf+t)/2,Hf+=i*(Of+n)/2,jf+=i,Wf(Uf=t,Of=n)}function Kf(){$f.point=Wf}function ts(){$f.point=es}function ns(){rs(Df,Lf)}function es(t,n){$f.point=rs,Wf(Df=Uf=t,Lf=Of=n)}function rs(t,n){var e=t-Uf,r=n-Of,i=Qa(e*e+r*r);If+=i*(Uf+t)/2,Hf+=i*(Of+n)/2,jf+=i,Xf+=(i=Of*t-Uf*n)*(Uf+t),Gf+=i*(Of+n),Vf+=3*i,Wf(Uf=t,Of=n)}function is(t){this._context=t}is.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,Oa)}},result:eu};var os,as,us,cs,fs,ss=Ea(),ls={point:eu,lineStart:function(){ls.point=hs},lineEnd:function(){os&&ds(as,us),ls.point=eu},polygonStart:function(){os=!0},polygonEnd:function(){os=null},result:function(){var t=+ss;return ss.reset(),t}};function hs(t,n){ls.point=ds,as=cs=t,us=fs=n}function ds(t,n){cs-=t,fs-=n,ss.add(Qa(cs*cs+fs*fs)),cs=t,fs=n}function ps(){this._string=[]}function vs(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function gs(t){return function(n){var e=new ys;for(var r in t)e[r]=t[r];return e.stream=n,e}}function ys(){}function _s(t,n,e){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),cu(e,t.stream(qf)),n(qf.result()),null!=r&&t.clipExtent(r),t}function bs(t,n,e){return _s(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 ms(t,n,e){return bs(t,[[0,0],n],e)}function xs(t,n,e){return _s(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 ws(t,n,e){return _s(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)}ps.prototype={_radius:4.5,_circle:vs(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=vs(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}},ys.prototype={constructor:ys,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 Ms=16,Ns=ja(30*Ba);function As(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=Qa(m*m+x*x+w*w),N=tu(w/=M),A=Fa(Fa(w)-1)n||Fa((y*E+_*C)/b-.5)>.3||a*h+u*d+c*p2?t[2]%360*Ba:0,k()):[g*Ya,y*Ya,_*Ya]},A.angle=function(t){return arguments.length?(b=t%360*Ba,k()):b*Ya},A.precision=function(t){return arguments.length?(a=As(u,N=t*t),T()):Qa(N)},A.fitExtent=function(t,n){return bs(A,t,n)},A.fitSize=function(t,n){return ms(A,t,n)},A.fitWidth=function(t,n){return xs(A,t,n)},A.fitHeight=function(t,n){return ws(A,t,n)},function(){return n=t.apply(this,arguments),A.invert=n.invert&&S,k()}}function Cs(t){var n=0,e=Da/3,r=Es(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*Ba,e=t[1]*Ba):[n*Ya,e*Ya]},i}function Ps(t,n){var e=Wa(t),r=(e+Wa(n))/2;if(Fa(r)0?n<-La+Ra&&(n=-La+Ra):n>La-Ra&&(n=La-Ra);var e=i/$a(Bs(n),r);return[e*Wa(r*t),i-e*ja(r*t)]}return o.invert=function(t,n){var e=i-n,o=Za(r)*Qa(t*t+e*e);return[Ha(t,Fa(e))/r*Za(e),2*Ia($a(i/o,1/r))-La]},o}function Is(t,n){return[t,n]}function Hs(t,n){var e=ja(t),r=t===n?Wa(t):(e-ja(n))/(n-t),i=e/r+t;if(Fa(r)=0;)n+=e[r].value;else n=1;t.value=n}function al(t,n){var e,r,i,o,a,u=new sl(t),c=+t.value&&(u.value=t.value),f=[u];for(null==n&&(n=ul);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 sl(i[o])),r.parent=e,r.depth=e.depth+1;return u.eachBefore(fl)}function ul(t){return t.children}function cl(t){t.data=t.data.data}function fl(t){var n=0;do{t.height=n}while((t=t.parent)&&t.height<++n)}function sl(t){this.data=t,this.depth=this.height=0,this.parent=null}Ws.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*(js+Xs*i+o*(Gs+Vs*i))-n)/(js+3*Xs*i+o*(7*Gs+9*Vs*i)))*r)*i*i,!(Fa(e)Ra&&--i>0);return[t/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r]},Ks.invert=Ds(tu),tl.invert=Ds(function(t){return 2*Ia(t)}),nl.invert=function(t,n){return[-n,2*Ia(Ga(t))-La]},sl.prototype=al.prototype={constructor:sl,count:function(){return this.eachAfter(ol)},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 al(this).eachBefore(cl)}};var ll=Array.prototype.slice;function hl(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}(ll.call(t))).length,o=[];r0&&e*e>r*r+i*i}function gl(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 xl(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 wl(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 Ml(t){this._=t,this.next=null,this.previous=null}function Nl(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;ml(e,n,r=t[2]),n=new Ml(n),e=new Ml(e),r=new Ml(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}(Gl);var Wl=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}(Gl);function Zl(t,n){return t[0]-n[0]||t[1]-n[1]}function Ql(t){for(var n,e,r,i=t.length,o=[0,1],a=2,u=2;u1&&(n=t[o[a-2]],e=t[o[a-1]],r=t[u],(e[0]-n[0])*(r[1]-n[1])-(e[1]-n[1])*(r[0]-n[0])<=0);)--a;o[a++]=u}return o.slice(0,a)}function Jl(){return Math.random()}var Kl=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}(Jl),th=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}(Jl),nh=function t(n){function e(){var t=th.source(n).apply(this,arguments);return function(){return Math.exp(t())}}return e.source=t,e}(Jl),eh=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 _h(t,n,e){var r=t[0],i=t[1],o=n[0],a=n[1];return i2?bh:_h,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),he)))(e)))},l.domain=function(t){return arguments.length?(a=ch.call(t,dh),f===vh||(f=yh(a)),s()):a.slice()},l.range=function(t){return arguments.length?(u=fh.call(t),s()):u.slice()},l.rangeRound=function(t){return u=fh.call(t),c=_e,s()},l.clamp=function(t){return arguments.length?(f=t?yh(a):vh,l):f!==vh},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 wh(t,n){return xh()(t,n)}function Mh(n,e,r,i){var o,a=w(n,e,r);switch((i=ya(null==i?",f":i)).type){case"s":var u=Math.max(Math.abs(n),Math.abs(e));return null!=i.precision||isNaN(o=ka(a,u))||(i.precision=o),t.formatPrefix(i,u);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=Ta(a,Math.max(Math.abs(n),Math.abs(e))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=Sa(a))||(i.precision=o-2*("%"===i.type))}return t.format(i)}function Nh(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 Mh(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 Ah(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 Fh.setTime(+n),Ih.setTime(+r),t(Fh),t(Ih),Math.floor(e(Fh,Ih))},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 jh=Hh(function(){},function(t,n){t.setTime(+t+n)},function(t,n){return n-t});jh.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?Hh(function(n){n.setTime(Math.floor(n/t)*t)},function(n,e){n.setTime(+n+e*t)},function(n,e){return(e-n)/t}):jh:null};var Xh=jh.range,Gh=6e4,Vh=6048e5,$h=Hh(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()}),Wh=$h.range,Zh=Hh(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds())},function(t,n){t.setTime(+t+n*Gh)},function(t,n){return(n-t)/Gh},function(t){return t.getMinutes()}),Qh=Zh.range,Jh=Hh(function(t){t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()-t.getMinutes()*Gh)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getHours()}),Kh=Jh.range,td=Hh(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())*Gh)/864e5},function(t){return t.getDate()-1}),nd=td.range;function ed(t){return Hh(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())*Gh)/Vh})}var rd=ed(0),id=ed(1),od=ed(2),ad=ed(3),ud=ed(4),cd=ed(5),fd=ed(6),sd=rd.range,ld=id.range,hd=od.range,dd=ad.range,pd=ud.range,vd=cd.range,gd=fd.range,yd=Hh(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()}),_d=yd.range,bd=Hh(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()});bd.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Hh(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 md=bd.range,xd=Hh(function(t){t.setUTCSeconds(0,0)},function(t,n){t.setTime(+t+n*Gh)},function(t,n){return(n-t)/Gh},function(t){return t.getUTCMinutes()}),wd=xd.range,Md=Hh(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()}),Nd=Md.range,Ad=Hh(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}),Sd=Ad.range;function kd(t){return Hh(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)/Vh})}var Td=kd(0),Ed=kd(1),Cd=kd(2),Pd=kd(3),zd=kd(4),Rd=kd(5),qd=kd(6),Dd=Td.range,Ld=Ed.range,Ud=Cd.range,Od=Pd.range,Yd=zd.range,Bd=Rd.range,Fd=qd.range,Id=Hh(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()}),Hd=Id.range,jd=Hh(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()});jd.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Hh(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 Xd=jd.range;function Gd(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 Vd(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 $d(t){return{y:t,m:0,d:1,H:0,M:0,S:0,L:0}}function Wd(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=rp(i),s=ip(i),l=rp(o),h=ip(o),d=rp(a),p=ip(a),v=rp(u),g=ip(u),y=rp(c),_=ip(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:Np,e:Np,f:Ep,H:Ap,I:Sp,j:kp,L:Tp,m:Cp,M:Pp,p:function(t){return i[+(t.getHours()>=12)]},Q:ov,s:av,S:zp,u:Rp,U:qp,V:Dp,w:Lp,W:Up,x:null,X:null,y:Op,Y:Yp,Z:Bp,"%":iv},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:Fp,e:Fp,f:Gp,H:Ip,I:Hp,j:jp,L:Xp,m:Vp,M:$p,p:function(t){return i[+(t.getUTCHours()>=12)]},Q:ov,s:av,S:Wp,u:Zp,U:Qp,V:Jp,w:Kp,W:tv,x:null,X:null,y:nv,Y:ev,Z:rv,"%":iv},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:pp,e:pp,f:mp,H:gp,I:gp,j:vp,L:bp,m:dp,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:wp,s:Mp,S:_p,u:ap,U:up,V:cp,w:op,W:fp,x:function(t,n,r){return N(t,e,n,r)},X:function(t,n,e){return N(t,r,n,e)},y:lp,Y:sp,Z:hp,"%":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=Vd($d(o.y))).getUTCDay(),r=i>4||0===i?Ed.ceil(r):Ed(r),r=Ad.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=n($d(o.y))).getDay(),r=i>4||0===i?id.ceil(r):id(r),r=td.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?Vd($d(o.y)).getUTCDay():n($d(o.y)).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,Vd(o)):n(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 Qd?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+="",Gd);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,Vd);return n.toString=function(){return t},n}}}var Zd,Qd={"-":"",_:" ",0:"0"},Jd=/^\s*\d+/,Kd=/^%/,tp=/[\\^$*+?|[\]().{}]/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 hp(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 dp(t,n,e){var r=Jd.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function pp(t,n,e){var r=Jd.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function vp(t,n,e){var r=Jd.exec(n.slice(e,e+3));return r?(t.m=0,t.d=+r[0],e+r[0].length):-1}function gp(t,n,e){var r=Jd.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function yp(t,n,e){var r=Jd.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function _p(t,n,e){var r=Jd.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function bp(t,n,e){var r=Jd.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function mp(t,n,e){var r=Jd.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=Kd.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function wp(t,n,e){var r=Jd.exec(n.slice(e));return r?(t.Q=+r[0],e+r[0].length):-1}function Mp(t,n,e){var r=Jd.exec(n.slice(e));return r?(t.Q=1e3*+r[0],e+r[0].length):-1}function Np(t,n){return np(t.getDate(),n,2)}function Ap(t,n){return np(t.getHours(),n,2)}function Sp(t,n){return np(t.getHours()%12||12,n,2)}function kp(t,n){return np(1+td.count(bd(t),t),n,3)}function Tp(t,n){return np(t.getMilliseconds(),n,3)}function Ep(t,n){return Tp(t,n)+"000"}function Cp(t,n){return np(t.getMonth()+1,n,2)}function Pp(t,n){return np(t.getMinutes(),n,2)}function zp(t,n){return np(t.getSeconds(),n,2)}function Rp(t){var n=t.getDay();return 0===n?7:n}function qp(t,n){return np(rd.count(bd(t),t),n,2)}function Dp(t,n){var e=t.getDay();return t=e>=4||0===e?ud(t):ud.ceil(t),np(ud.count(bd(t),t)+(4===bd(t).getDay()),n,2)}function Lp(t){return t.getDay()}function Up(t,n){return np(id.count(bd(t),t),n,2)}function Op(t,n){return np(t.getFullYear()%100,n,2)}function Yp(t,n){return np(t.getFullYear()%1e4,n,4)}function Bp(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+np(n/60|0,"0",2)+np(n%60,"0",2)}function Fp(t,n){return np(t.getUTCDate(),n,2)}function Ip(t,n){return np(t.getUTCHours(),n,2)}function Hp(t,n){return np(t.getUTCHours()%12||12,n,2)}function jp(t,n){return np(1+Ad.count(jd(t),t),n,3)}function Xp(t,n){return np(t.getUTCMilliseconds(),n,3)}function Gp(t,n){return Xp(t,n)+"000"}function Vp(t,n){return np(t.getUTCMonth()+1,n,2)}function $p(t,n){return np(t.getUTCMinutes(),n,2)}function Wp(t,n){return np(t.getUTCSeconds(),n,2)}function Zp(t){var n=t.getUTCDay();return 0===n?7:n}function Qp(t,n){return np(Td.count(jd(t),t),n,2)}function Jp(t,n){var e=t.getUTCDay();return t=e>=4||0===e?zd(t):zd.ceil(t),np(zd.count(jd(t),t)+(4===jd(t).getUTCDay()),n,2)}function Kp(t){return t.getUTCDay()}function tv(t,n){return np(Ed.count(jd(t),t),n,2)}function nv(t,n){return np(t.getUTCFullYear()%100,n,2)}function ev(t,n){return np(t.getUTCFullYear()%1e4,n,4)}function rv(){return"+0000"}function iv(){return"%"}function ov(t){return+t}function av(t){return Math.floor(+t/1e3)}function uv(n){return Zd=Wd(n),t.timeFormat=Zd.format,t.timeParse=Zd.parse,t.utcFormat=Zd.utcFormat,t.utcParse=Zd.utcParse,Zd}uv({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 cv=Date.prototype.toISOString?function(t){return t.toISOString()}:t.utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");var fv=+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"),sv=1e3,lv=60*sv,hv=60*lv,dv=24*hv,pv=7*dv,vv=30*dv,gv=365*dv;function yv(t){return new Date(t)}function _v(t){return t instanceof Date?+t:+new Date(+t)}function bv(t,n,r,i,o,a,u,c,f){var s=wh(vh,vh),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,sv],[u,5,5*sv],[u,15,15*sv],[u,30,30*sv],[a,1,lv],[a,5,5*lv],[a,15,15*lv],[a,30,30*lv],[o,1,hv],[o,3,3*hv],[o,6,6*hv],[o,12,12*hv],[i,1,dv],[i,2,2*dv],[r,1,pv],[n,1,vv],[n,3,3*vv],[t,1,gv]];function M(e){return(u(e)=1?iy:t<=-1?-iy:Math.asin(t)}function uy(t){return t.innerRadius}function cy(t){return t.outerRadius}function fy(t){return t.startAngle}function sy(t){return t.endAngle}function ly(t){return t&&t.padAngle}function hy(t,n,e,r,i,o,a){var u=t-e,c=n-r,f=(a?o:-o)/ny(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)*ny(Jg(0,x*x*m-w*w)),N=(w*b-_*M)/m,A=(-w*_-b*M)/m,S=(w*b+_*M)/m,k=(-w*_+b*M)/m,T=N-g,E=A-y,C=S-g,P=k-y;return T*T+E*E>C*C+P*P&&(N=S,A=k),{cx:N,cy:A,x01:-s,y01:-l,x11:N*(i/x-1),y11:A*(i/x-1)}}function dy(t){this._context=t}function py(t){return new dy(t)}function vy(t){return t[0]}function gy(t){return t[1]}function yy(){var t=vy,n=gy,e=$g(!0),r=null,i=py,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 yy().defined(i).curve(a).context(o)}return c.x=function(e){return arguments.length?(t="function"==typeof e?e:$g(+e),n=null,c):t},c.x0=function(n){return arguments.length?(t="function"==typeof n?n:$g(+n),c):t},c.x1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:$g(+t),c):n},c.y=function(t){return arguments.length?(e="function"==typeof t?t:$g(+t),r=null,c):e},c.y0=function(t){return arguments.length?(e="function"==typeof t?t:$g(+t),c):e},c.y1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:$g(+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:$g(!!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 by(t,n){return nt?1:n>=t?0:NaN}function my(t){return t}dy.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 xy=My(py);function wy(t){this._curve=t}function My(t){function n(n){return new wy(t(n))}return n._curve=t,n}function Ny(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(My(t)):n()._curve},t}function Ay(){return Ny(yy().curve(xy))}function Sy(){var t=_y().curve(xy),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 Ny(e())},delete t.lineX0,t.lineEndAngle=function(){return Ny(r())},delete t.lineX1,t.lineInnerRadius=function(){return Ny(i())},delete t.lineY0,t.lineOuterRadius=function(){return Ny(o())},delete t.lineY1,t.curve=function(t){return arguments.length?n(My(t)):n()._curve},t}function ky(t,n){return[(n=+n)*Math.cos(t-=Math.PI/2),n*Math.sin(t)]}wy.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 Ty=Array.prototype.slice;function Ey(t){return t.source}function Cy(t){return t.target}function Py(t){var n=Ey,e=Cy,r=vy,i=gy,o=null;function a(){var a,u=Ty.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:$g(+t),a):r},a.y=function(t){return arguments.length?(i="function"==typeof t?t:$g(+t),a):i},a.context=function(t){return arguments.length?(o=null==t?null:t,a):o},a}function zy(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n=(n+r)/2,e,n,i,r,i)}function Ry(t,n,e,r,i){t.moveTo(n,e),t.bezierCurveTo(n,e=(e+i)/2,r,e,r,i)}function qy(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 Dy={draw:function(t,n){var e=Math.sqrt(n/ry);t.moveTo(e,0),t.arc(0,0,e,0,oy)}},Ly={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()}},Uy=Math.sqrt(1/3),Oy=2*Uy,Yy={draw:function(t,n){var e=Math.sqrt(n/Oy),r=e*Uy;t.moveTo(0,-e),t.lineTo(r,0),t.lineTo(0,e),t.lineTo(-r,0),t.closePath()}},By=Math.sin(ry/10)/Math.sin(7*ry/10),Fy=Math.sin(oy/10)*By,Iy=-Math.cos(oy/10)*By,Hy={draw:function(t,n){var e=Math.sqrt(.8908130915292852*n),r=Fy*e,i=Iy*e;t.moveTo(0,-e),t.lineTo(r,i);for(var o=1;o<5;++o){var a=oy*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()}},jy={draw:function(t,n){var e=Math.sqrt(n),r=-e/2;t.rect(r,r,e,e)}},Xy=Math.sqrt(3),Gy={draw:function(t,n){var e=-Math.sqrt(n/(3*Xy));t.moveTo(0,2*e),t.lineTo(-Xy*e,-e),t.lineTo(Xy*e,-e),t.closePath()}},Vy=Math.sqrt(3)/2,$y=1/Math.sqrt(12),Wy=3*($y/2+1),Zy={draw:function(t,n){var e=Math.sqrt(n/Wy),r=e/2,i=e*$y,o=r,a=e*$y+e,u=-o,c=a;t.moveTo(r,i),t.lineTo(o,a),t.lineTo(u,c),t.lineTo(-.5*r-Vy*i,Vy*r+-.5*i),t.lineTo(-.5*o-Vy*a,Vy*o+-.5*a),t.lineTo(-.5*u-Vy*c,Vy*u+-.5*c),t.lineTo(-.5*r+Vy*i,-.5*i-Vy*r),t.lineTo(-.5*o+Vy*a,-.5*a-Vy*o),t.lineTo(-.5*u+Vy*c,-.5*c-Vy*u),t.closePath()}},Qy=[Dy,Ly,Yy,jy,Hy,Gy,Zy];function Jy(){}function Ky(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 n_(t){this._context=t}function e_(t){this._context=t}function r_(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:Ky(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:Ky(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},n_.prototype={areaStart:Jy,areaEnd:Jy,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:Ky(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},e_.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:Ky(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},r_.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 i_=function t(n){function e(t){return 1===n?new t_(t):new r_(t,n)}return e.beta=function(n){return t(+n)},e}(.85);function o_(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 a_(t,n){this._context=t,this._k=(1-n)/6}a_.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:o_(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:o_(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 u_=function t(n){function e(t){return new a_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function c_(t,n){this._context=t,this._k=(1-n)/6}c_.prototype={areaStart:Jy,areaEnd:Jy,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:o_(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 f_=function t(n){function e(t){return new c_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function s_(t,n){this._context=t,this._k=(1-n)/6}s_.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:o_(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 s_(t,n)}return e.tension=function(n){return t(+n)},e}(0);function h_(t,n,e){var r=t._x1,i=t._y1,o=t._x2,a=t._y2;if(t._l01_a>ey){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>ey){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 d_(t,n){this._context=t,this._alpha=n}d_.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:h_(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 p_=function t(n){function e(t){return n?new d_(t,n):new a_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function v_(t,n){this._context=t,this._alpha=n}v_.prototype={areaStart:Jy,areaEnd:Jy,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:h_(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 g_=function t(n){function e(t){return n?new v_(t,n):new c_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function y_(t,n){this._context=t,this._alpha=n}y_.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:h_(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 __=function t(n){function e(t){return n?new y_(t,n):new s_(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function b_(t){this._context=t}function m_(t){return t<0?-1:1}function x_(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(m_(o)+m_(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(u))||0}function w_(t,n){var e=t._x1-t._x0;return e?(3*(t._y1-t._y0)/e-n)/2:n}function M_(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 N_(t){this._context=t}function A_(t){this._context=new S_(t)}function S_(t){this._context=t}function k_(t){this._context=t}function T_(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 z_(t,n){return t[n]}function R_(t){var n=t.map(q_);return P_(t).sort(function(t,e){return n[t]-n[e]})}function q_(t){for(var n,e=-1,r=0,i=t.length,o=-1/0;++eo&&(o=n,r=e);return r}function D_(t){var n=t.map(L_);return P_(t).sort(function(t,e){return n[t]-n[e]})}function L_(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 W_(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}},B_.prototype={constructor:B_,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=j_(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&&(I_(this,e),e=(t=e).U),e.C=!1,r.C=!0,H_(this,r)):(i=r.L)&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.L&&(H_(this,e),e=(t=e).U),e.C=!1,r.C=!0,I_(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?j_(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,I_(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,H_(this,n),n=i.R),n.C=i.C,i.C=n.R.C=!1,I_(this,i),t=this._;break}}else if((n=i.L).C&&(n.C=!1,i.C=!0,H_(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,I_(this,n),n=i.L),n.C=i.C,i.C=n.L.C=!1,H_(this,i),t=this._;break}n.C=!0,t=i,i=i.U}while(!t.C);t&&(t.C=!1)}}};var K_,tb=[];function nb(){F_(this),this.x=this.y=this.arc=this.site=this.cy=null}function eb(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>=-yb)){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 nb;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=pb._;b;)if(y.ygb)u=u.L;else{if(!((i=o-lb(u,a))>gb)){r>-gb?(n=u.P,e=u):i>-gb?(n=u,e=u.N):n=e=u;break}if(!u.R){n=u;break}u=u.R}!function(t){db[t.index]={site:t,halfedges:[]}}(t);var c=ab(t);if(hb.insert(n,c),n||e){if(n===e)return rb(n),e=ab(n.site),hb.insert(c,e),c.edge=e.edge=X_(n.site,c.site),eb(n),void eb(e);if(e){rb(n),rb(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];V_(e.edge,f,p,m),c.edge=X_(f,t,null,m),e.edge=X_(t,p,null,m),eb(n),eb(e)}else c.edge=X_(n.site,c.site)}}function sb(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 sb(e,n);var r=t.site;return r[1]===n?r[0]:1/0}var hb,db,pb,vb,gb=1e-6,yb=1e-12;function _b(t,n){return n[1]-t[1]||n[0]-t[0]}function bb(t,n){var e,r,i,o=t.sort(_b).pop();for(vb=[],db=new Array(t.length),hb=new B_,pb=new B_;;)if(i=K_,o&&(!i||o[1]gb||Math.abs(i[0][1]-i[1][1])>gb)||delete vb[o]}(a,u,c,f),function(t,n,e,r){var i,o,a,u,c,f,s,l,h,d,p,v,g=db.length,y=!0;for(i=0;igb||Math.abs(v-h)>gb)&&(c.splice(u,0,vb.push(G_(a,d,Math.abs(p-t)gb?[t,Math.abs(l-t)gb?[Math.abs(h-r)gb?[e,Math.abs(l-e)gb?[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))}Nb.prototype=wb.prototype,t.version="5.8.2",t.bisect=i,t.bisectRight=i,t.bisectLeft=o,t.ascending=n,t.bisector=e,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.extent=s,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=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=Qi(),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,to,no),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.set=io,t.map=Qi,t.keys=function(t){var n=[];for(var e in t)n.push(e);return n},t.values=function(t){var n=[];for(var e in t)n.push(t[e]);return n},t.entries=function(t){var n=[];for(var e in t)n.push({key:e,value:t[e]});return n},t.color=hn,t.rgb=gn,t.hsl=mn,t.lab=Rn,t.hcl=Bn,t.lch=function(t,n,e,r){return 1===arguments.length?Yn(t):new Fn(e,n,t,null==r?1:r)},t.gray=function(t,n){return new qn(t,0,0,null==n?1:n)},t.cubehelix=Zn,t.contours=po,t.contourDensity=function(){var t=yo,n=_o,e=bo,r=960,i=500,o=20,a=2,u=3*o,c=r+2*u>>a,f=i+2*u>>a,s=uo(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),go({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),vo({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),go({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a),vo({width:c,height:f,data:i},{width:c,height:f,data:l},o>>a),go({width:c,height:f,data:l},{width:c,height:f,data:i},o>>a);var d=s(i);if(!Array.isArray(d)){var p=A(i);d=w(0,p,d),(d=g(0,Math.floor(p/d)*d,d)).shift()}return po().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:uo(+n),l):t},l.y=function(t){return arguments.length?(n="function"==typeof t?t:uo(+t),l):n},l.weight=function(t){return arguments.length?(e="function"==typeof t?t:uo(+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)?uo(oo.call(t)):uo(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.dispatch=I,t.drag=function(){var n,e,r,i,o=Gt,a=Vt,u=$t,c=Wt,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),Ot,this,arguments);u&&(zt(t.event.view).on("mousemove.drag",v,!0).on("mouseup.drag",g,!0),It(t.event.view),Bt(),r=!1,n=t.event.clientX,e=t.event.clientY,u("start"))}}function v(){if(Ft(),!r){var i=t.event.clientX-n,o=t.event.clientY-e;r=i*i+o*o>h}f.mouse("drag")}function g(){zt(t.event.view).on("mousemove.drag mouseup.drag",null),Ht(t.event.view,r),Ft(),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=Zo())*s),0===l&&(d+=(l=Zo())*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=Wo(.1);function o(t){for(var i,o=0,a=n.length;ofc(r[0],r[1])&&(r[1]=i[1]),fc(i[0],r[1])>fc(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=fc(r[1],i[0]))>a&&(a=u,Tu=i[0],Cu=r[1])}return Lu=Uu=null,Tu===1/0||Eu===1/0?[[NaN,NaN],[NaN,NaN]]:[[Tu,Eu],[Cu,Pu]]},t.geoCentroid=function(t){Ou=Yu=Bu=Fu=Iu=Hu=ju=Xu=Gu=Vu=$u=0,cu(t,hc);var n=Gu,e=Vu,r=$u,i=n*n+e*e+r*r;return i=.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;++e2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90]).scale(159.155)},t.geoTransverseMercatorRaw=nl,t.geoRotation=Cc,t.geoStream=cu,t.geoTransform=function(t){return{stream:gs(t)}},t.cluster=function(){var t=el,n=1,e=1,r=!1;function i(i){var o,a=0;i.eachAfter(function(n){var e=n.children;e?(n.x=function(t){return t.reduce(rl,0)/t.length}(e),n.y=function(t){return 1+t.reduce(il,0)}(e)):(n.x=o?a+=t(n,o):0,n.y=0,o=n)});var u=function(t){for(var n;n=t.children;)t=n[0];return t}(i),c=function(t){for(var n;n=t.children;)t=n[n.length-1];return t}(i),f=u.x-t(u,c)/2,s=c.x+t(c,u)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*n,t.y=(i.y-t.y)*e}:function(t){t.x=(t.x-f)/(s-f)*n,t.y=(1-(i.y?t.y/i.y:1))*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.hierarchy=al,t.pack=function(){var t=null,n=1,e=1,r=Sl;function i(i){return i.x=n/2,i.y=e/2,t?i.eachBefore(El(t)).eachAfter(Cl(r,.5)).eachBefore(Pl(1)):i.eachBefore(El(Tl)).eachAfter(Cl(Sl,1)).eachAfter(Cl(r,i.r/Math.min(n,e))).eachBefore(Pl(Math.min(n,e)/(2*i.r))),i}return i.radius=function(n){return arguments.length?(t=null==(e=n)?null:Al(e),i):t;var e},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:kl(+t),i):r},i},t.packSiblings=function(t){return Nl(t),t},t.packEnclose=hl,t.partition=function(){var t=1,n=1,e=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=e,i.x1=t,i.y1=n/o,i.eachBefore(function(t,n){return function(r){r.children&&Rl(r,r.x0,t*(r.depth+1)/n,r.x1,t*(r.depth+2)/n);var i=r.x0,o=r.y0,a=r.x1-e,u=r.y1-e;a0)throw new Error("cycle");return o}return e.id=function(n){return arguments.length?(t=Al(n),e):t},e.parentId=function(t){return arguments.length?(n=Al(t),e):n},e},t.tree=function(){var t=Yl,n=1,e=1,r=null;function i(i){var c=function(t){for(var n,e,r,i,o,a=new jl(t,0),u=[a];n=u.pop();)if(r=n._.children)for(n.children=new Array(o=r.length),i=o-1;i>=0;--i)u.push(e=n.children[i]=new jl(r[i],i)),e.parent=n;return(a.parent=new jl(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=Fl(u),o=Bl(o),u&&o;)c=Bl(c),(a=Fl(a)).a=n,(i=u.z+l-o.z-f+t(u._,o._))>0&&(Il(Hl(u,n,r),n,i),f+=i,s+=i),l+=u.m,f+=o.m,h+=c.m,s+=a.m;u&&!Fl(a)&&(a.t=u,a.m+=l-s),o&&!Bl(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=$l,n=!1,e=1,r=1,i=[0],o=Sl,a=Sl,u=Sl,c=Sl,f=Sl;function s(t){return t.x0=t.y0=0,t.x1=e,t.y1=r,t.eachBefore(l),i=[0],n&&t.eachBefore(zl),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=Rl,t.treemapSlice=Xl,t.treemapSliceDice=function(t,n,e,r,i){(1&t.depth?Xl:Rl)(t,n,e,r,i)},t.treemapSquarify=$l,t.treemapResquarify=Wl,t.interpolate=ye,t.interpolateArray=se,t.interpolateBasis=Kn,t.interpolateBasisClosed=te,t.interpolateDate=le,t.interpolateDiscrete=function(t){var n=t.length;return function(e){return t[Math.max(0,Math.min(n-1,Math.floor(e*n)))]}},t.interpolateHue=function(t,n){var e=re(+t,+n);return function(t){var n=e(t);return n-360*Math.floor(n/360)}},t.interpolateNumber=he,t.interpolateObject=de,t.interpolateRound=_e,t.interpolateString=ge,t.interpolateTransformCss=ke,t.interpolateTransformSvg=Te,t.interpolateZoom=qe,t.interpolateRgb=ae,t.interpolateRgbBasis=ce,t.interpolateRgbBasisClosed=fe,t.interpolateHsl=Le,t.interpolateHslLong=Ue,t.interpolateLab=function(t,n){var e=oe((t=Rn(t)).l,(n=Rn(n)).l),r=oe(t.a,n.a),i=oe(t.b,n.b),o=oe(t.opacity,n.opacity);return function(n){return t.l=e(n),t.a=r(n),t.b=i(n),t.opacity=o(n),t+""}},t.interpolateHcl=Ye,t.interpolateHclLong=Be,t.interpolateCubehelix=Ie,t.interpolateCubehelixLong=He,t.piecewise=function(t,n){for(var e=0,r=n.length-1,i=n[0],o=new Array(r<0?0:r);e=0;--n)f.push(t[r[o[n]][2]]);for(n=+u;nu!=f>u&&a<(c-e)*(u-r)/(f-r)+e&&(s=!s),c=e,f=r;return s},t.polygonLength=function(t){for(var n,e,r=-1,i=t.length,o=t[i-1],a=o[0],u=o[1],c=0;++r0?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)},oh.apply(Nh(c),arguments)},t.scaleThreshold=function t(){var n,e=[.5],r=[0,1],o=1;function a(t){return t<=t?r[i(e,t,0,o)]:n}return a.domain=function(t){return arguments.length?(e=fh.call(t),o=Math.min(e.length,r.length-1),a):e.slice()},a.range=function(t){return arguments.length?(r=fh.call(t),o=Math.min(e.length,r.length-1),a):r.slice()},a.invertExtent=function(t){var n=r.indexOf(t);return[e[n-1],e[n]]},a.unknown=function(t){return arguments.length?(n=t,a):n},a.copy=function(){return t().domain(e).range(r).unknown(n)},oh.apply(a,arguments)},t.scaleTime=function(){return oh.apply(bv(bd,yd,rd,td,Jh,Zh,$h,jh,t.timeFormat).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)},t.scaleUtc=function(){return oh.apply(bv(jd,Id,Td,Ad,Md,xd,$h,jh,t.utcFormat).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},t.scaleSequential=function t(){var n=Nh(mv()(vh));return n.copy=function(){return xv(n,t())},ah.apply(n,arguments)},t.scaleSequentialLog=function t(){var n=zh(mv()).domain([1,10]);return n.copy=function(){return xv(n,t()).base(n.base())},ah.apply(n,arguments)},t.scaleSequentialPow=wv,t.scaleSequentialSqrt=function(){return wv.apply(null,arguments).exponent(.5)},t.scaleSequentialSymlog=function t(){var n=Dh(mv());return n.copy=function(){return xv(n,t()).constant(n.constant())},ah.apply(n,arguments)},t.scaleSequentialQuantile=function t(){var e=[],r=vh;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;i1)&&(t-=Math.floor(t));var n=Math.abs(t-.5);return Yg.h=360*t-100,Yg.s=1.5-1.5*n,Yg.l=.8-.9*n,Yg+""},t.interpolateWarm=Ug,t.interpolateCool=Og,t.interpolateSinebow=function(t){var n;return t=(.5-t)*Math.PI,Bg.r=255*(n=Math.sin(t))*n,Bg.g=255*(n=Math.sin(t+Fg))*n,Bg.b=255*(n=Math.sin(t+Ig))*n,Bg+""},t.interpolateViridis=jg,t.interpolateMagma=Xg,t.interpolateInferno=Gg,t.interpolatePlasma=Vg,t.create=function(t){return zt(W(t).call(document.documentElement))},t.creator=W,t.local=qt,t.matcher=tt,t.mouse=Ot,t.namespace=$,t.namespaces=V,t.clientPoint=Ut,t.select=zt,t.selectAll=function(t){return"string"==typeof t?new Ct([document.querySelectorAll(t)],[document.documentElement]):new Ct([null==t?[]:t],Et)},t.selection=Pt,t.selector=Q,t.selectorAll=K,t.style=ct,t.touch=Yt,t.touches=function(t,n){null==n&&(n=Lt().touches);for(var e=0,r=n?n.length:0,i=new Array(r);ed;if(u||(u=c=ji()),hey)if(v>oy-ey)u.moveTo(h*Qg(d),h*ty(d)),u.arc(0,0,h,d,p,!g),l>ey&&(u.moveTo(l*Qg(p),l*ty(p)),u.arc(0,0,l,p,d,g));else{var y,_,b=d,m=p,x=d,w=p,M=v,N=v,A=a.apply(this,arguments)/2,S=A>ey&&(r?+r.apply(this,arguments):ny(l*l+h*h)),k=Kg(Wg(h-l)/2,+e.apply(this,arguments)),T=k,E=k;if(S>ey){var C=ay(S/l*ty(A)),P=ay(S/h*ty(A));(M-=2*C)>ey?(x+=C*=g?1:-1,w-=C):(M=0,x=w=(d+p)/2),(N-=2*P)>ey?(b+=P*=g?1:-1,m-=P):(N=0,b=m=(d+p)/2)}var z=h*Qg(b),R=h*ty(b),q=l*Qg(w),D=l*ty(w);if(k>ey){var L,U=h*Qg(m),O=h*ty(m),Y=l*Qg(x),B=l*ty(x);if(v1?0:s<-1?ry:Math.acos(s))/2),G=ny(L[0]*L[0]+L[1]*L[1]);T=Kg(k,(l-G)/(X-1)),E=Kg(k,(h-G)/(X+1))}}N>ey?E>ey?(y=hy(Y,B,z,R,h,E,g),_=hy(U,O,q,D,h,E,g),u.moveTo(y.cx+y.x01,y.cy+y.y01),Eey&&M>ey?T>ey?(y=hy(q,D,U,O,l,-T,g),_=hy(z,R,Y,B,l,-T,g),u.lineTo(y.cx+y.x01,y.cy+y.y01),T0&&(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:$g(+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:$g(+t),a):r},a.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:$g(+t),a):i},a.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:$g(+t),a):o},a},t.areaRadial=Sy,t.radialArea=Sy,t.lineRadial=Ay,t.radialLine=Ay,t.pointRadial=ky,t.linkHorizontal=function(){return Py(zy)},t.linkVertical=function(){return Py(Ry)},t.linkRadial=function(){var t=Py(qy);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t},t.symbol=function(){var t=$g(Dy),n=$g(64),e=null;function r(){var r;if(e||(e=r=ji()),t.apply(this,arguments).draw(e,+n.apply(this,arguments)),r)return e=null,r+""||null}return r.type=function(n){return arguments.length?(t="function"==typeof n?n:$g(n),r):t},r.size=function(t){return arguments.length?(n="function"==typeof t?t:$g(+t),r):n},r.context=function(t){return arguments.length?(e=null==t?null:t,r):e},r},t.symbols=Qy,t.symbolCircle=Dy,t.symbolCross=Ly,t.symbolDiamond=Yy,t.symbolSquare=jy,t.symbolStar=Hy,t.symbolTriangle=Gy,t.symbolWye=Zy,t.curveBasisClosed=function(t){return new n_(t)},t.curveBasisOpen=function(t){return new e_(t)},t.curveBasis=function(t){return new t_(t)},t.curveBundle=i_,t.curveCardinalClosed=f_,t.curveCardinalOpen=l_,t.curveCardinal=u_,t.curveCatmullRomClosed=g_,t.curveCatmullRomOpen=__,t.curveCatmullRom=p_,t.curveLinearClosed=function(t){return new b_(t)},t.curveLinear=py,t.curveMonotoneX=function(t){return new N_(t)},t.curveMonotoneY=function(t){return new A_(t)},t.curveNatural=function(t){return new k_(t)},t.curveStep=function(t){return new E_(t,.5)},t.curveStepAfter=function(t){return new E_(t,1)},t.curveStepBefore=function(t){return new E_(t,0)},t.stack=function(){var t=$g([]),n=P_,e=C_,r=z_;function i(i){var o,a,u=t.apply(this,arguments),c=i.length,f=u.length,s=new Array(f);for(o=0;o0){for(var e,r,i,o=0,a=t[0].length;o1)for(var e,r,i,o,a,u,c=0,f=t[n[0]].length;c=0?(r[0]=o,r[1]=o+=i):i<0?(r[1]=a,r[0]=a+=i):r[0]=o},t.stackOffsetNone=C_,t.stackOffsetSilhouette=function(t,n){if((e=t.length)>0){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;adr&&e.name===n)return new Er([[t]],fi,n,+r);return null},t.interrupt=Mr,t.voronoi=function(){var t=O_,n=Y_,e=null;function r(r){return new bb(r.map(function(e,i){var o=[Math.round(t(e,i,r)/gb)*gb,Math.round(n(e,i,r)/gb)*gb];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:U_(+n),r):t},r.y=function(t){return arguments.length?(n="function"==typeof t?t:U_(+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.zoom=function(){var n,e,r=kb,i=Tb,o=zb,a=Cb,u=Pb,c=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],s=250,l=qe,h=[],d=I("start","zoom","end"),p=500,v=150,g=0;function y(t){t.property("__zoom",Eb).on("wheel.zoom",N).on("mousedown.zoom",A).on("dblclick.zoom",S).filter(u).on("touchstart.zoom",k).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(t,n){return(n=Math.max(c[0],Math.min(c[1],n)))===t.k?t:new wb(n,t.x,t.y)}function b(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 wb(t.k,r,i)}function m(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function x(t,n,e){t.on("start.zoom",function(){w(this,arguments).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).end()}).tween("zoom",function(){var t=arguments,r=w(this,t),o=i.apply(this,t),a=e||m(o),u=Math.max(o[1][0]-o[0][0],o[1][1]-o[0][1]),c=this.__zoom,f="function"==typeof n?n.apply(this,t):n,s=l(c.invert(a).concat(u/c.k),f.invert(a).concat(u/f.k));return function(t){if(1===t)t=f;else{var n=s(t),e=u/n[2];t=new wb(e,a[0]-n[0]*e,a[1]-n[1]*e)}r.zoom(null,t)}})}function w(t,n){for(var e,r=0,i=h.length;rg}n.zoom("mouse",o(b(n.that.__zoom,n.mouse[0]=Ot(n.that),n.mouse[1]),n.extent,f))},!0).on("mouseup.zoom",function(){i.on("mousemove.zoom mouseup.zoom",null),Ht(t.event.view,n.moved),Sb(),n.end()},!0),a=Ot(this),u=t.event.clientX,c=t.event.clientY;It(t.event.view),Ab(),n.mouse=[a,this.__zoom.invert(a)],Mr(this),n.start()}}function S(){if(r.apply(this,arguments)){var n=this.__zoom,e=Ot(this),a=n.invert(e),u=n.k*(t.event.shiftKey?.5:2),c=o(b(_(n,u),e,a),i.apply(this,arguments),f);Sb(),s>0?zt(this).transition().duration(s).call(x,c,e):zt(this).call(y.transform,c)}}function k(){if(r.apply(this,arguments)){var e,i,o,a,u=w(this,arguments),c=t.event.changedTouches,f=c.length;for(Ab(),i=0;i')};i(["foundation-mq-small","foundation-mq-medium","foundation-mq-large","foundation-mq-xlarge","foundation-mq-xxlarge","foundation-data-attribute-namespace"]),e(function(){typeof FastClick!="undefined"&&typeof n.body!="undefined"&&FastClick.attach(n.body)});var s=function(t,r){if(typeof t=="string"){if(r){var i;if(r.jquery){i=r[0];if(!i)return r}else i=r;return e(i.querySelectorAll(t))}return e(n.querySelectorAll(t))}return e(t,r)},o=function(e){var t=[];return e||t.push("data"),this.namespace.length>0&&t.push(this.namespace),t.push(this.name),t.join("-")},u=function(e){var t=e.split("-"),n=t.length,r=[];while(n--)n!==0?r.push(t[n]):this.namespace.length>0?r.push(this.namespace,t[n]):r.push(t[n]);return r.reverse().join("-")},a=function(t,n){var r=this,i=!s(this).data(this.attr_name(!0));if(typeof t=="string")return this[t].call(this,n);s(this.scope).is("["+this.attr_name()+"]")?(s(this.scope).data(this.attr_name(!0)+"-init",e.extend({},this.settings,n||t,this.data_options(s(this.scope)))),i&&this.events(this.scope)):s("["+this.attr_name()+"]",this.scope).each(function(){var i=!s(this).data(r.attr_name(!0)+"-init");s(this).data(r.attr_name(!0)+"-init",e.extend({},r.settings,n||t,r.data_options(s(this)))),i&&r.events(this)})},f=function(e,t){function n(){t(e[0])}function r(){this.one("load",n);if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var e=this.attr("src"),t=e.match(/\?/)?"&":"?";t+="random="+(new Date).getTime(),this.attr("src",e+t)}}if(!e.attr("src")){n();return}e[0].complete||e[0].readyState===4?n():r.call(e)};t.matchMedia=t.matchMedia||function(e){var t,n=e.documentElement,r=n.firstElementChild||n.firstChild,i=e.createElement("body"),s=e.createElement("div");return s.id="mq-test-1",s.style.cssText="position:absolute;top:-100em",i.style.background="none",i.appendChild(s),function(e){return s.innerHTML='­',n.insertBefore(i,r),t=s.offsetWidth===42,n.removeChild(i),{matches:t,media:e}}}(n),function(e){function a(){n&&(s(a),u&&jQuery.fx.tick())}var n,r=0,i=["webkit","moz"],s=t.requestAnimationFrame,o=t.cancelAnimationFrame,u="undefined"!=typeof jQuery.fx;for(;r").appendTo("head")[0].sheet,global:{namespace:r},init:function(e,t,n,r,i){var o=[e,n,r,i],u=[];this.rtl=/rtl/i.test(s("html").attr("dir")),this.scope=e||this.scope,this.set_namespace();if(t&&typeof t=="string"&&!/reflow/i.test(t))this.libs.hasOwnProperty(t)&&u.push(this.init_lib(t,o));else for(var a in this.libs)u.push(this.init_lib(a,t));return e},init_lib:function(t,n){return this.libs.hasOwnProperty(t)?(this.patch(this.libs[t]),n&&n.hasOwnProperty(t)?(typeof this.libs[t].settings!="undefined"?e.extend(!0,this.libs[t].settings,n[t]):typeof this.libs[t].defaults!="undefined"&&e.extend(!0,this.libs[t].defaults,n[t]),this.libs[t].init.apply(this.libs[t],[this.scope,n[t]])):(n=n instanceof Array?n:new Array(n),this.libs[t].init.apply(this.libs[t],n))):function(){}},patch:function(e){e.scope=this.scope,e.namespace=this.global.namespace,e.rtl=this.rtl,e.data_options=this.utils.data_options,e.attr_name=o,e.add_namespace=u,e.bindings=a,e.S=this.utils.S},inherit:function(e,t){var n=t.split(" "),r=n.length;while(r--)this.utils.hasOwnProperty(n[r])&&(e[n[r]]=this.utils[n[r]])},set_namespace:function(){var t=this.global.namespace===r?e(".foundation-data-attribute-namespace").css("font-family"):this.global.namespace;this.global.namespace=t===r||/false/i.test(t)?"":t},libs:{},utils:{S:s,throttle:function(e,t){var n=null;return function(){var r=this,i=arguments;n==null&&(n=setTimeout(function(){e.apply(r,i),n=null},t))}},debounce:function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},data_options:function(t){function a(e){return!isNaN(e-0)&&e!==null&&e!==""&&e!==!1&&e!==!0}function f(t){return typeof t=="string"?e.trim(t):t}var n={},r,i,s,o=function(e){var t=Foundation.global.namespace;return t.length>0?e.data(t+"-options"):e.data("options")},u=o(t);if(typeof u=="object")return u;s=(u||":").split(";"),r=s.length;while(r--)i=s[r].split(":"),/true/i.test(i[1])&&(i[1]=!0),/false/i.test(i[1])&&(i[1]=!1),a(i[1])&&(i[1].indexOf(".")===-1?i[1]=parseInt(i[1],10):i[1]=parseFloat(i[1])),i.length===2&&i[0].length>0&&(n[f(i[0])]=f(i[1]));return n},register_media:function(t,n){Foundation.media_queries[t]===r&&(e("head").append(''),Foundation.media_queries[t]=l(e("."+n).css("font-family")))},add_custom_rule:function(e,t){if(t===r&&Foundation.stylesheet)Foundation.stylesheet.insertRule(e,Foundation.stylesheet.cssRules.length);else{var n=Foundation.media_queries[t];n!==r&&Foundation.stylesheet.insertRule("@media "+Foundation.media_queries[t]+"{ "+e+" }")}},image_loaded:function(e,t){var n=this,r=e.length;r===0&&t(e),e.each(function(){f(n.S(this),function(){r-=1,r===0&&t(e)})})},random_str:function(){return this.fidx||(this.fidx=0),this.prefix=this.prefix||[this.name||"F",(+(new Date)).toString(36)].join("-"),this.prefix+(this.fidx++).toString(36)}}},e.fn.foundation=function(){var e=Array.prototype.slice.call(arguments,0);return this.each(function(){return Foundation.init.apply(Foundation,[this].concat(e)),this})}})(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.slider={name:"slider",version:"5.2.2",settings:{start:0,end:100,step:1,initial:null,display_selector:"",on_change:function(){}},cache:{},init:function(e,t,n){Foundation.inherit(this,"throttle"),this.bindings(t,n),this.reflow()},events:function(){var n=this;e(this.scope).off(".slider").on("mousedown.fndtn.slider touchstart.fndtn.slider pointerdown.fndtn.slider","["+n.attr_name()+"] .range-slider-handle",function(t){n.cache.active||(t.preventDefault(),n.set_active_slider(e(t.target)))}).on("mousemove.fndtn.slider touchmove.fndtn.slider pointermove.fndtn.slider",function(e){!n.cache.active||(e.preventDefault(),n.calculate_position(n.cache.active,e.pageX||e.originalEvent.clientX||e.originalEvent.touches[0].clientX||e.currentPoint.x))}).on("mouseup.fndtn.slider touchend.fndtn.slider pointerup.fndtn.slider",function(e){n.remove_active_slider()}).on("change.fndtn.slider",function(e){n.settings.on_change()}),n.S(t).on("resize.fndtn.slider",n.throttle(function(e){n.reflow()},300))},set_active_slider:function(e){this.cache.active=e},remove_active_slider:function(){this.cache.active=null},calculate_position:function(t,n){var r=this,i=e.extend({},r.settings,r.data_options(t.parent())),s=e.data(t[0],"handle_w"),o=e.data(t[0],"handle_o"),u=e.data(t[0],"bar_w"),a=e.data(t[0],"bar_o");requestAnimationFrame(function(){var e;Foundation.rtl?e=r.limit_to((a+u-n)/u,0,1):e=r.limit_to((n-a)/u,0,1);var s=r.normalized_value(e,i.start,i.end,i.step);r.set_ui(t,s)})},set_ui:function(t,n){var r=e.extend({},this.settings,this.data_options(t.parent())),i=e.data(t[0],"handle_w"),s=e.data(t[0],"bar_w"),o=this.normalized_percentage(n,r.start,r.end),u=o*(s-i)-1,a=o*100;Foundation.rtl&&(u=-u),this.set_translate(t,u),t.siblings(".range-slider-active-segment").css("width",a+"%"),t.parent().attr(this.attr_name(),n),t.parent().trigger("change"),t.parent().children("input[type=hidden]").val(n),r.input_id!=""&&e(r.display_selector).each(function(){this.hasOwnProperty("value")?e(this).val(n):e(this).text(n)})},normalized_percentage:function(e,t,n){return(e-t)/(n-t)},normalized_value:function(e,t,n,r){var i=n-t,r=r,s=e*i,o=(s-s%r)/r,u=s%r,a=u>=r*.5?r:0;return o*r+a+t},set_translate:function(t,n,r){r?e(t).css("-webkit-transform","translateY("+n+"px)").css("-moz-transform","translateY("+n+"px)").css("-ms-transform","translateY("+n+"px)").css("-o-transform","translateY("+n+"px)").css("transform","translateY("+n+"px)"):e(t).css("-webkit-transform","translateX("+n+"px)").css("-moz-transform","translateX("+n+"px)").css("-ms-transform","translateX("+n+"px)").css("-o-transform","translateX("+n+"px)").css("transform","translateX("+n+"px)")},limit_to:function(e,t,n){return Math.min(Math.max(e,t),n)},initialize_settings:function(t){e.data(t,"bar",e(t).parent()),e.data(t,"bar_o",e(t).parent().offset().left),e.data(t,"bar_w",e(t).parent().outerWidth()),e.data(t,"handle_o",e(t).offset().left),e.data(t,"handle_w",e(t).outerWidth()),e.data(t,"settings",e.extend({},this.settings,this.data_options(e(t).parent())))},set_initial_position:function(t){var n=e.data(t.children(".range-slider-handle")[0],"settings"),r=n.initial?n.initial:Math.floor((n.end-n.start)*.5/n.step)*n.step+n.start,i=t.children(".range-slider-handle");this.set_ui(i,r)},set_value:function(t){var n=this;e("["+n.attr_name()+"]",this.scope).each(function(){e(this).attr(n.attr_name(),t)}),!e(this.scope).attr(n.attr_name())||e(this.scope).attr(n.attr_name(),t),n.reflow()},reflow:function(){var t=this;t.S("["+this.attr_name()+"]").each(function(){var n=e(this).children(".range-slider-handle")[0],r=e(this).attr(t.attr_name());t.initialize_settings(n),r?t.set_ui(e(n),parseFloat(r)):t.set_initial_position(e(this))})}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";var i=i||!1;Foundation.libs.joyride={name:"joyride",version:"5.2.2",defaults:{expose:!1,modal:!0,tip_location:"bottom",nub_position:"auto",scroll_speed:1500,scroll_animation:"linear",timer:0,start_timer_on_click:!0,start_offset:0,next_button:!0,tip_animation:"fade",pause_after:[],exposed:[],tip_animation_fade_speed:300,cookie_monster:!1,cookie_name:"joyride",cookie_domain:!1,cookie_expires:365,tip_container:"body",abort_on_close:!0,tip_location_patterns:{top:["bottom"],bottom:[],left:["right","top","bottom"],right:["left","top","bottom"]},post_ride_callback:function(){},post_step_callback:function(){},pre_step_callback:function(){},pre_ride_callback:function(){},post_expose_callback:function(){},template:{link:'×',timer:'
',tip:'
',wrapper:'
',button:'',modal:'
',expose:'
',expose_cover:'
'},expose_add_class:""},init:function(t,n,r){Foundation.inherit(this,"throttle random_str"),this.settings=this.settings||e.extend({},this.defaults,r||n),this.bindings(n,r)},events:function(){var n=this;e(this.scope).off(".joyride").on("click.fndtn.joyride",".joyride-next-tip, .joyride-modal-bg",function(e){e.preventDefault(),this.settings.$li.next().length<1?this.end():this.settings.timer>0?(clearTimeout(this.settings.automate),this.hide(),this.show(),this.startTimer()):(this.hide(),this.show())}.bind(this)).on("click.fndtn.joyride",".joyride-close-tip",function(e){e.preventDefault(),this.end(this.settings.abort_on_close)}.bind(this)),e(t).off(".joyride").on("resize.fndtn.joyride",n.throttle(function(){if(e("["+n.attr_name()+"]").length>0&&n.settings.$next_tip){if(n.settings.exposed.length>0){var t=e(n.settings.exposed);t.each(function(){var t=e(this);n.un_expose(t),n.expose(t)})}n.is_phone()?n.pos_phone():n.pos_default(!1,!0)}},100))},start:function(){var t=this,n=e("["+this.attr_name()+"]",this.scope),r=["timer","scrollSpeed","startOffset","tipAnimationFadeSpeed","cookieExpires"],i=r.length;if(!n.length>0)return;this.settings.init||this.events(),this.settings=n.data(this.attr_name(!0)+"-init"),this.settings.$content_el=n,this.settings.$body=e(this.settings.tip_container),this.settings.body_offset=e(this.settings.tip_container).position(),this.settings.$tip_content=this.settings.$content_el.find("> li"),this.settings.paused=!1,this.settings.attempts=0,typeof e.cookie!="function"&&(this.settings.cookie_monster=!1);if(!this.settings.cookie_monster||this.settings.cookie_monster&&!e.cookie(this.settings.cookie_name))this.settings.$tip_content.each(function(n){var s=e(this);this.settings=e.extend({},t.defaults,t.data_options(s));var o=i;while(o--)t.settings[r[o]]=parseInt(t.settings[r[o]],10);t.create({$li:s,index:n})}),!this.settings.start_timer_on_click&&this.settings.timer>0?(this.show("init"),this.startTimer()):this.show("init")},resume:function(){this.set_li(),this.show()},tip_template:function(t){var n,r;return t.tip_class=t.tip_class||"",n=e(this.settings.template.tip).addClass(t.tip_class),r=e.trim(e(t.li).html())+this.button_text(t.button_text)+this.settings.template.link+this.timer_instance(t.index),n.append(e(this.settings.template.wrapper)),n.first().attr(this.add_namespace("data-index"),t.index),e(".joyride-content-wrapper",n).append(r),n[0]},timer_instance:function(t){var n;return t===0&&this.settings.start_timer_on_click&&this.settings.timer>0||this.settings.timer===0?n="":n=e(this.settings.template.timer)[0].outerHTML,n},button_text:function(t){return this.settings.next_button?(t=e.trim(t)||"Next",t=e(this.settings.template.button).append(t)[0].outerHTML):t="",t},create:function(t){var n=t.$li.attr(this.add_namespace("data-button"))||t.$li.attr(this.add_namespace("data-text")),r=t.$li.attr("class"),i=e(this.tip_template({tip_class:r,index:t.index,button_text:n,li:t.$li}));e(this.settings.tip_container).append(i)},show:function(t){var n=null;this.settings.$li===r||e.inArray(this.settings.$li.index(),this.settings.pause_after)===-1?(this.settings.paused?this.settings.paused=!1:this.set_li(t),this.settings.attempts=0,this.settings.$li.length&&this.settings.$target.length>0?(t&&(this.settings.pre_ride_callback(this.settings.$li.index(),this.settings.$next_tip),this.settings.modal&&this.show_modal()),this.settings.pre_step_callback(this.settings.$li.index(),this.settings.$next_tip),this.settings.modal&&this.settings.expose&&this.expose(),this.settings.tip_settings=e.extend({},this.settings,this.data_options(this.settings.$li)),this.settings.timer=parseInt(this.settings.timer,10),this.settings.tip_settings.tip_location_pattern=this.settings.tip_location_patterns[this.settings.tip_settings.tip_location],/body/i.test(this.settings.$target.selector)||this.scroll_to(),this.is_phone()?this.pos_phone(!0):this.pos_default(!0),n=this.settings.$next_tip.find(".joyride-timer-indicator"),/pop/i.test(this.settings.tip_animation)?(n.width(0),this.settings.timer>0?(this.settings.$next_tip.show(),setTimeout(function(){n.animate({width:n.parent().width()},this.settings.timer,"linear")}.bind(this),this.settings.tip_animation_fade_speed)):this.settings.$next_tip.show()):/fade/i.test(this.settings.tip_animation)&&(n.width(0),this.settings.timer>0?(this.settings.$next_tip.fadeIn(this.settings.tip_animation_fade_speed).show(),setTimeout(function(){n.animate({width:n.parent().width()},this.settings.timer,"linear")}.bind(this),this.settings.tip_animation_fadeSpeed)):this.settings.$next_tip.fadeIn(this.settings.tip_animation_fade_speed)),this.settings.$current_tip=this.settings.$next_tip):this.settings.$li&&this.settings.$target.length<1?this.show():this.end()):this.settings.paused=!0},is_phone:function(){return matchMedia(Foundation.media_queries.small).matches&&!matchMedia(Foundation.media_queries.medium).matches},hide:function(){this.settings.modal&&this.settings.expose&&this.un_expose(),this.settings.modal||e(".joyride-modal-bg").hide(),this.settings.$current_tip.css("visibility","hidden"),setTimeout(e.proxy(function(){this.hide(),this.css("visibility","visible")},this.settings.$current_tip),0),this.settings.post_step_callback(this.settings.$li.index(),this.settings.$current_tip)},set_li:function(e){e?(this.settings.$li=this.settings.$tip_content.eq(this.settings.start_offset),this.set_next_tip(),this.settings.$current_tip=this.settings.$next_tip):(this.settings.$li=this.settings.$li.next(),this.set_next_tip()),this.set_target()},set_next_tip:function(){this.settings.$next_tip=e(".joyride-tip-guide").eq(this.settings.$li.index()),this.settings.$next_tip.data("closed","")},set_target:function(){var t=this.settings.$li.attr(this.add_namespace("data-class")),r=this.settings.$li.attr(this.add_namespace("data-id")),i=function(){return r?e(n.getElementById(r)):t?e("."+t).first():e("body")};this.settings.$target=i()},scroll_to:function(){var n,r;n=e(t).height()/2,r=Math.ceil(this.settings.$target.offset().top-n+this.settings.$next_tip.outerHeight()),r!=0&&e("html, body").animate({scrollTop:r},this.settings.scroll_speed,"swing")},paused:function(){return e.inArray(this.settings.$li.index()+1,this.settings.pause_after)===-1},restart:function(){this.hide(),this.settings.$li=r,this.show("init")},pos_default:function(n,r){var i=Math.ceil(e(t).height()/2),s=this.settings.$next_tip.offset(),o=this.settings.$next_tip.find(".joyride-nub"),u=Math.ceil(o.outerWidth()/2),a=Math.ceil(o.outerHeight()/2),f=n||!1;f&&(this.settings.$next_tip.css("visibility","hidden"),this.settings.$next_tip.show()),typeof r=="undefined"&&(r=!1),/body/i.test(this.settings.$target.selector)?this.settings.$li.length&&this.pos_modal(o):(this.bottom()?(this.rtl?this.settings.$next_tip.css({top:this.settings.$target.offset().top+a+this.settings.$target.outerHeight(),left:this.settings.$target.offset().left+this.settings.$target.outerWidth()-this.settings.$next_tip.outerWidth()}):this.settings.$next_tip.css({top:this.settings.$target.offset().top+a+this.settings.$target.outerHeight(),left:this.settings.$target.offset().left}),this.nub_position(o,this.settings.tip_settings.nub_position,"top")):this.top()?(this.rtl?this.settings.$next_tip.css({top:this.settings.$target.offset().top-this.settings.$next_tip.outerHeight()-a,left:this.settings.$target.offset().left+this.settings.$target.outerWidth()-this.settings.$next_tip.outerWidth()}):this.settings.$next_tip.css({top:this.settings.$target.offset().top-this.settings.$next_tip.outerHeight()-a,left:this.settings.$target.offset().left}),this.nub_position(o,this.settings.tip_settings.nub_position,"bottom")):this.right()?(this.settings.$next_tip.css({top:this.settings.$target.offset().top,left:this.settings.$target.outerWidth()+this.settings.$target.offset().left+u}),this.nub_position(o,this.settings.tip_settings.nub_position,"left")):this.left()&&(this.settings.$next_tip.css({top:this.settings.$target.offset().top,left:this.settings.$target.offset().left-this.settings.$next_tip.outerWidth()-u}),this.nub_position(o,this.settings.tip_settings.nub_position,"right")),!this.visible(this.corners(this.settings.$next_tip))&&this.settings.attempts0&&arguments[0]instanceof e)i=arguments[0];else{if(!this.settings.$target||!!/body/i.test(this.settings.$target.selector))return!1;i=this.settings.$target}if(i.length<1)return t.console&&console.error("element not valid",i),!1;n=e(this.settings.template.expose),this.settings.$body.append(n),n.css({top:i.offset().top,left:i.offset().left,width:i.outerWidth(!0),height:i.outerHeight(!0)}),r=e(this.settings.template.expose_cover),s={zIndex:i.css("z-index"),position:i.css("position")},o=i.attr("class")==null?"":i.attr("class"),i.css("z-index",parseInt(n.css("z-index"))+1),s.position=="static"&&i.css("position","relative"),i.data("expose-css",s),i.data("orig-class",o),i.attr("class",o+" "+this.settings.expose_add_class),r.css({top:i.offset().top,left:i.offset().left,width:i.outerWidth(!0),height:i.outerHeight(!0)}),this.settings.modal&&this.show_modal(),this.settings.$body.append(r),n.addClass(u),r.addClass(u),i.data("expose",u),this.settings.post_expose_callback(this.settings.$li.index(),this.settings.$next_tip,i),this.add_exposed(i)},un_expose:function(){var n,r,i,s,o,u=!1;if(arguments.length>0&&arguments[0]instanceof e)r=arguments[0];else{if(!this.settings.$target||!!/body/i.test(this.settings.$target.selector))return!1;r=this.settings.$target}if(r.length<1)return t.console&&console.error("element not valid",r),!1;n=r.data("expose"),i=e("."+n),arguments.length>1&&(u=arguments[1]),u===!0?e(".joyride-expose-wrapper,.joyride-expose-cover").remove():i.remove(),s=r.data("expose-css"),s.zIndex=="auto"?r.css("z-index",""):r.css("z-index",s.zIndex),s.position!=r.css("position")&&(s.position=="static"?r.css("position",""):r.css("position",s.position)),o=r.data("orig-class"),r.attr("class",o),r.removeData("orig-classes"),r.removeData("expose"),r.removeData("expose-z-index"),this.remove_exposed(r)},add_exposed:function(t){this.settings.exposed=this.settings.exposed||[],t instanceof e||typeof t=="object"?this.settings.exposed.push(t[0]):typeof t=="string"&&this.settings.exposed.push(t)},remove_exposed:function(t){var n,r;t instanceof e?n=t[0]:typeof t=="string"&&(n=t),this.settings.exposed=this.settings.exposed||[],r=this.settings.exposed.length;while(r--)if(this.settings.exposed[r]==n){this.settings.exposed.splice(r,1);return}},center:function(){var n=e(t);return this.settings.$next_tip.css({top:(n.height()-this.settings.$next_tip.outerHeight())/2+n.scrollTop(),left:(n.width()-this.settings.$next_tip.outerWidth())/2+n.scrollLeft()}),!0},bottom:function(){return/bottom/i.test(this.settings.tip_settings.tip_location)},top:function(){return/top/i.test(this.settings.tip_settings.tip_location)},right:function(){return/right/i.test(this.settings.tip_settings.tip_location)},left:function(){return/left/i.test(this.settings.tip_settings.tip_location)},corners:function(n){var r=e(t),i=r.height()/2,s=Math.ceil(this.settings.$target.offset().top-i+this.settings.$next_tip.outerHeight()),o=r.width()+r.scrollLeft(),u=r.height()+s,a=r.height()+r.scrollTop(),f=r.scrollTop();return sa&&(a=u),[n.offset().topn.offset().left]},visible:function(e){var t=e.length;while(t--)if(e[t])return!1;return!0},nub_position:function(e,t,n){t==="auto"?e.addClass(n):e.addClass(t)},startTimer:function(){this.settings.$li.length?this.settings.automate=setTimeout(function(){this.hide(),this.show(),this.startTimer()}.bind(this),this.settings.timer):clearTimeout(this.settings.automate)},end:function(t){this.settings.cookie_monster&&e.cookie(this.settings.cookie_name,"ridden",{expires:this.settings.cookie_expires,domain:this.settings.cookie_domain}),this.settings.timer>0&&clearTimeout(this.settings.automate),this.settings.modal&&this.settings.expose&&this.un_expose(),this.settings.$next_tip.data("closed",!0),e(".joyride-modal-bg").hide(),this.settings.$current_tip.hide(),typeof t=="undefined"&&(this.settings.post_step_callback(this.settings.$li.index(),this.settings.$current_tip),this.settings.post_ride_callback(this.settings.$li.index(),this.settings.$current_tip)),e(".joyride-tip-guide").remove()},off:function(){e(this.scope).off(".joyride"),e(t).off(".joyride"),e(".joyride-close-tip, .joyride-next-tip, .joyride-modal-bg").off(".joyride"),e(".joyride-tip-guide, .joyride-modal-bg").remove(),clearTimeout(this.settings.automate),this.settings={}},reflow:function(){}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.equalizer={name:"equalizer",version:"5.2.2",settings:{use_tallest:!0,before_height_change:e.noop,after_height_change:e.noop},init:function(e,t,n){Foundation.inherit(this,"image_loaded"),this.bindings(t,n),this.reflow()},events:function(){this.S(t).off(".equalizer").on("resize.fndtn.equalizer",function(e){this.reflow()}.bind(this))},equalize:function(t){var n=!1,r=t.find("["+this.attr_name()+"-watch]:visible"),i=r.first().offset().top,s=t.data(this.attr_name(!0)+"-init");if(r.length===0)return;s.before_height_change(),t.trigger("before-height-change"),r.height("inherit"),r.each(function(){var t=e(this);t.offset().top!==i&&(n=!0)});if(n)return;var o=r.map(function(){return e(this).outerHeight()}).get();if(s.use_tallest){var u=Math.max.apply(null,o);r.css("height",u)}else{var a=Math.min.apply(null,o);r.css("height",a)}s.after_height_change(),t.trigger("after-height-change")},reflow:function(){var t=this;this.S("["+this.attr_name()+"]",this.scope).each(function(){var n=e(this);t.image_loaded(t.S("img",this),function(){t.equalize(n)})})}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.dropdown={name:"dropdown",version:"5.2.2",settings:{active_class:"open",align:"bottom",is_hover:!1,opened:function(){},closed:function(){}},init:function(e,t,n){Foundation.inherit(this,"throttle"),this.bindings(t,n)},events:function(n){var r=this,i=r.S;i(this.scope).off(".dropdown").on("click.fndtn.dropdown","["+this.attr_name()+"]",function(t){var n=i(this).data(r.attr_name(!0)+"-init")||r.settings;if(!n.is_hover||Modernizr.touch)t.preventDefault(),r.toggle(e(this))}).on("mouseenter.fndtn.dropdown","["+this.attr_name()+"], ["+this.attr_name()+"-content]",function(e){var t=i(this);clearTimeout(r.timeout);if(t.data(r.data_attr()))var n=i("#"+t.data(r.data_attr())),s=t;else{var n=t;s=i("["+r.attr_name()+"='"+n.attr("id")+"']")}var o=s.data(r.attr_name(!0)+"-init")||r.settings;i(e.target).data(r.data_attr())&&o.is_hover&&r.closeall.call(r),o.is_hover&&r.open.apply(r,[n,s])}).on("mouseleave.fndtn.dropdown","["+this.attr_name()+"], ["+this.attr_name()+"-content]",function(e){var t=i(this);r.timeout=setTimeout(function(){if(t.data(r.data_attr())){var e=t.data(r.data_attr(!0)+"-init")||r.settings;e.is_hover&&r.close.call(r,i("#"+t.data(r.data_attr())))}else{var n=i("["+r.attr_name()+'="'+i(this).attr("id")+'"]'),e=n.data(r.attr_name(!0)+"-init")||r.settings;e.is_hover&&r.close.call(r,t)}}.bind(this),150)}).on("click.fndtn.dropdown",function(t){var n=i(t.target).closest("["+r.attr_name()+"-content]");if(i(t.target).data(r.data_attr())||i(t.target).parent().data(r.data_attr()))return;if(!i(t.target).data("revealId")&&n.length>0&&(i(t.target).is("["+r.attr_name()+"-content]")||e.contains(n.first()[0],t.target))){t.stopPropagation();return}r.close.call(r,i("["+r.attr_name()+"-content]"))}).on("opened.fndtn.dropdown","["+r.attr_name()+"-content]",function(){r.settings.opened.call(this)}).on("closed.fndtn.dropdown","["+r.attr_name()+"-content]",function(){r.settings.closed.call(this)}),i(t).off(".dropdown").on("resize.fndtn.dropdown",r.throttle(function(){r.resize.call(r)},50)),this.resize()},close:function(e){var t=this;e.each(function(){t.S(this).hasClass(t.settings.active_class)&&(t.S(this).css(Foundation.rtl?"right":"left","-99999px").removeClass(t.settings.active_class).prev("["+t.attr_name()+"]").removeClass(t.settings.active_class),t.S(this).trigger("closed",[e]))})},closeall:function(){var t=this;e.each(t.S("["+this.attr_name()+"-content]"),function(){t.close.call(t,t.S(this))})},open:function(e,t){this.css(e.addClass(this.settings.active_class),t),e.prev("["+this.attr_name()+"]").addClass(this.settings.active_class),e.trigger("opened",[e,t])},data_attr:function(){return this.namespace.length>0?this.namespace+"-"+this.name:this.name},toggle:function(e){var t=this.S("#"+e.data(this.data_attr()));if(t.length===0)return;this.close.call(this,this.S("["+this.attr_name()+"-content]").not(t)),t.hasClass(this.settings.active_class)?this.close.call(this,t):(this.close.call(this,this.S("["+this.attr_name()+"-content]")),this.open.call(this,t,e))},resize:function(){var e=this.S("["+this.attr_name()+"-content].open"),t=this.S("["+this.attr_name()+"='"+e.attr("id")+"']");e.length&&t.length&&this.css(e,t)},css:function(e,t){this.clear_idx();if(this.small()){var n=this.dirs.bottom.call(e,t);e.attr("style","").removeClass("drop-left drop-right drop-top").css({position:"absolute",width:"95%","max-width":"none",top:n.top}),e.css(Foundation.rtl?"right":"left","2.5%")}else{var r=t.data(this.attr_name(!0)+"-init")||this.settings;this.style(e,t,r)}return e},style:function(t,n,r){var i=e.extend({position:"absolute"},this.dirs[r.align].call(t,n,r));t.attr("style","").css(i)},dirs:{_base:function(e){var t=this.offsetParent(),n=t.offset(),r=e.offset();return r.top-=n.top,r.left-=n.left,r},top:function(e,t){var n=Foundation.libs.dropdown,r=n.dirs._base.call(this,e),i=e.outerWidth()/2-8;return this.addClass("drop-top"),(e.outerWidth()×'},close_selectors:".clearing-close",touch_label:"",init:!1,locked:!1},init:function(e,t,n){var r=this;Foundation.inherit(this,"throttle image_loaded"),this.bindings(t,n),r.S(this.scope).is("["+this.attr_name()+"]")?this.assemble(r.S("li",this.scope)):r.S("["+this.attr_name()+"]",this.scope).each(function(){r.assemble(r.S("li",this))})},events:function(r){var i=this,s=i.S;e(".scroll-container").length>0&&(this.scope=e(".scroll-container")),s(this.scope).off(".clearing").on("click.fndtn.clearing","ul["+this.attr_name()+"] li",function(e,t,n){var t=t||s(this),n=n||t,r=t.next("li"),o=t.closest("["+i.attr_name()+"]").data(i.attr_name(!0)+"-init"),u=s(e.target);e.preventDefault(),o||(i.init(),o=t.closest("["+i.attr_name()+"]").data(i.attr_name(!0)+"-init")),n.hasClass("visible")&&t[0]===n[0]&&r.length>0&&i.is_open(t)&&(n=r,u=s("img",n)),i.open(u,t,n),i.update_paddles(n)}).on("click.fndtn.clearing",".clearing-main-next",function(e){i.nav(e,"next")}).on("click.fndtn.clearing",".clearing-main-prev",function(e){i.nav(e,"prev")}).on("click.fndtn.clearing",this.settings.close_selectors,function(e){Foundation.libs.clearing.close(e,this)}),e(n).on("keydown.fndtn.clearing",function(e){i.keydown(e)}),s(t).off(".clearing").on("resize.fndtn.clearing",function(){i.resize()}),this.swipe_events(r)},swipe_events:function(e){var t=this,n=t.S;n(this.scope).on("touchstart.fndtn.clearing",".visible-img",function(e){e.touches||(e=e.originalEvent);var t={start_page_x:e.touches[0].pageX,start_page_y:e.touches[0].pageY,start_time:(new Date).getTime(),delta_x:0,is_scrolling:r};n(this).data("swipe-transition",t),e.stopPropagation()}).on("touchmove.fndtn.clearing",".visible-img",function(e){e.touches||(e=e.originalEvent);if(e.touches.length>1||e.scale&&e.scale!==1)return;var r=n(this).data("swipe-transition");typeof r=="undefined"&&(r={}),r.delta_x=e.touches[0].pageX-r.start_page_x,typeof r.is_scrolling=="undefined"&&(r.is_scrolling=!!(r.is_scrolling||Math.abs(r.delta_x)');var r=n.detach(),i="";if(r[0]==null)return;i=r[0].outerHTML;var s=this.S("#foundationClearingHolder"),o=n.data(this.attr_name(!0)+"-init"),r=n.detach(),u={grid:'",viewing:o.templates.viewing},a='
'+u.viewing+u.grid+"
",f=this.settings.touch_label;Modernizr.touch&&(a=e(a).find(".clearing-touch-label").html(f).end()),s.after(a).remove()},open:function(t,r,i){function p(){setTimeout(function(){this.image_loaded(l,function(){l.outerWidth()===1&&!h?p.call(this):d.call(this,l)}.bind(this))}.bind(this),50)}function d(t){var n=e(t);t.css("visibility","visible"),o.css("overflow","hidden"),u.addClass("clearing-blackout"),a.addClass("clearing-container"),f.show(),this.fix_height(i).caption(s.S(".clearing-caption",f),s.S("img",i)).center_and_label(t,c).shift(r,i,function(){i.siblings().removeClass("visible"),i.addClass("visible")})}var s=this,o=e(n.body),u=i.closest(".clearing-assembled"),a=s.S("div",u).first(),f=s.S(".visible-img",a),l=s.S("img",f).not(t),c=s.S(".clearing-touch-label",a),h=!1;l.error(function(){h=!0}),this.locked()||(l.attr("src",this.load(t)).css("visibility","hidden"),p.call(this))},close:function(t,r){t.preventDefault();var i=function(e){return/blackout/.test(e.selector)?e:e.closest(".clearing-blackout")}(e(r)),s=e(n.body),o,u;return r===t.target&&i&&(s.css("overflow",""),o=e("div",i).first(),u=e(".visible-img",o),this.settings.prev_index=0,e("ul["+this.attr_name()+"]",i).attr("style","").closest(".clearing-blackout").removeClass("clearing-blackout"),o.removeClass("clearing-container"),u.hide()),!1},is_open:function(e){return e.parent().prop("style").length>0},keydown:function(t){var n=e(".clearing-blackout ul["+this.attr_name()+"]"),r=this.rtl?37:39,i=this.rtl?39:37,s=27;t.which===r&&this.go(n,"next"),t.which===i&&this.go(n,"prev"),t.which===s&&this.S("a.clearing-close").trigger("click")},nav:function(t,n){var r=e("ul["+this.attr_name()+"]",".clearing-blackout");t.preventDefault(),this.go(r,n)},resize:function(){var t=e("img",".clearing-blackout .visible-img"),n=e(".clearing-touch-label",".clearing-blackout");t.length&&this.center_and_label(t,n)},fix_height:function(e){var t=e.parent().children(),n=this;return t.each(function(){var e=n.S(this),t=e.find("img");e.height()>t.outerHeight()&&e.addClass("fix-height")}).closest("ul").width(t.length*100+"%"),this},update_paddles:function(e){var t=e.closest(".carousel").siblings(".visible-img");e.next().length>0?this.S(".clearing-main-next",t).removeClass("disabled"):this.S(".clearing-main-next",t).addClass("disabled"),e.prev().length>0?this.S(".clearing-main-prev",t).removeClass("disabled"):this.S(".clearing-main-prev",t).addClass("disabled")},center_and_label:function(e,t){return this.rtl?(e.css({marginRight:-(e.outerWidth()/2),marginTop:-(e.outerHeight()/2),left:"auto",right:"50%"}),t.length>0&&t.css({marginRight:-(t.outerWidth()/2),marginTop:-(e.outerHeight()/2)-t.outerHeight()-10,left:"auto",right:"50%"})):(e.css({marginLeft:-(e.outerWidth()/2),marginTop:-(e.outerHeight()/2)}),t.length>0&&t.css({marginLeft:-(t.outerWidth()/2),marginTop:-(e.outerHeight()/2)-t.outerHeight()-10})),this},load:function(e){if(e[0].nodeName==="A")var t=e.attr("href");else var t=e.parent().attr("href");return this.preload(e),t?t:e.attr("src")},preload:function(e){this.img(e.closest("li").next()).img(e.closest("li").prev())},img:function(e){if(e.length){var t=new Image,n=this.S("a",e);n.length?t.src=n.attr("href"):t.src=this.S("img",e).attr("src")}return this},caption:function(e,t){var n=t.attr("data-caption");return n?e.html(n).show():e.text("").hide(),this},go:function(e,t){var n=this.S(".visible",e),r=n[t]();r.length&&this.S("img",r).trigger("click",[n,r])},shift:function(e,t,n){var r=t.parent(),i=this.settings.prev_index||t.index(),s=this.direction(r,e,t),o=this.rtl?"right":"left",u=parseInt(r.css("left"),10),a=t.outerWidth(),f,l={};t.index()!==i&&!/skip/.test(s)?/left/.test(s)?(this.lock(),l[o]=u+a,r.animate(l,300,this.unlock())):/right/.test(s)&&(this.lock(),l[o]=u-a,r.animate(l,300,this.unlock())):/skip/.test(s)&&(f=t.index()-this.settings.up_count,this.lock(),f>0?(l[o]=-(f*a),r.animate(l,300,this.unlock())):(l[o]=0,r.animate(l,300,this.unlock()))),n()},direction:function(e,t,n){var r=this.S("li",e),i=r.outerWidth()+r.outerWidth()/4,s=Math.floor(this.S(".clearing-container").outerWidth()/i)-1,o=r.index(n),u;return this.settings.up_count=s,this.adjacent(this.settings.prev_index,o)?o>s&&o>this.settings.prev_index?u="right":o>s-1&&o<=this.settings.prev_index?u="left":u=!1:u="skip",this.settings.prev_index=o,u},adjacent:function(e,t){for(var n=t+1;n>=t-1;n--)if(n===e)return!0;return!1},lock:function(){this.settings.locked=!0},unlock:function(){this.settings.locked=!1},locked:function(){return this.settings.locked},off:function(){this.S(this.scope).off(".fndtn.clearing"),this.S(t).off(".fndtn.clearing")},reflow:function(){this.init()}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";var i=function(){},s=function(r,i){if(r.hasClass(i.slides_container_class))return this;var s=this,a,f=r,l,c,h,p=0,d,v=!1,m=f.find("."+i.active_slide_class).length>0;s.cache={},s.slides=function(){return f.children(i.slide_selector)},m||s.slides().first().addClass(i.active_slide_class),s.update_slide_number=function(t){i.slide_number&&(l.find("span:first").text(parseInt(t)+1),l.find("span:last").text(s.slides().length)),i.bullets&&(c.children().removeClass(i.bullets_active_class),e(c.children().get(t)).addClass(i.bullets_active_class))},s.update_active_link=function(t){var n=e('[data-orbit-link="'+s.slides().eq(t).attr("data-orbit-slide")+'"]');n.siblings().removeClass(i.bullets_active_class),n.addClass(i.bullets_active_class)},s.build_markup=function(){f.wrap('
'),a=f.parent(),f.addClass(i.slides_container_class),f.addClass(i.animation),i.stack_on_small&&a.addClass(i.stack_on_small_class),i.navigation_arrows&&(a.append(e('').addClass(i.prev_class)),a.append(e('').addClass(i.next_class))),i.timer&&(h=e("
").addClass(i.timer_container_class),h.append(""),i.timer_show_progress_bar&&h.append(e("
").addClass(i.timer_progress_class)),h.addClass(i.timer_paused_class),a.append(h)),i.slide_number&&(l=e("
").addClass(i.slide_number_class),l.append(" "+i.slide_number_text+" "),a.append(l)),i.bullets&&(c=e("
    ").addClass(i.bullets_container_class),a.append(c),c.wrap('
    '),s.slides().each(function(t,n){var r=e("
  1. ").attr("data-orbit-slide",t);c.append(r)}))},s._prepare_direction=function(t,n){var r="next";t<=p&&(r="prev"),i.animation==="slide"&&setTimeout(function(){f.removeClass("swipe-prev swipe-next"),r==="next"?f.addClass("swipe-next"):r==="prev"&&f.addClass("swipe-prev")},0);var o=s.slides();if(t>=o.length){if(!i.circular)return!1;t=0}else if(t<0){if(!i.circular)return!1;t=o.length-1}var u=e(o.get(p)),a=e(o.get(t));return[r,u,a,t]},s._goto=function(e,t){if(e===null)return!1;if(s.cache.animating)return!1;if(e===p)return!1;typeof s.cache.timer=="object"&&s.cache.timer.restart();var n=s.slides();s.cache.animating=!0;var r=s._prepare_direction(e),o=r[0],u=r[1],a=r[2],e=r[3];if(r===!1)return!1;f.trigger("before-slide-change.fndtn.orbit"),i.before_slide_change(),p=e,u.css("transitionDuration",i.animation_speed+"ms"),a.css("transitionDuration",i.animation_speed+"ms");var l=function(){var r=function(){t===!0&&s.cache.timer.restart(),s.update_slide_number(p),a.addClass(i.active_slide_class),s.update_active_link(e),f.trigger("after-slide-change.fndtn.orbit",[{slide_number:p,total_slides:n.length}]),i.after_slide_change(p,n.length),setTimeout(function(){s.cache.animating=!1},100)};f.height()!=a.height()&&i.variable_height?f.animate({height:a.height()},250,"linear",r):r()};if(n.length===1)return l(),!1;var c=function(){o==="next"&&d.next(u,a,l),o==="prev"&&d.prev(u,a,l)};a.height()>f.height()&&i.variable_height?f.animate({height:a.height()},250,"linear",c):c()},s.next=function(e){e.stopImmediatePropagation(),e.preventDefault(),s._prepare_direction(p+1),setTimeout(function(){s._goto(p+1)},100)},s.prev=function(e){e.stopImmediatePropagation(),e.preventDefault(),s._prepare_direction(p-1),setTimeout(function(){s._goto(p-1)},100)},s.link_custom=function(t){t.preventDefault();var n=e(this).attr("data-orbit-link");if(typeof n=="string"&&(n=e.trim(n))!=""){var r=a.find("[data-orbit-slide="+n+"]");r.index()!=-1&&setTimeout(function(){s._goto(r.index())},100)}},s.link_bullet=function(t){var n=e(this).attr("data-orbit-slide");if(typeof n=="string"&&(n=e.trim(n))!="")if(isNaN(parseInt(n))){var r=a.find("[data-orbit-slide="+n+"]");r.index()!=-1&&setTimeout(function(){s._goto(r.index()+1)},100)}else setTimeout(function(){s._goto(parseInt(n))},100)},s.timer_callback=function(){s._goto(p+1,!0)},s.compute_dimensions=function(){var t=e(s.slides().get(p)),n=t.height();i.variable_height||s.slides().each(function(){e(this).height()>n&&(n=e(this).height())}),f.height(n)},s.create_timer=function(){var e=new o(a.find("."+i.timer_container_class),i,s.timer_callback);return e},s.stop_timer=function(){typeof s.cache.timer=="object"&&s.cache.timer.stop()},s.toggle_timer=function(){var e=a.find("."+i.timer_container_class);e.hasClass(i.timer_paused_class)?(typeof s.cache.timer=="undefined"&&(s.cache.timer=s.create_timer()),s.cache.timer.start()):typeof s.cache.timer=="object"&&s.cache.timer.stop()},s.init=function(){s.build_markup(),i.timer&&(s.cache.timer=s.create_timer(),Foundation.utils.image_loaded(this.slides().children("img"),s.cache.timer.start)),d=new u(i,f);if(m){var r=f.find("."+i.active_slide_class),o=i.animation_speed;i.animation_speed=1,r.removeClass("active"),s._goto(r.index()),i.animation_speed=o}a.on("click","."+i.next_class,s.next),a.on("click","."+i.prev_class,s.prev),i.next_on_click&&a.on("click","[data-orbit-slide]",s.link_bullet),a.on("click",s.toggle_timer),i.swipe&&f.on("touchstart.fndtn.orbit",function(e){if(s.cache.animating)return;e.touches||(e=e.originalEvent),e.preventDefault(),e.stopPropagation(),s.cache.start_page_x=e.touches[0].pageX,s.cache.start_page_y=e.touches[0].pageY,s.cache.start_time=(new Date).getTime(),s.cache.delta_x=0,s.cache.is_scrolling=null,s.cache.direction=null,s.stop_timer()}).on("touchmove.fndtn.orbit",function(e){Math.abs(s.cache.delta_x)>5&&(e.preventDefault(),e.stopPropagation());if(s.cache.animating)return;requestAnimationFrame(function(){e.touches||(e=e.originalEvent);if(e.touches.length>1||e.scale&&e.scale!==1)return;s.cache.delta_x=e.touches[0].pageX-s.cache.start_page_x,s.cache.is_scrolling===null&&(s.cache.is_scrolling=!!(s.cache.is_scrolling||Math.abs(s.cache.delta_x)=0?o=-(100-r):o=100+r,s.cache.current.css("transform","translate3d("+r+"%,0,0)"),s.cache.next.css("transform","translate3d("+o+"%,0,0)")}})}).on("touchend.fndtn.orbit",function(e){if(s.cache.animating)return;e.preventDefault(),e.stopPropagation(),setTimeout(function(){s._goto(s.cache.direction)},50)}),a.on("mouseenter.fndtn.orbit",function(e){i.timer&&i.pause_on_hover&&s.stop_timer()}).on("mouseleave.fndtn.orbit",function(e){i.timer&&i.resume_on_mouseout&&s.cache.timer.start()}),e(n).on("click","[data-orbit-link]",s.link_custom),e(t).on("load resize",s.compute_dimensions);var l=this.slides().find("img");Foundation.utils.image_loaded(l,s.compute_dimensions),Foundation.utils.image_loaded(l,function(){a.prev("."+i.preloader_class).css("display","none"),s.update_slide_number(p),s.update_active_link(p),f.trigger("ready.fndtn.orbit")})},s.init()},o=function(e,t,n){var r=this,i=t.timer_speed,s=e.find("."+t.timer_progress_class),o=s&&s.css("display")!="none",u,a,f=-1;this.update_progress=function(e){var t=s.clone();t.attr("style",""),t.css("width",e+"%"),s.replaceWith(t),s=t},this.restart=function(){clearTimeout(a),e.addClass(t.timer_paused_class),f=-1,o&&r.update_progress(0),r.start()},this.start=function(){if(!e.hasClass(t.timer_paused_class))return!0;f=f===-1?i:f,e.removeClass(t.timer_paused_class),o&&(u=(new Date).getTime(),s.animate({width:"100%"},f,"linear")),a=setTimeout(function(){r.restart(),n()},f),e.trigger("timer-started.fndtn.orbit")},this.stop=function(){if(e.hasClass(t.timer_paused_class))return!0;clearTimeout(a),e.addClass(t.timer_paused_class);if(o){var n=(new Date).getTime();f-=n-u;var s=100-f/i*100;r.update_progress(s)}e.trigger("timer-stopped.fndtn.orbit")}},u=function(e,t){var n="webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend";this.next=function(r,i,s){Modernizr.csstransitions?i.on(n,function(e){i.unbind(n),r.removeClass("active animate-out"),i.removeClass("animate-in"),t.children().css({transform:"","-ms-transform":"","-webkit-transition-duration":"","-moz-transition-duration":"","-o-transition-duration":"","transition-duration":""}),s()}):setTimeout(function(){r.removeClass("active animate-out"),i.removeClass("animate-in"),t.children().css({transform:"","-ms-transform":"","-webkit-transition-duration":"","-moz-transition-duration":"","-o-transition-duration":"","transition-duration":""}),s()},e.animation_speed),t.children().css({transform:"","-ms-transform":"","-webkit-transition-duration":"","-moz-transition-duration":"","-o-transition-duration":"","transition-duration":""}),r.addClass("animate-out"),i.addClass("animate-in")},this.prev=function(r,i,s){Modernizr.csstransitions?i.on(n,function(e){i.unbind(n),r.removeClass("active animate-out"),i.removeClass("animate-in"),t.children().css({transform:"","-ms-transform":"","-webkit-transition-duration":"","-moz-transition-duration":"","-o-transition-duration":"","transition-duration":""}),s()}):setTimeout(function(){r.removeClass("active animate-out"),i.removeClass("animate-in"),t.children().css({transform:"","-ms-transform":"","-webkit-transition-duration":"","-moz-transition-duration":"","-o-transition-duration":"","transition-duration":""}),s()},e.animation_speed),t.children().css({transform:"","-ms-transform":"","-webkit-transition-duration":"","-moz-transition-duration":"","-o-transition-duration":"","transition-duration":""}),r.addClass("animate-out"),i.addClass("animate-in")}};Foundation.libs=Foundation.libs||{},Foundation.libs.orbit={name:"orbit",version:"5.2.2",settings:{animation:"slide",timer_speed:1e4,pause_on_hover:!0,resume_on_mouseout:!1,next_on_click:!0,animation_speed:500,stack_on_small:!1,navigation_arrows:!0,slide_number:!0,slide_number_text:"of",container_class:"orbit-container",stack_on_small_class:"orbit-stack-on-small",next_class:"orbit-next",prev_class:"orbit-prev",timer_container_class:"orbit-timer",timer_paused_class:"paused",timer_progress_class:"orbit-progress",timer_show_progress_bar:!0,slides_container_class:"orbit-slides-container",preloader_class:"preloader",slide_selector:"*",bullets_container_class:"orbit-bullets",bullets_active_class:"active",slide_number_class:"orbit-slide-number",caption_class:"orbit-caption",active_slide_class:"active",orbit_transition_class:"orbit-transitioning",bullets:!0,circular:!0,timer:!0,variable_height:!1,swipe:!0,before_slide_change:i,after_slide_change:i},init:function(e,t,n){var r=this;this.bindings(t,n)},events:function(e){var t=new s(this.S(e),this.S(e).data("orbit-init"));this.S(e).data(self.name+"-instance",t)},reflow:function(){var e=this;if(e.S(e.scope).is("[data-orbit]")){var t=e.S(e.scope),n=t.data(e.name+"-instance");n.compute_dimensions()}else e.S("[data-orbit]",e.scope).each(function(t,n){var r=e.S(n),i=e.data_options(r),s=r.data(e.name+"-instance");s.compute_dimensions()})}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.offcanvas={name:"offcanvas",version:"5.2.2",settings:{},init:function(e,t,n){this.events()},events:function(){var e=this,t=e.S;t(this.scope).off(".offcanvas").on("click.fndtn.offcanvas",".left-off-canvas-toggle",function(t){e.click_toggle_class(t,"move-right")}).on("click.fndtn.offcanvas",".left-off-canvas-menu a",function(e){t(".off-canvas-wrap").removeClass("move-right")}).on("click.fndtn.offcanvas",".right-off-canvas-toggle",function(t){e.click_toggle_class(t,"move-left")}).on("click.fndtn.offcanvas",".right-off-canvas-menu a",function(e){t(".off-canvas-wrap").removeClass("move-left")}).on("click.fndtn.offcanvas",".exit-off-canvas",function(t){e.click_remove_class(t,"move-left"),e.click_remove_class(t,"move-right")})},click_toggle_class:function(e,t){e.preventDefault(),this.S(e.target).closest(".off-canvas-wrap").toggleClass(t)},click_remove_class:function(e,t){e.preventDefault(),this.S(".off-canvas-wrap").removeClass(t)},reflow:function(){}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.alert={name:"alert",version:"5.2.2",settings:{callback:function(){}},init:function(e,t,n){this.bindings(t,n)},events:function(){var n=this,r=this.S;e(this.scope).off(".alert").on("click.fndtn.alert","["+this.attr_name()+"] a.close",function(e){var i=r(this).closest("["+n.attr_name()+"]"),s=i.data(n.attr_name(!0)+"-init")||n.settings;e.preventDefault(),"transitionend"in t||"webkitTransitionEnd"in t||"oTransitionEnd"in t?(i.addClass("alert-close"),i.on("transitionend webkitTransitionEnd oTransitionEnd",function(e){r(this).trigger("close").remove(),s.callback()})):i.fadeOut(300,function(){r(this).trigger("close").remove(),s.callback()})})},reflow:function(){}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";function i(e){var t=/fade/i.test(e),n=/pop/i.test(e);return{animate:t||n,pop:n,fade:t}}Foundation.libs.reveal={name:"reveal",version:"5.2.2",locked:!1,settings:{animation:"fadeAndPop",animation_speed:250,close_on_background_click:!0,close_on_esc:!0,dismiss_modal_class:"close-reveal-modal",bg_class:"reveal-modal-bg",open:function(){},opened:function(){},close:function(){},closed:function(){},bg:e(".reveal-modal-bg"),css:{open:{opacity:0,visibility:"visible",display:"block"},close:{opacity:1,visibility:"hidden",display:"none"}}},init:function(t,n,r){e.extend(!0,this.settings,n,r),this.bindings(n,r)},events:function(e){var t=this,r=t.S;return r(this.scope).off(".reveal").on("click.fndtn.reveal","["+this.add_namespace("data-reveal-id")+"]",function(e){e.preventDefault();if(!t.locked){var n=r(this),i=n.data(t.data_attr("reveal-ajax"));t.locked=!0;if(typeof i=="undefined")t.open.call(t,n);else{var s=i===!0?n.attr("href"):i;t.open.call(t,n,{url:s})}}}),r(n).on("touchend.fndtn.reveal click.fndtn.reveal",this.close_targets(),function(e){e.preventDefault();if(!t.locked){var n=r("["+t.attr_name()+"].open").data(t.attr_name(!0)+"-init"),i=r(e.target)[0]===r("."+n.bg_class)[0];if(i){if(!n.close_on_background_click)return;e.stopPropagation()}t.locked=!0,t.close.call(t,i?r("["+t.attr_name()+"].open"):r(this).closest("["+t.attr_name()+"]"))}}),r("["+t.attr_name()+"]",this.scope).length>0?r(this.scope).on("open.fndtn.reveal",this.settings.open).on("opened.fndtn.reveal",this.settings.opened).on("opened.fndtn.reveal",this.open_video).on("close.fndtn.reveal",this.settings.close).on("closed.fndtn.reveal",this.settings.closed).on("closed.fndtn.reveal",this.close_video):r(this.scope).on("open.fndtn.reveal","["+t.attr_name()+"]",this.settings.open).on("opened.fndtn.reveal","["+t.attr_name()+"]",this.settings.opened).on("opened.fndtn.reveal","["+t.attr_name()+"]",this.open_video).on("close.fndtn.reveal","["+t.attr_name()+"]",this.settings.close).on("closed.fndtn.reveal","["+t.attr_name()+"]",this.settings.closed).on("closed.fndtn.reveal","["+t.attr_name()+"]",this.close_video),!0},key_up_on:function(e){var t=this;return t.S("body").off("keyup.fndtn.reveal").on("keyup.fndtn.reveal",function(e){var n=t.S("["+t.attr_name()+"].open"),r=n.data(t.attr_name(!0)+"-init");r&&e.which===27&&r.close_on_esc&&!t.locked&&t.close.call(t,n)}),!0},key_up_off:function(e){return this.S("body").off("keyup.fndtn.reveal"),!0},open:function(t,n){var r=this;if(t)if(typeof t.selector!="undefined")var i=r.S("#"+t.data(r.data_attr("reveal-id")));else{var i=r.S(this.scope);n=t}else var i=r.S(this.scope);var s=i.data(r.attr_name(!0)+"-init");if(!i.hasClass("open")){var o=r.S("["+r.attr_name()+"].open");typeof i.data("css-top")=="undefined"&&i.data("css-top",parseInt(i.css("top"),10)).data("offset",this.cache_offset(i)),this.key_up_on(i),i.trigger("open"),o.length<1&&this.toggle_bg(i),typeof n=="string"&&(n={url:n});if(typeof n=="undefined"||!n.url)o.length>0&&this.hide(o,s.css.close),this.show(i,s.css.open);else{var u=typeof n.success!="undefined"?n.success:null;e.extend(n,{success:function(t,n,a){e.isFunction(u)&&u(t,n,a),i.html(t),r.S(i).foundation("section","reflow"),o.length>0&&r.hide(o,s.css.close),r.show(i,s.css.open)}}),e.ajax(n)}}},close:function(e){var e=e&&e.length?e:this.S(this.scope),t=this.S("["+this.attr_name()+"].open"),n=e.data(this.attr_name(!0)+"-init");t.length>0&&(this.locked=!0,this.key_up_off(e),e.trigger("close"),this.toggle_bg(e),this.hide(t,n.css.close,n))},close_targets:function(){var e="."+this.settings.dismiss_modal_class;return this.settings.close_on_background_click?e+", ."+this.settings.bg_class:e},toggle_bg:function(t){var n=t.data(this.attr_name(!0));this.S("."+this.settings.bg_class).length===0&&(this.settings.bg=e("
    ",{"class":this.settings.bg_class}).appendTo("body").hide()),this.settings.bg.filter(":visible").length>0?this.hide(this.settings.bg):this.show(this.settings.bg)},show:function(n,r){if(r){var s=n.data(this.attr_name(!0)+"-init");if(n.parent("body").length===0){var o=n.wrap('
    ').parent(),u=this.settings.rootElement||"body";n.on("closed.fndtn.reveal.wrapped",function(){n.detach().appendTo(o),n.unwrap().unbind("closed.fndtn.reveal.wrapped")}),n.detach().appendTo(u)}var a=i(s.animation);a.animate||(this.locked=!1);if(a.pop){r.top=e(t).scrollTop()-n.data("offset")+"px";var f={top:e(t).scrollTop()+n.data("css-top")+"px",opacity:1};return setTimeout(function(){return n.css(r).animate(f,s.animation_speed,"linear",function(){this.locked=!1,n.trigger("opened")}.bind(this)).addClass("open")}.bind(this),s.animation_speed/2)}if(a.fade){r.top=e(t).scrollTop()+n.data("css-top")+"px";var f={opacity:1};return setTimeout(function(){return n.css(r).animate(f,s.animation_speed,"linear",function(){this.locked=!1,n.trigger("opened")}.bind(this)).addClass("open")}.bind(this),s.animation_speed/2)}return n.css(r).show().css({opacity:1}).addClass("open").trigger("opened")}var s=this.settings;return i(s.animation).fade?n.fadeIn(s.animation_speed/2):(this.locked=!1,n.show())},hide:function(n,r){if(r){var s=n.data(this.attr_name(!0)+"-init"),o=i(s.animation);o.animate||(this.locked=!1);if(o.pop){var u={top:-e(t).scrollTop()-n.data("offset")+"px",opacity:0};return setTimeout(function(){return n.animate(u,s.animation_speed,"linear",function(){this.locked=!1,n.css(r).trigger("closed")}.bind(this)).removeClass("open")}.bind(this),s.animation_speed/2)}if(o.fade){var u={opacity:0};return setTimeout(function(){return n.animate(u,s.animation_speed,"linear",function(){this.locked=!1,n.css(r).trigger("closed")}.bind(this)).removeClass("open")}.bind(this),s.animation_speed/2)}return n.hide().css(r).removeClass("open").trigger("closed")}var s=this.settings;return i(s.animation).fade?n.fadeOut(s.animation_speed/2):n.hide()},close_video:function(t){var n=e(".flex-video",t.target),r=e("iframe",n);r.length>0&&(r.attr("data-src",r[0].src),r.attr("src","about:blank"),n.hide())},open_video:function(t){var n=e(".flex-video",t.target),i=n.find("iframe");if(i.length>0){var s=i.attr("data-src");if(typeof s=="string")i[0].src=i.attr("data-src");else{var o=i[0].src;i[0].src=r,i[0].src=o}n.show()}},data_attr:function(e){return this.namespace.length>0?this.namespace+"-"+e:e},cache_offset:function(e){var t=e.show().height()+parseInt(e.css("top"),10);return e.hide(),t},off:function(){e(this.scope).off(".fndtn.reveal")},reflow:function(){}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.interchange={name:"interchange",version:"5.2.2",cache:{},images_loaded:!1,nodes_loaded:!1,settings:{load_attr:"interchange",named_queries:{"default":"only screen",small:Foundation.media_queries.small,medium:Foundation.media_queries.medium,large:Foundation.media_queries.large,xlarge:Foundation.media_queries.xlarge,xxlarge:Foundation.media_queries.xxlarge,landscape:"only screen and (orientation: landscape)",portrait:"only screen and (orientation: portrait)",retina:"only screen and (-webkit-min-device-pixel-ratio: 2),only screen and (min--moz-device-pixel-ratio: 2),only screen and (-o-min-device-pixel-ratio: 2/1),only screen and (min-device-pixel-ratio: 2),only screen and (min-resolution: 192dpi),only screen and (min-resolution: 2dppx)"},directives:{replace:function(t,n,r){if(/IMG/.test(t[0].nodeName)){var i=t[0].src;if((new RegExp(n,"i")).test(i))return;return t[0].src=n,r(t[0].src)}var s=t.data(this.data_attr+"-last-path");if(s==n)return;return/\.(gif|jpg|jpeg|tiff|png)([?#].*)?/i.test(n)?(e(t).css("background-image","url("+n+")"),t.data("interchange-last-path",n),r(n)):e.get(n,function(e){t.html(e),t.data(this.data_attr+"-last-path",n),r()})}}},init:function(t,n,r){Foundation.inherit(this,"throttle random_str"),this.data_attr=this.set_data_attr(),e.extend(!0,this.settings,n,r),this.bindings(n,r),this.load("images"),this.load("nodes")},get_media_hash:function(){var e="";for(var t in this.settings.named_queries)e+=matchMedia(this.settings.named_queries[t]).matches.toString();return e},events:function(){var n=this,r;return e(t).off(".interchange").on("resize.fndtn.interchange",n.throttle(function(){var e=n.get_media_hash();e!==r&&n.resize(),r=e},50)),this},resize:function(){var t=this.cache;if(!this.images_loaded||!this.nodes_loaded){setTimeout(e.proxy(this.resize,this),50);return}for(var n in t)if(t.hasOwnProperty(n)){var r=this.results(n,t[n]);r&&this.settings.directives[r.scenario[1]].call(this,r.el,r.scenario[0],function(){if(arguments[0]instanceof Array)var e=arguments[0];else var e=Array.prototype.slice.call(arguments,0);r.el.trigger(r.scenario[1],e)})}},results:function(e,t){var n=t.length;if(n>0){var r=this.S("["+this.add_namespace("data-uuid")+'="'+e+'"]');while(n--){var i,s=t[n][2];this.settings.named_queries.hasOwnProperty(s)?i=matchMedia(this.settings.named_queries[s]):i=matchMedia(s);if(i.matches)return{el:r,scenario:t[n]}}}return!1},load:function(e,t){return(typeof this["cached_"+e]=="undefined"||t)&&this["update_"+e](),this["cached_"+e]},update_images:function(){var e=this.S("img["+this.data_attr+"]"),t=e.length,n=t,r=0,i=this.data_attr;this.cache={},this.cached_images=[],this.images_loaded=t===0;while(n--){r++;if(e[n]){var s=e[n].getAttribute(i)||"";s.length>0&&this.cached_images.push(e[n])}r===t&&(this.images_loaded=!0,this.enhance("images"))}return this},update_nodes:function(){var e=this.S("["+this.data_attr+"]").not("img"),t=e.length,n=t,r=0,i=this.data_attr;this.cached_nodes=[],this.nodes_loaded=t===0;while(n--){r++;var s=e[n].getAttribute(i)||"";s.length>0&&this.cached_nodes.push(e[n]),r===t&&(this.nodes_loaded=!0,this.enhance("nodes"))}return this},enhance:function(n){var r=this["cached_"+n].length;while(r--)this.object(e(this["cached_"+n][r]));return e(t).trigger("resize")},parse_params:function(e,t,n){return[this.trim(e),this.convert_directive(t),this.trim(n)]},convert_directive:function(e){var t=this.trim(e);return t.length>0?t:"replace"},object:function(e){var t=this.parse_data_attr(e),n=[],r=t.length;if(r>0)while(r--){var i=t[r].split(/\((.*?)(\))$/);if(i.length>1){var s=i[0].split(","),o=this.parse_params(s[0],s[1],i[1]);n.push(o)}}return this.store(e,n)},store:function(e,t){var n=this.random_str(),r=e.data(this.add_namespace("uuid",!0));return this.cache[r]?this.cache[r]:(e.attr(this.add_namespace("data-uuid"),n),this.cache[n]=t)},trim:function(t){return typeof t=="string"?e.trim(t):t},set_data_attr:function(e){return e?this.namespace.length>0?this.namespace+"-"+this.settings.load_attr:this.settings.load_attr:this.namespace.length>0?"data-"+this.namespace+"-"+this.settings.load_attr:"data-"+this.settings.load_attr},parse_data_attr:function(e){var t=e.attr(this.attr_name()).split(/\[(.*?)\]/),n=t.length,r=[];while(n--)t[n].replace(/[\W\d]+/,"").length>4&&r.push(t[n]);return r},reflow:function(){this.load("images",!0),this.load("nodes",!0)}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs["magellan-expedition"]={name:"magellan-expedition",version:"5.2.2",settings:{active_class:"active",threshold:0,destination_threshold:20,throttle_delay:30},init:function(e,t,n){Foundation.inherit(this,"throttle"),this.bindings(t,n)},events:function(){var n=this,r=n.S,i=n.settings;n.set_expedition_position(),r(n.scope).off(".magellan").on("click.fndtn.magellan","["+n.add_namespace("data-magellan-arrival")+'] a[href^="#"]',function(t){t.preventDefault();var r=e(this).closest("["+n.attr_name()+"]"),i=r.data("magellan-expedition-init"),s=this.hash.split("#").join(""),o=e("a[name='"+s+"']");o.length===0&&(o=e("#"+s));var u=o.offset().top;u-=r.outerHeight(),e("html, body").stop().animate({scrollTop:u},700,"swing",function(){history.pushState?history.pushState(null,null,"#"+s):location.hash="#"+s})}).on("scroll.fndtn.magellan",n.throttle(this.check_for_arrivals.bind(this),i.throttle_delay)),e(t).on("resize.fndtn.magellan",n.throttle(this.set_expedition_position.bind(this),i.throttle_delay))},check_for_arrivals:function(){var e=this;e.update_arrivals(),e.update_expedition_positions()},set_expedition_position:function(){var t=this;e("["+this.attr_name()+"=fixed]",t.scope).each(function(n,r){var i=e(this),s=i.attr("styles"),o;i.attr("style",""),o=i.offset().top +,i.data(t.data_attr("magellan-top-offset"),o),i.attr("style",s)})},update_expedition_positions:function(){var n=this,r=e(t).scrollTop();e("["+this.attr_name()+"=fixed]",n.scope).each(function(){var t=e(this),i=t.data("magellan-top-offset");if(r>=i){var s=t.prev("["+n.add_namespace("data-magellan-expedition-clone")+"]");s.length===0&&(s=t.clone(),s.removeAttr(n.attr_name()),s.attr(n.add_namespace("data-magellan-expedition-clone"),""),t.before(s)),t.css({position:"fixed",top:0})}else t.prev("["+n.add_namespace("data-magellan-expedition-clone")+"]").remove(),t.attr("style","")})},update_arrivals:function(){var n=this,r=e(t).scrollTop();e("["+this.attr_name()+"]",n.scope).each(function(){var t=e(this),i=i=t.data(n.attr_name(!0)+"-init"),s=n.offsets(t,r),o=t.find("["+n.add_namespace("data-magellan-arrival")+"]"),u=!1;s.each(function(e,r){if(r.viewport_offset>=r.top_offset){var s=t.find("["+n.add_namespace("data-magellan-arrival")+"]");return s.not(r.arrival).removeClass(i.active_class),r.arrival.addClass(i.active_class),u=!0,!0}}),u||o.removeClass(i.active_class)})},offsets:function(t,n){var r=this,i=t.data(r.attr_name(!0)+"-init"),s=n;return t.find("["+r.add_namespace("data-magellan-arrival")+"]").map(function(n,o){var u=e(this).data(r.data_attr("magellan-arrival")),a=e("["+r.add_namespace("data-magellan-destination")+"="+u+"]");if(a.length>0){var f=a.offset().top-i.destination_threshold-t.outerHeight();return{destination:a,arrival:e(this),top_offset:f,viewport_offset:s}}}).sort(function(e,t){return e.top_offsett.top_offset?1:0})},data_attr:function(e){return this.namespace.length>0?this.namespace+"-"+e:e},off:function(){this.S(this.scope).off(".magellan"),this.S(t).off(".magellan")},reflow:function(){var t=this;e("["+t.add_namespace("data-magellan-expedition-clone")+"]",t.scope).remove()}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.accordion={name:"accordion",version:"5.2.2",settings:{active_class:"active",multi_expand:!1,toggleable:!0},init:function(e,t,n){this.bindings(t,n)},events:function(){var t=this,n=this.S;n(this.scope).off(".fndtn.accordion").on("click.fndtn.accordion","["+this.attr_name()+"] dd > a",function(r){var i=n(this).closest("["+t.attr_name()+"]"),s=n("#"+this.href.split("#")[1]),o=n("dd > .content",i),u=e("dd",i),a=i.data(t.attr_name(!0)+"-init"),f=n("dd > .content."+a.active_class,i),l=n("dd."+a.active_class,i);r.preventDefault();if(!n(this).closest("dl").is(i))return;if(a.toggleable&&s.is(f))return l.toggleClass(a.active_class,!1),s.toggleClass(a.active_class,!1);a.multi_expand||(o.removeClass(a.active_class),u.removeClass(a.active_class)),s.addClass(a.active_class).parent().addClass(a.active_class)})},off:function(){},reflow:function(){}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.topbar={name:"topbar",version:"5.2.2",settings:{index:0,sticky_class:"sticky",custom_back_text:!0,back_text:"Back",is_hover:!0,mobile_show_parent_link:!1,scrolltop:!0,sticky_on:"all"},init:function(t,n,r){Foundation.inherit(this,"add_custom_rule register_media throttle");var i=this;i.register_media("topbar","foundation-mq-topbar"),this.bindings(n,r),i.S("["+this.attr_name()+"]",this.scope).each(function(){var t=e(this),n=t.data(i.attr_name(!0)+"-init"),r=i.S("section",this),s=t.children().filter("ul").first();t.data("index",0);var o=t.parent();o.hasClass("fixed")||i.is_sticky(t,o,n)?(i.settings.sticky_class=n.sticky_class,i.settings.sticky_topbar=t,t.data("height",o.outerHeight()),t.data("stickyoffset",o.offset().top)):t.data("height",t.outerHeight()),n.assembled||i.assemble(t),n.is_hover?i.S(".has-dropdown",t).addClass("not-click"):i.S(".has-dropdown",t).removeClass("not-click"),i.add_custom_rule(".f-topbar-fixed { padding-top: "+t.data("height")+"px }"),o.hasClass("fixed")&&i.S("body").addClass("f-topbar-fixed")})},is_sticky:function(e,t,n){var r=t.hasClass(n.sticky_class);return r&&n.sticky_on==="all"?!0:r&&this.small()&&n.sticky_on==="small"?!0:r&&this.medium()&&n.sticky_on==="medium"?!0:r&&this.large()&&n.sticky_on==="large"?!0:!1},toggle:function(n){var r=this;if(n)var i=r.S(n).closest("["+this.attr_name()+"]");else var i=r.S("["+this.attr_name()+"]");var s=i.data(this.attr_name(!0)+"-init"),o=r.S("section, .section",i);r.breakpoint()&&(r.rtl?(o.css({right:"0%"}),e(">.name",o).css({right:"100%"})):(o.css({left:"0%"}),e(">.name",o).css({left:"100%"})),r.S("li.moved",o).removeClass("moved"),i.data("index",0),i.toggleClass("expanded").css("height","")),s.scrolltop?i.hasClass("expanded")?i.parent().hasClass("fixed")&&(s.scrolltop?(i.parent().removeClass("fixed"),i.addClass("fixed"),r.S("body").removeClass("f-topbar-fixed"),t.scrollTo(0,0)):i.parent().removeClass("expanded")):i.hasClass("fixed")&&(i.parent().addClass("fixed"),i.removeClass("fixed"),r.S("body").addClass("f-topbar-fixed")):(r.is_sticky(i,i.parent(),s)&&i.parent().addClass("fixed"),i.parent().hasClass("fixed")&&(i.hasClass("expanded")?(i.addClass("fixed"),i.parent().addClass("expanded"),r.S("body").addClass("f-topbar-fixed")):(i.removeClass("fixed"),i.parent().removeClass("expanded"),r.update_sticky_positioning())))},timer:null,events:function(n){var r=this,i=this.S;i(this.scope).off(".topbar").on("click.fndtn.topbar","["+this.attr_name()+"] .toggle-topbar",function(e){e.preventDefault(),r.toggle(this)}).on("click.fndtn.topbar",'.top-bar .top-bar-section li a[href^="#"],['+this.attr_name()+'] .top-bar-section li a[href^="#"]',function(t){var n=e(this).closest("li");r.breakpoint()&&!n.hasClass("back")&&!n.hasClass("has-dropdown")&&r.toggle()}).on("click.fndtn.topbar","["+this.attr_name()+"] li.has-dropdown",function(t){var n=i(this),s=i(t.target),o=n.closest("["+r.attr_name()+"]"),u=o.data(r.attr_name(!0)+"-init");if(s.data("revealId")){r.toggle();return}if(r.breakpoint())return;if(u.is_hover&&!Modernizr.touch)return;t.stopImmediatePropagation(),n.hasClass("hover")?(n.removeClass("hover").find("li").removeClass("hover"),n.parents("li.hover").removeClass("hover")):(n.addClass("hover"),e(n).siblings().removeClass("hover"),s[0].nodeName==="A"&&s.parent().hasClass("has-dropdown")&&t.preventDefault())}).on("click.fndtn.topbar","["+this.attr_name()+"] .has-dropdown>a",function(e){if(r.breakpoint()){e.preventDefault();var t=i(this),n=t.closest("["+r.attr_name()+"]"),s=n.find("section, .section"),o=t.next(".dropdown").outerHeight(),u=t.closest("li");n.data("index",n.data("index")+1),u.addClass("moved"),r.rtl?(s.css({right:-(100*n.data("index"))+"%"}),s.find(">.name").css({right:100*n.data("index")+"%"})):(s.css({left:-(100*n.data("index"))+"%"}),s.find(">.name").css({left:100*n.data("index")+"%"})),n.css("height",t.siblings("ul").outerHeight(!0)+n.data("height"))}}),i(t).off(".topbar").on("resize.fndtn.topbar",r.throttle(function(){r.resize.call(r)},50)).trigger("resize"),i("body").off(".topbar").on("click.fndtn.topbar touchstart.fndtn.topbar",function(e){var t=i(e.target).closest("li").closest("li.hover");if(t.length>0)return;i("["+r.attr_name()+"] li.hover").removeClass("hover")}),i(this.scope).on("click.fndtn.topbar","["+this.attr_name()+"] .has-dropdown .back",function(e){e.preventDefault();var t=i(this),n=t.closest("["+r.attr_name()+"]"),s=n.find("section, .section"),o=n.data(r.attr_name(!0)+"-init"),u=t.closest("li.moved"),a=u.parent();n.data("index",n.data("index")-1),r.rtl?(s.css({right:-(100*n.data("index"))+"%"}),s.find(">.name").css({right:100*n.data("index")+"%"})):(s.css({left:-(100*n.data("index"))+"%"}),s.find(">.name").css({left:100*n.data("index")+"%"})),n.data("index")===0?n.css("height",""):n.css("height",a.outerHeight(!0)+n.data("height")),setTimeout(function(){u.removeClass("moved")},300)})},resize:function(){var e=this;e.S("["+this.attr_name()+"]").each(function(){var t=e.S(this),r=t.data(e.attr_name(!0)+"-init"),i=t.parent("."+e.settings.sticky_class),s;if(!e.breakpoint()){var o=t.hasClass("expanded");t.css("height","").removeClass("expanded").find("li").removeClass("hover"),o&&e.toggle(t)}e.is_sticky(t,i,r)&&(i.hasClass("fixed")?(i.removeClass("fixed"),s=i.offset().top,e.S(n.body).hasClass("f-topbar-fixed")&&(s-=t.data("height")),t.data("stickyoffset",s),i.addClass("fixed")):(s=i.offset().top,t.data("stickyoffset",s)))})},breakpoint:function(){return!matchMedia(Foundation.media_queries.topbar).matches},small:function(){return matchMedia(Foundation.media_queries.small).matches},medium:function(){return matchMedia(Foundation.media_queries.medium).matches},large:function(){return matchMedia(Foundation.media_queries.large).matches},assemble:function(t){var n=this,r=t.data(this.attr_name(!0)+"-init"),i=n.S("section",t),s=e(this).children().filter("ul").first();i.detach(),n.S(".has-dropdown>a",i).each(function(){var t=n.S(this),i=t.siblings(".dropdown"),s=t.attr("href");if(!i.find(".title.back").length){if(r.mobile_show_parent_link&&s&&s.length>1)var o=e('
  2. '+t.text()+"
  3. ");else var o=e('
  4. ');r.custom_back_text==1?e("h5>a",o).html(r.back_text):e("h5>a",o).html("« "+t.html()),i.prepend(o)}}),i.appendTo(t),this.sticky(),this.assembled(t)},assembled:function(t){t.data(this.attr_name(!0),e.extend({},t.data(this.attr_name(!0)),{assembled:!0}))},height:function(t){var n=0,r=this;return e("> li",t).each(function(){n+=r.S(this).outerHeight(!0)}),n},sticky:function(){var e=this.S(t),n=this;this.S(t).on("scroll",function(){n.update_sticky_positioning()})},update_sticky_positioning:function(){var e="."+this.settings.sticky_class,n=this.S(t),r=this;if(r.settings.sticky_topbar&&r.is_sticky(this.settings.sticky_topbar,this.settings.sticky_topbar.parent(),this.settings)){var i=this.settings.sticky_topbar.data("stickyoffset");r.S(e).hasClass("expanded")||(n.scrollTop()>i?r.S(e).hasClass("fixed")||(r.S(e).addClass("fixed"),r.S("body").addClass("f-topbar-fixed")):n.scrollTop()<=i&&r.S(e).hasClass("fixed")&&(r.S(e).removeClass("fixed"),r.S("body").removeClass("f-topbar-fixed")))}},off:function(){this.S(this.scope).off(".fndtn.topbar"),this.S(t).off(".fndtn.topbar")},reflow:function(){}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.tab={name:"tab",version:"5.2.2",settings:{active_class:"active",callback:function(){},deep_linking:!1,scroll_to_content:!0,is_hover:!1},default_tab_hashes:[],init:function(e,t,n){var r=this,i=this.S;this.bindings(t,n),this.handle_location_hash_change(),i("["+this.attr_name()+"] > dd.active > a",this.scope).each(function(){r.default_tab_hashes.push(this.hash)})},events:function(){var e=this,n=this.S;n(this.scope).off(".tab").on("click.fndtn.tab","["+this.attr_name()+"] > dd > a",function(t){var r=n(this).closest("["+e.attr_name()+"]").data(e.attr_name(!0)+"-init");if(!r.is_hover||Modernizr.touch)t.preventDefault(),t.stopPropagation(),e.toggle_active_tab(n(this).parent())}).on("mouseenter.fndtn.tab","["+this.attr_name()+"] > dd > a",function(t){var r=n(this).closest("["+e.attr_name()+"]").data(e.attr_name(!0)+"-init");r.is_hover&&e.toggle_active_tab(n(this).parent())}),n(t).on("hashchange.fndtn.tab",function(t){t.preventDefault(),e.handle_location_hash_change()})},handle_location_hash_change:function(){var t=this,n=this.S;n("["+this.attr_name()+"]",this.scope).each(function(){var i=n(this).data(t.attr_name(!0)+"-init");if(i.deep_linking){var s=t.scope.location.hash;if(s!=""){var o=n(s);if(o.hasClass("content")&&o.parent().hasClass("tab-content"))t.toggle_active_tab(e("["+t.attr_name()+"] > dd > a[href="+s+"]").parent());else{var u=o.closest(".content").attr("id");u!=r&&t.toggle_active_tab(e("["+t.attr_name()+"] > dd > a[href=#"+u+"]").parent(),s)}}else for(var a in t.default_tab_hashes)t.toggle_active_tab(e("["+t.attr_name()+"] > dd > a[href="+t.default_tab_hashes[a]+"]").parent())}})},toggle_active_tab:function(n,i){var s=this.S,o=n.closest("["+this.attr_name()+"]"),u=n.children("a").first(),a="#"+u.attr("href").split("#")[1],f=s(a),l=n.siblings(),c=o.data(this.attr_name(!0)+"-init");s(this).data(this.data_attr("tab-content"))&&(a="#"+s(this).data(this.data_attr("tab-content")).split("#")[1],f=s(a));if(c.deep_linking){var h=e("body,html").scrollTop();i!=r?t.location.hash=i:t.location.hash=a,c.scroll_to_content?i==r||i==a?n.parent()[0].scrollIntoView():s(a)[0].scrollIntoView():(i==r||i==a)&&e("body,html").scrollTop(h)}n.addClass(c.active_class).triggerHandler("opened"),l.removeClass(c.active_class),f.siblings().removeClass(c.active_class).end().addClass(c.active_class),c.callback(n),f.triggerHandler("toggled",[n]),o.triggerHandler("toggled",[f])},data_attr:function(e){return this.namespace.length>0?this.namespace+"-"+e:e},off:function(){},reflow:function(){}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.abide={name:"abide",version:"5.2.2",settings:{live_validate:!0,focus_on_invalid:!0,error_labels:!0,timeout:1e3,patterns:{alpha:/^[a-zA-Z]+$/,alpha_numeric:/^[a-zA-Z0-9]+$/,integer:/^[-+]?\d+$/,number:/^[-+]?\d*(?:\.\d+)?$/,card:/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,cvv:/^([0-9]){3,4}$/,email:/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,url:/^(https?|ftp|file|ssh):\/\/(((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/,domain:/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/,datetime:/^([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))$/,date:/(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))$/,time:/^(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}$/,dateISO:/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/,month_day_year:/^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.](19|20)\d\d$/,color:/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/},validators:{equalTo:function(e,t,r){var i=n.getElementById(e.getAttribute(this.add_namespace("data-equalto"))).value,s=e.value,o=i===s;return o}}},timer:null,init:function(e,t,n){this.bindings(t,n)},events:function(t){var n=this,r=n.S(t).attr("novalidate","novalidate"),i=r.data(this.attr_name(!0)+"-init")||{};this.invalid_attr=this.add_namespace("data-invalid"),r.off(".abide").on("submit.fndtn.abide validate.fndtn.abide",function(e){var t=/ajax/i.test(n.S(this).attr(n.attr_name()));return n.validate(n.S(this).find("input, textarea, select").get(),e,t)}).on("reset",function(){return n.reset(e(this))}).find("input, textarea, select").off(".abide").on("blur.fndtn.abide change.fndtn.abide",function(e){n.validate([this],e)}).on("keydown.fndtn.abide",function(e){i.live_validate===!0&&(clearTimeout(n.timer),n.timer=setTimeout(function(){n.validate([this],e)}.bind(this),i.timeout))})},reset:function(t){t.removeAttr(this.invalid_attr),e(this.invalid_attr,t).removeAttr(this.invalid_attr),e(".error",t).not("small").removeClass("error")},validate:function(e,t,n){var r=this.parse_patterns(e),i=r.length,s=this.S(e[0]).closest("[data-"+this.attr_name(!0)+"]"),o=s.data(this.attr_name(!0)+"-init")||{},u=/submit/.test(t.type);s.trigger("validated");for(var a=0;a0?[e,this.settings.patterns[r],n]:r.length>0?[e,new RegExp("^"+r+"$"),n]:this.settings.patterns.hasOwnProperty(t)?[e,this.settings.patterns[t],n]:(r=/.*/,[e,r,n])},check_validation_and_apply_styles:function(t){var n=t.length,r=[],i=this.S(t[0][0]).closest("[data-"+this.attr_name(!0)+"]"),s=i.data(this.attr_name(!0)+"-init")||{};while(n--){var o=t[n][0],u=t[n][2],a=o.value,f=this.S(o).parent(),l=o.getAttribute(this.add_namespace("data-abide-validator")),c=o.type==="radio",h=o.type==="checkbox",p=this.S('label[for="'+o.getAttribute("id")+'"]'),d=u?o.value.length>0:!0,v,m;o.getAttribute(this.add_namespace("data-equalto"))&&(l="equalTo"),f.is("label")?v=f.parent():v=f,c&&u?r.push(this.valid_radio(o,u)):h&&u?r.push(this.valid_checkbox(o,u)):l?(m=this.settings.validators[l].apply(this,[o,u,v]),r.push(m),m?(this.S(o).removeAttr(this.invalid_attr),v.removeClass("error")):(this.S(o).attr(this.invalid_attr,""),v.addClass("error"))):t[n][1].test(a)&&d||!u&&o.value.length<1||e(o).attr("disabled")?(this.S(o).removeAttr(this.invalid_attr),v.removeClass("error"),p.length>0&&s.error_labels&&p.removeClass("error"),r.push(!0),e(o).triggerHandler("valid")):(this.S(o).attr(this.invalid_attr,""),v.addClass("error"),p.length>0&&s.error_labels&&p.addClass("error"),r.push(!1),e(o).triggerHandler("invalid"))}return r},valid_checkbox:function(e,t){var e=this.S(e),n=e.is(":checked")||!t;return n?e.removeAttr(this.invalid_attr).parent().removeClass("error"):e.attr(this.invalid_attr,"").parent().addClass("error"),n},valid_radio:function(e,t){var n=e.getAttribute("name"),r=this.S(e).closest("[data-"+this.attr_name(!0)+"]").find("[name="+n+"]"),i=r.length,s=!1;for(var o=0;o0;s?e.removeAttr(this.invalid_attr).parent().removeClass("error"):e.attr(this.invalid_attr,"").parent().addClass("error");if(!r){var o=this;i.each(function(){o.valid_oneof.call(o,this,null,null,!0)})}return s}}}(jQuery,this,this.document),function(e,t,n,r){"use strict";Foundation.libs.tooltip={name:"tooltip",version:"5.2.2",settings:{additional_inheritable_classes:[],tooltip_class:".tooltip",append_to:"body",touch_close_text:"Tap To Close",disable_for_touch:!1,hover_delay:200,tip_template:function(e,t){return''+t+''}},cache:{},init:function(e,t,n){Foundation.inherit(this,"random_str"),this.bindings(t,n)},events:function(t){var n=this,r=n.S;n.create(this.S(t)),e(this.scope).off(".tooltip").on("mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip","["+this.attr_name()+"]",function(t){var i=r(this),s=e.extend({},n.settings,n.data_options(i)),o=!1;if(Modernizr.touch&&/touchstart|MSPointerDown/i.test(t.type)&&r(t.target).is("a"))return!1;if(/mouse/i.test(t.type)&&n.ie_touch(t))return!1;if(i.hasClass("open"))Modernizr.touch&&/touchstart|MSPointerDown/i.test(t.type)&&t.preventDefault(),n.hide(i);else{if(s.disable_for_touch&&Modernizr.touch&&/touchstart|MSPointerDown/i.test(t.type))return;!s.disable_for_touch&&Modernizr.touch&&/touchstart|MSPointerDown/i.test(t.type)&&(t.preventDefault(),r(s.tooltip_class+".open").hide(),o=!0),/enter|over/i.test(t.type)?this.timer=setTimeout(function(){var e=n.showTip(i)}.bind(this),n.settings.hover_delay):t.type==="mouseout"||t.type==="mouseleave"?(clearTimeout(this.timer),n.hide(i)):n.showTip(i)}}).on("mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip","["+this.attr_name()+"].open",function(t){if(/mouse/i.test(t.type)&&n.ie_touch(t))return!1;if(e(this).data("tooltip-open-event-type")=="touch"&&t.type=="mouseleave")return;e(this).data("tooltip-open-event-type")=="mouse"&&/MSPointerDown|touchstart/i.test(t.type)?n.convert_to_touch(e(this)):n.hide(e(this))}).on("DOMNodeRemoved DOMAttrModified","["+this.attr_name()+"]:not(a)",function(e){n.hide(r(this))})},ie_touch:function(e){return!1},showTip:function(e){var t=this.getTip(e);return this.show(e)},getTip:function(t){var n=this.selector(t),r=e.extend({},this.settings,this.data_options(t)),i=null;return n&&(i=this.S('span[data-selector="'+n+'"]'+r.tooltip_class)),typeof i=="object"?i:!1},selector:function(e){var t=e.attr("id"),n=e.attr(this.attr_name())||e.attr("data-selector");return(t&&t.length<1||!t)&&typeof n!="string"&&(n=this.random_str(6),e.attr("data-selector",n)),t&&t.length>0?t:n},create:function(n){var r=this,i=e.extend({},this.settings,this.data_options(n)),s=this.settings.tip_template;typeof i.tip_template=="string"&&t.hasOwnProperty(i.tip_template)&&(s=t[i.tip_template]);var o=e(s(this.selector(n),e("
    ").html(n.attr("title")).html())),u=this.inheritable_classes(n);o.addClass(u).appendTo(i.append_to),Modernizr.touch&&(o.append(''+i.touch_close_text+""),o.on("touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip",function(e){r.hide(n)})),n.removeAttr("title").attr("title","")},reposition:function(t,n,r){var i,s,o,u,a,f;n.css("visibility","hidden").show(),i=t.data("width"),s=n.children(".nub"),o=s.outerHeight(),u=s.outerHeight(),this.small()?n.css({width:"100%"}):n.css({width:i?i:"auto"}),f=function(e,t,n,r,i,s){return e.css({top:t?t:"auto",bottom:r?r:"auto",left:i?i:"auto",right:n?n:"auto"}).end()},f(n,t.offset().top+t.outerHeight()+10,"auto","auto",t.offset().left);if(this.small())f(n,t.offset().top+t.outerHeight()+10,"auto","auto",12.5,e(this.scope).width()),n.addClass("tip-override"),f(s,-o,"auto","auto",t.offset().left);else{var l=t.offset().left;Foundation.rtl&&(s.addClass("rtl"),l=t.offset().left+t.outerWidth()-n.outerWidth()),f(n,t.offset().top+t.outerHeight()+10,"auto","auto",l),n.removeClass("tip-override"),r&&r.indexOf("tip-top")>-1?(Foundation.rtl&&s.addClass("rtl"),f(n,t.offset().top-n.outerHeight(),"auto","auto",l).removeClass("tip-override")):r&&r.indexOf("tip-left")>-1?(f(n,t.offset().top+t.outerHeight()/2-n.outerHeight()/2,"auto","auto",t.offset().left-n.outerWidth()-o).removeClass("tip-override"),s.removeClass("rtl")):r&&r.indexOf("tip-right")>-1&&(f(n,t.offset().top+t.outerHeight()/2-n.outerHeight()/2,"auto","auto",t.offset().left+t.outerWidth()+o).removeClass("tip-override"),s.removeClass("rtl"))}n.css("visibility","visible").hide()},small:function(){return matchMedia(Foundation.media_queries.small).matches&&!matchMedia(Foundation.media_queries.medium).matches},inheritable_classes:function(t){var n=e.extend({},this.settings,this.data_options(t)),r=["tip-top","tip-left","tip-bottom","tip-right","radius","round"].concat(n.additional_inheritable_classes),i=t.attr("class"),s=i?e.map(i.split(" "),function(t,n){if(e.inArray(t,r)!==-1)return t}).join(" "):"";return e.trim(s)},convert_to_touch:function(t){var n=this,r=n.getTip(t),i=e.extend({},n.settings,n.data_options(t));r.find(".tap-to-close").length===0&&(r.append(''+i.touch_close_text+""),r.on("click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose MSPointerDown.fndtn.tooltip.tapclose",function(e){n.hide(t)})),t.data("tooltip-open-event-type","touch")},show:function(e){var t=this.getTip(e);e.data("tooltip-open-event-type")=="touch"&&this.convert_to_touch(e),this.reposition(e,t,e.attr("class")),e.addClass("open"),t.fadeIn(150)},hide:function(e){var t=this.getTip(e);t.fadeOut(150,function(){t.find(".tap-to-close").remove(),t.off("click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose MSPointerDown.fndtn.tapclose"),e.removeClass("open")})},off:function(){var t=this;this.S(this.scope).off(".fndtn.tooltip"),this.S(this.settings.tooltip_class).each(function(n){e("["+t.attr_name()+"]").eq(n).attr("title",e(this).text())}).remove()},reflow:function(){}}}(jQuery,this,this.document); diff --git a/server/static/server/c3/docs/js/gettingstarted.js b/server/static/server/c3/docs/js/gettingstarted.js new file mode 100644 index 0000000..7614eb3 --- /dev/null +++ b/server/static/server/c3/docs/js/gettingstarted.js @@ -0,0 +1,186 @@ +c3.generate({ + bindto: '#chart2_1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + } +}); + +c3.generate({ + bindto: '#chart3_1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data2: 'y2' + } + }, + axis: { + y2: { + show: true + } + } +}); + +c3.generate({ + bindto: '#chart3_2', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data2: 'y2' + } + }, + axis: { + y: { + label: { + text: 'Y Label', + position: 'outer-middle' + } + }, + y2: { + show: true, + label: { + text: 'Y2 Label', + position: 'outer-middle' + } + } + } +}); + +c3.generate({ + bindto: '#chart3_3', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data2: 'y2' + }, + types: { + data2: 'bar' + } + }, + axis: { + y: { + label: { + text: 'Y Label', + position: 'outer-middle' + } + }, + y2: { + show: true, + label: { + text: 'Y2 Label', + position: 'outer-middle' + } + } + } +}); + +c3.generate({ + bindto: '#chart3_4', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data2: 'y2' + }, + types: { + data2: 'bar' + } + }, + axis: { + y: { + label: { + text: 'Y Label', + position: 'outer-middle' + }, + tick: { + format: d3.format("$,") + } + }, + y2: { + show: true, + label: { + text: 'Y2 Label', + position: 'outer-middle' + } + } + } +}); + +var chart4_1 = c3.generate({ + bindto: '#chart4_1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + } +}); + +function example4_1() { + chart4_1.load({ + columns: [ + ['data1', 300, 100, 250, 150, 300, 150, 500], + ['data2', 100, 200, 150, 50, 100, 250], + ['data3', 600, 700, 350, 450, 800, 550] + ] + }); +} + +var chart4_2 = c3.generate({ + bindto: '#chart4_2', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 600, 700, 350, 450, 800, 550] + ] + } +}); + +function example4_2() { + chart4_2.unload({ + ids: ['data2', 'data3'] + }); +} + +var chart4_3 = c3.generate({ + bindto: '#chart4_3', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 600, 700, 350, 450, 800, 550] + ] + } +}); + +function example4_3_1() { + chart4_3.show(['data2', 'data3']); +} +function example4_3_2() { + chart4_3.hide(['data2', 'data3']); +} + +c3.generate({ + bindto: '#chart5_1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 600, 700, 350, 450, 800, 550] + ] + } +}); diff --git a/server/static/server/c3/docs/js/highlight.pack.js b/server/static/server/c3/docs/js/highlight.pack.js new file mode 100644 index 0000000..cab4867 --- /dev/null +++ b/server/static/server/c3/docs/js/highlight.pack.js @@ -0,0 +1 @@ +var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(//gm,">")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=("")}while(o!=u.node);r.splice(q,1);while(q'+L[0]+""}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return''+r.value+""}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+=""}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"
    ")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.javascript=function(a){return{k:{keyword:"in if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const",literal:"true false null undefined NaN Infinity"},c:[a.ASM,a.QSM,a.CLCM,a.CBLCLM,a.CNM,{b:"("+a.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[a.CLCM,a.CBLCLM,{cN:"regexp",b:"/",e:"/[gim]*",i:"\\n",c:[{b:"\\\\/"}]},{b:"<",e:">;",sL:"xml"}],r:0},{cN:"function",bWK:true,e:"{",k:"function",c:[{cN:"title",b:"[A-Za-z$_][0-9A-Za-z$_]*"},{cN:"params",b:"\\(",e:"\\)",c:[a.CLCM,a.CBLCLM],i:"[\"'\\(]"}],i:"\\[|%"}]}}(hljs); \ No newline at end of file diff --git a/server/static/server/c3/docs/js/index.js b/server/static/server/c3/docs/js/index.js new file mode 100644 index 0000000..93c32b4 --- /dev/null +++ b/server/static/server/c3/docs/js/index.js @@ -0,0 +1,168 @@ +var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250, 50, 100, 250] + ], + selection: { + enabled: true + } + } +}); + +var defaultMessage = $('#message').html(), currentIndex = 0, timer, duration = 1500, demos = [ + function () { + chart.load({ + columns: [['data2', 100, 30, 200, 320, 50, 150, 230, 80, 150]] + }) + setMessage('Load data2'); + }, + function () { + chart.load({ + columns: [['data3', 70, 90, 170, 220, 100, 110, 130, 40, 50]] + }) + setMessage('Load data3'); + }, + function () { + chart.select(['data1'], [2]); + setMessage('Select point for index 2 of data1'); + }, + function () { + chart.select(['data1'], [4,6]); + setMessage('Select point for index 4,6 of data1'); + }, + function () { + chart.unselect(); + setMessage('Unselect points'); + }, + function () { + chart.focus('data2'); + setMessage('Focus on data2'); + }, + function () { + chart.focus('data3'); + setMessage('Focus on data3'); + }, + function () { + chart.revert(); + setMessage('Defocus'); + }, + function () { + chart.load({ + columns: [['data1', 300, 230, 400, 520, 230, 250, 330, 280, 250]] + }) + setMessage('Update data1'); + }, + function () { + chart.load({ + columns: [['data2', 30, 50, 90, 120, 40, 50, 80, 70, 50]] + }) + setMessage('Update data2'); + }, + function () { + chart.regions([{start:1,end:3}]); + setMessage('Add region from 1 to 3'); + }, + function () { + chart.regions.add([{start:6}]); + setMessage('Add region from 6 to end'); + }, + function () { + chart.regions([]); + setMessage('Clear regions'); + }, + function () { + chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]); + setMessage('Add x grid lines for 1, 4'); + }, + function () { + chart.ygrids.add([{value: 450, text:'Label 450'}]); + setMessage('Add y grid lines for 450'); + }, + function () { + chart.xgrids.remove({value: 1}); + chart.xgrids.remove({value: 4}); + setMessage('Remove grid lines for 1, 4'); + }, + function () { + chart.ygrids.remove({value: 450}); + setMessage('Remove grid line for 450'); + }, + function () { + chart.transform('bar'); + setMessage('Show as bar chart'); + }, + function () { + chart.groups([['data2','data3']]); + setMessage('Grouping data2 and data3'); + }, + function () { + chart.groups([['data1', 'data2', 'data3']]); + setMessage('Grouping data1, data2 and data3'); + }, + function () { + chart.groups([['data2', 'data3']]); + chart.transform('line', 'data1'); + setMessage('Show data1 as line'); + }, + function () { + chart.unload({ + ids: 'data3' + }); + setMessage('Unload data3'); + }, + function () { + chart.unload({ + ids: 'data2' + }); + setMessage('Unload data2'); + }, + function () { + chart.flow({ + columns: [ + ['data1', 390, 400, 200, 500] + ], + duration: 1000, + }); + setMessage('Flow 4 data'); + }, + function () { + // wait for end of transition for flow + }, + function () { + chart.flow({ + columns: [ + ['data1', 190, 230] + ], + }); + setMessage('Flow 2 data'); + }, + function () { + // wait for end of transition for flow + }, + function () { + chart.transform('line', ['data1', 'data2', 'data3']); + chart.groups([['data1'], ['data2'], ['data3']]); + chart.load({ + columns: [['data1', 30, 200, 100, 400, 150, 250, 50, 100, 250]] + }) + setMessage('Starting Demo..'); + } +]; + +function setMessage(message) { + document.getElementById('message').innerHTML = ''+message+''; +// $('#demoMessage').tooltip('toggle'); +} + +function startDemo() { + setMessage('Starting Demo..'); + timer = setInterval(function(){ + if (currentIndex == demos.length) currentIndex = 0; + demos[currentIndex++](); + }, duration); +} + +function stopDemo() { + clearInterval(timer); + document.getElementById('message').innerHTML = defaultMessage; +} diff --git a/server/static/server/c3/docs/js/jquery-1.11.0.min.js b/server/static/server/c3/docs/js/jquery-1.11.0.min.js new file mode 100644 index 0000000..73f33fb --- /dev/null +++ b/server/static/server/c3/docs/js/jquery-1.11.0.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.11.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m="1.11.0",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(n.isPlainObject(c)||(b=n.isArray(c)))?(b?(b=!1,f=a&&n.isArray(a)?a:[]):f=a&&n.isPlainObject(a)?a:{},g[d]=n.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray||function(a){return"array"===n.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==n.type(a)||a.nodeType||n.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(l.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&n.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:k&&!k.call("\ufeff\xa0")?function(a){return null==a?"":k.call(a)}:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),n.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||n.guid++,e):void 0},now:function(){return+new Date},support:l}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="
    ",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},z=b?function(a,b){if(a===b)return j=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=db.selectors={cacheLength:50,createPseudo:fb,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||db.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),t=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(t&&((l[s]||(l[s]={}))[a]=[u,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[u,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function sb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="
    ","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return n.inArray(a,b)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;e>b;b++)if(n.contains(d[b],this))return!0}));for(b=0;e>b;b++)n.find(a,d[b],c);return c=this.pushStack(e>1?n.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=a.document,A=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,B=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:A.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:z,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=z.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return y.find(a);this.length=1,this[0]=d}return this.context=z,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};B.prototype=n.fn,y=n(z);var C=/^(?:parents|prev(?:Until|All))/,D={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!n(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b,c=n(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(n.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?n.inArray(this[0],n(a)):n.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function E(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return E(a,"nextSibling")},prev:function(a){return E(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return n.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(D[a]||(e=n.unique(e)),C.test(a)&&(e=e.reverse())),this.pushStack(e)}});var F=/\S+/g,G={};function H(a){var b=G[a]={};return n.each(a.match(F)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?G[a]||H(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&n.each(arguments,function(a,c){var d;while((d=n.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var I;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){if(a===!0?!--n.readyWait:!n.isReady){if(!z.body)return setTimeout(n.ready);n.isReady=!0,a!==!0&&--n.readyWait>0||(I.resolveWith(z,[n]),n.fn.trigger&&n(z).trigger("ready").off("ready"))}}});function J(){z.addEventListener?(z.removeEventListener("DOMContentLoaded",K,!1),a.removeEventListener("load",K,!1)):(z.detachEvent("onreadystatechange",K),a.detachEvent("onload",K))}function K(){(z.addEventListener||"load"===event.type||"complete"===z.readyState)&&(J(),n.ready())}n.ready.promise=function(b){if(!I)if(I=n.Deferred(),"complete"===z.readyState)setTimeout(n.ready);else if(z.addEventListener)z.addEventListener("DOMContentLoaded",K,!1),a.addEventListener("load",K,!1);else{z.attachEvent("onreadystatechange",K),a.attachEvent("onload",K);var c=!1;try{c=null==a.frameElement&&z.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!n.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}J(),n.ready()}}()}return I.promise(b)};var L="undefined",M;for(M in n(l))break;l.ownLast="0"!==M,l.inlineBlockNeedsLayout=!1,n(function(){var a,b,c=z.getElementsByTagName("body")[0];c&&(a=z.createElement("div"),a.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",b=z.createElement("div"),c.appendChild(a).appendChild(b),typeof b.style.zoom!==L&&(b.style.cssText="border:0;margin:0;width:1px;padding:1px;display:inline;zoom:1",(l.inlineBlockNeedsLayout=3===b.offsetWidth)&&(c.style.zoom=1)),c.removeChild(a),a=b=null)}),function(){var a=z.createElement("div");if(null==l.deleteExpando){l.deleteExpando=!0;try{delete a.test}catch(b){l.deleteExpando=!1}}a=null}(),n.acceptData=function(a){var b=n.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(O,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}n.data(a,b,c)}else c=void 0}return c}function Q(a){var b;for(b in a)if(("data"!==b||!n.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function R(a,b,d,e){if(n.acceptData(a)){var f,g,h=n.expando,i=a.nodeType,j=i?n.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||n.guid++:h),j[k]||(j[k]=i?{}:{toJSON:n.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=n.extend(j[k],b):j[k].data=n.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[n.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[n.camelCase(b)])):f=g,f +}}function S(a,b,c){if(n.acceptData(a)){var d,e,f=a.nodeType,g=f?n.cache:a,h=f?a[n.expando]:n.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){n.isArray(b)?b=b.concat(n.map(b,n.camelCase)):b in d?b=[b]:(b=n.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!Q(d):!n.isEmptyObject(d))return}(c||(delete g[h].data,Q(g[h])))&&(f?n.cleanData([a],!0):l.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}n.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?n.cache[a[n.expando]]:a[n.expando],!!a&&!Q(a)},data:function(a,b,c){return R(a,b,c)},removeData:function(a,b){return S(a,b)},_data:function(a,b,c){return R(a,b,c,!0)},_removeData:function(a,b){return S(a,b,!0)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=n.data(f),1===f.nodeType&&!n._data(f,"parsedAttrs"))){c=g.length;while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d]));n._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){n.data(this,a)}):arguments.length>1?this.each(function(){n.data(this,a,b)}):f?P(f,a,n.data(f,a)):void 0},removeData:function(a){return this.each(function(){n.removeData(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=n._data(a,b),c&&(!d||n.isArray(c)?d=n._data(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return n._data(a,c)||n._data(a,c,{empty:n.Callbacks("once memory").add(function(){n._removeData(a,b+"queue"),n._removeData(a,c)})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},X=/^(?:checkbox|radio)$/i;!function(){var a=z.createDocumentFragment(),b=z.createElement("div"),c=z.createElement("input");if(b.setAttribute("className","t"),b.innerHTML="
    a",l.leadingWhitespace=3===b.firstChild.nodeType,l.tbody=!b.getElementsByTagName("tbody").length,l.htmlSerialize=!!b.getElementsByTagName("link").length,l.html5Clone="<:nav>"!==z.createElement("nav").cloneNode(!0).outerHTML,c.type="checkbox",c.checked=!0,a.appendChild(c),l.appendChecked=c.checked,b.innerHTML="",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,a.appendChild(b),b.innerHTML="",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,l.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){l.noCloneEvent=!1}),b.cloneNode(!0).click()),null==l.deleteExpando){l.deleteExpando=!0;try{delete b.test}catch(d){l.deleteExpando=!1}}a=b=c=null}(),function(){var b,c,d=z.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(l[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),l[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var Y=/^(?:input|select|textarea)$/i,Z=/^key/,$=/^(?:mouse|contextmenu)|click/,_=/^(?:focusinfocus|focusoutblur)$/,ab=/^([^.]*)(?:\.(.+)|)$/;function bb(){return!0}function cb(){return!1}function db(){try{return z.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=n.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof n===L||a&&n.event.triggered===a.type?void 0:n.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(F)||[""],h=b.length;while(h--)f=ab.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=n.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=n.event.special[o]||{},l=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},i),(m=g[o])||(m=g[o]=[],m.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,l):m.push(l),n.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n.hasData(a)&&n._data(a);if(r&&(k=r.events)){b=(b||"").match(F)||[""],j=b.length;while(j--)if(h=ab.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;while(f--)g=m[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(k)&&(delete r.handle,n._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,m,o=[d||z],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||z,3!==d.nodeType&&8!==d.nodeType&&!_.test(p+n.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[n.expando]?b:new n.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),k=n.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!n.isWindow(d)){for(i=k.delegateType||p,_.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||z)&&o.push(l.defaultView||l.parentWindow||a)}m=0;while((h=o[m++])&&!b.isPropagationStopped())b.type=m>1?i:k.bindType||p,f=(n._data(h,"events")||{})[b.type]&&n._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&n.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&n.acceptData(d)&&g&&d[p]&&!n.isWindow(d)){l=d[g],l&&(d[g]=null),n.event.triggered=p;try{d[p]()}catch(r){}n.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(n._data(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((n.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?n(c,this).index(i)>=0:n.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),ib=/^\s+/,jb=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,kb=/<([\w:]+)/,lb=/\s*$/g,sb={option:[1,""],legend:[1,"
    ","
    "],area:[1,"",""],param:[1,"",""],thead:[1,"","
    "],tr:[2,"","
    "],col:[2,"","
    "],td:[3,"","
    "],_default:l.htmlSerialize?[0,"",""]:[1,"X
    ","
    "]},tb=eb(z),ub=tb.appendChild(z.createElement("div"));sb.optgroup=sb.option,sb.tbody=sb.tfoot=sb.colgroup=sb.caption=sb.thead,sb.th=sb.td;function vb(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==L?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==L?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||n.nodeName(d,b)?f.push(d):n.merge(f,vb(d,b));return void 0===b||b&&n.nodeName(a,b)?n.merge([a],f):f}function wb(a){X.test(a.type)&&(a.defaultChecked=a.checked)}function xb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function yb(a){return a.type=(null!==n.find.attr(a,"type"))+"/"+a.type,a}function zb(a){var b=qb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ab(a,b){for(var c,d=0;null!=(c=a[d]);d++)n._data(c,"globalEval",!b||n._data(b[d],"globalEval"))}function Bb(a,b){if(1===b.nodeType&&n.hasData(a)){var c,d,e,f=n._data(a),g=n._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)n.event.add(b,c,h[c][d])}g.data&&(g.data=n.extend({},g.data))}}function Cb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!l.noCloneEvent&&b[n.expando]){e=n._data(b);for(d in e.events)n.removeEvent(b,d,e.handle);b.removeAttribute(n.expando)}"script"===c&&b.text!==a.text?(yb(b).text=a.text,zb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),l.html5Clone&&a.innerHTML&&!n.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&X.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}n.extend({clone:function(a,b,c){var d,e,f,g,h,i=n.contains(a.ownerDocument,a);if(l.html5Clone||n.isXMLDoc(a)||!hb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ub.innerHTML=a.outerHTML,ub.removeChild(f=ub.firstChild)),!(l.noCloneEvent&&l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(d=vb(f),h=vb(a),g=0;null!=(e=h[g]);++g)d[g]&&Cb(e,d[g]);if(b)if(c)for(h=h||vb(a),d=d||vb(f),g=0;null!=(e=h[g]);g++)Bb(e,d[g]);else Bb(a,f);return d=vb(f,"script"),d.length>0&&Ab(d,!i&&vb(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,m=a.length,o=eb(b),p=[],q=0;m>q;q++)if(f=a[q],f||0===f)if("object"===n.type(f))n.merge(p,f.nodeType?[f]:f);else if(mb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(kb.exec(f)||["",""])[1].toLowerCase(),k=sb[i]||sb._default,h.innerHTML=k[1]+f.replace(jb,"<$1>")+k[2],e=k[0];while(e--)h=h.lastChild;if(!l.leadingWhitespace&&ib.test(f)&&p.push(b.createTextNode(ib.exec(f)[0])),!l.tbody){f="table"!==i||lb.test(f)?""!==k[1]||lb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)n.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}n.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),l.appendChecked||n.grep(vb(p,"input"),wb),q=0;while(f=p[q++])if((!d||-1===n.inArray(f,d))&&(g=n.contains(f.ownerDocument,f),h=vb(o.appendChild(f),"script"),g&&Ab(h),c)){e=0;while(f=h[e++])pb.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=n.expando,j=n.cache,k=l.deleteExpando,m=n.event.special;null!=(d=a[h]);h++)if((b||n.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)m[e]?n.event.remove(d,e):n.removeEvent(d,e,g.handle);j[f]&&(delete j[f],k?delete d[i]:typeof d.removeAttribute!==L?d.removeAttribute(i):d[i]=null,c.push(f))}}}),n.fn.extend({text:function(a){return W(this,function(a){return void 0===a?n.text(this):this.empty().append((this[0]&&this[0].ownerDocument||z).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(vb(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&Ab(vb(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&n.cleanData(vb(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&n.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return W(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(gb,""):void 0;if(!("string"!=typeof a||nb.test(a)||!l.htmlSerialize&&hb.test(a)||!l.leadingWhitespace&&ib.test(a)||sb[(kb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(jb,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(vb(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(vb(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,o=k-1,p=a[0],q=n.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&ob.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(i=n.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=n.map(vb(i,"script"),yb),f=g.length;k>j;j++)d=i,j!==o&&(d=n.clone(d,!0,!0),f&&n.merge(g,vb(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,n.map(g,zb),j=0;f>j;j++)d=g[j],pb.test(d.type||"")&&!n._data(d,"globalEval")&&n.contains(h,d)&&(d.src?n._evalUrl&&n._evalUrl(d.src):n.globalEval((d.text||d.textContent||d.innerHTML||"").replace(rb,"")));i=c=null}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=0,e=[],g=n(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),n(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Db,Eb={};function Fb(b,c){var d=n(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:n.css(d[0],"display");return d.detach(),e}function Gb(a){var b=z,c=Eb[a];return c||(c=Fb(a,b),"none"!==c&&c||(Db=(Db||n("