diff options
author | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-21 20:33:44 +0100 |
---|---|---|
committer | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-21 20:33:44 +0100 |
commit | 5ba657e0bca0e4970b08583f6dfc94bfae34741c (patch) | |
tree | 44ed77deecd40ca984aae4bfa1bb949cb87bf7a0 /web/nms-public.gathering.org/old/speedometer/c3-master | |
parent | d528cad67897dd2c3b98ec15a82868ac2764e2c7 (diff) | |
parent | 727e4ab31aa6d1a754711d4cd29dbcefae2e952a (diff) |
Merge branch 'master' of https://github.com/tech-server/tgmanage
Diffstat (limited to 'web/nms-public.gathering.org/old/speedometer/c3-master')
219 files changed, 26428 insertions, 0 deletions
diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/.editorconfig b/web/nms-public.gathering.org/old/speedometer/c3-master/.editorconfig new file mode 100644 index 0000000..8f96039 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/.editorconfig @@ -0,0 +1,10 @@ +# 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 diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/.gitignore b/web/nms-public.gathering.org/old/speedometer/c3-master/.gitignore new file mode 100644 index 0000000..85c9d4f --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/.gitignore @@ -0,0 +1,8 @@ +# npm modules +node_modules +bower_components +d3.js +d3.min.js +components +build +.sass-cache diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/.jshintrc b/web/nms-public.gathering.org/old/speedometer/c3-master/.jshintrc new file mode 100644 index 0000000..9b4294c --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/.jshintrc @@ -0,0 +1,31 @@ +{ + "bitwise": true, + "eqeqeq": true, + "curly": true, + "strict": true, + "trailing": true, + "white": true, + "maxlen": 210, + "undef": true, + "unused": true, + "indent": 4, + + "eqnull": true, + "expr": true, + "newcap": false, + "loopfunc": true, + "bitwise": false, + + "browser": true, + + "globals": { + "jasmine": false, + "describe": false, + "beforeEach": false, + "beforeAll": false, + "it": false, + "expect": false, + "d3": false + } + +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/.travis.yml b/web/nms-public.gathering.org/old/speedometer/c3-master/.travis.yml new file mode 100644 index 0000000..cd93ed1 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/.travis.yml @@ -0,0 +1,5 @@ +language: node_js + +before_script: +- npm install -g grunt-cli +- gem install sass diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/Gruntfile.coffee b/web/nms-public.gathering.org/old/speedometer/c3-master/Gruntfile.coffee new file mode 100644 index 0000000..750bbc7 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/Gruntfile.coffee @@ -0,0 +1,113 @@ +module.exports = (grunt) -> + require('load-grunt-tasks') grunt, pattern: ['grunt-contrib-*', 'grunt-sass'] + + grunt.initConfig + watch: + concat: + tasks: 'concat' + files: ['src/*.js'] + sass: + tasks: 'sass' + files: ['src/scss/*.scss'] + + concat: + dist: + options: + process: (src, filepath) -> + if filepath != 'src/head.js' && filepath != 'src/tail.js' + lines = [] + src.split('\n').forEach (line) -> + lines.push( (if line.length > 0 then ' ' else '') + line) + src = lines.join('\n') + return src + src: [ + 'src/head.js', + 'src/core.js', + 'src/config.js', + 'src/scale.js', + 'src/domain.js', + 'src/data.js', + 'src/data.convert.js', + 'src/data.load.js', + 'src/category.js', + 'src/interaction.js', + 'src/size.js', + 'src/shape.js', + 'src/shape.line.js', + 'src/shape.bar.js', + 'src/text.js', + 'src/type.js', + 'src/grid.js', + 'src/tooltip.js', + 'src/legend.js', + 'src/axis.js', + 'src/clip.js', + 'src/arc.js', + 'src/region.js', + 'src/drag.js', + 'src/selection.js', + 'src/subchart.js', + 'src/zoom.js', + 'src/color.js', + 'src/format.js', + 'src/cache.js', + 'src/class.js', + 'src/util.js', + 'src/api.focus.js', + 'src/api.show.js', + 'src/api.zoom.js', + 'src/api.load.js', + 'src/api.flow.js', + 'src/api.selection.js', + 'src/api.transform.js', + 'src/api.group.js', + 'src/api.grid.js', + 'src/api.region.js', + 'src/api.data.js', + 'src/api.category.js', + 'src/api.color.js', + 'src/api.x.js', + 'src/api.axis.js', + 'src/api.legend.js', + 'src/api.chart.js', + 'src/api.tooltip.js', + 'src/c3.axis.js', + 'src/ua.js', + 'src/polyfill.js', + 'src/tail.js' + ] + dest: 'c3.js' + + jshint: + c3: 'c3.js' + spec: 'spec/*.js' + options: + jshintrc: '.jshintrc' + + jasmine: + c3: + src: 'c3.js' + options: + specs: 'spec/*-spec.js' + helpers: 'spec/*-helper.js' + styles: 'c3.css' + vendor: 'https://raw.githubusercontent.com/mbostock/d3/v3.5.0/d3.min.js' + + uglify: + c3: + files: + 'c3.min.js': 'c3.js' + + cssmin: + c3: + src: 'c3.css' + dest: 'c3.min.css' + + sass: + options: + sourcemap: 'none' + c3: + files: + 'c3.css': 'src/scss/main.scss' + + grunt.registerTask 'default', ['concat', 'jshint', 'jasmine', 'sass', 'cssmin', 'uglify'] diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/LICENSE b/web/nms-public.gathering.org/old/speedometer/c3-master/LICENSE new file mode 100644 index 0000000..29ce9cb --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/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/web/nms-public.gathering.org/old/speedometer/c3-master/README.md b/web/nms-public.gathering.org/old/speedometer/c3-master/README.md new file mode 100644 index 0000000..53d97e2 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/README.md @@ -0,0 +1,51 @@ +c3 [](https://travis-ci.org/masayuki0812/c3) [](https://david-dm.org/masayuki0812/c3) [](https://david-dm.org/masayuki0812/c3#info=devDependencies) [](https://github.com/masayuki0812/c3/blob/master/LICENSE) +== + +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/) + +## Tutorial and Examples + ++ [Getting Started](http://c3js.org/gettingstarted.html) ++ [Examples](http://c3js.org/examples.html) + +Additional samples can be found in this repository: ++ [https://github.com/masayuki0812/c3/tree/master/htdocs/samples](https://github.com/masayuki0812/c3/tree/master/htdocs/samples) + +You can run these samples as: +``` +$ cd c3/htdocs +$ python -m SimpleHTTPServer 8080 +``` + +## 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). + +## Using the issue queue +The [issue queue](https://github.com/masayuki0812/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/masayuki0812/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! + +## Playground +Please fork this fiddle: ++ [http://jsfiddle.net/masayuki0812/7kYJu/](http://jsfiddle.net/masayuki0812/7kYJu/) + +## Dependency ++ [D3.js](https://github.com/mbostock/d3) `<=3.5.0` + +## License +MIT + +[](https://flattr.com/submit/auto?user_id=masayuki0812&url=https://github.com/masayuki0812/c3&title=c3&language=javascript&tags=github&category=software) diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/bower.json b/web/nms-public.gathering.org/old/speedometer/c3-master/bower.json new file mode 100644 index 0000000..31e1336 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/bower.json @@ -0,0 +1,32 @@ +{ + "name": "c3", + "main": [ + "c3.css", + "c3.js" + ], + "version": "0.4.10", + "homepage": "https://github.com/masayuki0812/c3", + "authors": [ + "Masayuki Tanaka <masayuki0812@mac.com>" + ], + "description": "D3-based reusable chart library", + "keywords": [ + "chart", + "d3" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "htdocs", + "spec", + "src", + "package.json", + "component.json", + "Gruntfile.*" + ], + "dependencies": { + "d3": "<=3.5.0" + } +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/c3.css b/web/nms-public.gathering.org/old/speedometer/c3-master/c3.css new file mode 100644 index 0000000..ab0b70a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/c3.css @@ -0,0 +1,158 @@ +/*-- Chart --*/ +.c3 svg { + font: 10px sans-serif; } + +.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 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._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: 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; } + +/*-- 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; } + +/*-- 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 td.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: none; } + +.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;*/ } diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/c3.js b/web/nms-public.gathering.org/old/speedometer/c3-master/c3.js new file mode 100644 index 0000000..233d1b5 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/c3.js @@ -0,0 +1,7049 @@ +(function (window) { + 'use strict'; + + /*global define, module, exports, require */ + + var c3 = { version: "0.4.10" }; + + var c3_chart_fn, + c3_chart_internal_fn, + c3_chart_internal_axis_fn; + + function API(owner) { + this.owner = owner; + } + + function inherit(base, derived) { + + if (Object.create) { + derived.prototype = Object.create(base.prototype); + } else { + var f = function f() {}; + f.prototype = base.prototype; + derived.prototype = new f(); + } + + derived.prototype.constructor = derived; + + return derived; + } + + function Chart(config) { + var $$ = this.internal = new ChartInternal(this); + $$.loadConfig(config); + $$.init(); + + // 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); + } + }); + })(c3_chart_fn, this, this); + } + + function ChartInternal(api) { + var $$ = this; + $$.d3 = window.d3 ? window.d3 : typeof require !== 'undefined' ? require("d3") : undefined; + $$.api = api; + $$.config = $$.getDefaultConfig(); + $$.data = {}; + $$.cache = {}; + $$.axes = {}; + } + + c3.generate = function (config) { + return new Chart(config); + }; + + c3.chart = { + fn: Chart.prototype, + internal: { + fn: ChartInternal.prototype, + axis: { + fn: Axis.prototype + } + } + }; + c3_chart_fn = c3.chart.fn; + c3_chart_internal_fn = c3.chart.internal.fn; + c3_chart_internal_axis_fn = c3.chart.internal.axis.fn; + + c3_chart_internal_fn.init = function () { + var $$ = this, config = $$.config; + + $$.initParams(); + + if (config.data_url) { + $$.convertUrlToData(config.data_url, config.data_mimeType, 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.'); + } + }; + + c3_chart_internal_fn.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()) + '-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 = false; + $$.transiting = false; + + $$.color = $$.generateColor(); + $$.levelColor = $$.generateLevelColor(); + + $$.dataTimeFormat = config.data_xLocaltime ? d3.time.format : d3.time.format.utc; + $$.axisTimeFormat = config.axis_x_localtime ? d3.time.format : d3.time.format.utc; + $$.defaultAxisTimeFormat = $$.axisTimeFormat.multi([ + [".%L", function (d) { return d.getMilliseconds(); }], + [":%S", function (d) { return d.getSeconds(); }], + ["%I:%M", function (d) { return d.getMinutes(); }], + ["%I %p", function (d) { return d.getHours(); }], + ["%-m/%-d", function (d) { return d.getDay() && d.getDate() !== 1; }], + ["%-m/%-d", function (d) { return d.getDate() !== 1; }], + ["%-m/%-d", function (d) { return d.getMonth(); }], + ["%Y/%-m/%-d", function () { return true; }] + ]); + + $$.hiddenTargetIds = []; + $$.hiddenLegendIds = []; + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; + + $$.xOrient = config.axis_rotated ? "left" : "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 + }; + + c3_chart_internal_fn.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(); } + }; + + c3_chart_internal_fn.initWithData = function (data) { + var $$ = this, d3 = $$.d3, config = $$.config; + var defs, main, binding = true; + + $$.axis = new Axis($$); + + if ($$.initPie) { $$.initPie(); } + if ($$.initBrush) { $$.initBrush(); } + if ($$.initZoom) { $$.initZoom(); } + + 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); + } + + // when gauge, hide legend // TODO: fix + if ($$.hasType('gauge')) { + config.legend_show = false; + } + + // 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(); + + // Set initialized scales to brush and zoom + if ($$.brush) { $$.brush.scale($$.subX); } + if (config.zoom_enabled) { $$.zoom.scale($$.x); } + + /*-- 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($$); }); + + // 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 ($$.initSubchart) { $$.initSubchart(); } + if ($$.initTooltip) { $$.initTooltip(); } + if ($$.initLegend) { $$.initLegend(); } + + /*-- 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(); } + + // Cover whole with rects for events + $$.initEventRect(); + + // Define g for chart + $$.initChartElements(); + + // if zoom privileged, insert rect to forefront + // TODO: is this needed? + main.insert('rect', config.zoom_privileged ? null : 'g.' + CLASS.regions) + .attr('class', CLASS.zoomRect) + .attr('width', $$.width) + .attr('height', $$.height) + .style('opacity', 0) + .on("dblclick.zoom", null); + + // Set default extent if defined + if (config.axis_x_extent) { $$.brush.extent($$.getDefaultExtent()); } + + // Add Axis + $$.axis.init(); + + // Set targets + $$.updateTargets($$.data.targets); + + // Draw with targets + if (binding) { + $$.updateDimension(); + $$.config.oninit.call($$); + $$.redraw({ + withTransition: false, + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransitionForAxis: false + }); + } + + // Bind resize event + if (window.onresize == null) { + window.onresize = $$.generateResize(); + } + if (window.onresize.add) { + window.onresize.add(function () { + config.onresize.call($$); + }); + window.onresize.add(function () { + $$.api.flush(); + }); + window.onresize.add(function () { + config.onresized.call($$); + }); + } + + // export element of the chart + $$.api.element = $$.selectChart.node(); + }; + + c3_chart_internal_fn.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) + }); + }); + } + }; + + + c3_chart_internal_fn.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')) { + $$.arcHeight += $$.height - $$.getGaugeLabelHeight(); + } + if ($$.updateRadius) { $$.updateRadius(); } + + if ($$.isLegendRight && hasArc) { + $$.margin3.left = $$.arcWidth / 2 + $$.radiusExpanded * 1.1; + } + }; + + c3_chart_internal_fn.updateTargets = function (targets) { + var $$ = this; + + /*-- Main --*/ + + //-- Text --// + $$.updateTargetsForText(targets); + + //-- Bar --// + $$.updateTargetsForBar(targets); + + //-- Line --// + $$.updateTargetsForLine(targets); + + //-- Arc --// + if ($$.hasArcType() && $$.updateTargetsForArc) { $$.updateTargetsForArc(targets); } + + /*-- Sub --*/ + + if ($$.updateTargetsForSubchart) { $$.updateTargetsForSubchart(targets); } + + // Fade-in each chart + $$.showTargets(); + }; + c3_chart_internal_fn.showTargets = function () { + var $$ = this; + $$.svg.selectAll('.' + CLASS.target).filter(function (d) { return $$.isTargetToShow(d.id); }) + .transition().duration($$.config.transition_duration) + .style("opacity", 1); + }; + + c3_chart_internal_fn.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 waitForDraw, flow; + 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(transitions, 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 sub domain + if (withY) { + $$.subY.domain($$.getYDomain(targetsToShow, 'y')); + $$.subY2.domain($$.getYDomain(targetsToShow, 'y2')); + } + + // tooltip + $$.tooltip.style("display", "none"); + + // 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); + + // grid + $$.updateGrid(duration); + + // rect for regions + $$.updateRegion(duration); + + // bars + $$.updateBar(durationForExit); + + // lines, areas and cricles + $$.updateLine(durationForExit); + $$.updateArea(durationForExit); + $$.updateCircle(); + + // text + if ($$.hasDataLabel()) { + $$.updateText(durationForExit); + } + + // arc + if ($$.redrawArc) { $$.redrawArc(duration, durationForExit, withTransform); } + + // subchart + if ($$.redrawSubchart) { + $$.redrawSubchart(withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices); + } + + // circles for select + main.selectAll('.' + CLASS.selectedCircles) + .filter($$.isBarType.bind($$)) + .selectAll('circle') + .remove(); + + // event rects will redrawn when flow called + if (config.interaction_enabled && !options.flow && withEventRect) { + $$.redrawEventRect(); + if ($$.updateZoom) { $$.updateZoom(); } + } + + // 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($$); + + 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 || flow) && $$.isTabVisible()) { // Only use transition if tab visible. See #938. + // transition should be derived from one transition + d3.transition().duration(duration).each(function () { + var transitionsToWait = []; + + // redraw and gather transitions + [ + $$.redrawBar(drawBar, true), + $$.redrawLine(drawLine, true), + $$.redrawArea(drawArea, true), + $$.redrawCircle(cx, cy, true), + $$.redrawText(xForText, yForText, options.flow, true), + $$.redrawRegion(true), + $$.redrawGrid(true), + ].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); + }); + }) + .call(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 (config.onrendered) { + config.onrendered.call($$); + } + } + + // update fadein condition + $$.mapToIds($$.data.targets).forEach(function (id) { + $$.withoutFadeIn[id] = true; + }); + }; + + c3_chart_internal_fn.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 = true; + 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); + }; + c3_chart_internal_fn.redrawWithoutRescale = function () { + this.redraw({ + withY: false, + withSubchart: false, + withEventRect: false, + withTransitionForAxis: false + }); + }; + + c3_chart_internal_fn.isTimeSeries = function () { + return this.config.axis_x_type === 'timeseries'; + }; + c3_chart_internal_fn.isCategorized = function () { + return this.config.axis_x_type.indexOf('categor') >= 0; + }; + c3_chart_internal_fn.isCustomX = function () { + var $$ = this, config = $$.config; + return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)); + }; + + c3_chart_internal_fn.isTimeSeriesY = function () { + return this.config.axis_y_type === 'timeseries'; + }; + + c3_chart_internal_fn.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; + } + return "translate(" + x + "," + y + ")"; + }; + c3_chart_internal_fn.initialOpacity = function (d) { + return d.value !== null && this.withoutFadeIn[d.id] ? 1 : 0; + }; + c3_chart_internal_fn.initialOpacityForCircle = function (d) { + return d.value !== null && this.withoutFadeIn[d.id] ? this.opacityForCircle(d) : 0; + }; + c3_chart_internal_fn.opacityForCircle = function (d) { + var opacity = this.config.point_show ? 1 : 0; + return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0; + }; + c3_chart_internal_fn.opacityForText = function () { + return this.hasDataLabel() ? 1 : 0; + }; + c3_chart_internal_fn.xx = function (d) { + return d ? this.x(d.x) : null; + }; + c3_chart_internal_fn.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)); + }; + c3_chart_internal_fn.yv = function (d) { + var $$ = this, + yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y; + return Math.ceil(yScale(d.value)); + }; + c3_chart_internal_fn.subxx = function (d) { + return d ? this.subX(d.x) : null; + }; + + c3_chart_internal_fn.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')); + }; + c3_chart_internal_fn.transformAll = function (withTransition, transitions) { + var $$ = this; + $$.transformMain(withTransition, transitions); + if ($$.config.subchart_show) { $$.transformContext(withTransition, transitions); } + if ($$.legend) { $$.transformLegend(withTransition); } + }; + + c3_chart_internal_fn.updateSvgSize = function () { + var $$ = this, + brush = $$.svg.select(".c3-brush .background"); + $$.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); + $$.svg.select('.' + CLASS.zoomRect) + .attr('width', $$.width) + .attr('height', $$.height); + // MEMO: parent div's height will be bigger than svg when <!DOCTYPE html> + $$.selectChart.style('max-height', $$.currentHeight + "px"); + }; + + + c3_chart_internal_fn.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); + }; + + c3_chart_internal_fn.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(); + $$.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}); + }; + + + c3_chart_internal_fn.generateResize = function () { + var resizeFunctions = []; + function callResizeFunctions() { + resizeFunctions.forEach(function (f) { + f(); + }); + } + callResizeFunctions.add = function (f) { + resizeFunctions.push(f); + }; + return callResizeFunctions; + }; + + c3_chart_internal_fn.endall = function (transition, callback) { + var n = 0; + transition + .each(function () { ++n; }) + .each("end", function () { + if (!--n) { callback.apply(this, arguments); } + }); + }; + c3_chart_internal_fn.generateWait = function () { + var transitionsToWait = [], + f = function (transition, callback) { + var timer = setInterval(function () { + 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(); } + } + }, 10); + }; + f.add = function (transition) { + transitionsToWait.push(transition); + }; + return f; + }; + + c3_chart_internal_fn.parseDate = function (date) { + var $$ = this, parsedDate; + if (date instanceof Date) { + parsedDate = date; + } else if (typeof date === 'string') { + parsedDate = $$.dataTimeFormat($$.config.data_xFormat).parse(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; + }; + + c3_chart_internal_fn.isTabVisible = function () { + var hidden; + if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support + hidden = "hidden"; + } else if (typeof document.mozHidden !== "undefined") { + hidden = "mozHidden"; + } else if (typeof document.msHidden !== "undefined") { + hidden = "msHidden"; + } else if (typeof document.webkitHidden !== "undefined") { + hidden = "webkitHidden"; + } + + return document[hidden] ? false : true; + }; + + c3_chart_internal_fn.getDefaultConfig = function () { + var config = { + bindto: '#chart', + size_width: undefined, + size_height: undefined, + padding_left: undefined, + padding_right: undefined, + padding_top: undefined, + padding_bottom: undefined, + zoom_enabled: false, + zoom_extent: undefined, + zoom_privileged: false, + zoom_rescale: false, + zoom_onzoom: function () {}, + zoom_onzoomstart: function () {}, + zoom_onzoomend: function () {}, + interaction_enabled: true, + onmouseover: function () {}, + onmouseout: function () {}, + onresize: function () {}, + onresized: function () {}, + oninit: function () {}, + onrendered: function () {}, + transition_duration: 350, + 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_onclick: function () {}, + data_onmouseover: function () {}, + data_onmouseout: function () {}, + data_onselected: function () {}, + data_onunselected: function () {}, + data_url: 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_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, + // 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_width: null, + axis_x_max: undefined, + axis_x_min: undefined, + axis_x_padding: {}, + axis_x_height: undefined, + axis_x_extent: undefined, + axis_x_label: {}, + axis_y_show: true, + axis_y_type: undefined, + 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_count: undefined, + axis_y_tick_time_value: undefined, + axis_y_tick_time_interval: undefined, + axis_y_padding: {}, + axis_y_default: undefined, + axis_y2_show: false, + 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_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, + // area + area_zerobased: true, + // pie + pie_label_show: true, + pie_label_format: undefined, + pie_label_threshold: 0.05, + pie_expand: true, + // gauge + gauge_label_show: true, + gauge_label_format: undefined, + gauge_expand: true, + gauge_min: 0, + gauge_max: 100, + gauge_units: undefined, + gauge_width: undefined, + // donut + donut_label_show: true, + donut_label_format: undefined, + donut_label_threshold: 0.05, + donut_width: undefined, + donut_expand: true, + donut_title: "", + // region - region to change style + regions: [], + // tooltip - show when mouseover on each data + tooltip_show: true, + tooltip_grouped: true, + tooltip_format_title: undefined, + tooltip_format_name: undefined, + tooltip_format_value: 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'} + }; + + Object.keys(this.additionalConfig).forEach(function (key) { + config[key] = this.additionalConfig[key]; + }, this); + + return config; + }; + c3_chart_internal_fn.additionalConfig = {}; + + c3_chart_internal_fn.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; + } + }); + }; + + c3_chart_internal_fn.getScale = function (min, max, forTimeseries) { + return (forTimeseries ? this.d3.time.scale() : this.d3.scale.linear()).range([min, max]); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.getY = function (min, max, domain) { + var scale = this.getScale(min, max, this.isTimeSeriesY()); + if (domain) { scale.domain(domain); } + return scale; + }; + c3_chart_internal_fn.getYScale = function (id) { + return this.axis.getId(id) === 'y2' ? this.y2 : this.y; + }; + c3_chart_internal_fn.getSubYScale = function (id) { + return this.axis.getId(id) === 'y2' ? this.subY2 : this.subY; + }; + c3_chart_internal_fn.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($$.yMin, $$.yMax, forInit ? config.axis_y_default : $$.y.domain()); + $$.y2 = $$.getY($$.yMin, $$.yMax, forInit ? config.axis_y2_default : $$.y2.domain()); + $$.subX = $$.getX($$.xMin, $$.xMax, $$.orgXDomain, function (d) { return d % 1 ? 0 : $$.subXAxis.tickOffset(); }); + $$.subY = $$.getY($$.subYMin, $$.subYMax, forInit ? config.axis_y_default : $$.subY.domain()); + $$.subY2 = $$.getY($$.subYMin, $$.subYMax, forInit ? config.axis_y2_default : $$.subY2.domain()); + // 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, $$.yOrient, config.axis_y_tick_format, $$.yAxisTickValues, config.axis_y_tick_outer); + $$.y2Axis = $$.axis.getYAxis($$.y2, $$.y2Orient, config.axis_y2_tick_format, $$.y2AxisTickValues, config.axis_y2_tick_outer); + + // Set initialized scales to brush and zoom + if (!forInit) { + if ($$.brush) { $$.brush.scale($$.subX); } + if (config.zoom_enabled) { $$.zoom.scale($$.x); } + } + // update for arc + if ($$.updateArc) { $$.updateArc(); } + }; + + c3_chart_internal_fn.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]); })); + }; + c3_chart_internal_fn.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]); })); + }; + c3_chart_internal_fn.getYDomain = function (targets, axisId, xDomain) { + var $$ = this, config = $$.config, + 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, 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 = 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'); + padding_top += $$.axis.convertPixelsToAxisPadding(lengths[1], domainLength); + padding_bottom += $$.axis.convertPixelsToAxisPadding(lengths[0], domainLength); + } + 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; + }; + c3_chart_internal_fn.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; }); }); + }; + c3_chart_internal_fn.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; }); }); + }; + c3_chart_internal_fn.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}; + }; + c3_chart_internal_fn.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]; + }; + c3_chart_internal_fn.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.scale($$.x).updateScaleExtent(); } + $$.subX.domain($$.x.domain()); + if ($$.brush) { $$.brush.scale($$.subX); } + } + if (withUpdateXDomain) { + $$.x.domain(domain ? domain : (!$$.brush || $$.brush.empty()) ? $$.orgXDomain : $$.brush.extent()); + if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); } + } + + // Trim domain when too big by zoom mousemove event + if (withTrim) { $$.x.domain($$.trimXDomain($$.x.orgDomain())); } + + return $$.x.domain(); + }; + c3_chart_internal_fn.trimXDomain = function (domain) { + var $$ = this; + if (domain[0] <= $$.orgXDomain[0]) { + domain[1] = +domain[1] + ($$.orgXDomain[0] - domain[0]); + domain[0] = $$.orgXDomain[0]; + } + if ($$.orgXDomain[1] <= domain[1]) { + domain[0] = +domain[0] - (domain[1] - $$.orgXDomain[1]); + domain[1] = $$.orgXDomain[1]; + } + return domain; + }; + + c3_chart_internal_fn.isX = function (key) { + var $$ = this, config = $$.config; + return (config.data_x && key === config.data_x) || (notEmpty(config.data_xs) && hasValue(config.data_xs, key)); + }; + c3_chart_internal_fn.isNotX = function (key) { + return !this.isX(key); + }; + c3_chart_internal_fn.getXKey = function (id) { + var $$ = this, config = $$.config; + return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null; + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.getIndexByX = function (x) { + var $$ = this, + data = $$.filterByX($$.data.targets, x); + return data.length ? data[0].index : null; + }; + c3_chart_internal_fn.getXValue = function (id, i) { + var $$ = this; + return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i; + }; + c3_chart_internal_fn.getOtherTargetXs = function () { + var $$ = this, + idsForX = Object.keys($$.data.xs); + return idsForX.length ? $$.data.xs[idsForX[0]] : null; + }; + c3_chart_internal_fn.getOtherTargetX = function (index) { + var xs = this.getOtherTargetXs(); + return xs && index < xs.length ? xs[index] : null; + }; + c3_chart_internal_fn.addXs = function (xs) { + var $$ = this; + Object.keys(xs).forEach(function (id) { + $$.config.data_xs[id] = xs[id]; + }); + }; + c3_chart_internal_fn.hasMultipleX = function (xs) { + return this.d3.set(Object.keys(xs).map(function (id) { return xs[id]; })).size() > 1; + }; + c3_chart_internal_fn.isMultipleX = function () { + return notEmpty(this.config.data_xs) || !this.config.data_xSort || this.hasType('scatter'); + }; + c3_chart_internal_fn.addName = function (data) { + var $$ = this, name; + if (data) { + name = $$.config.data_names[data.id]; + data.name = name ? name : data.id; + } + return data; + }; + c3_chart_internal_fn.getValueOnIndex = function (values, index) { + var valueOnIndex = values.filter(function (v) { return v.index === index; }); + return valueOnIndex.length ? valueOnIndex[0] : null; + }; + c3_chart_internal_fn.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; + }); + }; + c3_chart_internal_fn.updateTargetXs = function (targets, xs) { + var $$ = this; + targets.forEach(function (t) { + if (xs[t.id]) { + $$.updateTargetX([t], xs[t.id]); + } + }); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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}; + }) + }; + }; + c3_chart_internal_fn.updateXs = function () { + var $$ = this; + if ($$.data.targets.length) { + $$.xs = []; + $$.data.targets[0].values.forEach(function (v) { + $$.xs[v.index] = v.x; + }); + } + }; + c3_chart_internal_fn.getPrevX = function (i) { + var x = this.xs[i - 1]; + return typeof x !== 'undefined' ? x : null; + }; + c3_chart_internal_fn.getNextX = function (i) { + var x = this.xs[i + 1]; + return typeof x !== 'undefined' ? x : null; + }; + c3_chart_internal_fn.getMaxDataCount = function () { + var $$ = this; + return $$.d3.max($$.data.targets, function (t) { return t.values.length; }); + }; + c3_chart_internal_fn.getMaxDataCountTarget = function (targets) { + var length = targets.length, max = 0, maxTarget; + if (length > 1) { + targets.forEach(function (t) { + if (t.values.length > max) { + maxTarget = t; + max = t.values.length; + } + }); + } else { + maxTarget = length ? targets[0] : null; + } + return maxTarget; + }; + c3_chart_internal_fn.getEdgeX = function (targets) { + var $$ = this; + return !targets.length ? [0, 0] : [ + $$.d3.min(targets, function (t) { return t.values[0].x; }), + $$.d3.max(targets, function (t) { return t.values[t.values.length - 1].x; }) + ]; + }; + c3_chart_internal_fn.mapToIds = function (targets) { + return targets.map(function (d) { return d.id; }); + }; + c3_chart_internal_fn.mapToTargetIds = function (ids) { + var $$ = this; + return ids ? (isString(ids) ? [ids] : ids) : $$.mapToIds($$.data.targets); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.isTargetToShow = function (targetId) { + return this.hiddenTargetIds.indexOf(targetId) < 0; + }; + c3_chart_internal_fn.isLegendToShow = function (targetId) { + return this.hiddenLegendIds.indexOf(targetId) < 0; + }; + c3_chart_internal_fn.filterTargetsToShow = function (targets) { + var $$ = this; + return targets.filter(function (t) { return $$.isTargetToShow(t.id); }); + }; + c3_chart_internal_fn.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(); + return $$.isTimeSeries() ? xs.map(function (x) { return new Date(+x); }) : xs.map(function (x) { return +x; }); + }; + c3_chart_internal_fn.addHiddenTargetIds = function (targetIds) { + this.hiddenTargetIds = this.hiddenTargetIds.concat(targetIds); + }; + c3_chart_internal_fn.removeHiddenTargetIds = function (targetIds) { + this.hiddenTargetIds = this.hiddenTargetIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); + }; + c3_chart_internal_fn.addHiddenLegendIds = function (targetIds) { + this.hiddenLegendIds = this.hiddenLegendIds.concat(targetIds); + }; + c3_chart_internal_fn.removeHiddenLegendIds = function (targetIds) { + this.hiddenLegendIds = this.hiddenLegendIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.hasNegativeValueInTargets = function (targets) { + return this.checkValueInTargets(targets, function (v) { return v < 0; }); + }; + c3_chart_internal_fn.hasPositiveValueInTargets = function (targets) { + return this.checkValueInTargets(targets, function (v) { return v > 0; }); + }; + c3_chart_internal_fn.isOrderDesc = function () { + var config = this.config; + return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'desc'; + }; + c3_chart_internal_fn.isOrderAsc = function () { + var config = this.config; + return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'asc'; + }; + c3_chart_internal_fn.orderTargets = function (targets) { + var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc(); + if (orderAsc || orderDesc) { + targets.sort(function (t1, t2) { + var reducer = function (p, c) { return p + Math.abs(c.value); }; + 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)) { + targets.sort(config.data_order); + } // TODO: accept name array for order + return targets; + }; + c3_chart_internal_fn.filterByX = function (targets, x) { + return this.d3.merge(targets.map(function (t) { return t.values; })).filter(function (v) { return v.x - x === 0; }); + }; + c3_chart_internal_fn.filterRemoveNull = function (data) { + return data.filter(function (d) { return isValue(d.value); }); + }; + c3_chart_internal_fn.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]; + }) + }; + }); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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] = this.getBoundingClientRect()[key] * paddingCoef; + }) + .remove(); + return lengths; + }; + c3_chart_internal_fn.isNoneArc = function (d) { + return this.hasTarget(this.data.targets, d.id); + }, + c3_chart_internal_fn.isArc = function (d) { + return 'data' in d && this.hasTarget(this.data.targets, d.data.id); + }; + c3_chart_internal_fn.findSameXOfValues = function (values, index) { + var i, targetX = values[index].x, sames = []; + for (i = index - 1; i >= 0; i--) { + if (targetX !== values[i].x) { break; } + sames.push(values[i]); + } + for (i = index; i < values.length; i++) { + if (targetX !== values[i].x) { break; } + sames.push(values[i]); + } + return sames; + }; + + c3_chart_internal_fn.findClosestFromTargets = function (targets, pos) { + var $$ = this, candidates; + + // map to array of closest points of each target + candidates = targets.map(function (target) { + return $$.findClosest(target.values, pos); + }); + + // decide closest point and return + return $$.findClosest(candidates, pos); + }; + c3_chart_internal_fn.findClosest = function (values, pos) { + var $$ = this, minDist = 100, closest; + + // find mouseovering bar + values.filter(function (v) { return v && $$.isBarType(v.id); }).forEach(function (v) { + var shape = $$.main.select('.' + CLASS.bars + $$.getTargetSelectorSuffix(v.id) + ' .' + CLASS.bar + '-' + v.index).node(); + if (!closest && $$.isWithinBar(shape)) { + closest = v; + } + }); + + // find closest point from non-bar + values.filter(function (v) { return v && !$$.isBarType(v.id); }).forEach(function (v) { + var d = $$.dist(v, pos); + if (d < minDist) { + minDist = d; + closest = v; + } + }); + + return closest; + }; + c3_chart_internal_fn.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.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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; + }; + + c3_chart_internal_fn.convertUrlToData = function (url, mimeType, keys, done) { + var $$ = this, type = mimeType ? mimeType : 'csv'; + $$.d3.xhr(url, function (error, data) { + var d; + if (!data) { + throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')'); + } + if (type === 'json') { + d = $$.convertJsonToData(JSON.parse(data.response), keys); + } else if (type === 'tsv') { + d = $$.convertTsvToData(data.response); + } else { + d = $$.convertCsvToData(data.response); + } + done.call($$, d); + }); + }; + c3_chart_internal_fn.convertXsvToData = function (xsv, parser) { + var rows = parser.parseRows(xsv), d; + if (rows.length === 1) { + d = [{}]; + rows[0].forEach(function (id) { + d[0][id] = null; + }); + } else { + d = parser.parse(xsv); + } + return d; + }; + c3_chart_internal_fn.convertCsvToData = function (csv) { + return this.convertXsvToData(csv, this.d3.csv); + }; + c3_chart_internal_fn.convertTsvToData = function (tsv) { + return this.convertXsvToData(tsv, this.d3.tsv); + }; + c3_chart_internal_fn.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 = isUndefined(o[key]) ? null : o[key]; + 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; + }; + c3_chart_internal_fn.convertRowsToData = function (rows) { + var keys = rows[0], new_row = {}, new_rows = [], i, j; + for (i = 1; i < rows.length; i++) { + new_row = {}; + for (j = 0; j < rows[i].length; j++) { + if (isUndefined(rows[i][j])) { + throw new Error("Source data is missing a component at (" + i + "," + j + ")!"); + } + new_row[keys[j]] = rows[i][j]; + } + new_rows.push(new_row); + } + return new_rows; + }; + c3_chart_internal_fn.convertColumnsToData = function (columns) { + var new_rows = [], i, j, key; + for (i = 0; i < columns.length; i++) { + key = columns[i][0]; + for (j = 1; j < columns[i].length; j++) { + if (isUndefined(new_rows[j - 1])) { + new_rows[j - 1] = {}; + } + if (isUndefined(columns[i][j])) { + throw new Error("Source data is missing a component at (" + i + "," + j + ")!"); + } + new_rows[j - 1][key] = columns[i][j]; + } + } + return new_rows; + }; + c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) { + var $$ = this, config = $$.config, + ids = $$.d3.keys(data[0]).filter($$.isNotX, $$), + xs = $$.d3.keys(data[0]).filter($$.isX, $$), + targets; + + // 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], x = $$.generateTargetX(rawX, id, i); + // use x as categories if custom x and categorized + if ($$.isCustomX() && $$.isCategorized() && index === 0 && rawX) { + if (i === 0) { config.axis_x_categories = []; } + config.axis_x_categories.push(rawX); + } + // 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; + } + return {x: x, value: d[id] !== null && !isNaN(d[id]) ? +d[id] : null, id: convertedId}; + }).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; + }); + }); + + // 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; + }; + + c3_chart_internal_fn.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(); } + }; + c3_chart_internal_fn.loadFromArgs = function (args) { + var $$ = this; + if (args.data) { + $$.load($$.convertDataToTargets(args.data), args); + } + else if (args.url) { + $$.convertUrlToData(args.url, args.mimeType, 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); + } + }; + c3_chart_internal_fn.unload = function (targetIds, done) { + var $$ = this; + 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; + }); + }); + }; + + c3_chart_internal_fn.categoryName = function (i) { + var config = this.config; + return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i; + }; + + c3_chart_internal_fn.initEventRect = function () { + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.eventRects) + .style('fill-opacity', 0); + }; + c3_chart_internal_fn.redrawEventRect = function () { + var $$ = this, config = $$.config, + eventRectUpdate, maxDataCountTarget, + isMultipleX = $$.isMultipleX(); + + // rects for mouseover + var eventRects = $$.main.select('.' + CLASS.eventRects) + .style('cursor', config.zoom_enabled ? config.axis_rotated ? 'ns-resize' : 'ew-resize' : null) + .classed(CLASS.eventRectsMultiple, isMultipleX) + .classed(CLASS.eventRectsSingle, !isMultipleX); + + // clear old rects + eventRects.selectAll('.' + CLASS.eventRect).remove(); + + // open as public variable + $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); + + if (isMultipleX) { + eventRectUpdate = $$.eventRect.data([0]); + // enter : only one rect will be added + $$.generateEventRectsForMultipleXs(eventRectUpdate.enter()); + // update + $$.updateEventRect(eventRectUpdate); + // exit : not needed because always only one rect exists + } + else { + // Set data and update $$.eventRect + maxDataCountTarget = $$.getMaxDataCountTarget($$.data.targets); + eventRects.datum(maxDataCountTarget ? maxDataCountTarget.values : []); + $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); + eventRectUpdate = $$.eventRect.data(function (d) { return d; }); + // enter + $$.generateEventRectsForSingleX(eventRectUpdate.enter()); + // update + $$.updateEventRect(eventRectUpdate); + // exit + eventRectUpdate.exit().remove(); + } + }; + c3_chart_internal_fn.updateEventRect = function (eventRectUpdate) { + var $$ = this, config = $$.config, + x, y, w, h, rectW, rectX; + + // set update selection if null + eventRectUpdate = eventRectUpdate || $$.eventRect.data(function (d) { return d; }); + + if ($$.isMultipleX()) { + // TODO: rotated not supported yet + x = 0; + y = 0; + w = $$.width; + h = $$.height; + } + else { + if (($$.isCustomX() || $$.isTimeSeries()) && !$$.isCategorized()) { + + // update index for x that is used by prevX and nextX + $$.updateXs(); + + rectW = function (d) { + var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index); + + // if there this is a single data point make the eventRect full width (or height) + if (prevX === null && nextX === null) { + return config.axis_rotated ? $$.height : $$.width; + } + + if (prevX === null) { prevX = $$.x.domain()[0]; } + if (nextX === null) { nextX = $$.x.domain()[1]; } + + return Math.max(0, ($$.x(nextX) - $$.x(prevX)) / 2); + }; + rectX = function (d) { + var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index), + thisX = $$.data.xs[d.id][d.index]; + + // if there this is a single data point position the eventRect at 0 + if (prevX === null && nextX === null) { + return 0; + } + + if (prevX === null) { prevX = $$.x.domain()[0]; } + + return ($$.x(thisX) + $$.x(prevX)) / 2; + }; + } else { + rectW = $$.getEventRectWidth(); + rectX = function (d) { + return $$.x(d.x) - (rectW / 2); + }; + } + x = config.axis_rotated ? 0 : rectX; + y = config.axis_rotated ? rectX : 0; + w = config.axis_rotated ? $$.width : rectW; + h = config.axis_rotated ? rectW : $$.height; + } + + eventRectUpdate + .attr('class', $$.classEvent.bind($$)) + .attr("x", x) + .attr("y", y) + .attr("width", w) + .attr("height", h); + }; + c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { + var $$ = this, d3 = $$.d3, config = $$.config; + eventRectEnter.append("rect") + .attr("class", $$.classEvent.bind($$)) + .style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null) + .on('mouseover', function (d) { + var index = d.index; + + if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing + if ($$.hasArcType()) { return; } + + // Expand shapes for selection + if (config.point_focus_expand_enabled) { $$.expandCircles(index, null, true); } + $$.expandBars(index, null, true); + + // Call event handler + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { + config.data_onmouseover.call($$.api, d); + }); + }) + .on('mouseout', function (d) { + var index = d.index; + if (!$$.config) { return; } // chart is destroyed + if ($$.hasArcType()) { return; } + $$.hideXGridFocus(); + $$.hideTooltip(); + // Undo expanded shapes + $$.unexpandCircles(); + $$.unexpandBars(); + // Call event handler + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { + config.data_onmouseout.call($$.api, d); + }); + }) + .on('mousemove', function (d) { + var selectedData, index = d.index, + eventRect = $$.svg.select('.' + CLASS.eventRect + '-' + index); + + if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing + if ($$.hasArcType()) { return; } + + if ($$.isStepType(d) && $$.config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { + index -= 1; + } + + // Show tooltip + selectedData = $$.filterTargetsToShow($$.data.targets).map(function (t) { + return $$.addName($$.getValueOnIndex(t.values, index)); + }); + + if (config.tooltip_grouped) { + $$.showTooltip(selectedData, this); + $$.showXGridFocus(selectedData); + } + + if (config.tooltip_grouped && (!config.data_selection_enabled || config.data_selection_grouped)) { + return; + } + + $$.main.selectAll('.' + CLASS.shape + '-' + index) + .each(function () { + d3.select(this).classed(CLASS.EXPANDED, true); + if (config.data_selection_enabled) { + eventRect.style('cursor', config.data_selection_grouped ? 'pointer' : null); + } + if (!config.tooltip_grouped) { + $$.hideXGridFocus(); + $$.hideTooltip(); + if (!config.data_selection_grouped) { + $$.unexpandCircles(index); + $$.unexpandBars(index); + } + } + }) + .filter(function (d) { + return $$.isWithinShape(this, d); + }) + .each(function (d) { + if (config.data_selection_enabled && (config.data_selection_grouped || config.data_selection_isselectable(d))) { + eventRect.style('cursor', 'pointer'); + } + if (!config.tooltip_grouped) { + $$.showTooltip([d], this); + $$.showXGridFocus([d]); + if (config.point_focus_expand_enabled) { $$.expandCircles(index, d.id, true); } + $$.expandBars(index, d.id, true); + } + }); + }) + .on('click', function (d) { + var index = d.index; + if ($$.hasArcType() || !$$.toggleShape) { return; } + if ($$.cancelClick) { + $$.cancelClick = false; + return; + } + if ($$.isStepType(d) && config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { + index -= 1; + } + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { + if (config.data_selection_grouped || $$.isWithinShape(this, d)) { + $$.toggleShape(this, d, index); + $$.config.data_onclick.call($$.api, d, this); + } + }); + }) + .call( + config.data_selection_draggable && $$.drag ? ( + d3.behavior.drag().origin(Object) + .on('drag', function () { $$.drag(d3.mouse(this)); }) + .on('dragstart', function () { $$.dragstart(d3.mouse(this)); }) + .on('dragend', function () { $$.dragend(); }) + ) : function () {} + ); + }; + + c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) { + var $$ = this, d3 = $$.d3, config = $$.config; + + function mouseout() { + $$.svg.select('.' + CLASS.eventRect).style('cursor', null); + $$.hideXGridFocus(); + $$.hideTooltip(); + $$.unexpandCircles(); + $$.unexpandBars(); + } + + eventRectEnter.append('rect') + .attr('x', 0) + .attr('y', 0) + .attr('width', $$.width) + .attr('height', $$.height) + .attr('class', CLASS.eventRect) + .on('mouseout', function () { + if (!$$.config) { return; } // chart is destroyed + if ($$.hasArcType()) { return; } + mouseout(); + }) + .on('mousemove', function () { + var targetsToShow = $$.filterTargetsToShow($$.data.targets); + var mouse, closest, sameXData, selectedData; + + if ($$.dragging) { return; } // do nothing when dragging + if ($$.hasArcType(targetsToShow)) { return; } + + mouse = d3.mouse(this); + closest = $$.findClosestFromTargets(targetsToShow, mouse); + + if ($$.mouseover && (!closest || closest.id !== $$.mouseover.id)) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + + if (! closest) { + mouseout(); + return; + } + + if ($$.isScatterType(closest) || !config.tooltip_grouped) { + sameXData = [closest]; + } else { + sameXData = $$.filterByX(targetsToShow, closest.x); + } + + // show tooltip when cursor is close to some point + selectedData = sameXData.map(function (d) { + return $$.addName(d); + }); + $$.showTooltip(selectedData, this); + + // expand points + if (config.point_focus_expand_enabled) { + $$.expandCircles(closest.index, closest.id, true); + } + $$.expandBars(closest.index, closest.id, true); + + // Show xgrid focus line + $$.showXGridFocus(selectedData); + + // Show cursor as pointer if point is close to mouse position + if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < 100) { + $$.svg.select('.' + CLASS.eventRect).style('cursor', 'pointer'); + if (!$$.mouseover) { + config.data_onmouseover.call($$.api, closest); + $$.mouseover = closest; + } + } + }) + .on('click', function () { + var targetsToShow = $$.filterTargetsToShow($$.data.targets); + var mouse, closest; + + if ($$.hasArcType(targetsToShow)) { return; } + + mouse = d3.mouse(this); + closest = $$.findClosestFromTargets(targetsToShow, mouse); + + if (! closest) { return; } + + // select if selection enabled + if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < 100) { + $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll('.' + CLASS.shape + '-' + closest.index).each(function () { + if (config.data_selection_grouped || $$.isWithinShape(this, closest)) { + $$.toggleShape(this, closest, closest.index); + $$.config.data_onclick.call($$.api, closest, this); + } + }); + } + }) + .call( + config.data_selection_draggable && $$.drag ? ( + d3.behavior.drag().origin(Object) + .on('drag', function () { $$.drag(d3.mouse(this)); }) + .on('dragstart', function () { $$.dragstart(d3.mouse(this)); }) + .on('dragend', function () { $$.dragend(); }) + ) : function () {} + ); + }; + c3_chart_internal_fn.dispatchEvent = function (type, index, mouse) { + var $$ = this, + selector = '.' + CLASS.eventRect + (!$$.isMultipleX() ? '-' + index : ''), + 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); + }; + + c3_chart_internal_fn.getCurrentWidth = function () { + var $$ = this, config = $$.config; + return config.size_width ? config.size_width : $$.getParentWidth(); + }; + c3_chart_internal_fn.getCurrentHeight = function () { + var $$ = this, config = $$.config, + h = config.size_height ? config.size_height : $$.getParentHeight(); + return h > 0 ? h : 320 / ($$.hasType('gauge') ? 2 : 1); + }; + c3_chart_internal_fn.getCurrentPaddingTop = function () { + var config = this.config; + return isValue(config.padding_top) ? config.padding_top : 0; + }; + c3_chart_internal_fn.getCurrentPaddingBottom = function () { + var config = this.config; + return isValue(config.padding_bottom) ? config.padding_bottom : 0; + }; + c3_chart_internal_fn.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 ? 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)); + } + }; + c3_chart_internal_fn.getCurrentPaddingRight = function () { + var $$ = this, config = $$.config, + defaultPadding = 10, legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0; + if (isValue(config.padding_right)) { + return config.padding_right + 1; // 1 is needed not to hide tick line + } else if (config.axis_rotated) { + return defaultPadding + legendWidthOnRight; + } else if (!config.axis_y2_show || config.axis_y2_inner) { // && !config.axis_rotated + return 2 + legendWidthOnRight + ($$.axis.getY2AxisLabelPosition().isOuter ? 20 : 0); + } else { + return ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight; + } + }; + + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.getParentWidth = function () { + return this.getParentRectValue('width'); + }; + c3_chart_internal_fn.getParentHeight = function () { + var h = this.selectChart.style('height'); + return h.indexOf('px') > 0 ? +h.replace('px', '') : 0; + }; + + + c3_chart_internal_fn.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; + }; + + + c3_chart_internal_fn.getAxisWidthByAxisId = function (id, withoutRecompute) { + var $$ = this, position = $$.axis.getLabelPositionById(id); + return $$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40); + }; + c3_chart_internal_fn.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 - config.axis_x_tick_rotate) / 180); + } + return h + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + (axisId === 'y2' ? -10 : 0); + }; + + c3_chart_internal_fn.getEventRectWidth = function () { + return Math.max(0, this.xAxis.tickInterval()); + }; + + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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; + }; + }; + c3_chart_internal_fn.getShapeY = function (isSub) { + var $$ = this; + return function (d) { + var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id); + return scale(d.value); + }; + }; + c3_chart_internal_fn.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 values = $$.isStepType(d) ? $$.convertValuesToStep(t.values) : t.values; + if (t.id === d.id || indices[t.id] !== indices[d.id]) { return; } + if (targetIds.indexOf(t.id) < targetIds.indexOf(d.id)) { + if (values[i].value * d.value >= 0) { + offset += scale(values[i].value) - y0; + } + } + }); + return offset; + }; + }; + c3_chart_internal_fn.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(that) : true; + } + return isWithin; + }; + + + c3_chart_internal_fn.getInterpolate = function (d) { + var $$ = this; + return $$.isSplineType(d) ? "cardinal" : $$.isStepType(d) ? $$.config.line_step_type : "linear"; + }; + + c3_chart_internal_fn.initLine = function () { + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartLines); + }; + c3_chart_internal_fn.updateTargetsForLine = function (targets) { + var $$ = this, config = $$.config, + mainLineUpdate, mainLineEnter, + classChartLine = $$.classChartLine.bind($$), + classLines = $$.classLines.bind($$), + classAreas = $$.classAreas.bind($$), + classCircles = $$.classCircles.bind($$), + classFocus = $$.classFocus.bind($$); + mainLineUpdate = $$.main.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) + .data(targets) + .attr('class', function (d) { return classChartLine(d) + classFocus(d); }); + mainLineEnter = mainLineUpdate.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(); + }; + c3_chart_internal_fn.updateLine = function (durationForExit) { + var $$ = this; + $$.mainLine = $$.main.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + $$.mainLine.enter().append('path') + .attr('class', $$.classLine.bind($$)) + .style("stroke", $$.color); + $$.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) + .remove(); + }; + c3_chart_internal_fn.redrawLine = function (drawLine, withTransition) { + return [ + (withTransition ? this.mainLine.transition() : this.mainLine) + .attr("d", drawLine) + .style("stroke", this.color) + .style("opacity", 1) + ]; + }; + c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) { + var $$ = this, config = $$.config, + line = $$.d3.svg.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 ? $$.x : $$.subX, 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.interpolate($$.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"; + }; + }; + c3_chart_internal_fn.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 + ]; + }; + }; + + + c3_chart_internal_fn.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; + }; + + + c3_chart_internal_fn.updateArea = function (durationForExit) { + var $$ = this, d3 = $$.d3; + $$.mainArea = $$.main.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + $$.mainArea.enter().append('path') + .attr("class", $$.classArea.bind($$)) + .style("fill", $$.color) + .style("opacity", function () { $$.orgAreaOpacity = +d3.select(this).style('opacity'); return 0; }); + $$.mainArea + .style("opacity", $$.orgAreaOpacity); + $$.mainArea.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); + }; + c3_chart_internal_fn.redrawArea = function (drawArea, withTransition) { + return [ + (withTransition ? this.mainArea.transition() : this.mainArea) + .attr("d", drawArea) + .style("fill", this.color) + .style("opacity", this.orgAreaOpacity) + ]; + }; + c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) { + var $$ = this, config = $$.config, area = $$.d3.svg.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(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.interpolate($$.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"; + }; + }; + c3_chart_internal_fn.getAreaBaseValue = function () { + return 0; + }; + c3_chart_internal_fn.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 + ]; + }; + }; + + + c3_chart_internal_fn.updateCircle = function () { + var $$ = this; + $$.mainCircle = $$.main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle) + .data($$.lineOrScatterData.bind($$)); + $$.mainCircle.enter().append("circle") + .attr("class", $$.classCircle.bind($$)) + .attr("r", $$.pointR.bind($$)) + .style("fill", $$.color); + $$.mainCircle + .style("opacity", $$.initialOpacityForCircle.bind($$)); + $$.mainCircle.exit().remove(); + }; + c3_chart_internal_fn.redrawCircle = function (cx, cy, withTransition) { + var selectedCircles = this.main.selectAll('.' + CLASS.selectedCircle); + return [ + (withTransition ? this.mainCircle.transition() : this.mainCircle) + .style('opacity', this.opacityForCircle.bind(this)) + .style("fill", this.color) + .attr("cx", cx) + .attr("cy", cy), + (withTransition ? selectedCircles.transition() : selectedCircles) + .attr("cx", cx) + .attr("cy", cy) + ]; + }; + c3_chart_internal_fn.circleX = function (d) { + return d.x || d.x === 0 ? this.x(d.x) : null; + }; + c3_chart_internal_fn.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); + }; + } + }; + c3_chart_internal_fn.getCircles = function (i, id) { + var $$ = this; + return (id ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')); + }; + c3_chart_internal_fn.expandCircles = function (i, id, reset) { + var $$ = this, + r = $$.pointExpandedR.bind($$); + if (reset) { $$.unexpandCircles(); } + $$.getCircles(i, id) + .classed(CLASS.EXPANDED, true) + .attr('r', r); + }; + c3_chart_internal_fn.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); + }; + c3_chart_internal_fn.pointR = function (d) { + var $$ = this, config = $$.config; + return $$.isStepType(d) ? 0 : (isFunction(config.point_r) ? config.point_r(d) : config.point_r); + }; + c3_chart_internal_fn.pointExpandedR = function (d) { + var $$ = this, config = $$.config; + return config.point_focus_expand_enabled ? (config.point_focus_expand_r ? config.point_focus_expand_r : $$.pointR(d) * 1.75) : $$.pointR(d); + }; + c3_chart_internal_fn.pointSelectR = function (d) { + var $$ = this, config = $$.config; + return config.point_select_r ? config.point_select_r : $$.pointR(d) * 4; + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.isWithinStep = function (that, y) { + return Math.abs(y - this.d3.mouse(that)[1]) < 30; + }; + + c3_chart_internal_fn.initBar = function () { + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartBars); + }; + c3_chart_internal_fn.updateTargetsForBar = function (targets) { + var $$ = this, config = $$.config, + mainBarUpdate, mainBarEnter, + classChartBar = $$.classChartBar.bind($$), + classBars = $$.classBars.bind($$), + classFocus = $$.classFocus.bind($$); + mainBarUpdate = $$.main.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) + .data(targets) + .attr('class', function (d) { return classChartBar(d) + classFocus(d); }); + mainBarEnter = mainBarUpdate.enter().append('g') + .attr('class', classChartBar) + .style('opacity', 0) + .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; }); + + }; + c3_chart_internal_fn.updateBar = function (durationForExit) { + var $$ = this, + barData = $$.barData.bind($$), + classBar = $$.classBar.bind($$), + initialOpacity = $$.initialOpacity.bind($$), + color = function (d) { return $$.color(d.id); }; + $$.mainBar = $$.main.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) + .data(barData); + $$.mainBar.enter().append('path') + .attr("class", classBar) + .style("stroke", color) + .style("fill", color); + $$.mainBar + .style("opacity", initialOpacity); + $$.mainBar.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); + }; + c3_chart_internal_fn.redrawBar = function (drawBar, withTransition) { + return [ + (withTransition ? this.mainBar.transition() : this.mainBar) + .attr('d', drawBar) + .style("fill", this.color) + .style("opacity", 1) + ]; + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.getBars = function (i, id) { + var $$ = this; + return (id ? $$.main.selectAll('.' + CLASS.bars + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')); + }; + c3_chart_internal_fn.expandBars = function (i, id, reset) { + var $$ = this; + if (reset) { $$.unexpandBars(); } + $$.getBars(i, id).classed(CLASS.EXPANDED, true); + }; + c3_chart_internal_fn.unexpandBars = function (i) { + var $$ = this; + $$.getBars(i).classed(CLASS.EXPANDED, false); + }; + c3_chart_internal_fn.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; + }; + }; + c3_chart_internal_fn.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), + 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; } + } + // 4 points that make a bar + return [ + [posX, offset], + [posX, posY - (y0 - offset)], + [posX + barW, posY - (y0 - offset)], + [posX + barW, offset] + ]; + }; + }; + c3_chart_internal_fn.isWithinBar = function (that) { + var mouse = this.d3.mouse(that), box = that.getBoundingClientRect(), + seg0 = that.pathSegList.getItem(0), seg1 = that.pathSegList.getItem(1), + x = Math.min(seg0.x, seg1.x), y = Math.min(seg0.y, seg1.y), + w = box.width, h = box.height, offset = 2, + sx = x - offset, ex = x + w + offset, sy = y + h + offset, ey = y - offset; + return sx < mouse[0] && mouse[0] < ex && ey < mouse[1] && mouse[1] < sy; + }; + + c3_chart_internal_fn.initText = function () { + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartTexts); + $$.mainText = $$.d3.selectAll([]); + }; + c3_chart_internal_fn.updateTargetsForText = function (targets) { + var $$ = this, mainTextUpdate, mainTextEnter, + classChartText = $$.classChartText.bind($$), + classTexts = $$.classTexts.bind($$), + classFocus = $$.classFocus.bind($$); + mainTextUpdate = $$.main.select('.' + CLASS.chartTexts).selectAll('.' + CLASS.chartText) + .data(targets) + .attr('class', function (d) { return classChartText(d) + classFocus(d); }); + mainTextEnter = mainTextUpdate.enter().append('g') + .attr('class', classChartText) + .style('opacity', 0) + .style("pointer-events", "none"); + mainTextEnter.append('g') + .attr('class', classTexts); + }; + c3_chart_internal_fn.updateText = function (durationForExit) { + var $$ = this, config = $$.config, + barOrLineData = $$.barOrLineData.bind($$), + classText = $$.classText.bind($$); + $$.mainText = $$.main.selectAll('.' + CLASS.texts).selectAll('.' + CLASS.text) + .data(barOrLineData); + $$.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') + .style("fill", function (d) { return $$.color(d); }) + .style("fill-opacity", 0); + $$.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(); + }; + c3_chart_internal_fn.redrawText = function (xForText, yForText, forFlow, withTransition) { + return [ + (withTransition ? this.mainText.transition() : this.mainText) + .attr('x', xForText) + .attr('y', yForText) + .style("fill", this.color) + .style("fill-opacity", forFlow ? 0 : this.opacityForText.bind(this)) + ]; + }; + c3_chart_internal_fn.getTextRect = function (text, cls) { + 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), + rect; + svg.selectAll('.dummy') + .data([text]) + .enter().append('text') + .classed(cls ? cls : "", true) + .text(text) + .each(function () { rect = this.getBoundingClientRect(); }); + dummy.remove(); + return rect; + }; + c3_chart_internal_fn.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); + }; + }; + c3_chart_internal_fn.getXForText = function (points, d, textElement) { + var $$ = this, + box = textElement.getBoundingClientRect(), 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; + }; + c3_chart_internal_fn.getYForText = function (points, d, textElement) { + var $$ = this, + box = textElement.getBoundingClientRect(), + 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) { + 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; + }; + + c3_chart_internal_fn.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; + } + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.hasArcType = function (targets) { + return this.hasType('pie', targets) || this.hasType('donut', targets) || this.hasType('gauge', targets); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.isStepType = function (d) { + var id = isString(d) ? d : d.id; + return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0; + }; + c3_chart_internal_fn.isSplineType = function (d) { + var id = isString(d) ? d : d.id; + return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0; + }; + c3_chart_internal_fn.isAreaType = function (d) { + var id = isString(d) ? d : d.id; + return ['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= 0; + }; + c3_chart_internal_fn.isBarType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'bar'; + }; + c3_chart_internal_fn.isScatterType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'scatter'; + }; + c3_chart_internal_fn.isPieType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'pie'; + }; + c3_chart_internal_fn.isGaugeType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'gauge'; + }; + c3_chart_internal_fn.isDonutType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'donut'; + }; + c3_chart_internal_fn.isArcType = function (d) { + return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d); + }; + c3_chart_internal_fn.lineData = function (d) { + return this.isLineType(d) ? [d] : []; + }; + c3_chart_internal_fn.arcData = function (d) { + return this.isArcType(d.data) ? [d] : []; + }; + /* not used + function scatterData(d) { + return isScatterType(d) ? d.values : []; + } + */ + c3_chart_internal_fn.barData = function (d) { + return this.isBarType(d) ? d.values : []; + }; + c3_chart_internal_fn.lineOrScatterData = function (d) { + return this.isLineType(d) || this.isScatterType(d) ? d.values : []; + }; + c3_chart_internal_fn.barOrLineData = function (d) { + return this.isBarType(d) || this.isLineType(d) ? d.values : []; + }; + + c3_chart_internal_fn.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(); } + }; + c3_chart_internal_fn.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([]); + }; + c3_chart_internal_fn.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 + }; + + $$.xgrid = $$.main.select('.' + CLASS.xgrids).selectAll('.' + CLASS.xgrid) + .data(xgridData); + $$.xgrid.enter().append('line').attr("class", CLASS.xgrid); + if (!withoutUpdate) { + $$.xgrid.attr($$.xgridAttr) + .style("opacity", function () { return +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1') === (config.axis_rotated ? $$.height : 0) ? 0 : 1; }); + } + $$.xgrid.exit().remove(); + }; + + c3_chart_internal_fn.updateYGrid = function () { + var $$ = this, config = $$.config, + gridValues = $$.yAxis.tickValues() || $$.y.ticks(config.grid_y_ticks); + $$.ygrid = $$.main.select('.' + CLASS.ygrids).selectAll('.' + CLASS.ygrid) + .data(gridValues); + $$.ygrid.enter().append('line') + .attr('class', CLASS.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'); + }; + + c3_chart_internal_fn.gridTextAnchor = function (d) { + return d.position ? d.position : "end"; + }; + c3_chart_internal_fn.gridTextDx = function (d) { + return d.position === 'start' ? 4 : d.position === 'middle' ? 0 : -4; + }; + c3_chart_internal_fn.xGridTextX = function (d) { + return d.position === 'start' ? -this.height : d.position === 'middle' ? -this.height / 2 : 0; + }; + c3_chart_internal_fn.yGridTextX = function (d) { + return d.position === 'start' ? 0 : d.position === 'middle' ? this.width / 2 : this.width; + }; + c3_chart_internal_fn.updateGrid = function (duration) { + var $$ = this, main = $$.main, config = $$.config, + xgridLine, ygridLine, yv; + + // hide if arc type + $$.grid.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + + main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); + if (config.grid_x_show) { + $$.updateXGrid(); + } + $$.xgridLines = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine) + .data(config.grid_x_lines); + // enter + xgridLine = $$.xgridLines.enter().append('g') + .attr("class", function (d) { return CLASS.xgridLine + (d['class'] ? ' ' + d['class'] : ''); }); + xgridLine.append('line') + .style("opacity", 0); + xgridLine.append('text') + .attr("text-anchor", $$.gridTextAnchor) + .attr("transform", config.axis_rotated ? "" : "rotate(-90)") + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style("opacity", 0); + // udpate + // done in d3.transition() of the end of this function + // exit + $$.xgridLines.exit().transition().duration(duration) + .style("opacity", 0) + .remove(); + + // Y-Grid + if (config.grid_y_show) { + $$.updateYGrid(); + } + $$.ygridLines = main.select('.' + CLASS.ygridLines).selectAll('.' + CLASS.ygridLine) + .data(config.grid_y_lines); + // enter + ygridLine = $$.ygridLines.enter().append('g') + .attr("class", function (d) { return CLASS.ygridLine + (d['class'] ? ' ' + d['class'] : ''); }); + ygridLine.append('line') + .style("opacity", 0); + ygridLine.append('text') + .attr("text-anchor", $$.gridTextAnchor) + .attr("transform", config.axis_rotated ? "rotate(-90)" : "") + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style("opacity", 0); + // update + yv = $$.yv.bind($$); + $$.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 + $$.ygridLines.exit().transition().duration(duration) + .style("opacity", 0) + .remove(); + }; + c3_chart_internal_fn.redrawGrid = function (withTransition) { + var $$ = this, config = $$.config, xv = $$.xv.bind($$), + lines = $$.xgridLines.select('line'), + texts = $$.xgridLines.select('text'); + return [ + (withTransition ? lines.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() : texts) + .attr("x", config.axis_rotated ? $$.yGridTextX.bind($$) : $$.xGridTextX.bind($$)) + .attr("y", xv) + .text(function (d) { return d.text; }) + .style("opacity", 1) + ]; + }; + c3_chart_internal_fn.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 scatter plot exists + if ($$.hasType('scatter') || $$.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'); + }; + c3_chart_internal_fn.hideXGridFocus = function () { + this.main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); + }; + c3_chart_internal_fn.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); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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; }; + }; + c3_chart_internal_fn.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); + } + }; + + c3_chart_internal_fn.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"); + } + }; + c3_chart_internal_fn.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; }, + valueFormat = config.tooltip_format_value || defaultValueFormat, + text, i, title, value, name, bgcolor; + for (i = 0; i < d.length; i++) { + if (! (d[i] && (d[i].value || d[i].value === 0))) { continue; } + + if (! text) { + title = titleFormat ? titleFormat(d[i].x) : d[i].x; + text = "<table class='" + CLASS.tooltip + "'>" + (title || title === 0 ? "<tr><th colspan='2'>" + title + "</th></tr>" : ""); + } + + value = valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index); + if (value !== undefined) { + name = nameFormat(d[i].name, d[i].ratio, d[i].id, d[i].index); + bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); + + text += "<tr class='" + CLASS.tooltipName + "-" + d[i].id + "'>"; + text += "<td class='name'><span style='background-color:" + bgcolor + "'></span>" + name + "</td>"; + text += "<td class='value'>" + value + "</td>"; + text += "</tr>"; + } + } + return text + "</table>"; + }; + c3_chart_internal_fn.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 = ($$.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 tooletip width + tooltipLeft -= tooltipRight - chartRight + 20; + } + if (tooltipTop + tHeight > $$.currentHeight) { + tooltipTop -= tHeight + 30; + } + } + if (tooltipTop < 0) { + tooltipTop = 0; + } + return {top: tooltipTop, left: tooltipLeft}; + }; + c3_chart_internal_fn.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 || c3_chart_internal_fn.tooltipPosition; + if (dataToShow.length === 0 || !config.tooltip_show) { + 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'); + }; + c3_chart_internal_fn.hideTooltip = function () { + this.tooltip.style("display", "none"); + }; + + c3_chart_internal_fn.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 upated by this, so transform not needed in updateLegend() + $$.updateLegendWithDefaults(); + }; + c3_chart_internal_fn.updateLegendWithDefaults = function () { + var $$ = this; + $$.updateLegend($$.mapToIds($$.data.targets), {withTransform: false, withTransitionForTransform: false, withTransition: false}); + }; + c3_chart_internal_fn.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 + }; + }; + c3_chart_internal_fn.transformLegend = function (withTransition) { + var $$ = this; + (withTransition ? $$.legend.transition() : $$.legend).attr("transform", $$.getTranslate('legend')); + }; + c3_chart_internal_fn.updateLegendStep = function (step) { + this.legendStep = step; + }; + c3_chart_internal_fn.updateLegendItemWidth = function (w) { + this.legendItemWidth = w; + }; + c3_chart_internal_fn.updateLegendItemHeight = function (h) { + this.legendItemHeight = h; + }; + c3_chart_internal_fn.getLegendWidth = function () { + var $$ = this; + return $$.config.legend_show ? $$.isLegendRight || $$.isLegendInset ? $$.legendItemWidth * ($$.legendStep + 1) : $$.currentWidth : 0; + }; + c3_chart_internal_fn.getLegendHeight = function () { + var $$ = this, h = 0; + if ($$.config.legend_show) { + if ($$.isLegendRight) { + h = $$.currentHeight; + } else { + h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1); + } + } + return h; + }; + c3_chart_internal_fn.opacityForLegend = function (legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 1; + }; + c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 0.3; + }; + c3_chart_internal_fn.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)); + }); + }; + c3_chart_internal_fn.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)); }); + }; + c3_chart_internal_fn.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)); }); + }; + c3_chart_internal_fn.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'); + }; + c3_chart_internal_fn.clearLegendItemTextBoxCache = function () { + this.legendItemTextBox = {}; + }; + c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { + var $$ = this, config = $$.config; + var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect; + var paddingTop = 4, paddingRight = 10, maxWidth = 0, maxHeight = 0, posMin = 10, tileWidth = 15; + var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; + var withTransition, withTransitionForTransform; + var texts, rects, tiles, background; + + 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); + } + 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), + 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) + 14; }; + 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; }; + + // 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', 'pointer') + .on('click', 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(); + } + } + }) + .on('mouseover', function (id) { + $$.d3.select(this).classed(CLASS.legendItemFocused, true); + if (!$$.transiting && $$.isTargetToShow(id)) { + $$.api.focus(id); + } + if (config.legend_item_onmouseover) { + config.legend_item_onmouseover.call($$, id); + } + }) + .on('mouseout', function (id) { + $$.d3.select(this).classed(CLASS.legendItemFocused, false); + $$.api.revert(); + if (config.legend_item_onmouseout) { + config.legend_item_onmouseout.call($$, id); + } + }); + 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('rect') + .attr("class", CLASS.legendItemTile) + .style("pointer-events", "none") + .style('fill', $$.color) + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegend) + .attr('width', 10) + .attr('height', 10); + + // 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('rect.' + CLASS.legendItemTile) + .data(targetIds); + (withTransition ? tiles.transition() : tiles) + .style('fill', $$.color) + .attr('x', xForLegend) + .attr('y', yForLegend); + + 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; + }; + + function Axis(owner) { + API.call(this, owner); + } + + inherit(API, Axis); + + 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", $$.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, + tickWidth: config.axis_x_tick_width, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_x_tick_rotate, + withoutTransition: withoutTransition, + }, + axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient); + + if ($$.isTimeSeries() && tickValues) { + 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(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition) { + var axisParams = { + withOuterTick: withOuterTick, + withoutTransition: withoutTransition, + }, + $$ = this.owner, + d3 = $$.d3, + config = $$.config, + axis = c3_axis(d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat); + if ($$.isTimeSeriesY()) { + axis.ticks(d3.time[config.axis_y_tick_time_value], 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() { + var $$ = this.owner, config = $$.config, + format = $$.isTimeSeries() ? $$.defaultAxisTimeFormat : $$.isCategorized() ? $$.categoryName : function (v) { return v < 0 ? v.toFixed(0) : 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 - this.getMaxTickWidth('x'); + } else { + return position.isInner ? "-0.5em" : config.axis_x_height ? config.axis_x_height - 10 : "3em"; + } + }; + 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, config = $$.config, + 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(scale, $$.yOrient, config.axis_y_tick_format, $$.yAxisTickValues, false, true); + } else if (id === 'y2') { + scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); + axis = this.getYAxis(scale, $$.y2Orient, config.axis_y2_tick_format, $$.y2AxisTickValues, false, 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 = this.getBoundingClientRect(); + 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) { + if (!isValue(padding[key])) { + return defaultValue; + } + if (padding.unit === 'ratio') { + return padding[key] * domainLength; + } + // assume padding is pixels if unit is not specified + return this.convertPixelsToAxisPadding(padding[key], 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(transitions, isHidden) { + var $$ = this.owner; + $$.axes.x.style("opacity", isHidden ? 0 : 1); + $$.axes.y.style("opacity", isHidden ? 0 : 1); + $$.axes.y2.style("opacity", isHidden ? 0 : 1); + $$.axes.subx.style("opacity", isHidden ? 0 : 1); + transitions.axisX.call($$.xAxis); + transitions.axisY.call($$.yAxis); + transitions.axisY2.call($$.y2Axis); + transitions.axisSubX.call($$.subXAxis); + }; + + c3_chart_internal_fn.getClipPath = function (id) { + var isIE9 = window.navigator.appVersion.toLowerCase().indexOf("msie 9.") >= 0; + return "url(" + (isIE9 ? "" : document.URL.split('#')[0]) + "#" + id + ")"; + }; + c3_chart_internal_fn.appendClip = function (parent, id) { + return parent.append("clipPath").attr("id", id).append("rect"); + }; + c3_chart_internal_fn.getAxisClipX = function (forHorizontal) { + // axis line width + padding for left + var left = Math.max(30, this.margin.left); + return forHorizontal ? -(1 + left) : -(left - 1); + }; + c3_chart_internal_fn.getAxisClipY = function (forHorizontal) { + return forHorizontal ? -20 : -this.margin.top; + }; + c3_chart_internal_fn.getXAxisClipX = function () { + var $$ = this; + return $$.getAxisClipX(!$$.config.axis_rotated); + }; + c3_chart_internal_fn.getXAxisClipY = function () { + var $$ = this; + return $$.getAxisClipY(!$$.config.axis_rotated); + }; + c3_chart_internal_fn.getYAxisClipX = function () { + var $$ = this; + return $$.config.axis_y_inner ? -1 : $$.getAxisClipX($$.config.axis_rotated); + }; + c3_chart_internal_fn.getYAxisClipY = function () { + var $$ = this; + return $$.getAxisClipY($$.config.axis_rotated); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.getXAxisClipWidth = function () { + var $$ = this; + return $$.getAxisClipWidth(!$$.config.axis_rotated); + }; + c3_chart_internal_fn.getXAxisClipHeight = function () { + var $$ = this; + return $$.getAxisClipHeight(!$$.config.axis_rotated); + }; + c3_chart_internal_fn.getYAxisClipWidth = function () { + var $$ = this; + return $$.getAxisClipWidth($$.config.axis_rotated) + ($$.config.axis_y_inner ? 20 : 0); + }; + c3_chart_internal_fn.getYAxisClipHeight = function () { + var $$ = this; + return $$.getAxisClipHeight($$.config.axis_rotated); + }; + + c3_chart_internal_fn.initPie = function () { + var $$ = this, d3 = $$.d3, config = $$.config; + $$.pie = d3.layout.pie().value(function (d) { + return d.values.reduce(function (a, b) { return a + b.value; }, 0); + }); + if (!config.data_order) { + $$.pie.sort(null); + } + }; + + c3_chart_internal_fn.updateRadius = function () { + var $$ = this, config = $$.config, + w = config.gauge_width || config.donut_width; + $$.radiusExpanded = Math.min($$.arcWidth, $$.arcHeight) / 2; + $$.radius = $$.radiusExpanded * 0.95; + $$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6; + $$.innerRadius = $$.hasType('donut') || $$.hasType('gauge') ? $$.radius * $$.innerRadiusRatio : 0; + }; + + c3_chart_internal_fn.updateArc = function () { + var $$ = this; + $$.svgArc = $$.getSvgArc(); + $$.svgArcExpanded = $$.getSvgArcExpanded(); + $$.svgArcExpandedSub = $$.getSvgArcExpanded(0.98); + }; + + c3_chart_internal_fn.updateAngle = function (d) { + var $$ = this, config = $$.config, + found = false, index = 0, + gMin = config.gauge_min, gMax = config.gauge_max, gTic, gValue; + $$.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)) { + gTic = (Math.PI) / (gMax - gMin); + gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : (gMax - gMin); + d.startAngle = -1 * (Math.PI / 2); + d.endAngle = d.startAngle + gTic * gValue; + } + return found ? d : null; + }; + + c3_chart_internal_fn.getSvgArc = function () { + var $$ = this, + arc = $$.d3.svg.arc().outerRadius($$.radius).innerRadius($$.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; + }; + + c3_chart_internal_fn.getSvgArcExpanded = function (rate) { + var $$ = this, + arc = $$.d3.svg.arc().outerRadius($$.radiusExpanded * (rate ? rate : 1)).innerRadius($$.innerRadius); + return function (d) { + var updated = $$.updateAngle(d); + return updated ? arc(updated) : "M 0 0"; + }; + }; + + c3_chart_internal_fn.getArc = function (d, withoutUpdate, force) { + return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0"; + }; + + + c3_chart_internal_fn.transformForArcLabel = function (d) { + var $$ = this, + updated = $$.updateAngle(d), c, x, y, h, ratio, translate = ""; + if (updated && !$$.hasType('gauge')) { + 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); + // TODO: ratio should be an option? + ratio = $$.radius && h ? (36 / $$.radius > 0.375 ? 1.175 - 36 / $$.radius : 0.8) * $$.radius / h : 0; + translate = "translate(" + (x * ratio) + ',' + (y * ratio) + ")"; + } + return translate; + }; + + c3_chart_internal_fn.getArcRatio = function (d) { + var $$ = this, + whole = $$.hasType('gauge') ? Math.PI : (Math.PI * 2); + return d ? (d.endAngle - d.startAngle) / whole : null; + }; + + c3_chart_internal_fn.convertToArcData = function (d) { + return this.addName({ + id: d.data.id, + value: d.value, + ratio: this.getArcRatio(d), + index: d.index + }); + }; + + c3_chart_internal_fn.textForArcLabel = function (d) { + var $$ = this, + updated, value, ratio, id, format; + if (! $$.shouldShowArcLabel()) { return ""; } + updated = $$.updateAngle(d); + value = updated ? updated.value : null; + ratio = $$.getArcRatio(updated); + id = d.data.id; + if (! $$.hasType('gauge') && ! $$.meetsArcLabelThreshold(ratio)) { return ""; } + format = $$.getArcLabelFormat(); + return format ? format(value, ratio, id) : $$.defaultArcValueFormat(value, ratio); + }; + + c3_chart_internal_fn.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(50) + .attr("d", $$.svgArcExpanded) + .transition().duration(100) + .attr("d", $$.svgArcExpandedSub) + .each(function (d) { + if ($$.isDonutType(d.data)) { + // callback here + } + }); + }); + }; + + c3_chart_internal_fn.unexpandArc = function (targetIds) { + var $$ = this; + + if ($$.transiting) { return; } + + targetIds = $$.mapToTargetIds(targetIds); + + $$.svg.selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)).selectAll('path') + .transition().duration(50) + .attr("d", $$.svgArc); + $$.svg.selectAll('.' + CLASS.arc) + .style("opacity", 1); + }; + + c3_chart_internal_fn.shouldExpand = function (id) { + var $$ = this, config = $$.config; + return ($$.isDonutType(id) && config.donut_expand) || ($$.isGaugeType(id) && config.gauge_expand) || ($$.isPieType(id) && config.pie_expand); + }; + + c3_chart_internal_fn.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; + }; + + c3_chart_internal_fn.meetsArcLabelThreshold = function (ratio) { + var $$ = this, config = $$.config, + threshold = $$.hasType('donut') ? config.donut_label_threshold : config.pie_label_threshold; + return ratio >= threshold; + }; + + c3_chart_internal_fn.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; + }; + + c3_chart_internal_fn.getArcTitle = function () { + var $$ = this; + return $$.hasType('donut') ? $$.config.donut_title : ""; + }; + + c3_chart_internal_fn.updateTargetsForArc = function (targets) { + var $$ = this, main = $$.main, + mainPieUpdate, mainPieEnter, + classChartArc = $$.classChartArc.bind($$), + classArcs = $$.classArcs.bind($$), + classFocus = $$.classFocus.bind($$); + mainPieUpdate = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc) + .data($$.pie(targets)) + .attr("class", function (d) { return classChartArc(d) + classFocus(d.data); }); + mainPieEnter = mainPieUpdate.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(); + }; + + c3_chart_internal_fn.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()); + }; + + c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransform) { + var $$ = this, d3 = $$.d3, config = $$.config, main = $$.main, + mainArc; + mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc) + .data($$.arcData.bind($$)); + mainArc.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; }) + .style("opacity", 0) + .each(function (d) { + if ($$.isGaugeType(d.data)) { + d.startAngle = d.endAngle = -1 * (Math.PI / 2); + } + this._current = d; + }); + mainArc + .attr("transform", function (d) { return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : ""; }) + .style("opacity", function (d) { return d === this._current ? 0 : 1; }) + .on('mouseover', config.interaction_enabled ? function (d) { + var updated, arcData; + if ($$.transiting) { // skip while transiting + return; + } + updated = $$.updateAngle(d); + 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 = $$.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); + 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 = $$.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) { + 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[0].value) : $$.color(d.data.id); + }) // Where gauge reading color would receive customization. + .style("opacity", 1) + .call($$.endall, function () { + $$.transiting = false; + }); + mainArc.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) ? 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') || $$.hasType('gauge') ? 1 : 0); + + if ($$.hasType('gauge')) { + $$.arcs.select('.' + CLASS.chartArcsBackground) + .attr("d", function () { + var d = { + data: [{value: config.gauge_max}], + startAngle: -1 * (Math.PI / 2), + endAngle: Math.PI / 2 + }; + return $$.getArc(d, true, true); + }); + $$.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) / 2)) + "px") + .attr("dy", "1.2em") + .text(config.gauge_label_show ? config.gauge_min : ''); + $$.arcs.select('.' + CLASS.chartArcsGaugeMax) + .attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / 2) + "px") + .attr("dy", "1.2em") + .text(config.gauge_label_show ? config.gauge_max : ''); + } + }; + c3_chart_internal_fn.initGauge = function () { + var arcs = this.arcs; + if (this.hasType('gauge')) { + arcs.append('path') + .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"); + } + }; + c3_chart_internal_fn.getGaugeLabelHeight = function () { + return this.config.gauge_label_show ? 20 : 0; + }; + + c3_chart_internal_fn.initRegion = function () { + var $$ = this; + $$.region = $$.main.append('g') + .attr("clip-path", $$.clipPath) + .attr("class", CLASS.regions); + }; + c3_chart_internal_fn.updateRegion = function (duration) { + var $$ = this, config = $$.config; + + // hide if arc type + $$.region.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + + $$.mainRegion = $$.main.select('.' + CLASS.regions).selectAll('.' + CLASS.region) + .data(config.regions); + $$.mainRegion.enter().append('g') + .attr('class', $$.classRegion.bind($$)) + .append('rect') + .style("fill-opacity", 0); + $$.mainRegion.exit().transition().duration(duration) + .style("opacity", 0) + .remove(); + }; + c3_chart_internal_fn.redrawRegion = function (withTransition) { + var $$ = this, + regions = $$.mainRegion.selectAll('rect'), + x = $$.regionX.bind($$), + y = $$.regionY.bind($$), + w = $$.regionWidth.bind($$), + h = $$.regionHeight.bind($$); + return [ + (withTransition ? regions.transition() : regions) + .attr("x", x) + .attr("y", y) + .attr("width", w) + .attr("height", h) + .style("fill-opacity", function (d) { return isValue(d.opacity) ? d.opacity : 0.1; }) + ]; + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.isRegionOnX = function (d) { + return !d.axis || d.axis === 'x'; + }; + + c3_chart_internal_fn.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.zoom_enabled && ! $$.zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior + 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) + .filter(function (d) { return config.data_selection_isselectable(d); }) + .each(function (d, i) { + 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); + } + }); + }; + + c3_chart_internal_fn.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; + }; + + c3_chart_internal_fn.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; + }; + + c3_chart_internal_fn.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); + }; + c3_chart_internal_fn.unselectPoint = function (target, d, i) { + var $$ = this; + $$.config.data_onunselected(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(); + }; + c3_chart_internal_fn.togglePoint = function (selected, target, d, i) { + selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i); + }; + c3_chart_internal_fn.selectPath = function (target, d) { + var $$ = this; + $$.config.data_onselected.call($$, d, target.node()); + target.transition().duration(100) + .style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); }); + }; + c3_chart_internal_fn.unselectPath = function (target, d) { + var $$ = this; + $$.config.data_onunselected.call($$, d, target.node()); + target.transition().duration(100) + .style("fill", function () { return $$.color(d); }); + }; + c3_chart_internal_fn.togglePath = function (selected, target, d, i) { + selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i); + }; + c3_chart_internal_fn.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; + }; + c3_chart_internal_fn.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); + } + }; + + c3_chart_internal_fn.initBrush = function () { + var $$ = this, d3 = $$.d3; + $$.brush = d3.svg.brush().on("brush", function () { $$.redrawForBrush(); }); + $$.brush.update = function () { + if ($$.context) { $$.context.select('.' + CLASS.brush).call(this); } + return this; + }; + $$.brush.scale = function (scale) { + return $$.config.axis_rotated ? this.y(scale) : this.x(scale); + }; + }; + c3_chart_internal_fn.initSubchart = function () { + var $$ = this, config = $$.config, + context = $$.context = $$.svg.append("g").attr("transform", $$.getTranslate('context')); + + context.style('visibility', config.subchart_show ? 'visible' : 'hidden'); + + // 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) + .call($$.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); + }; + c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { + var $$ = this, context = $$.context, config = $$.config, + contextLineEnter, contextLineUpdate, contextBarEnter, contextBarUpdate, + classChartBar = $$.classChartBar.bind($$), + classBars = $$.classBars.bind($$), + classChartLine = $$.classChartLine.bind($$), + classLines = $$.classLines.bind($$), + classAreas = $$.classAreas.bind($$); + + if (config.subchart_show) { + //-- Bar --// + contextBarUpdate = context.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) + .data(targets) + .attr('class', classChartBar); + contextBarEnter = contextBarUpdate.enter().append('g') + .style('opacity', 0) + .attr('class', classChartBar); + // Bars for each data + contextBarEnter.append('g') + .attr("class", classBars); + + //-- Line --// + contextLineUpdate = context.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) + .data(targets) + .attr('class', classChartLine); + contextLineEnter = contextLineUpdate.enter().append('g') + .style('opacity', 0) + .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); + } + }; + c3_chart_internal_fn.updateBarForSubchart = function (durationForExit) { + var $$ = this; + $$.contextBar = $$.context.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) + .data($$.barData.bind($$)); + $$.contextBar.enter().append('path') + .attr("class", $$.classBar.bind($$)) + .style("stroke", 'none') + .style("fill", $$.color); + $$.contextBar + .style("opacity", $$.initialOpacity.bind($$)); + $$.contextBar.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); + }; + c3_chart_internal_fn.redrawBarForSubchart = function (drawBarOnSub, withTransition, duration) { + (withTransition ? this.contextBar.transition().duration(duration) : this.contextBar) + .attr('d', drawBarOnSub) + .style('opacity', 1); + }; + c3_chart_internal_fn.updateLineForSubchart = function (durationForExit) { + var $$ = this; + $$.contextLine = $$.context.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + $$.contextLine.enter().append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + $$.contextLine + .style("opacity", $$.initialOpacity.bind($$)); + $$.contextLine.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); + }; + c3_chart_internal_fn.redrawLineForSubchart = function (drawLineOnSub, withTransition, duration) { + (withTransition ? this.contextLine.transition().duration(duration) : this.contextLine) + .attr("d", drawLineOnSub) + .style('opacity', 1); + }; + c3_chart_internal_fn.updateAreaForSubchart = function (durationForExit) { + var $$ = this, d3 = $$.d3; + $$.contextArea = $$.context.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + $$.contextArea.enter().append('path') + .attr("class", $$.classArea.bind($$)) + .style("fill", $$.color) + .style("opacity", function () { $$.orgAreaOpacity = +d3.select(this).style('opacity'); return 0; }); + $$.contextArea + .style("opacity", 0); + $$.contextArea.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); + }; + c3_chart_internal_fn.redrawAreaForSubchart = function (drawAreaOnSub, withTransition, duration) { + (withTransition ? this.contextArea.transition().duration(duration) : this.contextArea) + .attr("d", drawAreaOnSub) + .style("fill", this.color) + .style("opacity", this.orgAreaOpacity); + }; + c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices) { + var $$ = this, d3 = $$.d3, config = $$.config, + drawAreaOnSub, drawBarOnSub, drawLineOnSub; + + $$.context.style('visibility', config.subchart_show ? 'visible' : 'hidden'); + + // subchart + if (config.subchart_show) { + // reflect main chart to extent on subchart if zoomed + if (d3.event && d3.event.type === 'zoom') { + $$.brush.extent($$.x.orgDomain()).update(); + } + // update subchart elements if needed + if (withSubchart) { + + // extent rect + if (!$$.brush.empty()) { + $$.brush.extent($$.x.orgDomain()).update(); + } + // 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); + } + } + }; + c3_chart_internal_fn.redrawForBrush = function () { + var $$ = this, x = $$.x; + $$.redraw({ + withTransition: false, + withY: $$.config.zoom_rescale, + withSubchart: false, + withUpdateXDomain: true, + withDimension: false + }); + $$.config.subchart_onbrush.call($$.api, x.orgDomain()); + }; + c3_chart_internal_fn.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')); + }; + c3_chart_internal_fn.getDefaultExtent = function () { + var $$ = this, config = $$.config, + extent = isFunction(config.axis_x_extent) ? config.axis_x_extent($$.getXDomain($$.data.targets)) : config.axis_x_extent; + if ($$.isTimeSeries()) { + extent = [$$.parseDate(extent[0]), $$.parseDate(extent[1])]; + } + return extent; + }; + + c3_chart_internal_fn.initZoom = function () { + var $$ = this, d3 = $$.d3, config = $$.config, startEvent; + + $$.zoom = d3.behavior.zoom() + .on("zoomstart", function () { + startEvent = d3.event.sourceEvent; + $$.zoom.altDomain = d3.event.sourceEvent.altKey ? $$.x.orgDomain() : null; + config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent); + }) + .on("zoom", function () { + $$.redrawForZoom.call($$); + }) + .on('zoomend', function () { + var event = d3.event.sourceEvent; + // if click, do nothing. otherwise, click interaction will be canceled. + if (event && startEvent.clientX === event.clientX && startEvent.clientY === event.clientY) { + return; + } + $$.redrawEventRect(); + $$.updateZoom(); + config.zoom_onzoomend.call($$.api, $$.x.orgDomain()); + }); + $$.zoom.scale = function (scale) { + return config.axis_rotated ? this.y(scale) : this.x(scale); + }; + $$.zoom.orgScaleExtent = function () { + var extent = config.zoom_extent ? config.zoom_extent : [1, 10]; + return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])]; + }; + $$.zoom.updateScaleExtent = function () { + var ratio = diffDomain($$.x.orgDomain()) / diffDomain($$.orgXDomain), + extent = this.orgScaleExtent(); + this.scaleExtent([extent[0] * ratio, extent[1] * ratio]); + return this; + }; + }; + c3_chart_internal_fn.updateZoom = function () { + var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {}; + $$.main.select('.' + CLASS.zoomRect).call(z).on("dblclick.zoom", null); + $$.main.selectAll('.' + CLASS.eventRect).call(z).on("dblclick.zoom", null); + }; + c3_chart_internal_fn.redrawForZoom = function () { + var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x; + if (!config.zoom_enabled) { + return; + } + if ($$.filterTargetsToShow($$.data.targets).length === 0) { + return; + } + if (d3.event.sourceEvent.type === 'mousemove' && zoom.altDomain) { + x.domain(zoom.altDomain); + zoom.scale(x).updateScaleExtent(); + 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.type === 'mousemove') { + $$.cancelClick = true; + } + config.zoom_onzoom.call($$.api, x.orgDomain()); + }; + + c3_chart_internal_fn.generateColor = function () { + var $$ = this, config = $$.config, d3 = $$.d3, + colors = config.data_colors, + pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.scale.category10().range(), + 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; + }; + }; + c3_chart_internal_fn.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(config.color_threshold) ? 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; + }; + + c3_chart_internal_fn.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); + }; + }; + c3_chart_internal_fn.yFormat = function (v) { + var $$ = this, config = $$.config, + format = config.axis_y_tick_format ? config.axis_y_tick_format : $$.defaultValueFormat; + return format(v); + }; + c3_chart_internal_fn.y2Format = function (v) { + var $$ = this, config = $$.config, + format = config.axis_y2_tick_format ? config.axis_y2_tick_format : $$.defaultValueFormat; + return format(v); + }; + c3_chart_internal_fn.defaultValueFormat = function (v) { + return isValue(v) ? +v : ""; + }; + c3_chart_internal_fn.defaultArcValueFormat = function (v, ratio) { + return (ratio * 100).toFixed(1) + '%'; + }; + c3_chart_internal_fn.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; + }; + + c3_chart_internal_fn.hasCaches = function (ids) { + for (var i = 0; i < ids.length; i++) { + if (! (ids[i] in this.cache)) { return false; } + } + return true; + }; + c3_chart_internal_fn.addCache = function (id, target) { + this.cache[id] = this.cloneTarget(target); + }; + c3_chart_internal_fn.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; + }; + + var CLASS = c3_chart_internal_fn.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', + focused: 'c3-focused', + defocused: 'c3-defocused', + region: 'c3-region', + regions: 'c3-regions', + 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', + 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', + 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_' + }; + c3_chart_internal_fn.generateClass = function (prefix, targetId) { + return " " + prefix + " " + prefix + this.getTargetSelectorSuffix(targetId); + }; + c3_chart_internal_fn.classText = function (d) { + return this.generateClass(CLASS.text, d.index); + }; + c3_chart_internal_fn.classTexts = function (d) { + return this.generateClass(CLASS.texts, d.id); + }; + c3_chart_internal_fn.classShape = function (d) { + return this.generateClass(CLASS.shape, d.index); + }; + c3_chart_internal_fn.classShapes = function (d) { + return this.generateClass(CLASS.shapes, d.id); + }; + c3_chart_internal_fn.classLine = function (d) { + return this.classShape(d) + this.generateClass(CLASS.line, d.id); + }; + c3_chart_internal_fn.classLines = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.lines, d.id); + }; + c3_chart_internal_fn.classCircle = function (d) { + return this.classShape(d) + this.generateClass(CLASS.circle, d.index); + }; + c3_chart_internal_fn.classCircles = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.circles, d.id); + }; + c3_chart_internal_fn.classBar = function (d) { + return this.classShape(d) + this.generateClass(CLASS.bar, d.index); + }; + c3_chart_internal_fn.classBars = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.bars, d.id); + }; + c3_chart_internal_fn.classArc = function (d) { + return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id); + }; + c3_chart_internal_fn.classArcs = function (d) { + return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id); + }; + c3_chart_internal_fn.classArea = function (d) { + return this.classShape(d) + this.generateClass(CLASS.area, d.id); + }; + c3_chart_internal_fn.classAreas = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.areas, d.id); + }; + c3_chart_internal_fn.classRegion = function (d, i) { + return this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d['class'] : ''); + }; + c3_chart_internal_fn.classEvent = function (d) { + return this.generateClass(CLASS.eventRect, d.index); + }; + c3_chart_internal_fn.classTarget = function (id) { + var $$ = this; + var additionalClassSuffix = $$.config.data_classes[id], additionalClass = ''; + if (additionalClassSuffix) { + additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; + } + return $$.generateClass(CLASS.target, id) + additionalClass; + }; + c3_chart_internal_fn.classFocus = function (d) { + return this.classFocused(d) + this.classDefocused(d); + }; + c3_chart_internal_fn.classFocused = function (d) { + return ' ' + (this.focusedTargetIds.indexOf(d.id) >= 0 ? CLASS.focused : ''); + }; + c3_chart_internal_fn.classDefocused = function (d) { + return ' ' + (this.defocusedTargetIds.indexOf(d.id) >= 0 ? CLASS.defocused : ''); + }; + c3_chart_internal_fn.classChartText = function (d) { + return CLASS.chartText + this.classTarget(d.id); + }; + c3_chart_internal_fn.classChartLine = function (d) { + return CLASS.chartLine + this.classTarget(d.id); + }; + c3_chart_internal_fn.classChartBar = function (d) { + return CLASS.chartBar + this.classTarget(d.id); + }; + c3_chart_internal_fn.classChartArc = function (d) { + return CLASS.chartArc + this.classTarget(d.data.id); + }; + c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) { + return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g, '-') : ''; + }; + c3_chart_internal_fn.selectorTarget = function (id, prefix) { + return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id); + }; + c3_chart_internal_fn.selectorTargets = function (ids, prefix) { + var $$ = this; + ids = ids || []; + return ids.length ? ids.map(function (id) { return $$.selectorTarget(id, prefix); }) : null; + }; + c3_chart_internal_fn.selectorLegend = function (id) { + return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id); + }; + c3_chart_internal_fn.selectorLegends = function (ids) { + var $$ = this; + return ids && ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null; + }; + + var isValue = c3_chart_internal_fn.isValue = function (v) { + return v || v === 0; + }, + isFunction = c3_chart_internal_fn.isFunction = function (o) { + return typeof o === 'function'; + }, + isString = c3_chart_internal_fn.isString = function (o) { + return typeof o === 'string'; + }, + isUndefined = c3_chart_internal_fn.isUndefined = function (v) { + return typeof v === 'undefined'; + }, + isDefined = c3_chart_internal_fn.isDefined = function (v) { + return typeof v !== 'undefined'; + }, + ceil10 = c3_chart_internal_fn.ceil10 = function (v) { + return Math.ceil(v / 10) * 10; + }, + asHalfPixel = c3_chart_internal_fn.asHalfPixel = function (n) { + return Math.ceil(n) + 0.5; + }, + diffDomain = c3_chart_internal_fn.diffDomain = function (d) { + return d[1] - d[0]; + }, + isEmpty = c3_chart_internal_fn.isEmpty = function (o) { + return !o || (isString(o) && o.length === 0) || (typeof o === 'object' && Object.keys(o).length === 0); + }, + notEmpty = c3_chart_internal_fn.notEmpty = function (o) { + return Object.keys(o).length > 0; + }, + getOption = c3_chart_internal_fn.getOption = function (options, key, defaultValue) { + return isDefined(options[key]) ? options[key] : defaultValue; + }, + hasValue = c3_chart_internal_fn.hasValue = function (dict, value) { + var found = false; + Object.keys(dict).forEach(function (key) { + if (dict[key] === value) { found = true; } + }); + return found; + }, + getPathBox = c3_chart_internal_fn.getPathBox = function (path) { + var box = path.getBoundingClientRect(), + 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}; + }; + + c3_chart_fn.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; + }); + }; + + c3_chart_fn.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; + }; + + c3_chart_fn.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 = []; + }; + + c3_chart_fn.show = function (targetIds, options) { + var $$ = this.internal, targets; + + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + + $$.removeHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + + targets.transition() + .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}); + }; + + c3_chart_fn.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); + }); + + if (options.withLegend) { + $$.hideLegend(targetIds); + } + + $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); + }; + + c3_chart_fn.toggle = function (targetIds, options) { + var that = this, $$ = this.internal; + $$.mapToTargetIds(targetIds).forEach(function (targetId) { + $$.isTargetToShow(targetId) ? that.hide(targetId, options) : that.show(targetId, options); + }); + }; + + c3_chart_fn.zoom = function (domain) { + var $$ = this.internal; + if (domain) { + if ($$.isTimeSeries()) { + domain = domain.map(function (x) { return $$.parseDate(x); }); + } + $$.brush.extent(domain); + $$.redraw({withUpdateXDomain: true, withY: $$.config.zoom_rescale}); + $$.config.zoom_onzoom.call(this, $$.x.orgDomain()); + } + return $$.brush.extent(); + }; + c3_chart_fn.zoom.enable = function (enabled) { + var $$ = this.internal; + $$.config.zoom_enabled = enabled; + $$.updateAndRedraw(); + }; + c3_chart_fn.unzoom = function () { + var $$ = this.internal; + $$.brush.clear().update(); + $$.redraw({withUpdateXDomain: true}); + }; + + c3_chart_fn.load = function (args) { + var $$ = this.internal, config = $$.config; + // update xs if specified + if (args.xs) { + $$.addXs(args.xs); + } + // 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 ('unload' in args) { + // TODO: do not unload if target will load (included in url/rows/columns) + $$.unload($$.mapToTargetIds((typeof args.unload === 'boolean' && args.unload) ? null : args.unload), function () { + $$.loadFromArgs(args); + }); + } else { + $$.loadFromArgs(args); + } + }; + + c3_chart_fn.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(); } + }); + }; + + c3_chart_fn.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, + }); + }; + + c3_chart_internal_fn.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 = $$.xgrid || d3.selectAll([]), + 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([]); + + // 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); } + + // 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.x === 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)'; + + // hide tooltip + $$.hideXGridFocus(); + $$.hideTooltip(); + + d3.transition().ease('linear').duration(durationForFlow).each(function () { + wait.add($$.axes.x.transition().call($$.xAxis)); + wait.add(mainBar.transition().attr('transform', transform)); + wait.add(mainLine.transition().attr('transform', transform)); + wait.add(mainArea.transition().attr('transform', transform)); + wait.add(mainCircle.transition().attr('transform', transform)); + wait.add(mainText.transition().attr('transform', transform)); + wait.add(mainRegion.filter($$.isRegionOnX).transition().attr('transform', transform)); + wait.add(xgrid.transition().attr('transform', transform)); + wait.add(xgridLines.transition().attr('transform', transform)); + }) + .call(wait, function () { + var i, shapes = [], texts = [], eventRects = []; + + // remove flowed elements + if (flowLength) { + for (i = 0; i < flowLength; i++) { + shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); + texts.push('.' + CLASS.text + '-' + (flowIndex + i)); + eventRects.push('.' + CLASS.eventRect + '-' + (flowIndex + i)); + } + $$.svg.selectAll('.' + CLASS.shapes).selectAll(shapes).remove(); + $$.svg.selectAll('.' + CLASS.texts).selectAll(texts).remove(); + $$.svg.selectAll('.' + CLASS.eventRects).selectAll(eventRects).remove(); + $$.svg.select('.' + CLASS.xgrid).remove(); + } + + // draw again for removing flowed elements and reverting attr + xgrid + .attr('transform', null) + .attr($$.xgridAttr); + 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.select('rect').filter($$.isRegionOnX) + .attr("x", $$.regionX.bind($$)) + .attr("width", $$.regionWidth.bind($$)); + + if (config.interaction_enabled) { + $$.redrawEventRect(); + } + + // callback for end of flow + done(); + + $$.flowing = false; + }); + }; + }; + + c3_chart_fn.selected = function (targetId) { + var $$ = this.internal, d3 = $$.d3; + return d3.merge( + $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)).selectAll('.' + CLASS.shape) + .filter(function () { return d3.select(this).classed(CLASS.SELECTED); }) + .map(function (d) { return d.map(function (d) { var data = d.__data__; return data.data ? data.data : data; }); }) + ); + }; + c3_chart_fn.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); + } + } + }); + }; + c3_chart_fn.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); + } + } + } + }); + }; + + c3_chart_fn.transform = function (type, targetIds) { + var $$ = this.internal, + options = ['pie', 'donut'].indexOf(type) >= 0 ? {withTransform: true} : null; + $$.transformTo(targetIds, type, options); + }; + + c3_chart_internal_fn.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); + }; + + c3_chart_fn.groups = function (groups) { + var $$ = this.internal, config = $$.config; + if (isUndefined(groups)) { return config.data_groups; } + config.data_groups = groups; + $$.redraw(); + return config.data_groups; + }; + + c3_chart_fn.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; + }; + c3_chart_fn.xgrids.add = function (grids) { + var $$ = this.internal; + return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : [])); + }; + c3_chart_fn.xgrids.remove = function (params) { // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, true); + }; + + c3_chart_fn.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; + }; + c3_chart_fn.ygrids.add = function (grids) { + var $$ = this.internal; + return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : [])); + }; + c3_chart_fn.ygrids.remove = function (params) { // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, false); + }; + + c3_chart_fn.regions = function (regions) { + var $$ = this.internal, config = $$.config; + if (!regions) { return config.regions; } + config.regions = regions; + $$.redrawWithoutRescale(); + return config.regions; + }; + c3_chart_fn.regions.add = function (regions) { + var $$ = this.internal, config = $$.config; + if (!regions) { return config.regions; } + config.regions = config.regions.concat(regions); + $$.redrawWithoutRescale(); + return config.regions; + }; + c3_chart_fn.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; + }; + + c3_chart_fn.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; + }); + }; + c3_chart_fn.data.shown = function (targetIds) { + return this.internal.filterTargetsToShow(this.data(targetIds)); + }; + c3_chart_fn.data.values = function (targetId) { + var targets, values = null; + if (targetId) { + targets = this.data(targetId); + values = targets[0] ? targets[0].values.map(function (d) { return d.value; }) : null; + } + return values; + }; + c3_chart_fn.data.names = function (names) { + this.internal.clearLegendItemTextBoxCache(); + return this.internal.updateDataAttributes('names', names); + }; + c3_chart_fn.data.colors = function (colors) { + return this.internal.updateDataAttributes('colors', colors); + }; + c3_chart_fn.data.axes = function (axes) { + return this.internal.updateDataAttributes('axes', axes); + }; + + c3_chart_fn.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]; + }; + c3_chart_fn.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; + }; + + // TODO: fix + c3_chart_fn.color = function (id) { + var $$ = this.internal; + return $$.color(id); // more patterns + }; + + c3_chart_fn.x = function (x) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetX($$.data.targets, x); + $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); + } + return $$.data.xs; + }; + c3_chart_fn.xs = function (xs) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetXs($$.data.targets, xs); + $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); + } + return $$.data.xs; + }; + + c3_chart_fn.axis = function () {}; + c3_chart_fn.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? + }; + c3_chart_fn.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 + }; + } + }; + c3_chart_fn.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 + }; + } + }; + c3_chart_fn.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() + }; + } + }; + + c3_chart_fn.legend = function () {}; + c3_chart_fn.legend.show = function (targetIds) { + var $$ = this.internal; + $$.showLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({withLegend: true}); + }; + c3_chart_fn.legend.hide = function (targetIds) { + var $$ = this.internal; + $$.hideLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({withLegend: true}); + }; + + c3_chart_fn.resize = function (size) { + var $$ = this.internal, config = $$.config; + config.size_width = size ? size.width : null; + config.size_height = size ? size.height : null; + this.flush(); + }; + + c3_chart_fn.flush = function () { + var $$ = this.internal; + $$.updateAndRedraw({withLegend: true, withTransition: false, withTransitionForTransform: false}); + }; + + c3_chart_fn.destroy = function () { + var $$ = this.internal; + + window.clearInterval($$.intervalForObserveInserted); + window.onresize = null; + + $$.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; + }; + + c3_chart_fn.tooltip = function () {}; + c3_chart_fn.tooltip.show = function (args) { + var $$ = this.internal, index, mouse; + + // determine mouse position on the chart + if (args.mouse) { + mouse = args.mouse; + } + + // determine focus data + if (args.data) { + if ($$.isMultipleX()) { + // if multiple xs, target point will be determined by mouse + mouse = [$$.x(args.data.x), $$.getYScale(args.data.id)(args.data.value)]; + index = null; + } else { + // TODO: when tooltip_grouped = false + index = isValue(args.data.index) ? args.data.index : $$.getIndexByX(args.data.x); + } + } + else if (typeof args.x !== 'undefined') { + index = $$.getIndexByX(args.x); + } + else if (typeof args.index !== 'undefined') { + index = args.index; + } + + // emulate mouse events to show + $$.dispatchEvent('mouseover', index, mouse); + $$.dispatchEvent('mousemove', index, mouse); + }; + c3_chart_fn.tooltip.hide = function () { + // TODO: get target data by checking the state of focus + this.internal.dispatchEvent('mouseout', 0); + }; + + // Features: + // 1. category axis + // 2. ceil values of translate/x/y to int for half pixel antialiasing + // 3. multiline tick text + var tickTextCharSize; + function c3_axis(d3, params) { + var scale = d3.scale.linear(), orient = "bottom", innerTickSize = 6, outerTickSize, tickPadding = 3, tickValues = null, tickFormat, tickArguments; + + var tickOffset = 0, tickCulling = true, tickCentered; + + params = params || {}; + outerTickSize = params.withOuterTick ? 6 : 0; + + function axisX(selection, x) { + selection.attr("transform", function (d) { + return "translate(" + Math.ceil(x(d) + tickOffset) + ", 0)"; + }); + } + function axisY(selection, y) { + selection.attr("transform", function (d) { + return "translate(0," + Math.ceil(y(d)) + ")"; + }); + } + function scaleExtent(domain) { + var start = domain[0], stop = domain[domain.length - 1]; + return start < stop ? [ start, stop ] : [ stop, start ]; + } + function generateTicks(scale) { + var i, domain, ticks = []; + if (scale.ticks) { + return scale.ticks.apply(scale, 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; + } + function copyScale() { + var newScale = scale.copy(), domain; + if (params.isCategory) { + domain = scale.domain(); + newScale.domain([domain[0], domain[1] - 1]); + } + return newScale; + } + function textFormatted(v) { + var formatted = tickFormat ? tickFormat(v) : v; + return typeof formatted !== 'undefined' ? formatted : ''; + } + function getSizeFor1Char(tick) { + if (tickTextCharSize) { + return tickTextCharSize; + } + var size = { + h: 11.5, + w: 5.5 + }; + tick.select('text').text(textFormatted).each(function (d) { + var box = this.getBoundingClientRect(), + text = textFormatted(d), + h = box.height, + w = text ? (box.width / text.length) : undefined; + if (h && w) { + size.h = h; + size.w = w; + } + }).text(''); + tickTextCharSize = size; + return size; + } + function transitionise(selection) { + return params.withoutTransition ? selection : d3.transition(selection); + } + function axis(g) { + g.each(function () { + var g = axis.g = d3.select(this); + + var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = copyScale(); + + var ticks = tickValues ? tickValues : generateTicks(scale1), + tick = g.selectAll(".tick").data(ticks, scale1), + tickEnter = tick.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 = tick.exit().remove(), + tickUpdate = transitionise(tick).style("opacity", 1), + tickTransform, tickX, tickY; + + var range = scale.rangeExtent ? scale.rangeExtent() : scaleExtent(scale.range()), + path = g.selectAll(".domain").data([ 0 ]), + pathUpdate = (path.enter().append("path").attr("class", "domain"), transitionise(path)); + tickEnter.append("line"); + tickEnter.append("text"); + + var lineEnter = tickEnter.select("line"), + lineUpdate = tickUpdate.select("line"), + textEnter = tickEnter.select("text"), + textUpdate = tickUpdate.select("text"); + + if (params.isCategory) { + tickOffset = Math.ceil((scale1(1) - scale1(0)) / 2); + tickX = tickCentered ? 0 : tickOffset; + tickY = tickCentered ? tickOffset : 0; + } else { + tickOffset = tickX = 0; + } + + var text, tspan, sizeFor1Char = getSizeFor1Char(g.select('.tick')), counts = []; + var tickLength = Math.max(innerTickSize, 0) + tickPadding, + isVertical = orient === 'left' || orient === 'right'; + + // this should be called only when category axis + function splitTickText(d, maxWidth) { + var tickText = textFormatted(d), + subtext, spaceIndex, textWidth, splitted = []; + + if (Object.prototype.toString.call(tickText) === "[object Array]") { + return tickText; + } + + if (!maxWidth || maxWidth <= 0) { + maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[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 = sizeFor1Char.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 + ""); + } + + function tspanDy(d, i) { + var dy = sizeFor1Char.h; + if (i === 0) { + if (orient === 'left' || orient === 'right') { + dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3); + } else { + dy = ".71em"; + } + } + return dy; + } + + function tickSize(d) { + var tickPosition = scale(d) + (tickCentered ? 0 : tickOffset); + return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0; + } + + text = tick.select("text"); + tspan = text.selectAll('tspan') + .data(function (d, i) { + var splitted = params.tickMultiline ? splitTickText(d, params.tickWidth) : [].concat(textFormatted(d)); + counts[i] = splitted.length; + return splitted.map(function (s) { + return { index: i, splitted: s }; + }); + }); + tspan.enter().append('tspan'); + tspan.exit().remove(); + tspan.text(function (d) { return d.splitted; }); + + var rotate = params.tickTextRotate; + + function textAnchorForText(rotate) { + if (!rotate) { + return 'middle'; + } + return rotate > 0 ? "start" : "end"; + } + function textTransform(rotate) { + if (!rotate) { + return ''; + } + return "rotate(" + rotate + ")"; + } + function dxForText(rotate) { + if (!rotate) { + return 0; + } + return 8 * Math.sin(Math.PI * (rotate / 180)); + } + function yForText(rotate) { + if (!rotate) { + return tickLength; + } + return 11.5 - 2.5 * (rotate / 15) * (rotate > 0 ? 1 : -1); + } + + switch (orient) { + case "bottom": + { + tickTransform = axisX; + lineEnter.attr("y2", innerTickSize); + textEnter.attr("y", tickLength); + lineUpdate.attr("x1", tickX).attr("x2", tickX).attr("y2", tickSize); + textUpdate.attr("x", 0).attr("y", yForText(rotate)) + .style("text-anchor", textAnchorForText(rotate)) + .attr("transform", textTransform(rotate)); + tspan.attr('x', 0).attr("dy", tspanDy).attr('dx', dxForText(rotate)); + pathUpdate.attr("d", "M" + range[0] + "," + outerTickSize + "V0H" + range[1] + "V" + outerTickSize); + break; + } + case "top": + { + // TODO: rotated tick text + tickTransform = axisX; + lineEnter.attr("y2", -innerTickSize); + textEnter.attr("y", -tickLength); + lineUpdate.attr("x2", 0).attr("y2", -innerTickSize); + textUpdate.attr("x", 0).attr("y", -tickLength); + text.style("text-anchor", "middle"); + tspan.attr('x', 0).attr("dy", "0em"); + pathUpdate.attr("d", "M" + range[0] + "," + -outerTickSize + "V0H" + range[1] + "V" + -outerTickSize); + break; + } + case "left": + { + tickTransform = axisY; + lineEnter.attr("x2", -innerTickSize); + textEnter.attr("x", -tickLength); + lineUpdate.attr("x2", -innerTickSize).attr("y1", tickY).attr("y2", tickY); + textUpdate.attr("x", -tickLength).attr("y", tickOffset); + text.style("text-anchor", "end"); + tspan.attr('x', -tickLength).attr("dy", tspanDy); + pathUpdate.attr("d", "M" + -outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + -outerTickSize); + break; + } + case "right": + { + tickTransform = axisY; + lineEnter.attr("x2", innerTickSize); + textEnter.attr("x", tickLength); + lineUpdate.attr("x2", innerTickSize).attr("y2", 0); + textUpdate.attr("x", tickLength).attr("y", 0); + text.style("text-anchor", "start"); + tspan.attr('x', tickLength).attr("dy", tspanDy); + pathUpdate.attr("d", "M" + outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + 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); + } + tickEnter.call(tickTransform, scale0); + tickUpdate.call(tickTransform, scale1); + }); + } + axis.scale = function (x) { + if (!arguments.length) { return scale; } + scale = x; + return axis; + }; + axis.orient = function (x) { + if (!arguments.length) { return orient; } + orient = x in {top: 1, right: 1, bottom: 1, left: 1} ? x + "" : "bottom"; + return axis; + }; + axis.tickFormat = function (format) { + if (!arguments.length) { return tickFormat; } + tickFormat = format; + return axis; + }; + axis.tickCentered = function (isCentered) { + if (!arguments.length) { return tickCentered; } + tickCentered = isCentered; + return axis; + }; + axis.tickOffset = function () { + return tickOffset; + }; + axis.tickInterval = function () { + var interval, length; + if (params.isCategory) { + interval = tickOffset * 2; + } + else { + length = axis.g.select('path.domain').node().getTotalLength() - outerTickSize * 2; + interval = length / axis.g.selectAll('line').size(); + } + return interval === Infinity ? 0 : interval; + }; + axis.ticks = function () { + if (!arguments.length) { return tickArguments; } + tickArguments = arguments; + return axis; + }; + axis.tickCulling = function (culling) { + if (!arguments.length) { return tickCulling; } + tickCulling = culling; + return axis; + }; + axis.tickValues = function (x) { + if (typeof x === 'function') { + tickValues = function () { + return x(scale.domain()); + }; + } + else { + if (!arguments.length) { return tickValues; } + tickValues = x; + } + return axis; + }; + return axis; + } + + c3_chart_internal_fn.isSafari = function () { + var ua = window.navigator.userAgent; + return ua.indexOf('Safari') >= 0 && ua.indexOf('Chrome') < 0; + }; + c3_chart_internal_fn.isChrome = function () { + var ua = window.navigator.userAgent; + return ua.indexOf('Chrome') >= 0; + }; + + // PhantomJS doesn't have support for Function.prototype.bind, which has caused confusion. Use + // this polyfill to avoid the confusion. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill + + if (!Function.prototype.bind) { + Function.prototype.bind = function(oThis) { + if (typeof this !== 'function') { + // closest thing possible to the ECMAScript 5 + // internal IsCallable function + throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function() {}, + fBound = function() { + return fToBind.apply(this instanceof fNOP ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; + } + + if (typeof define === 'function' && define.amd) { + define("c3", ["d3"], c3); + } else if ('undefined' !== typeof exports && 'undefined' !== typeof module) { + module.exports = c3; + } else { + window.c3 = c3; + } + +})(window); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/c3.min.css b/web/nms-public.gathering.org/old/speedometer/c3-master/c3.min.css new file mode 100644 index 0000000..08e5084 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/c3.min.css @@ -0,0 +1 @@ +.c3 svg{font:10px sans-serif}.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 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:gray;font-size:2em}.c3-line{stroke-width:1px}.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:.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-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-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 td.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:none}.c3-chart-arcs .c3-chart-arcs-gauge-unit{fill:#000;font-size:16px}.c3-chart-arcs .c3-chart-arcs-gauge-max,.c3-chart-arcs .c3-chart-arcs-gauge-min{fill:#777}.c3-chart-arc .c3-gauge-value{fill:#000}
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/c3.min.js b/web/nms-public.gathering.org/old/speedometer/c3-master/c3.min.js new file mode 100644 index 0000000..d99c28b --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/c3.min.js @@ -0,0 +1,5 @@ +!function(a){"use strict";function b(a){this.owner=a}function c(a,b){if(Object.create)b.prototype=Object.create(a.prototype);else{var c=function(){};c.prototype=a.prototype,b.prototype=new c}return b.prototype.constructor=b,b}function d(a){var b=this.internal=new e(this);b.loadConfig(a),b.init(),function c(a,b,d){Object.keys(a).forEach(function(e){b[e]=a[e].bind(d),Object.keys(a[e]).length>0&&c(a[e],b[e],d)})}(h,this,this)}function e(b){var c=this;c.d3=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,c.api=b,c.config=c.getDefaultConfig(),c.data={},c.cache={},c.axes={}}function f(a){b.call(this,a)}function g(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+u)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,n);for(c=a.domain(),b=Math.ceil(c[0]);b<c[1];b++)d.push(b);return d.length>0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function g(){var a,c=p.copy();return b.isCategory&&(a=p.domain(),c.domain([a[0],a[1]-1])),c}function h(a){var b=m?m(a):a;return"undefined"!=typeof b?b:""}function i(a){if(z)return z;var b={h:11.5,w:5.5};return a.select("text").text(h).each(function(a){var c=this.getBoundingClientRect(),d=h(a),e=c.height,f=d?c.width/d.length:void 0;e&&f&&(b.h=e,b.w=f)}).text(""),z=b,b}function j(c){return b.withoutTransition?c:a.transition(c)}function k(m){m.each(function(){function m(a,c){function d(a,b){f=void 0;for(var h=1;h<b.length;h++)if(" "===b.charAt(h)&&(f=h),e=b.substr(0,h+1),g=U.w*e.length,g>c)return d(a.concat(b.substr(0,f?f:h)),b.slice(f?f+1:h));return a.concat(b)}var e,f,g,i=h(a),j=[];return"[object Array]"===Object.prototype.toString.call(i)?i:((!c||0>=c)&&(c=X?95:b.isCategory?Math.ceil(F(G[1])-F(G[0]))-12:110),d(j,i+""))}function n(a,b){var c=U.h;return 0===b&&(c="left"===q||"right"===q?-((V[a.index]-1)*(U.h/2)-3):".71em"),c}function v(a){var b=p(a)+(o?0:u);return L[0]<b&&b<L[1]?r:0}function w(a){return a?a>0?"start":"end":"middle"}function x(a){return a?"rotate("+a+")":""}function y(a){return a?8*Math.sin(Math.PI*(a/180)):0}function z(a){return a?11.5-2.5*(a/15)*(a>0?1:-1):W}var A,B,C,D=k.g=a.select(this),E=this.__chart__||p,F=this.__chart__=g(),G=t?t:f(F),H=D.selectAll(".tick").data(G,F),I=H.enter().insert("g",".domain").attr("class","tick").style("opacity",1e-6),J=H.exit().remove(),K=j(H).style("opacity",1),L=p.rangeExtent?p.rangeExtent():e(p.range()),M=D.selectAll(".domain").data([0]),N=(M.enter().append("path").attr("class","domain"),j(M));I.append("line"),I.append("text");var O=I.select("line"),P=K.select("line"),Q=I.select("text"),R=K.select("text");b.isCategory?(u=Math.ceil((F(1)-F(0))/2),B=o?0:u,C=o?u:0):u=B=0;var S,T,U=i(D.select(".tick")),V=[],W=Math.max(r,0)+s,X="left"===q||"right"===q;S=H.select("text"),T=S.selectAll("tspan").data(function(a,c){var d=b.tickMultiline?m(a,b.tickWidth):[].concat(h(a));return V[c]=d.length,d.map(function(a){return{index:c,splitted:a}})}),T.enter().append("tspan"),T.exit().remove(),T.text(function(a){return a.splitted});var Y=b.tickTextRotate;switch(q){case"bottom":A=c,O.attr("y2",r),Q.attr("y",W),P.attr("x1",B).attr("x2",B).attr("y2",v),R.attr("x",0).attr("y",z(Y)).style("text-anchor",w(Y)).attr("transform",x(Y)),T.attr("x",0).attr("dy",n).attr("dx",y(Y)),N.attr("d","M"+L[0]+","+l+"V0H"+L[1]+"V"+l);break;case"top":A=c,O.attr("y2",-r),Q.attr("y",-W),P.attr("x2",0).attr("y2",-r),R.attr("x",0).attr("y",-W),S.style("text-anchor","middle"),T.attr("x",0).attr("dy","0em"),N.attr("d","M"+L[0]+","+-l+"V0H"+L[1]+"V"+-l);break;case"left":A=d,O.attr("x2",-r),Q.attr("x",-W),P.attr("x2",-r).attr("y1",C).attr("y2",C),R.attr("x",-W).attr("y",u),S.style("text-anchor","end"),T.attr("x",-W).attr("dy",n),N.attr("d","M"+-l+","+L[0]+"H0V"+L[1]+"H"+-l);break;case"right":A=d,O.attr("x2",r),Q.attr("x",W),P.attr("x2",r).attr("y2",0),R.attr("x",W).attr("y",0),S.style("text-anchor","start"),T.attr("x",W).attr("dy",n),N.attr("d","M"+l+","+L[0]+"H0V"+L[1]+"H"+l)}if(F.rangeBand){var Z=F,$=Z.rangeBand()/2;E=F=function(a){return Z(a)+$}}else E.rangeBand?E=F:J.call(A,F);I.call(A,E),K.call(A,F)})}var l,m,n,o,p=a.scale.linear(),q="bottom",r=6,s=3,t=null,u=0,v=!0;return b=b||{},l=b.withOuterTick?6:0,k.scale=function(a){return arguments.length?(p=a,k):p},k.orient=function(a){return arguments.length?(q=a in{top:1,right:1,bottom:1,left:1}?a+"":"bottom",k):q},k.tickFormat=function(a){return arguments.length?(m=a,k):m},k.tickCentered=function(a){return arguments.length?(o=a,k):o},k.tickOffset=function(){return u},k.tickInterval=function(){var a,c;return b.isCategory?a=2*u:(c=k.g.select("path.domain").node().getTotalLength()-2*l,a=c/k.g.selectAll("line").size()),1/0===a?0:a},k.ticks=function(){return arguments.length?(n=arguments,k):n},k.tickCulling=function(a){return arguments.length?(v=a,k):v},k.tickValues=function(a){if("function"==typeof a)t=function(){return a(p.domain())};else{if(!arguments.length)return t;t=a}return k},k}var h,i,j,k={version:"0.4.10"};k.generate=function(a){return new d(a)},k.chart={fn:d.prototype,internal:{fn:e.prototype,axis:{fn:f.prototype}}},h=k.chart.fn,i=k.chart.internal.fn,j=k.chart.internal.axis.fn,i.init=function(){var a=this,b=a.config;if(a.initParams(),b.data_url)a.convertUrlToData(b.data_url,b.data_mimeType,b.data_keys,a.initWithData);else if(b.data_json)a.initWithData(a.convertJsonToData(b.data_json,b.data_keys));else if(b.data_rows)a.initWithData(a.convertRowsToData(b.data_rows));else{if(!b.data_columns)throw Error("url or json or rows or columns is required.");a.initWithData(a.convertColumnsToData(b.data_columns))}},i.initParams=function(){var a=this,b=a.d3,c=a.config;a.clipId="c3-"+ +new Date+"-clip",a.clipIdForXAxis=a.clipId+"-xaxis",a.clipIdForYAxis=a.clipId+"-yaxis",a.clipIdForGrid=a.clipId+"-grid",a.clipIdForSubchart=a.clipId+"-subchart",a.clipPath=a.getClipPath(a.clipId),a.clipPathForXAxis=a.getClipPath(a.clipIdForXAxis),a.clipPathForYAxis=a.getClipPath(a.clipIdForYAxis),a.clipPathForGrid=a.getClipPath(a.clipIdForGrid),a.clipPathForSubchart=a.getClipPath(a.clipIdForSubchart),a.dragStart=null,a.dragging=!1,a.flowing=!1,a.cancelClick=!1,a.mouseover=!1,a.transiting=!1,a.color=a.generateColor(),a.levelColor=a.generateLevelColor(),a.dataTimeFormat=c.data_xLocaltime?b.time.format:b.time.format.utc,a.axisTimeFormat=c.axis_x_localtime?b.time.format:b.time.format.utc,a.defaultAxisTimeFormat=a.axisTimeFormat.multi([[".%L",function(a){return a.getMilliseconds()}],[":%S",function(a){return a.getSeconds()}],["%I:%M",function(a){return a.getMinutes()}],["%I %p",function(a){return a.getHours()}],["%-m/%-d",function(a){return a.getDay()&&1!==a.getDate()}],["%-m/%-d",function(a){return 1!==a.getDate()}],["%-m/%-d",function(a){return a.getMonth()}],["%Y/%-m/%-d",function(){return!0}]]),a.hiddenTargetIds=[],a.hiddenLegendIds=[],a.focusedTargetIds=[],a.defocusedTargetIds=[],a.xOrient=c.axis_rotated?"left":"bottom",a.yOrient=c.axis_rotated?c.axis_y_inner?"top":"bottom":c.axis_y_inner?"right":"left",a.y2Orient=c.axis_rotated?c.axis_y2_inner?"bottom":"top":c.axis_y2_inner?"left":"right",a.subXOrient=c.axis_rotated?"left":"bottom",a.isLegendRight="right"===c.legend_position,a.isLegendInset="inset"===c.legend_position,a.isLegendTop="top-left"===c.legend_inset_anchor||"top-right"===c.legend_inset_anchor,a.isLegendLeft="top-left"===c.legend_inset_anchor||"bottom-left"===c.legend_inset_anchor,a.legendStep=0,a.legendItemWidth=0,a.legendItemHeight=0,a.currentMaxTickWidths={x:0,y:0,y2:0},a.rotated_padding_left=30,a.rotated_padding_right=c.axis_rotated&&!c.axis_x_show?0:30,a.rotated_padding_top=5,a.withoutFadeIn={},a.intervalForObserveInserted=void 0,a.axes.subx=b.selectAll([])},i.initChartElements=function(){this.initBar&&this.initBar(),this.initLine&&this.initLine(),this.initArc&&this.initArc(),this.initGauge&&this.initGauge(),this.initText&&this.initText()},i.initWithData=function(b){var c,d,e=this,g=e.d3,h=e.config,i=!0;e.axis=new f(e),e.initPie&&e.initPie(),e.initBrush&&e.initBrush(),e.initZoom&&e.initZoom(),e.selectChart=h.bindto?"function"==typeof h.bindto.node?h.bindto:g.select(h.bindto):g.selectAll([]),e.selectChart.empty()&&(e.selectChart=g.select(document.createElement("div")).style("opacity",0),e.observeInserted(e.selectChart),i=!1),e.selectChart.html("").classed("c3",!0),e.data.xs={},e.data.targets=e.convertDataToTargets(b),h.data_filter&&(e.data.targets=e.data.targets.filter(h.data_filter)),h.data_hide&&e.addHiddenTargetIds(h.data_hide===!0?e.mapToIds(e.data.targets):h.data_hide),h.legend_hide&&e.addHiddenLegendIds(h.legend_hide===!0?e.mapToIds(e.data.targets):h.legend_hide),e.hasType("gauge")&&(h.legend_show=!1),e.updateSizes(),e.updateScales(),e.x.domain(g.extent(e.getXDomain(e.data.targets))),e.y.domain(e.getYDomain(e.data.targets,"y")),e.y2.domain(e.getYDomain(e.data.targets,"y2")),e.subX.domain(e.x.domain()),e.subY.domain(e.y.domain()),e.subY2.domain(e.y2.domain()),e.orgXDomain=e.x.domain(),e.brush&&e.brush.scale(e.subX),h.zoom_enabled&&e.zoom.scale(e.x),e.svg=e.selectChart.append("svg").style("overflow","hidden").on("mouseenter",function(){return h.onmouseover.call(e)}).on("mouseleave",function(){return h.onmouseout.call(e)}),c=e.svg.append("defs"),e.clipChart=e.appendClip(c,e.clipId),e.clipXAxis=e.appendClip(c,e.clipIdForXAxis),e.clipYAxis=e.appendClip(c,e.clipIdForYAxis),e.clipGrid=e.appendClip(c,e.clipIdForGrid),e.clipSubchart=e.appendClip(c,e.clipIdForSubchart),e.updateSvgSize(),d=e.main=e.svg.append("g").attr("transform",e.getTranslate("main")),e.initSubchart&&e.initSubchart(),e.initTooltip&&e.initTooltip(),e.initLegend&&e.initLegend(),d.append("text").attr("class",l.text+" "+l.empty).attr("text-anchor","middle").attr("dominant-baseline","middle"),e.initRegion(),e.initGrid(),d.append("g").attr("clip-path",e.clipPath).attr("class",l.chart),h.grid_lines_front&&e.initGridLines(),e.initEventRect(),e.initChartElements(),d.insert("rect",h.zoom_privileged?null:"g."+l.regions).attr("class",l.zoomRect).attr("width",e.width).attr("height",e.height).style("opacity",0).on("dblclick.zoom",null),h.axis_x_extent&&e.brush.extent(e.getDefaultExtent()),e.axis.init(),e.updateTargets(e.data.targets),i&&(e.updateDimension(),e.config.oninit.call(e),e.redraw({withTransition:!1,withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransitionForAxis:!1})),null==a.onresize&&(a.onresize=e.generateResize()),a.onresize.add&&(a.onresize.add(function(){h.onresize.call(e)}),a.onresize.add(function(){e.api.flush()}),a.onresize.add(function(){h.onresized.call(e)})),e.api.element=e.selectChart.node()},i.smoothLines=function(a,b){var c=this;"grid"===b&&a.each(function(){var a=c.d3.select(this),b=a.attr("x1"),d=a.attr("x2"),e=a.attr("y1"),f=a.attr("y2");a.attr({x1:Math.ceil(b),x2:Math.ceil(d),y1:Math.ceil(e),y2:Math.ceil(f)})})},i.updateSizes=function(){var a=this,b=a.config,c=a.legend?a.getLegendHeight():0,d=a.legend?a.getLegendWidth():0,e=a.isLegendRight||a.isLegendInset?0:c,f=a.hasArcType(),g=b.axis_rotated||f?0:a.getHorizontalAxisHeight("x"),h=b.subchart_show&&!f?b.subchart_size_height+g:0;a.currentWidth=a.getCurrentWidth(),a.currentHeight=a.getCurrentHeight(),a.margin=b.axis_rotated?{top:a.getHorizontalAxisHeight("y2")+a.getCurrentPaddingTop(),right:f?0:a.getCurrentPaddingRight(),bottom:a.getHorizontalAxisHeight("y")+e+a.getCurrentPaddingBottom(),left:h+(f?0:a.getCurrentPaddingLeft())}:{top:4+a.getCurrentPaddingTop(),right:f?0:a.getCurrentPaddingRight(),bottom:g+h+e+a.getCurrentPaddingBottom(),left:f?0:a.getCurrentPaddingLeft()},a.margin2=b.axis_rotated?{top:a.margin.top,right:0/0,bottom:20+e,left:a.rotated_padding_left}:{top:a.currentHeight-h-e,right:0/0,bottom:g+e,left:a.margin.left},a.margin3={top:0,right:0/0,bottom:0,left:0},a.updateSizeForLegend&&a.updateSizeForLegend(c,d),a.width=a.currentWidth-a.margin.left-a.margin.right,a.height=a.currentHeight-a.margin.top-a.margin.bottom,a.width<0&&(a.width=0),a.height<0&&(a.height=0),a.width2=b.axis_rotated?a.margin.left-a.rotated_padding_left-a.rotated_padding_right:a.width,a.height2=b.axis_rotated?a.height:a.currentHeight-a.margin2.top-a.margin2.bottom,a.width2<0&&(a.width2=0),a.height2<0&&(a.height2=0),a.arcWidth=a.width-(a.isLegendRight?d+10:0),a.arcHeight=a.height-(a.isLegendRight?0:10),a.hasType("gauge")&&(a.arcHeight+=a.height-a.getGaugeLabelHeight()),a.updateRadius&&a.updateRadius(),a.isLegendRight&&f&&(a.margin3.left=a.arcWidth/2+1.1*a.radiusExpanded)},i.updateTargets=function(a){var b=this;b.updateTargetsForText(a),b.updateTargetsForBar(a),b.updateTargetsForLine(a),b.hasArcType()&&b.updateTargetsForArc&&b.updateTargetsForArc(a),b.updateTargetsForSubchart&&b.updateTargetsForSubchart(a),b.showTargets()},i.showTargets=function(){var a=this;a.svg.selectAll("."+l.target).filter(function(b){return a.isTargetToShow(b.id)}).transition().duration(a.config.transition_duration).style("opacity",1)},i.redraw=function(a,b){var c,d,e,f,g,h,i,j,k,m,n,o,p,q,r,s,t,u,v,x,y,z,A,B,C,D,E,F,G,H=this,I=H.main,J=H.d3,K=H.config,L=H.getShapeIndices(H.isAreaType),M=H.getShapeIndices(H.isBarType),N=H.getShapeIndices(H.isLineType),O=H.hasArcType(),P=H.filterTargetsToShow(H.data.targets),Q=H.xv.bind(H);if(a=a||{},c=w(a,"withY",!0),d=w(a,"withSubchart",!0),e=w(a,"withTransition",!0),h=w(a,"withTransform",!1),i=w(a,"withUpdateXDomain",!1),j=w(a,"withUpdateOrgXDomain",!1),k=w(a,"withTrimXDomain",!0),p=w(a,"withUpdateXAxis",i),m=w(a,"withLegend",!1),n=w(a,"withEventRect",!0),o=w(a,"withDimension",!0),f=w(a,"withTransitionForExit",e),g=w(a,"withTransitionForAxis",e),v=e?K.transition_duration:0,x=f?v:0,y=g?v:0,b=b||H.axis.generateTransitions(y),m&&K.legend_show?H.updateLegend(H.mapToIds(H.data.targets),a,b):o&&H.updateDimension(!0),H.isCategorized()&&0===P.length&&H.x.domain([0,H.axes.x.selectAll(".tick").size()]),P.length?(H.updateXDomain(P,i,j,k),K.axis_x_tick_values||(B=H.axis.updateXAxisTickValues(P))):(H.xAxis.tickValues([]),H.subXAxis.tickValues([])),K.zoom_rescale&&!a.flow&&(E=H.x.orgDomain()),H.y.domain(H.getYDomain(P,"y",E)),H.y2.domain(H.getYDomain(P,"y2",E)),!K.axis_y_tick_values&&K.axis_y_tick_count&&H.yAxis.tickValues(H.axis.generateTickValues(H.y.domain(),K.axis_y_tick_count)),!K.axis_y2_tick_values&&K.axis_y2_tick_count&&H.y2Axis.tickValues(H.axis.generateTickValues(H.y2.domain(),K.axis_y2_tick_count)),H.axis.redraw(b,O),H.axis.updateLabels(e),(i||p)&&P.length)if(K.axis_x_tick_culling&&B){for(C=1;C<B.length;C++)if(B.length/C<K.axis_x_tick_culling_max){D=C;break}H.svg.selectAll("."+l.axisX+" .tick text").each(function(a){var b=B.indexOf(a);b>=0&&J.select(this).style("display",b%D?"none":"block")})}else H.svg.selectAll("."+l.axisX+" .tick text").style("display","block");q=H.generateDrawArea?H.generateDrawArea(L,!1):void 0,r=H.generateDrawBar?H.generateDrawBar(M):void 0,s=H.generateDrawLine?H.generateDrawLine(N,!1):void 0,t=H.generateXYForText(L,M,N,!0),u=H.generateXYForText(L,M,N,!1),c&&(H.subY.domain(H.getYDomain(P,"y")),H.subY2.domain(H.getYDomain(P,"y2"))),H.tooltip.style("display","none"),H.updateXgridFocus(),I.select("text."+l.text+"."+l.empty).attr("x",H.width/2).attr("y",H.height/2).text(K.data_empty_label_text).transition().style("opacity",P.length?0:1),H.updateGrid(v),H.updateRegion(v),H.updateBar(x),H.updateLine(x),H.updateArea(x),H.updateCircle(),H.hasDataLabel()&&H.updateText(x),H.redrawArc&&H.redrawArc(v,x,h),H.redrawSubchart&&H.redrawSubchart(d,b,v,x,L,M,N),I.selectAll("."+l.selectedCircles).filter(H.isBarType.bind(H)).selectAll("circle").remove(),K.interaction_enabled&&!a.flow&&n&&(H.redrawEventRect(),H.updateZoom&&H.updateZoom()),H.updateCircleY(),F=(H.config.axis_rotated?H.circleY:H.circleX).bind(H),G=(H.config.axis_rotated?H.circleX:H.circleY).bind(H),a.flow&&(A=H.generateFlow({targets:P,flow:a.flow,duration:a.flow.duration,drawBar:r,drawLine:s,drawArea:q,cx:F,cy:G,xv:Q,xForText:t,yForText:u})),(v||A)&&H.isTabVisible()?J.transition().duration(v).each(function(){var b=[];[H.redrawBar(r,!0),H.redrawLine(s,!0),H.redrawArea(q,!0),H.redrawCircle(F,G,!0),H.redrawText(t,u,a.flow,!0),H.redrawRegion(!0),H.redrawGrid(!0)].forEach(function(a){a.forEach(function(a){b.push(a)})}),z=H.generateWait(),b.forEach(function(a){z.add(a)})}).call(z,function(){A&&A(),K.onrendered&&K.onrendered.call(H)}):(H.redrawBar(r),H.redrawLine(s),H.redrawArea(q),H.redrawCircle(F,G),H.redrawText(t,u,a.flow),H.redrawRegion(),H.redrawGrid(),K.onrendered&&K.onrendered.call(H)),H.mapToIds(H.data.targets).forEach(function(a){H.withoutFadeIn[a]=!0})},i.updateAndRedraw=function(a){var b,c=this,d=c.config;a=a||{},a.withTransition=w(a,"withTransition",!0),a.withTransform=w(a,"withTransform",!1),a.withLegend=w(a,"withLegend",!1),a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,a.withTransitionForTransform=w(a,"withTransitionForTransform",a.withTransition),c.updateSizes(),a.withLegend&&d.legend_show||(b=c.axis.generateTransitions(a.withTransitionForAxis?d.transition_duration:0),c.updateScales(),c.updateSvgSize(),c.transformAll(a.withTransitionForTransform,b)),c.redraw(a,b)},i.redrawWithoutRescale=function(){this.redraw({withY:!1,withSubchart:!1,withEventRect:!1,withTransitionForAxis:!1})},i.isTimeSeries=function(){return"timeseries"===this.config.axis_x_type},i.isCategorized=function(){return this.config.axis_x_type.indexOf("categor")>=0},i.isCustomX=function(){var a=this,b=a.config;return!a.isTimeSeries()&&(b.data_x||v(b.data_xs))},i.isTimeSeriesY=function(){return"timeseries"===this.config.axis_y_type},i.getTranslate=function(a){var b,c,d=this,e=d.config;return"main"===a?(b=s(d.margin.left),c=s(d.margin.top)):"context"===a?(b=s(d.margin2.left),c=s(d.margin2.top)):"legend"===a?(b=d.margin3.left,c=d.margin3.top):"x"===a?(b=0,c=e.axis_rotated?0:d.height):"y"===a?(b=0,c=e.axis_rotated?d.height:0):"y2"===a?(b=e.axis_rotated?0:d.width,c=e.axis_rotated?1:0):"subx"===a?(b=0,c=e.axis_rotated?0:d.height2):"arc"===a&&(b=d.arcWidth/2,c=d.arcHeight/2),"translate("+b+","+c+")"},i.initialOpacity=function(a){return null!==a.value&&this.withoutFadeIn[a.id]?1:0},i.initialOpacityForCircle=function(a){return null!==a.value&&this.withoutFadeIn[a.id]?this.opacityForCircle(a):0},i.opacityForCircle=function(a){var b=this.config.point_show?1:0;return m(a.value)?this.isScatterType(a)?.5:b:0},i.opacityForText=function(){return this.hasDataLabel()?1:0},i.xx=function(a){return a?this.x(a.x):null},i.xv=function(a){var b=this,c=a.value;return b.isTimeSeries()?c=b.parseDate(a.value):b.isCategorized()&&"string"==typeof a.value&&(c=b.config.axis_x_categories.indexOf(a.value)),Math.ceil(b.x(c))},i.yv=function(a){var b=this,c=a.axis&&"y2"===a.axis?b.y2:b.y;return Math.ceil(c(a.value))},i.subxx=function(a){return a?this.subX(a.x):null},i.transformMain=function(a,b){var c,d,e,f=this;b&&b.axisX?c=b.axisX:(c=f.main.select("."+l.axisX),a&&(c=c.transition())),b&&b.axisY?d=b.axisY:(d=f.main.select("."+l.axisY),a&&(d=d.transition())),b&&b.axisY2?e=b.axisY2:(e=f.main.select("."+l.axisY2),a&&(e=e.transition())),(a?f.main.transition():f.main).attr("transform",f.getTranslate("main")),c.attr("transform",f.getTranslate("x")),d.attr("transform",f.getTranslate("y")),e.attr("transform",f.getTranslate("y2")),f.main.select("."+l.chartArcs).attr("transform",f.getTranslate("arc"))},i.transformAll=function(a,b){var c=this;c.transformMain(a,b),c.config.subchart_show&&c.transformContext(a,b),c.legend&&c.transformLegend(a)},i.updateSvgSize=function(){var a=this,b=a.svg.select(".c3-brush .background");a.svg.attr("width",a.currentWidth).attr("height",a.currentHeight),a.svg.selectAll(["#"+a.clipId,"#"+a.clipIdForGrid]).select("rect").attr("width",a.width).attr("height",a.height),a.svg.select("#"+a.clipIdForXAxis).select("rect").attr("x",a.getXAxisClipX.bind(a)).attr("y",a.getXAxisClipY.bind(a)).attr("width",a.getXAxisClipWidth.bind(a)).attr("height",a.getXAxisClipHeight.bind(a)),a.svg.select("#"+a.clipIdForYAxis).select("rect").attr("x",a.getYAxisClipX.bind(a)).attr("y",a.getYAxisClipY.bind(a)).attr("width",a.getYAxisClipWidth.bind(a)).attr("height",a.getYAxisClipHeight.bind(a)),a.svg.select("#"+a.clipIdForSubchart).select("rect").attr("width",a.width).attr("height",b.size()?b.attr("height"):0),a.svg.select("."+l.zoomRect).attr("width",a.width).attr("height",a.height),a.selectChart.style("max-height",a.currentHeight+"px")},i.updateDimension=function(a){var b=this;a||(b.config.axis_rotated?(b.axes.x.call(b.xAxis),b.axes.subx.call(b.subXAxis)):(b.axes.y.call(b.yAxis),b.axes.y2.call(b.y2Axis))),b.updateSizes(),b.updateScales(),b.updateSvgSize(),b.transformAll(!1)},i.observeInserted=function(b){var c,d=this;return"undefined"==typeof MutationObserver?void a.console.error("MutationObserver not defined."):(c=new MutationObserver(function(e){e.forEach(function(e){"childList"===e.type&&e.previousSibling&&(c.disconnect(),d.intervalForObserveInserted=a.setInterval(function(){b.node().parentNode&&(a.clearInterval(d.intervalForObserveInserted),d.updateDimension(),d.config.oninit.call(d),d.redraw({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),b.transition().style("opacity",1))},10))})}),void c.observe(b.node(),{attributes:!0,childList:!0,characterData:!0}))},i.generateResize=function(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a},i.endall=function(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})},i.generateWait=function(){var a=[],b=function(b,c){var d=setInterval(function(){var b=0;a.forEach(function(a){if(a.empty())return void(b+=1);try{a.transition()}catch(c){b+=1}}),b===a.length&&(clearInterval(d),c&&c())},10)};return b.add=function(b){a.push(b)},b},i.parseDate=function(b){var c,d=this;return b instanceof Date?c=b:"string"==typeof b?c=d.dataTimeFormat(d.config.data_xFormat).parse(b):"number"!=typeof b&&isNaN(b)||(c=new Date(+b)),(!c||isNaN(+c))&&a.console.error("Failed to parse x '"+b+"' to Date object"),c},i.isTabVisible=function(){var a;return"undefined"!=typeof document.hidden?a="hidden":"undefined"!=typeof document.mozHidden?a="mozHidden":"undefined"!=typeof document.msHidden?a="msHidden":"undefined"!=typeof document.webkitHidden&&(a="webkitHidden"),document[a]?!1:!0},i.getDefaultConfig=function(){var a={bindto:"#chart",size_width:void 0,size_height:void 0,padding_left:void 0,padding_right:void 0,padding_top:void 0,padding_bottom:void 0,zoom_enabled:!1,zoom_extent:void 0,zoom_privileged:!1,zoom_rescale:!1,zoom_onzoom:function(){},zoom_onzoomstart:function(){},zoom_onzoomend:function(){},interaction_enabled:!0,onmouseover:function(){},onmouseout:function(){},onresize:function(){},onresized:function(){},oninit:function(){},onrendered:function(){},transition_duration:350,data_x:void 0,data_xs:{},data_xFormat:"%Y-%m-%d",data_xLocaltime:!0,data_xSort:!0,data_idConverter:function(a){return a},data_names:{},data_classes:{},data_groups:[],data_axes:{},data_type:void 0,data_types:{},data_labels:{},data_order:"desc",data_regions:{},data_color:void 0,data_colors:{},data_hide:!1,data_filter:void 0,data_selection_enabled:!1,data_selection_grouped:!1,data_selection_isselectable:function(){return!0},data_selection_multiple:!0,data_selection_draggable:!1,data_onclick:function(){},data_onmouseover:function(){},data_onmouseout:function(){},data_onselected:function(){},data_onunselected:function(){},data_url:void 0,data_json:void 0,data_rows:void 0,data_columns:void 0,data_mimeType:void 0,data_keys:void 0,data_empty_label_text:"",subchart_show:!1,subchart_size_height:60,subchart_onbrush:function(){},color_pattern:[],color_threshold:{},legend_show:!0,legend_hide:!1,legend_position:"bottom",legend_inset_anchor:"top-left",legend_inset_x:10,legend_inset_y:0,legend_inset_step:void 0,legend_item_onclick:void 0,legend_item_onmouseover:void 0,legend_item_onmouseout:void 0,legend_equally:!1,axis_rotated:!1,axis_x_show:!0,axis_x_type:"indexed",axis_x_localtime:!0,axis_x_categories:[],axis_x_tick_centered:!1,axis_x_tick_format:void 0,axis_x_tick_culling:{},axis_x_tick_culling_max:10,axis_x_tick_count:void 0,axis_x_tick_fit:!0,axis_x_tick_values:null,axis_x_tick_rotate:0,axis_x_tick_outer:!0,axis_x_tick_multiline:!0,axis_x_tick_width:null,axis_x_max:void 0,axis_x_min:void 0,axis_x_padding:{},axis_x_height:void 0,axis_x_extent:void 0,axis_x_label:{},axis_y_show:!0,axis_y_type:void 0,axis_y_max:void 0,axis_y_min:void 0,axis_y_inverted:!1,axis_y_center:void 0,axis_y_inner:void 0,axis_y_label:{},axis_y_tick_format:void 0,axis_y_tick_outer:!0,axis_y_tick_values:null,axis_y_tick_count:void 0,axis_y_tick_time_value:void 0,axis_y_tick_time_interval:void 0,axis_y_padding:{},axis_y_default:void 0,axis_y2_show:!1,axis_y2_max:void 0,axis_y2_min:void 0,axis_y2_inverted:!1,axis_y2_center:void 0,axis_y2_inner:void 0,axis_y2_label:{},axis_y2_tick_format:void 0,axis_y2_tick_outer:!0,axis_y2_tick_values:null,axis_y2_tick_count:void 0,axis_y2_padding:{},axis_y2_default:void 0,grid_x_show:!1,grid_x_type:"tick",grid_x_lines:[],grid_y_show:!1,grid_y_lines:[],grid_y_ticks:10,grid_focus_show:!0,grid_lines_front:!0,point_show:!0,point_r:2.5,point_focus_expand_enabled:!0,point_focus_expand_r:void 0,point_select_r:void 0,line_connectNull:!1,line_step_type:"step",bar_width:void 0,bar_width_ratio:.6,bar_width_max:void 0,bar_zerobased:!0,area_zerobased:!0,pie_label_show:!0,pie_label_format:void 0,pie_label_threshold:.05,pie_expand:!0,gauge_label_show:!0,gauge_label_format:void 0,gauge_expand:!0,gauge_min:0,gauge_max:100,gauge_units:void 0,gauge_width:void 0,donut_label_show:!0,donut_label_format:void 0,donut_label_threshold:.05,donut_width:void 0,donut_expand:!0,donut_title:"",regions:[],tooltip_show:!0,tooltip_grouped:!0,tooltip_format_title:void 0,tooltip_format_name:void 0,tooltip_format_value:void 0,tooltip_position:void 0,tooltip_contents:function(a,b,c,d){return this.getTooltipContent?this.getTooltipContent(a,b,c,d):""},tooltip_init_show:!1,tooltip_init_x:0,tooltip_init_position:{top:"0px",left:"50px"}};return Object.keys(this.additionalConfig).forEach(function(b){a[b]=this.additionalConfig[b]},this),a},i.additionalConfig={},i.loadConfig=function(a){function b(){var a=d.shift();return a&&c&&"object"==typeof c&&a in c?(c=c[a],b()):a?void 0:c}var c,d,e,f=this.config;Object.keys(f).forEach(function(g){c=a,d=g.split("_"),e=b(),q(e)&&(f[g]=e)})},i.getScale=function(a,b,c){return(c?this.d3.time.scale():this.d3.scale.linear()).range([a,b])},i.getX=function(a,b,c,d){var e,f=this,g=f.getScale(a,b,f.isTimeSeries()),h=c?g.domain(c):g;f.isCategorized()?(d=d||function(){return 0},g=function(a,b){var c=h(a)+d(a);return b?c:Math.ceil(c)}):g=function(a,b){var c=h(a);return b?c:Math.ceil(c)};for(e in h)g[e]=h[e];return g.orgDomain=function(){return h.domain()},f.isCategorized()&&(g.domain=function(a){return arguments.length?(h.domain(a),g):(a=this.orgDomain(),[a[0],a[1]+1])}),g},i.getY=function(a,b,c){var d=this.getScale(a,b,this.isTimeSeriesY());return c&&d.domain(c),d},i.getYScale=function(a){return"y2"===this.axis.getId(a)?this.y2:this.y},i.getSubYScale=function(a){return"y2"===this.axis.getId(a)?this.subY2:this.subY},i.updateScales=function(){var a=this,b=a.config,c=!a.x;a.xMin=b.axis_rotated?1:0,a.xMax=b.axis_rotated?a.height:a.width,a.yMin=b.axis_rotated?0:a.height,a.yMax=b.axis_rotated?a.width:1,a.subXMin=a.xMin,a.subXMax=a.xMax,a.subYMin=b.axis_rotated?0:a.height2,a.subYMax=b.axis_rotated?a.width2:1,a.x=a.getX(a.xMin,a.xMax,c?void 0:a.x.orgDomain(),function(){return a.xAxis.tickOffset()}),a.y=a.getY(a.yMin,a.yMax,c?b.axis_y_default:a.y.domain()),a.y2=a.getY(a.yMin,a.yMax,c?b.axis_y2_default:a.y2.domain()),a.subX=a.getX(a.xMin,a.xMax,a.orgXDomain,function(b){return b%1?0:a.subXAxis.tickOffset()}),a.subY=a.getY(a.subYMin,a.subYMax,c?b.axis_y_default:a.subY.domain()),a.subY2=a.getY(a.subYMin,a.subYMax,c?b.axis_y2_default:a.subY2.domain()),a.xAxisTickFormat=a.axis.getXAxisTickFormat(),a.xAxisTickValues=a.axis.getXAxisTickValues(),a.yAxisTickValues=a.axis.getYAxisTickValues(),a.y2AxisTickValues=a.axis.getY2AxisTickValues(),a.xAxis=a.axis.getXAxis(a.x,a.xOrient,a.xAxisTickFormat,a.xAxisTickValues,b.axis_x_tick_outer),a.subXAxis=a.axis.getXAxis(a.subX,a.subXOrient,a.xAxisTickFormat,a.xAxisTickValues,b.axis_x_tick_outer),a.yAxis=a.axis.getYAxis(a.y,a.yOrient,b.axis_y_tick_format,a.yAxisTickValues,b.axis_y_tick_outer),a.y2Axis=a.axis.getYAxis(a.y2,a.y2Orient,b.axis_y2_tick_format,a.y2AxisTickValues,b.axis_y2_tick_outer),c||(a.brush&&a.brush.scale(a.subX),b.zoom_enabled&&a.zoom.scale(a.x)),a.updateArc&&a.updateArc()},i.getYDomainMin=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i.data_groups.length>0)for(g=h.hasNegativeValueInTargets(a),b=0;b<i.data_groups.length;b++)if(e=i.data_groups[b].filter(function(a){return j.indexOf(a)>=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=0>a?a:0}),c=1;c<e.length;c++)f=e[c],k[f]&&k[f].forEach(function(a,b){h.axis.getId(f)!==h.axis.getId(d)||!k[d]||g&&+a>0||(k[d][b]+=+a)});return h.d3.min(Object.keys(k).map(function(a){return h.d3.min(k[a])}))},i.getYDomainMax=function(a){var b,c,d,e,f,g,h=this,i=h.config,j=h.mapToIds(a),k=h.getValuesAsIdKeyed(a);if(i.data_groups.length>0)for(g=h.hasPositiveValueInTargets(a),b=0;b<i.data_groups.length;b++)if(e=i.data_groups[b].filter(function(a){return j.indexOf(a)>=0}),0!==e.length)for(d=e[0],g&&k[d]&&k[d].forEach(function(a,b){k[d][b]=a>0?a:0}),c=1;c<e.length;c++)f=e[c],k[f]&&k[f].forEach(function(a,b){h.axis.getId(f)!==h.axis.getId(d)||!k[d]||g&&0>+a||(k[d][b]+=+a)});return h.d3.max(Object.keys(k).map(function(a){return h.d3.max(k[a])}))},i.getYDomain=function(a,b,c){var d,e,f,g,h,i,j,k,l,n,o,p=this,q=p.config,r=a.filter(function(a){return p.axis.getId(a.id)===b}),s=c?p.filterByXDomain(r,c):r,u="y2"===b?q.axis_y2_min:q.axis_y_min,w="y2"===b?q.axis_y2_max:q.axis_y_max,x=p.getYDomainMin(s),y=p.getYDomainMax(s),z="y2"===b?q.axis_y2_center:q.axis_y_center,A=p.hasType("bar",s)&&q.bar_zerobased||p.hasType("area",s)&&q.area_zerobased,B="y2"===b?q.axis_y2_inverted:q.axis_y_inverted,C=p.hasDataLabel()&&q.axis_rotated,D=p.hasDataLabel()&&!q.axis_rotated;return x=m(u)?u:m(w)?w>x?x:w-10:x,y=m(w)?w:m(u)?y>u?y:u+10:y,0===s.length?"y2"===b?p.y2.domain():p.y.domain():(isNaN(x)&&(x=0),isNaN(y)&&(y=x),x===y&&(0>x?y=0:x=0),n=x>=0&&y>=0,o=0>=x&&0>=y,(m(u)&&n||m(w)&&o)&&(A=!1),A&&(n&&(x=0),o&&(y=0)),e=Math.abs(y-x),f=g=h=.1*e,"undefined"!=typeof z&&(i=Math.max(Math.abs(x),Math.abs(y)),y=z+i,x=z-i),C?(j=p.getDataLabelLength(x,y,"width"),k=t(p.y.range()),l=[j[0]/k,j[1]/k],g+=e*(l[1]/(1-l[0]-l[1])),h+=e*(l[0]/(1-l[0]-l[1]))):D&&(j=p.getDataLabelLength(x,y,"height"),g+=p.axis.convertPixelsToAxisPadding(j[1],e),h+=p.axis.convertPixelsToAxisPadding(j[0],e)),"y"===b&&v(q.axis_y_padding)&&(g=p.axis.getPadding(q.axis_y_padding,"top",g,e),h=p.axis.getPadding(q.axis_y_padding,"bottom",h,e)),"y2"===b&&v(q.axis_y2_padding)&&(g=p.axis.getPadding(q.axis_y2_padding,"top",g,e),h=p.axis.getPadding(q.axis_y2_padding,"bottom",h,e)),A&&(n&&(h=x),o&&(g=-y)),d=[x-h,y+g],B?d.reverse():d)},i.getXDomainMin=function(a){var b=this,c=b.config;return q(c.axis_x_min)?b.isTimeSeries()?this.parseDate(c.axis_x_min):c.axis_x_min:b.d3.min(a,function(a){return b.d3.min(a.values,function(a){return a.x})})},i.getXDomainMax=function(a){var b=this,c=b.config;return q(c.axis_x_max)?b.isTimeSeries()?this.parseDate(c.axis_x_max):c.axis_x_max:b.d3.max(a,function(a){return b.d3.max(a.values,function(a){return a.x})})},i.getXDomainPadding=function(a){var b,c,d,e,f=this,g=f.config,h=a[1]-a[0];return f.isCategorized()?c=0:f.hasType("bar")?(b=f.getMaxDataCount(),c=b>1?h/(b-1)/2:.5):c=.01*h,"object"==typeof g.axis_x_padding&&v(g.axis_x_padding)?(d=m(g.axis_x_padding.left)?g.axis_x_padding.left:c,e=m(g.axis_x_padding.right)?g.axis_x_padding.right:c):d=e="number"==typeof g.axis_x_padding?g.axis_x_padding:c,{left:d,right:e}},i.getXDomain=function(a){var b=this,c=[b.getXDomainMin(a),b.getXDomainMax(a)],d=c[0],e=c[1],f=b.getXDomainPadding(c),g=0,h=0; +return d-e!==0||b.isCategorized()||(b.isTimeSeries()?(d=new Date(.5*d.getTime()),e=new Date(1.5*e.getTime())):(d=0===d?1:.5*d,e=0===e?-1:1.5*e)),(d||0===d)&&(g=b.isTimeSeries()?new Date(d.getTime()-f.left):d-f.left),(e||0===e)&&(h=b.isTimeSeries()?new Date(e.getTime()+f.right):e+f.right),[g,h]},i.updateXDomain=function(a,b,c,d,e){var f=this,g=f.config;return c&&(f.x.domain(e?e:f.d3.extent(f.getXDomain(a))),f.orgXDomain=f.x.domain(),g.zoom_enabled&&f.zoom.scale(f.x).updateScaleExtent(),f.subX.domain(f.x.domain()),f.brush&&f.brush.scale(f.subX)),b&&(f.x.domain(e?e:!f.brush||f.brush.empty()?f.orgXDomain:f.brush.extent()),g.zoom_enabled&&f.zoom.scale(f.x).updateScaleExtent()),d&&f.x.domain(f.trimXDomain(f.x.orgDomain())),f.x.domain()},i.trimXDomain=function(a){var b=this;return a[0]<=b.orgXDomain[0]&&(a[1]=+a[1]+(b.orgXDomain[0]-a[0]),a[0]=b.orgXDomain[0]),b.orgXDomain[1]<=a[1]&&(a[0]=+a[0]-(a[1]-b.orgXDomain[1]),a[1]=b.orgXDomain[1]),a},i.isX=function(a){var b=this,c=b.config;return c.data_x&&a===c.data_x||v(c.data_xs)&&x(c.data_xs,a)},i.isNotX=function(a){return!this.isX(a)},i.getXKey=function(a){var b=this,c=b.config;return c.data_x?c.data_x:v(c.data_xs)?c.data_xs[a]:null},i.getXValuesOfXKey=function(a,b){var c,d=this,e=b&&v(b)?d.mapToIds(b):[];return e.forEach(function(b){d.getXKey(b)===a&&(c=d.data.xs[b])}),c},i.getIndexByX=function(a){var b=this,c=b.filterByX(b.data.targets,a);return c.length?c[0].index:null},i.getXValue=function(a,b){var c=this;return a in c.data.xs&&c.data.xs[a]&&m(c.data.xs[a][b])?c.data.xs[a][b]:b},i.getOtherTargetXs=function(){var a=this,b=Object.keys(a.data.xs);return b.length?a.data.xs[b[0]]:null},i.getOtherTargetX=function(a){var b=this.getOtherTargetXs();return b&&a<b.length?b[a]:null},i.addXs=function(a){var b=this;Object.keys(a).forEach(function(c){b.config.data_xs[c]=a[c]})},i.hasMultipleX=function(a){return this.d3.set(Object.keys(a).map(function(b){return a[b]})).size()>1},i.isMultipleX=function(){return v(this.config.data_xs)||!this.config.data_xSort||this.hasType("scatter")},i.addName=function(a){var b,c=this;return a&&(b=c.config.data_names[a.id],a.name=b?b:a.id),a},i.getValueOnIndex=function(a,b){var c=a.filter(function(a){return a.index===b});return c.length?c[0]:null},i.updateTargetX=function(a,b){var c=this;a.forEach(function(a){a.values.forEach(function(d,e){d.x=c.generateTargetX(b[e],a.id,e)}),c.data.xs[a.id]=b})},i.updateTargetXs=function(a,b){var c=this;a.forEach(function(a){b[a.id]&&c.updateTargetX([a],b[a.id])})},i.generateTargetX=function(a,b,c){var d,e=this;return d=e.isTimeSeries()?e.parseDate(a?a:e.getXValue(b,c)):e.isCustomX()&&!e.isCategorized()?m(a)?+a:e.getXValue(b,c):c},i.cloneTarget=function(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}},i.updateXs=function(){var a=this;a.data.targets.length&&(a.xs=[],a.data.targets[0].values.forEach(function(b){a.xs[b.index]=b.x}))},i.getPrevX=function(a){var b=this.xs[a-1];return"undefined"!=typeof b?b:null},i.getNextX=function(a){var b=this.xs[a+1];return"undefined"!=typeof b?b:null},i.getMaxDataCount=function(){var a=this;return a.d3.max(a.data.targets,function(a){return a.values.length})},i.getMaxDataCountTarget=function(a){var b,c=a.length,d=0;return c>1?a.forEach(function(a){a.values.length>d&&(b=a,d=a.values.length)}):b=c?a[0]:null,b},i.getEdgeX=function(a){var b=this;return a.length?[b.d3.min(a,function(a){return a.values[0].x}),b.d3.max(a,function(a){return a.values[a.values.length-1].x})]:[0,0]},i.mapToIds=function(a){return a.map(function(a){return a.id})},i.mapToTargetIds=function(a){var b=this;return a?o(a)?[a]:a:b.mapToIds(b.data.targets)},i.hasTarget=function(a,b){var c,d=this.mapToIds(a);for(c=0;c<d.length;c++)if(d[c]===b)return!0;return!1},i.isTargetToShow=function(a){return this.hiddenTargetIds.indexOf(a)<0},i.isLegendToShow=function(a){return this.hiddenLegendIds.indexOf(a)<0},i.filterTargetsToShow=function(a){var b=this;return a.filter(function(a){return b.isTargetToShow(a.id)})},i.mapTargetsToUniqueXs=function(a){var b=this,c=b.d3.set(b.d3.merge(a.map(function(a){return a.values.map(function(a){return+a.x})}))).values();return c.map(b.isTimeSeries()?function(a){return new Date(+a)}:function(a){return+a})},i.addHiddenTargetIds=function(a){this.hiddenTargetIds=this.hiddenTargetIds.concat(a)},i.removeHiddenTargetIds=function(a){this.hiddenTargetIds=this.hiddenTargetIds.filter(function(b){return a.indexOf(b)<0})},i.addHiddenLegendIds=function(a){this.hiddenLegendIds=this.hiddenLegendIds.concat(a)},i.removeHiddenLegendIds=function(a){this.hiddenLegendIds=this.hiddenLegendIds.filter(function(b){return a.indexOf(b)<0})},i.getValuesAsIdKeyed=function(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b},i.checkValueInTargets=function(a,b){var c,d,e,f=Object.keys(a);for(c=0;c<f.length;c++)for(e=a[f[c]].values,d=0;d<e.length;d++)if(b(e[d].value))return!0;return!1},i.hasNegativeValueInTargets=function(a){return this.checkValueInTargets(a,function(a){return 0>a})},i.hasPositiveValueInTargets=function(a){return this.checkValueInTargets(a,function(a){return a>0})},i.isOrderDesc=function(){var a=this.config;return"string"==typeof a.data_order&&"desc"===a.data_order.toLowerCase()},i.isOrderAsc=function(){var a=this.config;return"string"==typeof a.data_order&&"asc"===a.data_order.toLowerCase()},i.orderTargets=function(a){var b=this,c=b.config,d=b.isOrderAsc(),e=b.isOrderDesc();return d||e?a.sort(function(a,b){var c=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(c,0),f=b.values.reduce(c,0);return d?f-e:e-f}):n(c.data_order)&&a.sort(c.data_order),a},i.filterByX=function(a,b){return this.d3.merge(a.map(function(a){return a.values})).filter(function(a){return a.x-b===0})},i.filterRemoveNull=function(a){return a.filter(function(a){return m(a.value)})},i.filterByXDomain=function(a,b){return a.map(function(a){return{id:a.id,id_org:a.id_org,values:a.values.filter(function(a){return b[0]<=a.x&&a.x<=b[1]})}})},i.hasDataLabel=function(){var a=this.config;return"boolean"==typeof a.data_labels&&a.data_labels?!0:"object"==typeof a.data_labels&&v(a.data_labels)?!0:!1},i.getDataLabelLength=function(a,b,c){var d=this,e=[0,0],f=1.3;return d.selectChart.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return d.dataLabelFormat(a.id)(a)}).each(function(a,b){e[b]=this.getBoundingClientRect()[c]*f}).remove(),e},i.isNoneArc=function(a){return this.hasTarget(this.data.targets,a.id)},i.isArc=function(a){return"data"in a&&this.hasTarget(this.data.targets,a.data.id)},i.findSameXOfValues=function(a,b){var c,d=a[b].x,e=[];for(c=b-1;c>=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c<a.length&&d===a[c].x;c++)e.push(a[c]);return e},i.findClosestFromTargets=function(a,b){var c,d=this;return c=a.map(function(a){return d.findClosest(a.values,b)}),d.findClosest(c,b)},i.findClosest=function(a,b){var c,d=this,e=100;return a.filter(function(a){return a&&d.isBarType(a.id)}).forEach(function(a){var b=d.main.select("."+l.bars+d.getTargetSelectorSuffix(a.id)+" ."+l.bar+"-"+a.index).node();!c&&d.isWithinBar(b)&&(c=a)}),a.filter(function(a){return a&&!d.isBarType(a.id)}).forEach(function(a){var f=d.dist(a,b);e>f&&(e=f,c=a)}),c},i.dist=function(a,b){var c=this,d=c.config,e=d.axis_rotated?1:0,f=d.axis_rotated?0:1,g=c.circleY(a,a.index),h=c.x(a.x);return Math.pow(h-b[e],2)+Math.pow(g-b[f],2)},i.convertValuesToStep=function(a){var b,c=[].concat(a);if(!this.isCategorized())return a;for(b=a.length+1;b>0;b--)c[b]=c[b-1];return c[0]={x:c[0].x-1,value:c[0].value,id:c[0].id},c[a.length+1]={x:c[a.length].x+1,value:c[a.length].value,id:c[a.length].id},c},i.updateDataAttributes=function(a,b){var c=this,d=c.config,e=d["data_"+a];return"undefined"==typeof b?e:(Object.keys(b).forEach(function(a){e[a]=b[a]}),c.redraw({withLegend:!0}),e)},i.convertUrlToData=function(a,b,c,d){var e=this,f=b?b:"csv";e.d3.xhr(a,function(a,b){var g;if(!b)throw new Error(a.responseURL+" "+a.status+" ("+a.statusText+")");g="json"===f?e.convertJsonToData(JSON.parse(b.response),c):"tsv"===f?e.convertTsvToData(b.response):e.convertCsvToData(b.response),d.call(e,g)})},i.convertXsvToData=function(a,b){var c,d=b.parseRows(a);return 1===d.length?(c=[{}],d[0].forEach(function(a){c[0][a]=null})):c=b.parse(a),c},i.convertCsvToData=function(a){return this.convertXsvToData(a,this.d3.csv)},i.convertTsvToData=function(a){return this.convertXsvToData(a,this.d3.tsv)},i.convertJsonToData=function(a,b){var c,d,e=this,f=[];return b?(b.x?(c=b.value.concat(b.x),e.config.data_x=b.x):c=b.value,f.push(c),a.forEach(function(a){var b=[];c.forEach(function(c){var d=p(a[c])?null:a[c];b.push(d)}),f.push(b)}),d=e.convertRowsToData(f)):(Object.keys(a).forEach(function(b){f.push([b].concat(a[b]))}),d=e.convertColumnsToData(f)),d},i.convertRowsToData=function(a){var b,c,d=a[0],e={},f=[];for(b=1;b<a.length;b++){for(e={},c=0;c<a[b].length;c++){if(p(a[b][c]))throw new Error("Source data is missing a component at ("+b+","+c+")!");e[d[c]]=a[b][c]}f.push(e)}return f},i.convertColumnsToData=function(a){var b,c,d,e=[];for(b=0;b<a.length;b++)for(d=a[b][0],c=1;c<a[b].length;c++){if(p(e[c-1])&&(e[c-1]={}),p(a[b][c]))throw new Error("Source data is missing a component at ("+b+","+c+")!");e[c-1][d]=a[b][c]}return e},i.convertDataToTargets=function(a,b){var c,d=this,e=d.config,f=d.d3.keys(a[0]).filter(d.isNotX,d),g=d.d3.keys(a[0]).filter(d.isX,d);return f.forEach(function(c){var f=d.getXKey(c);d.isCustomX()||d.isTimeSeries()?g.indexOf(f)>=0?d.data.xs[c]=(b&&d.data.xs[c]?d.data.xs[c]:[]).concat(a.map(function(a){return a[f]}).filter(m).map(function(a,b){return d.generateTargetX(a,c,b)})):e.data_x?d.data.xs[c]=d.getOtherTargetXs():v(e.data_xs)&&(d.data.xs[c]=d.getXValuesOfXKey(f,d.data.targets)):d.data.xs[c]=a.map(function(a,b){return b})}),f.forEach(function(a){if(!d.data.xs[a])throw new Error('x is not defined for id = "'+a+'".')}),c=f.map(function(b,c){var f=e.data_idConverter(b);return{id:f,id_org:b,values:a.map(function(a,g){var h=d.getXKey(b),i=a[h],j=d.generateTargetX(i,b,g);return d.isCustomX()&&d.isCategorized()&&0===c&&i&&(0===g&&(e.axis_x_categories=[]),e.axis_x_categories.push(i)),(p(a[b])||d.data.xs[b].length<=g)&&(j=void 0),{x:j,value:null===a[b]||isNaN(a[b])?null:+a[b],id:f}}).filter(function(a){return q(a.x)})}}),c.forEach(function(a){var b;e.data_xSort&&(a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d})),b=0,a.values.forEach(function(a){a.index=b++}),d.data.xs[a.id].sort(function(a,b){return a-b})}),e.data_type&&d.setTargetType(d.mapToIds(c).filter(function(a){return!(a in e.data_types)}),e.data_type),c.forEach(function(a){d.addCache(a.id_org,a)}),c},i.load=function(a,b){var c=this;a&&(b.filter&&(a=a.filter(b.filter)),(b.type||b.types)&&a.forEach(function(a){var d=b.types&&b.types[a.id]?b.types[a.id]:b.type;c.setTargetType(a.id,d)}),c.data.targets.forEach(function(b){for(var c=0;c<a.length;c++)if(b.id===a[c].id){b.values=a[c].values,a.splice(c,1);break}}),c.data.targets=c.data.targets.concat(a)),c.updateTargets(c.data.targets),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),b.done&&b.done()},i.loadFromArgs=function(a){var b=this;a.data?b.load(b.convertDataToTargets(a.data),a):a.url?b.convertUrlToData(a.url,a.mimeType,a.keys,function(c){b.load(b.convertDataToTargets(c),a)}):a.json?b.load(b.convertDataToTargets(b.convertJsonToData(a.json,a.keys)),a):a.rows?b.load(b.convertDataToTargets(b.convertRowsToData(a.rows)),a):a.columns?b.load(b.convertDataToTargets(b.convertColumnsToData(a.columns)),a):b.load(null,a)},i.unload=function(a,b){var c=this;return b||(b=function(){}),a=a.filter(function(a){return c.hasTarget(c.data.targets,a)}),a&&0!==a.length?(c.svg.selectAll(a.map(function(a){return c.selectorTarget(a)})).transition().style("opacity",0).remove().call(c.endall,b),void a.forEach(function(a){c.withoutFadeIn[a]=!1,c.legend&&c.legend.selectAll("."+l.legendItem+c.getTargetSelectorSuffix(a)).remove(),c.data.targets=c.data.targets.filter(function(b){return b.id!==a})})):void b()},i.categoryName=function(a){var b=this.config;return a<b.axis_x_categories.length?b.axis_x_categories[a]:a},i.initEventRect=function(){var a=this;a.main.select("."+l.chart).append("g").attr("class",l.eventRects).style("fill-opacity",0)},i.redrawEventRect=function(){var a,b,c=this,d=c.config,e=c.isMultipleX(),f=c.main.select("."+l.eventRects).style("cursor",d.zoom_enabled?d.axis_rotated?"ns-resize":"ew-resize":null).classed(l.eventRectsMultiple,e).classed(l.eventRectsSingle,!e);f.selectAll("."+l.eventRect).remove(),c.eventRect=f.selectAll("."+l.eventRect),e?(a=c.eventRect.data([0]),c.generateEventRectsForMultipleXs(a.enter()),c.updateEventRect(a)):(b=c.getMaxDataCountTarget(c.data.targets),f.datum(b?b.values:[]),c.eventRect=f.selectAll("."+l.eventRect),a=c.eventRect.data(function(a){return a}),c.generateEventRectsForSingleX(a.enter()),c.updateEventRect(a),a.exit().remove())},i.updateEventRect=function(a){var b,c,d,e,f,g,h=this,i=h.config;a=a||h.eventRect.data(function(a){return a}),h.isMultipleX()?(b=0,c=0,d=h.width,e=h.height):(!h.isCustomX()&&!h.isTimeSeries()||h.isCategorized()?(f=h.getEventRectWidth(),g=function(a){return h.x(a.x)-f/2}):(h.updateXs(),f=function(a){var b=h.getPrevX(a.index),c=h.getNextX(a.index);return null===b&&null===c?i.axis_rotated?h.height:h.width:(null===b&&(b=h.x.domain()[0]),null===c&&(c=h.x.domain()[1]),Math.max(0,(h.x(c)-h.x(b))/2))},g=function(a){var b=h.getPrevX(a.index),c=h.getNextX(a.index),d=h.data.xs[a.id][a.index];return null===b&&null===c?0:(null===b&&(b=h.x.domain()[0]),(h.x(d)+h.x(b))/2)}),b=i.axis_rotated?0:g,c=i.axis_rotated?g:0,d=i.axis_rotated?h.width:f,e=i.axis_rotated?f:h.height),a.attr("class",h.classEvent.bind(h)).attr("x",b).attr("y",c).attr("width",d).attr("height",e)},i.generateEventRectsForSingleX=function(a){var b=this,c=b.d3,d=b.config;a.append("rect").attr("class",b.classEvent.bind(b)).style("cursor",d.data_selection_enabled&&d.data_selection_grouped?"pointer":null).on("mouseover",function(a){var c=a.index;b.dragging||b.flowing||b.hasArcType()||(d.point_focus_expand_enabled&&b.expandCircles(c,null,!0),b.expandBars(c,null,!0),b.main.selectAll("."+l.shape+"-"+c).each(function(a){d.data_onmouseover.call(b.api,a)}))}).on("mouseout",function(a){var c=a.index;b.config&&(b.hasArcType()||(b.hideXGridFocus(),b.hideTooltip(),b.unexpandCircles(),b.unexpandBars(),b.main.selectAll("."+l.shape+"-"+c).each(function(a){d.data_onmouseout.call(b.api,a)})))}).on("mousemove",function(a){var e,f=a.index,g=b.svg.select("."+l.eventRect+"-"+f);b.dragging||b.flowing||b.hasArcType()||(b.isStepType(a)&&"step-after"===b.config.line_step_type&&c.mouse(this)[0]<b.x(b.getXValue(a.id,f))&&(f-=1),e=b.filterTargetsToShow(b.data.targets).map(function(a){return b.addName(b.getValueOnIndex(a.values,f))}),d.tooltip_grouped&&(b.showTooltip(e,this),b.showXGridFocus(e)),(!d.tooltip_grouped||d.data_selection_enabled&&!d.data_selection_grouped)&&b.main.selectAll("."+l.shape+"-"+f).each(function(){c.select(this).classed(l.EXPANDED,!0),d.data_selection_enabled&&g.style("cursor",d.data_selection_grouped?"pointer":null),d.tooltip_grouped||(b.hideXGridFocus(),b.hideTooltip(),d.data_selection_grouped||(b.unexpandCircles(f),b.unexpandBars(f)))}).filter(function(a){return b.isWithinShape(this,a)}).each(function(a){d.data_selection_enabled&&(d.data_selection_grouped||d.data_selection_isselectable(a))&&g.style("cursor","pointer"),d.tooltip_grouped||(b.showTooltip([a],this),b.showXGridFocus([a]),d.point_focus_expand_enabled&&b.expandCircles(f,a.id,!0),b.expandBars(f,a.id,!0))}))}).on("click",function(a){var e=a.index;if(!b.hasArcType()&&b.toggleShape){if(b.cancelClick)return void(b.cancelClick=!1);b.isStepType(a)&&"step-after"===d.line_step_type&&c.mouse(this)[0]<b.x(b.getXValue(a.id,e))&&(e-=1),b.main.selectAll("."+l.shape+"-"+e).each(function(a){(d.data_selection_grouped||b.isWithinShape(this,a))&&(b.toggleShape(this,a,e),b.config.data_onclick.call(b.api,a,this))})}}).call(d.data_selection_draggable&&b.drag?c.behavior.drag().origin(Object).on("drag",function(){b.drag(c.mouse(this))}).on("dragstart",function(){b.dragstart(c.mouse(this))}).on("dragend",function(){b.dragend()}):function(){})},i.generateEventRectsForMultipleXs=function(a){function b(){c.svg.select("."+l.eventRect).style("cursor",null),c.hideXGridFocus(),c.hideTooltip(),c.unexpandCircles(),c.unexpandBars()}var c=this,d=c.d3,e=c.config;a.append("rect").attr("x",0).attr("y",0).attr("width",c.width).attr("height",c.height).attr("class",l.eventRect).on("mouseout",function(){c.config&&(c.hasArcType()||b())}).on("mousemove",function(){var a,f,g,h,i=c.filterTargetsToShow(c.data.targets);if(!c.dragging&&!c.hasArcType(i)){if(a=d.mouse(this),f=c.findClosestFromTargets(i,a),!c.mouseover||f&&f.id===c.mouseover.id||(e.data_onmouseout.call(c.api,c.mouseover),c.mouseover=void 0),!f)return void b();g=c.isScatterType(f)||!e.tooltip_grouped?[f]:c.filterByX(i,f.x),h=g.map(function(a){return c.addName(a)}),c.showTooltip(h,this),e.point_focus_expand_enabled&&c.expandCircles(f.index,f.id,!0),c.expandBars(f.index,f.id,!0),c.showXGridFocus(h),(c.isBarType(f.id)||c.dist(f,a)<100)&&(c.svg.select("."+l.eventRect).style("cursor","pointer"),c.mouseover||(e.data_onmouseover.call(c.api,f),c.mouseover=f))}}).on("click",function(){var a,b,f=c.filterTargetsToShow(c.data.targets);c.hasArcType(f)||(a=d.mouse(this),b=c.findClosestFromTargets(f,a),b&&(c.isBarType(b.id)||c.dist(b,a)<100)&&c.main.selectAll("."+l.shapes+c.getTargetSelectorSuffix(b.id)).selectAll("."+l.shape+"-"+b.index).each(function(){(e.data_selection_grouped||c.isWithinShape(this,b))&&(c.toggleShape(this,b,b.index),c.config.data_onclick.call(c.api,b,this))}))}).call(e.data_selection_draggable&&c.drag?d.behavior.drag().origin(Object).on("drag",function(){c.drag(d.mouse(this))}).on("dragstart",function(){c.dragstart(d.mouse(this))}).on("dragend",function(){c.dragend()}):function(){})},i.dispatchEvent=function(b,c,d){var e=this,f="."+l.eventRect+(e.isMultipleX()?"":"-"+c),g=e.main.select(f).node(),h=g.getBoundingClientRect(),i=h.left+(d?d[0]:0),j=h.top+(d?d[1]:0),k=document.createEvent("MouseEvents");k.initMouseEvent(b,!0,!0,a,0,i,j,i,j,!1,!1,!1,!1,0,null),g.dispatchEvent(k)},i.getCurrentWidth=function(){var a=this,b=a.config;return b.size_width?b.size_width:a.getParentWidth()},i.getCurrentHeight=function(){var a=this,b=a.config,c=b.size_height?b.size_height:a.getParentHeight();return c>0?c:320/(a.hasType("gauge")?2:1)},i.getCurrentPaddingTop=function(){var a=this.config;return m(a.padding_top)?a.padding_top:0},i.getCurrentPaddingBottom=function(){var a=this.config;return m(a.padding_bottom)?a.padding_bottom:0},i.getCurrentPaddingLeft=function(a){var b=this,c=b.config;return m(c.padding_left)?c.padding_left:c.axis_rotated?c.axis_x_show?Math.max(r(b.getAxisWidthByAxisId("x",a)),40):1:!c.axis_y_show||c.axis_y_inner?b.axis.getYAxisLabelPosition().isOuter?30:1:r(b.getAxisWidthByAxisId("y",a))},i.getCurrentPaddingRight=function(){var a=this,b=a.config,c=10,d=a.isLegendRight?a.getLegendWidth()+20:0;return m(b.padding_right)?b.padding_right+1:b.axis_rotated?c+d:!b.axis_y2_show||b.axis_y2_inner?2+d+(a.axis.getY2AxisLabelPosition().isOuter?20:0):r(a.getAxisWidthByAxisId("y2"))+d},i.getParentRectValue=function(a){for(var b,c=this.selectChart.node();c&&"BODY"!==c.tagName;){try{b=c.getBoundingClientRect()[a]}catch(d){"width"===a&&(b=c.offsetWidth)}if(b)break;c=c.parentNode}return b},i.getParentWidth=function(){return this.getParentRectValue("width")},i.getParentHeight=function(){var a=this.selectChart.style("height");return a.indexOf("px")>0?+a.replace("px",""):0},i.getSvgLeft=function(a){var b=this,c=b.config,d=c.axis_rotated||!c.axis_rotated&&!c.axis_y_inner,e=c.axis_rotated?l.axisX:l.axisY,f=b.main.select("."+e).node(),g=f&&d?f.getBoundingClientRect():{right:0},h=b.selectChart.node().getBoundingClientRect(),i=b.hasArcType(),j=g.right-h.left-(i?0:b.getCurrentPaddingLeft(a));return j>0?j:0},i.getAxisWidthByAxisId=function(a,b){var c=this,d=c.axis.getLabelPositionById(a);return c.axis.getMaxTickWidth(a,b)+(d.isInner?20:40)},i.getHorizontalAxisHeight=function(a){var b=this,c=b.config,d=30;return"x"!==a||c.axis_x_show?"x"===a&&c.axis_x_height?c.axis_x_height:"y"!==a||c.axis_y_show?"y2"!==a||c.axis_y2_show?("x"===a&&!c.axis_rotated&&c.axis_x_tick_rotate&&(d=30+b.axis.getMaxTickWidth(a)*Math.cos(Math.PI*(90-c.axis_x_tick_rotate)/180)),d+(b.axis.getLabelPositionById(a).isInner?0:10)+("y2"===a?-10:0)):b.rotated_padding_top:!c.legend_show||b.isLegendRight||b.isLegendInset?1:10:8},i.getEventRectWidth=function(){return Math.max(0,this.xAxis.tickInterval())},i.getShapeIndices=function(a){var b,c,d=this,e=d.config,f={},g=0;return d.filterTargetsToShow(d.data.targets.filter(a,d)).forEach(function(a){for(b=0;b<e.data_groups.length;b++)if(!(e.data_groups[b].indexOf(a.id)<0))for(c=0;c<e.data_groups[b].length;c++)if(e.data_groups[b][c]in f){f[a.id]=f[e.data_groups[b][c]];break}p(f[a.id])&&(f[a.id]=g++)}),f.__max__=g-1,f},i.getShapeX=function(a,b,c,d){var e=this,f=d?e.subX:e.x;return function(d){var e=d.id in c?c[d.id]:0;return d.x||0===d.x?f(d.x)-a*(b/2-e):0}},i.getShapeY=function(a){var b=this;return function(c){var d=a?b.getSubYScale(c.id):b.getYScale(c.id);return d(c.value)}},i.getShapeOffset=function(a,b,c){var d=this,e=d.orderTargets(d.filterTargetsToShow(d.data.targets.filter(a,d))),f=e.map(function(a){return a.id});return function(a,g){var h=c?d.getSubYScale(a.id):d.getYScale(a.id),i=h(0),j=i;return e.forEach(function(c){var e=d.isStepType(a)?d.convertValuesToStep(c.values):c.values;c.id!==a.id&&b[c.id]===b[a.id]&&f.indexOf(c.id)<f.indexOf(a.id)&&e[g].value*a.value>=0&&(j+=h(e[g].value)-i)}),j}},i.isWithinShape=function(a,b){var c,d=this,e=d.d3.select(a);return d.isTargetToShow(b.id)?"circle"===a.nodeName?c=d.isStepType(b)?d.isWithinStep(a,d.getYScale(b.id)(b.value)):d.isWithinCircle(a,1.5*d.pointSelectR(b)):"path"===a.nodeName&&(c=e.classed(l.bar)?d.isWithinBar(a):!0):c=!1,c},i.getInterpolate=function(a){var b=this;return b.isSplineType(a)?"cardinal":b.isStepType(a)?b.config.line_step_type:"linear"},i.initLine=function(){var a=this;a.main.select("."+l.chart).append("g").attr("class",l.chartLines)},i.updateTargetsForLine=function(a){var b,c,d=this,e=d.config,f=d.classChartLine.bind(d),g=d.classLines.bind(d),h=d.classAreas.bind(d),i=d.classCircles.bind(d),j=d.classFocus.bind(d);b=d.main.select("."+l.chartLines).selectAll("."+l.chartLine).data(a).attr("class",function(a){return f(a)+j(a)}),c=b.enter().append("g").attr("class",f).style("opacity",0).style("pointer-events","none"),c.append("g").attr("class",g),c.append("g").attr("class",h),c.append("g").attr("class",function(a){return d.generateClass(l.selectedCircles,a.id)}),c.append("g").attr("class",i).style("cursor",function(a){return e.data_selection_isselectable(a)?"pointer":null}),a.forEach(function(a){d.main.selectAll("."+l.selectedCircles+d.getTargetSelectorSuffix(a.id)).selectAll("."+l.selectedCircle).each(function(b){b.value=a.values[b.index].value})})},i.updateLine=function(a){var b=this;b.mainLine=b.main.selectAll("."+l.lines).selectAll("."+l.line).data(b.lineData.bind(b)),b.mainLine.enter().append("path").attr("class",b.classLine.bind(b)).style("stroke",b.color),b.mainLine.style("opacity",b.initialOpacity.bind(b)).style("shape-rendering",function(a){return b.isStepType(a)?"crispEdges":""}).attr("transform",null),b.mainLine.exit().transition().duration(a).style("opacity",0).remove()},i.redrawLine=function(a,b){return[(b?this.mainLine.transition():this.mainLine).attr("d",a).style("stroke",this.color).style("opacity",1)]},i.generateDrawLine=function(a,b){var c=this,d=c.config,e=c.d3.svg.line(),f=c.generateGetLinePoints(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x(i).y(h):e.x(h).y(i),d.line_connectNull||(e=e.defined(function(a){return null!=a.value})),function(a){var f,h=d.line_connectNull?c.filterRemoveNull(a.values):a.values,i=b?c.x:c.subX,j=g.call(c,a.id),k=0,l=0;return c.isLineType(a)?d.data_regions[a.id]?f=c.lineWithRegions(h,i,j,d.data_regions[a.id]):(c.isStepType(a)&&(h=c.convertValuesToStep(h)),f=e.interpolate(c.getInterpolate(a))(h)):(h[0]&&(k=i(h[0].x),l=j(h[0].value)),f=d.axis_rotated?"M "+l+" "+k:"M "+k+" "+l),f?f:"M 0 0"}},i.generateGetLinePoints=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isLineType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0<a.value&&e>l||a.value<0&&l>e)&&(l=e),[[k,l-(e-j)],[k,l-(e-j)],[k,l-(e-j)],[k,l-(e-j)]]}},i.lineWithRegions=function(a,b,c,d){function e(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}function f(a){return"M"+a[0][0]+" "+a[0][1]+" "+a[1][0]+" "+a[1][1]}var g,h,i,j,k,l,m,n,o,r,s,t,u=this,v=u.config,w=-1,x="M",y=u.isCategorized()?.5:0,z=[];if(q(d))for(g=0;g<d.length;g++)z[g]={},z[g].start=p(d[g].start)?a[0].x:u.isTimeSeries()?u.parseDate(d[g].start):d[g].start,z[g].end=p(d[g].end)?a[a.length-1].x:u.isTimeSeries()?u.parseDate(d[g].end):d[g].end;for(s=v.axis_rotated?function(a){return c(a.value)}:function(a){return b(a.x)},t=v.axis_rotated?function(a){return b(a.x)}:function(a){return c(a.value)},i=u.isTimeSeries()?function(a,d,e,g){var h,i=a.x.getTime(),j=d.x-a.x,l=new Date(i+j*e),m=new Date(i+j*(e+g));return h=v.axis_rotated?[[c(k(e)),b(l)],[c(k(e+g)),b(m)]]:[[b(l),c(k(e))],[b(m),c(k(e+g))]],f(h)}:function(a,d,e,g){var h;return h=v.axis_rotated?[[c(k(e),!0),b(j(e))],[c(k(e+g),!0),b(j(e+g))]]:[[b(j(e),!0),c(k(e))],[b(j(e+g),!0),c(k(e+g))]],f(h)},g=0;g<a.length;g++){if(p(z)||!e(a[g].x,z))x+=" "+s(a[g])+" "+t(a[g]);else for(j=u.getScale(a[g-1].x+y,a[g].x+y,u.isTimeSeries()),k=u.getScale(a[g-1].value,a[g].value),l=b(a[g].x)-b(a[g-1].x),m=c(a[g].value)-c(a[g-1].value),n=Math.sqrt(Math.pow(l,2)+Math.pow(m,2)),o=2/n,r=2*o,h=o;1>=h;h+=r)x+=i(a[g-1],a[g],h,o);w=a[g].x}return x},i.updateArea=function(a){var b=this,c=b.d3;b.mainArea=b.main.selectAll("."+l.areas).selectAll("."+l.area).data(b.lineData.bind(b)),b.mainArea.enter().append("path").attr("class",b.classArea.bind(b)).style("fill",b.color).style("opacity",function(){return b.orgAreaOpacity=+c.select(this).style("opacity"),0}),b.mainArea.style("opacity",b.orgAreaOpacity),b.mainArea.exit().transition().duration(a).style("opacity",0).remove()},i.redrawArea=function(a,b){return[(b?this.mainArea.transition():this.mainArea).attr("d",a).style("fill",this.color).style("opacity",this.orgAreaOpacity)]},i.generateDrawArea=function(a,b){var c=this,d=c.config,e=c.d3.svg.area(),f=c.generateGetAreaPoints(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(c.getAreaBaseValue(a.id))},j=function(a,b){return d.data_groups.length>0?f(a,b)[1][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x0(i).x1(j).y(h):e.x(h).y0(i).y1(j),d.line_connectNull||(e=e.defined(function(a){return null!==a.value})),function(a){var b,f=d.line_connectNull?c.filterRemoveNull(a.values):a.values,g=0,h=0;return c.isAreaType(a)?(c.isStepType(a)&&(f=c.convertValuesToStep(f)),b=e.interpolate(c.getInterpolate(a))(f)):(f[0]&&(g=c.x(f[0].x),h=c.getYScale(a.id)(f[0].value)),b=d.axis_rotated?"M "+h+" "+g:"M "+g+" "+h),b?b:"M 0 0"}},i.getAreaBaseValue=function(){return 0},i.generateGetAreaPoints=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isAreaType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0<a.value&&e>l||a.value<0&&l>e)&&(l=e),[[k,j],[k,l-(e-j)],[k,l-(e-j)],[k,j]]}},i.updateCircle=function(){var a=this;a.mainCircle=a.main.selectAll("."+l.circles).selectAll("."+l.circle).data(a.lineOrScatterData.bind(a)),a.mainCircle.enter().append("circle").attr("class",a.classCircle.bind(a)).attr("r",a.pointR.bind(a)).style("fill",a.color),a.mainCircle.style("opacity",a.initialOpacityForCircle.bind(a)),a.mainCircle.exit().remove()},i.redrawCircle=function(a,b,c){var d=this.main.selectAll("."+l.selectedCircle);return[(c?this.mainCircle.transition():this.mainCircle).style("opacity",this.opacityForCircle.bind(this)).style("fill",this.color).attr("cx",a).attr("cy",b),(c?d.transition():d).attr("cx",a).attr("cy",b)]},i.circleX=function(a){return a.x||0===a.x?this.x(a.x):null},i.updateCircleY=function(){var a,b,c=this;c.config.data_groups.length>0?(a=c.getShapeIndices(c.isLineType),b=c.generateGetLinePoints(a),c.circleY=function(a,c){return b(a,c)[0][1]}):c.circleY=function(a){return c.getYScale(a.id)(a.value)}},i.getCircles=function(a,b){var c=this;return(b?c.main.selectAll("."+l.circles+c.getTargetSelectorSuffix(b)):c.main).selectAll("."+l.circle+(m(a)?"-"+a:""))},i.expandCircles=function(a,b,c){var d=this,e=d.pointExpandedR.bind(d);c&&d.unexpandCircles(),d.getCircles(a,b).classed(l.EXPANDED,!0).attr("r",e)},i.unexpandCircles=function(a){var b=this,c=b.pointR.bind(b);b.getCircles(a).filter(function(){return b.d3.select(this).classed(l.EXPANDED)}).classed(l.EXPANDED,!1).attr("r",c)},i.pointR=function(a){var b=this,c=b.config;return b.isStepType(a)?0:n(c.point_r)?c.point_r(a):c.point_r},i.pointExpandedR=function(a){var b=this,c=b.config;return c.point_focus_expand_enabled?c.point_focus_expand_r?c.point_focus_expand_r:1.75*b.pointR(a):b.pointR(a)},i.pointSelectR=function(a){var b=this,c=b.config;return c.point_select_r?c.point_select_r:4*b.pointR(a)},i.isWithinCircle=function(a,b){var c=this.d3,d=c.mouse(a),e=c.select(a),f=+e.attr("cx"),g=+e.attr("cy");return Math.sqrt(Math.pow(f-d[0],2)+Math.pow(g-d[1],2))<b},i.isWithinStep=function(a,b){return Math.abs(b-this.d3.mouse(a)[1])<30},i.initBar=function(){var a=this;a.main.select("."+l.chart).append("g").attr("class",l.chartBars)},i.updateTargetsForBar=function(a){var b,c,d=this,e=d.config,f=d.classChartBar.bind(d),g=d.classBars.bind(d),h=d.classFocus.bind(d);b=d.main.select("."+l.chartBars).selectAll("."+l.chartBar).data(a).attr("class",function(a){return f(a)+h(a)}),c=b.enter().append("g").attr("class",f).style("opacity",0).style("pointer-events","none"),c.append("g").attr("class",g).style("cursor",function(a){return e.data_selection_isselectable(a)?"pointer":null})},i.updateBar=function(a){var b=this,c=b.barData.bind(b),d=b.classBar.bind(b),e=b.initialOpacity.bind(b),f=function(a){return b.color(a.id)};b.mainBar=b.main.selectAll("."+l.bars).selectAll("."+l.bar).data(c),b.mainBar.enter().append("path").attr("class",d).style("stroke",f).style("fill",f),b.mainBar.style("opacity",e),b.mainBar.exit().transition().duration(a).style("opacity",0).remove()},i.redrawBar=function(a,b){return[(b?this.mainBar.transition():this.mainBar).attr("d",a).style("fill",this.color).style("opacity",1)]},i.getBarW=function(a,b){var c=this,d=c.config,e="number"==typeof d.bar_width?d.bar_width:b?a.tickInterval()*d.bar_width_ratio/b:0;return d.bar_width_max&&e>d.bar_width_max?d.bar_width_max:e},i.getBars=function(a,b){var c=this;return(b?c.main.selectAll("."+l.bars+c.getTargetSelectorSuffix(b)):c.main).selectAll("."+l.bar+(m(a)?"-"+a:""))},i.expandBars=function(a,b,c){var d=this;c&&d.unexpandBars(),d.getBars(a,b).classed(l.EXPANDED,!0)},i.unexpandBars=function(a){var b=this;b.getBars(a).classed(l.EXPANDED,!1)},i.generateDrawBar=function(a,b){var c=this,d=c.config,e=c.generateGetBarPoints(a,b);return function(a,b){var c=e(a,b),f=d.axis_rotated?1:0,g=d.axis_rotated?0:1,h="M "+c[0][f]+","+c[0][g]+" L"+c[1][f]+","+c[1][g]+" L"+c[2][f]+","+c[2][g]+" L"+c[3][f]+","+c[3][g]+" z";return h}},i.generateGetBarPoints=function(a,b){var c=this,d=b?c.subXAxis:c.xAxis,e=a.__max__+1,f=c.getBarW(d,e),g=c.getShapeX(f,e,a,!!b),h=c.getShapeY(!!b),i=c.getShapeOffset(c.isBarType,a,!!b),j=b?c.getSubYScale:c.getYScale; +return function(a,b){var d=j.call(c,a.id)(0),e=i(a,b)||d,k=g(a),l=h(a);return c.config.axis_rotated&&(0<a.value&&d>l||a.value<0&&l>d)&&(l=d),[[k,e],[k,l-(d-e)],[k+f,l-(d-e)],[k+f,e]]}},i.isWithinBar=function(a){var b=this.d3.mouse(a),c=a.getBoundingClientRect(),d=a.pathSegList.getItem(0),e=a.pathSegList.getItem(1),f=Math.min(d.x,e.x),g=Math.min(d.y,e.y),h=c.width,i=c.height,j=2,k=f-j,l=f+h+j,m=g+i+j,n=g-j;return k<b[0]&&b[0]<l&&n<b[1]&&b[1]<m},i.initText=function(){var a=this;a.main.select("."+l.chart).append("g").attr("class",l.chartTexts),a.mainText=a.d3.selectAll([])},i.updateTargetsForText=function(a){var b,c,d=this,e=d.classChartText.bind(d),f=d.classTexts.bind(d),g=d.classFocus.bind(d);b=d.main.select("."+l.chartTexts).selectAll("."+l.chartText).data(a).attr("class",function(a){return e(a)+g(a)}),c=b.enter().append("g").attr("class",e).style("opacity",0).style("pointer-events","none"),c.append("g").attr("class",f)},i.updateText=function(a){var b=this,c=b.config,d=b.barOrLineData.bind(b),e=b.classText.bind(b);b.mainText=b.main.selectAll("."+l.texts).selectAll("."+l.text).data(d),b.mainText.enter().append("text").attr("class",e).attr("text-anchor",function(a){return c.axis_rotated?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill",function(a){return b.color(a)}).style("fill-opacity",0),b.mainText.text(function(a,c,d){return b.dataLabelFormat(a.id)(a.value,a.id,c,d)}),b.mainText.exit().transition().duration(a).style("fill-opacity",0).remove()},i.redrawText=function(a,b,c,d){return[(d?this.mainText.transition():this.mainText).attr("x",a).attr("y",b).style("fill",this.color).style("fill-opacity",c?0:this.opacityForText.bind(this))]},i.getTextRect=function(a,b){var c,d=this.d3.select("body").append("div").classed("c3",!0),e=d.append("svg").style("visibility","hidden").style("position","fixed").style("top",0).style("left",0);return e.selectAll(".dummy").data([a]).enter().append("text").classed(b?b:"",!0).text(a).each(function(){c=this.getBoundingClientRect()}),d.remove(),c},i.generateXYForText=function(a,b,c,d){var e=this,f=e.generateGetAreaPoints(a,!1),g=e.generateGetBarPoints(b,!1),h=e.generateGetLinePoints(c,!1),i=d?e.getXForText:e.getYForText;return function(a,b){var c=e.isAreaType(a)?f:e.isBarType(a)?g:h;return i.call(e,c(a,b),a,this)}},i.getXForText=function(a,b,c){var d,e,f=this,g=c.getBoundingClientRect();return f.config.axis_rotated?(e=f.isBarType(b)?4:6,d=a[2][1]+e*(b.value<0?-1:1)):d=f.hasType("bar")?(a[2][0]+a[0][0])/2:a[0][0],null===b.value&&(d>f.width?d=f.width-g.width:0>d&&(d=4)),d},i.getYForText=function(a,b,c){var d,e=this,f=c.getBoundingClientRect();return e.config.axis_rotated?d=(a[0][0]+a[2][0]+.6*f.height)/2:(d=a[2][1],b.value<0?(d+=f.height,e.isBarType(b)&&e.isSafari()?d-=3:!e.isBarType(b)&&e.isChrome()&&(d+=3)):d+=e.isBarType(b)?-3:-6),null!==b.value||e.config.axis_rotated||(d<f.height?d=f.height:d>this.height&&(d=this.height-4)),d},i.setTargetType=function(a,b){var c=this,d=c.config;c.mapToTargetIds(a).forEach(function(a){c.withoutFadeIn[a]=b===d.data_types[a],d.data_types[a]=b}),a||(d.data_type=b)},i.hasType=function(a,b){var c=this,d=c.config.data_types,e=!1;return b=b||c.data.targets,b&&b.length?b.forEach(function(b){var c=d[b.id];(c&&c.indexOf(a)>=0||!c&&"line"===a)&&(e=!0)}):Object.keys(d).length?Object.keys(d).forEach(function(b){d[b]===a&&(e=!0)}):e=c.config.data_type===a,e},i.hasArcType=function(a){return this.hasType("pie",a)||this.hasType("donut",a)||this.hasType("gauge",a)},i.isLineType=function(a){var b=this.config,c=o(a)?a:a.id;return!b.data_types[c]||["line","spline","area","area-spline","step","area-step"].indexOf(b.data_types[c])>=0},i.isStepType=function(a){var b=o(a)?a:a.id;return["step","area-step"].indexOf(this.config.data_types[b])>=0},i.isSplineType=function(a){var b=o(a)?a:a.id;return["spline","area-spline"].indexOf(this.config.data_types[b])>=0},i.isAreaType=function(a){var b=o(a)?a:a.id;return["area","area-spline","area-step"].indexOf(this.config.data_types[b])>=0},i.isBarType=function(a){var b=o(a)?a:a.id;return"bar"===this.config.data_types[b]},i.isScatterType=function(a){var b=o(a)?a:a.id;return"scatter"===this.config.data_types[b]},i.isPieType=function(a){var b=o(a)?a:a.id;return"pie"===this.config.data_types[b]},i.isGaugeType=function(a){var b=o(a)?a:a.id;return"gauge"===this.config.data_types[b]},i.isDonutType=function(a){var b=o(a)?a:a.id;return"donut"===this.config.data_types[b]},i.isArcType=function(a){return this.isPieType(a)||this.isDonutType(a)||this.isGaugeType(a)},i.lineData=function(a){return this.isLineType(a)?[a]:[]},i.arcData=function(a){return this.isArcType(a.data)?[a]:[]},i.barData=function(a){return this.isBarType(a)?a.values:[]},i.lineOrScatterData=function(a){return this.isLineType(a)||this.isScatterType(a)?a.values:[]},i.barOrLineData=function(a){return this.isBarType(a)||this.isLineType(a)?a.values:[]},i.initGrid=function(){var a=this,b=a.config,c=a.d3;a.grid=a.main.append("g").attr("clip-path",a.clipPathForGrid).attr("class",l.grid),b.grid_x_show&&a.grid.append("g").attr("class",l.xgrids),b.grid_y_show&&a.grid.append("g").attr("class",l.ygrids),b.grid_focus_show&&a.grid.append("g").attr("class",l.xgridFocus).append("line").attr("class",l.xgridFocus),a.xgrid=c.selectAll([]),b.grid_lines_front||a.initGridLines()},i.initGridLines=function(){var a=this,b=a.d3;a.gridLines=a.main.append("g").attr("clip-path",a.clipPathForGrid).attr("class",l.grid+" "+l.gridLines),a.gridLines.append("g").attr("class",l.xgridLines),a.gridLines.append("g").attr("class",l.ygridLines),a.xgridLines=b.selectAll([])},i.updateXGrid=function(a){var b=this,c=b.config,d=b.d3,e=b.generateGridData(c.grid_x_type,b.x),f=b.isCategorized()?b.xAxis.tickOffset():0;b.xgridAttr=c.axis_rotated?{x1:0,x2:b.width,y1:function(a){return b.x(a)-f},y2:function(a){return b.x(a)-f}}:{x1:function(a){return b.x(a)+f},x2:function(a){return b.x(a)+f},y1:0,y2:b.height},b.xgrid=b.main.select("."+l.xgrids).selectAll("."+l.xgrid).data(e),b.xgrid.enter().append("line").attr("class",l.xgrid),a||b.xgrid.attr(b.xgridAttr).style("opacity",function(){return+d.select(this).attr(c.axis_rotated?"y1":"x1")===(c.axis_rotated?b.height:0)?0:1}),b.xgrid.exit().remove()},i.updateYGrid=function(){var a=this,b=a.config,c=a.yAxis.tickValues()||a.y.ticks(b.grid_y_ticks);a.ygrid=a.main.select("."+l.ygrids).selectAll("."+l.ygrid).data(c),a.ygrid.enter().append("line").attr("class",l.ygrid),a.ygrid.attr("x1",b.axis_rotated?a.y:0).attr("x2",b.axis_rotated?a.y:a.width).attr("y1",b.axis_rotated?0:a.y).attr("y2",b.axis_rotated?a.height:a.y),a.ygrid.exit().remove(),a.smoothLines(a.ygrid,"grid")},i.gridTextAnchor=function(a){return a.position?a.position:"end"},i.gridTextDx=function(a){return"start"===a.position?4:"middle"===a.position?0:-4},i.xGridTextX=function(a){return"start"===a.position?-this.height:"middle"===a.position?-this.height/2:0},i.yGridTextX=function(a){return"start"===a.position?0:"middle"===a.position?this.width/2:this.width},i.updateGrid=function(a){var b,c,d,e=this,f=e.main,g=e.config;e.grid.style("visibility",e.hasArcType()?"hidden":"visible"),f.select("line."+l.xgridFocus).style("visibility","hidden"),g.grid_x_show&&e.updateXGrid(),e.xgridLines=f.select("."+l.xgridLines).selectAll("."+l.xgridLine).data(g.grid_x_lines),b=e.xgridLines.enter().append("g").attr("class",function(a){return l.xgridLine+(a["class"]?" "+a["class"]:"")}),b.append("line").style("opacity",0),b.append("text").attr("text-anchor",e.gridTextAnchor).attr("transform",g.axis_rotated?"":"rotate(-90)").attr("dx",e.gridTextDx).attr("dy",-5).style("opacity",0),e.xgridLines.exit().transition().duration(a).style("opacity",0).remove(),g.grid_y_show&&e.updateYGrid(),e.ygridLines=f.select("."+l.ygridLines).selectAll("."+l.ygridLine).data(g.grid_y_lines),c=e.ygridLines.enter().append("g").attr("class",function(a){return l.ygridLine+(a["class"]?" "+a["class"]:"")}),c.append("line").style("opacity",0),c.append("text").attr("text-anchor",e.gridTextAnchor).attr("transform",g.axis_rotated?"rotate(-90)":"").attr("dx",e.gridTextDx).attr("dy",-5).style("opacity",0),d=e.yv.bind(e),e.ygridLines.select("line").transition().duration(a).attr("x1",g.axis_rotated?d:0).attr("x2",g.axis_rotated?d:e.width).attr("y1",g.axis_rotated?0:d).attr("y2",g.axis_rotated?e.height:d).style("opacity",1),e.ygridLines.select("text").transition().duration(a).attr("x",g.axis_rotated?e.xGridTextX.bind(e):e.yGridTextX.bind(e)).attr("y",d).text(function(a){return a.text}).style("opacity",1),e.ygridLines.exit().transition().duration(a).style("opacity",0).remove()},i.redrawGrid=function(a){var b=this,c=b.config,d=b.xv.bind(b),e=b.xgridLines.select("line"),f=b.xgridLines.select("text");return[(a?e.transition():e).attr("x1",c.axis_rotated?0:d).attr("x2",c.axis_rotated?b.width:d).attr("y1",c.axis_rotated?d:0).attr("y2",c.axis_rotated?d:b.height).style("opacity",1),(a?f.transition():f).attr("x",c.axis_rotated?b.yGridTextX.bind(b):b.xGridTextX.bind(b)).attr("y",d).text(function(a){return a.text}).style("opacity",1)]},i.showXGridFocus=function(a){var b=this,c=b.config,d=a.filter(function(a){return a&&m(a.value)}),e=b.main.selectAll("line."+l.xgridFocus),f=b.xx.bind(b);c.tooltip_show&&(b.hasType("scatter")||b.hasArcType()||(e.style("visibility","visible").data([d[0]]).attr(c.axis_rotated?"y1":"x1",f).attr(c.axis_rotated?"y2":"x2",f),b.smoothLines(e,"grid")))},i.hideXGridFocus=function(){this.main.select("line."+l.xgridFocus).style("visibility","hidden")},i.updateXgridFocus=function(){var a=this,b=a.config;a.main.select("line."+l.xgridFocus).attr("x1",b.axis_rotated?0:-10).attr("x2",b.axis_rotated?a.width:-10).attr("y1",b.axis_rotated?-10:0).attr("y2",b.axis_rotated?-10:a.height)},i.generateGridData=function(a,b){var c,d,e,f,g=this,h=[],i=g.main.select("."+l.axisX).selectAll(".tick").size();if("year"===a)for(c=g.getXDomain(),d=c[0].getFullYear(),e=c[1].getFullYear(),f=d;e>=f;f++)h.push(new Date(f+"-01-01 00:00:00"));else h=b.ticks(10),h.length>i&&(h=h.filter(function(a){return(""+a).indexOf(".")<0}));return h},i.getGridFilterToRemove=function(a){return a?function(b){var c=!1;return[].concat(a).forEach(function(a){("value"in a&&b.value===a.value||"class"in a&&b["class"]===a["class"])&&(c=!0)}),c}:function(){return!0}},i.removeGridLines=function(a,b){var c=this,d=c.config,e=c.getGridFilterToRemove(a),f=function(a){return!e(a)},g=b?l.xgridLines:l.ygridLines,h=b?l.xgridLine:l.ygridLine;c.main.select("."+g).selectAll("."+h).filter(e).transition().duration(d.transition_duration).style("opacity",0).remove(),b?d.grid_x_lines=d.grid_x_lines.filter(f):d.grid_y_lines=d.grid_y_lines.filter(f)},i.initTooltip=function(){var a,b=this,c=b.config;if(b.tooltip=b.selectChart.style("position","relative").append("div").attr("class",l.tooltipContainer).style("position","absolute").style("pointer-events","none").style("display","none"),c.tooltip_init_show){if(b.isTimeSeries()&&o(c.tooltip_init_x)){for(c.tooltip_init_x=b.parseDate(c.tooltip_init_x),a=0;a<b.data.targets[0].values.length&&b.data.targets[0].values[a].x-c.tooltip_init_x!==0;a++);c.tooltip_init_x=a}b.tooltip.html(c.tooltip_contents.call(b,b.data.targets.map(function(a){return b.addName(a.values[c.tooltip_init_x])}),b.axis.getXAxisTickFormat(),b.getYFormat(b.hasArcType()),b.color)),b.tooltip.style("top",c.tooltip_init_position.top).style("left",c.tooltip_init_position.left).style("display","block")}},i.getTooltipContent=function(a,b,c,d){var e,f,g,h,i,j,k=this,m=k.config,n=m.tooltip_format_title||b,o=m.tooltip_format_name||function(a){return a},p=m.tooltip_format_value||c;for(f=0;f<a.length;f++)a[f]&&(a[f].value||0===a[f].value)&&(e||(g=n?n(a[f].x):a[f].x,e="<table class='"+l.tooltip+"'>"+(g||0===g?"<tr><th colspan='2'>"+g+"</th></tr>":"")),h=p(a[f].value,a[f].ratio,a[f].id,a[f].index),void 0!==h&&(i=o(a[f].name,a[f].ratio,a[f].id,a[f].index),j=k.levelColor?k.levelColor(a[f].value):d(a[f].id),e+="<tr class='"+l.tooltipName+"-"+a[f].id+"'>",e+="<td class='name'><span style='background-color:"+j+"'></span>"+i+"</td>",e+="<td class='value'>"+h+"</td>",e+="</tr>"));return e+"</table>"},i.tooltipPosition=function(a,b,c,d){var e,f,g,h,i,j=this,k=j.config,l=j.d3,m=j.hasArcType(),n=l.mouse(d);return m?(f=(j.width-(j.isLegendRight?j.getLegendWidth():0))/2+n[0],h=j.height/2+n[1]+20):(e=j.getSvgLeft(!0),k.axis_rotated?(f=e+n[0]+100,g=f+b,i=j.currentWidth-j.getCurrentPaddingRight(),h=j.x(a[0].x)+20):(f=e+j.getCurrentPaddingLeft(!0)+j.x(a[0].x)+20,g=f+b,i=e+j.currentWidth-j.getCurrentPaddingRight(),h=n[1]+15),g>i&&(f-=g-i+20),h+c>j.currentHeight&&(h-=c+30)),0>h&&(h=0),{top:h,left:f}},i.showTooltip=function(a,b){var c,d,e,f=this,g=f.config,h=f.hasArcType(),j=a.filter(function(a){return a&&m(a.value)}),k=g.tooltip_position||i.tooltipPosition;0!==j.length&&g.tooltip_show&&(f.tooltip.html(g.tooltip_contents.call(f,a,f.axis.getXAxisTickFormat(),f.getYFormat(h),f.color)).style("display","block"),c=f.tooltip.property("offsetWidth"),d=f.tooltip.property("offsetHeight"),e=k.call(this,j,c,d,b),f.tooltip.style("top",e.top+"px").style("left",e.left+"px"))},i.hideTooltip=function(){this.tooltip.style("display","none")},i.initLegend=function(){var a=this;return a.legendItemTextBox={},a.legendHasRendered=!1,a.legend=a.svg.append("g").attr("transform",a.getTranslate("legend")),a.config.legend_show?void a.updateLegendWithDefaults():(a.legend.style("visibility","hidden"),void(a.hiddenLegendIds=a.mapToIds(a.data.targets)))},i.updateLegendWithDefaults=function(){var a=this;a.updateLegend(a.mapToIds(a.data.targets),{withTransform:!1,withTransitionForTransform:!1,withTransition:!1})},i.updateSizeForLegend=function(a,b){var c=this,d=c.config,e={top:c.isLegendTop?c.getCurrentPaddingTop()+d.legend_inset_y+5.5:c.currentHeight-a-c.getCurrentPaddingBottom()-d.legend_inset_y,left:c.isLegendLeft?c.getCurrentPaddingLeft()+d.legend_inset_x+.5:c.currentWidth-b-c.getCurrentPaddingRight()-d.legend_inset_x+.5};c.margin3={top:c.isLegendRight?0:c.isLegendInset?e.top:c.currentHeight-a,right:0/0,bottom:0,left:c.isLegendRight?c.currentWidth-b:c.isLegendInset?e.left:0}},i.transformLegend=function(a){var b=this;(a?b.legend.transition():b.legend).attr("transform",b.getTranslate("legend"))},i.updateLegendStep=function(a){this.legendStep=a},i.updateLegendItemWidth=function(a){this.legendItemWidth=a},i.updateLegendItemHeight=function(a){this.legendItemHeight=a},i.getLegendWidth=function(){var a=this;return a.config.legend_show?a.isLegendRight||a.isLegendInset?a.legendItemWidth*(a.legendStep+1):a.currentWidth:0},i.getLegendHeight=function(){var a=this,b=0;return a.config.legend_show&&(b=a.isLegendRight?a.currentHeight:Math.max(20,a.legendItemHeight)*(a.legendStep+1)),b},i.opacityForLegend=function(a){return a.classed(l.legendItemHidden)?null:1},i.opacityForUnfocusedLegend=function(a){return a.classed(l.legendItemHidden)?null:.3},i.toggleFocusLegend=function(a,b){var c=this;a=c.mapToTargetIds(a),c.legend.selectAll("."+l.legendItem).filter(function(b){return a.indexOf(b)>=0}).classed(l.legendItemFocused,b).transition().duration(100).style("opacity",function(){var a=b?c.opacityForLegend:c.opacityForUnfocusedLegend;return a.call(c,c.d3.select(this))})},i.revertLegend=function(){var a=this,b=a.d3;a.legend.selectAll("."+l.legendItem).classed(l.legendItemFocused,!1).transition().duration(100).style("opacity",function(){return a.opacityForLegend(b.select(this))})},i.showLegend=function(a){var b=this,c=b.config;c.legend_show||(c.legend_show=!0,b.legend.style("visibility","visible"),b.legendHasRendered||b.updateLegendWithDefaults()),b.removeHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("visibility","visible").transition().style("opacity",function(){return b.opacityForLegend(b.d3.select(this))})},i.hideLegend=function(a){var b=this,c=b.config;c.legend_show&&u(a)&&(c.legend_show=!1,b.legend.style("visibility","hidden")),b.addHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("opacity",0).style("visibility","hidden")},i.clearLegendItemTextBoxCache=function(){this.legendItemTextBox={}},i.updateLegend=function(a,b,c){function d(a,b){return u.legendItemTextBox[b]||(u.legendItemTextBox[b]=u.getTextRect(a.textContent,l.legendItem)),u.legendItemTextBox[b]}function e(b,c,e){function f(a,b){b||(g=(o-D-n)/2,B>g&&(g=(o-n)/2,D=0,J++)),I[a]=J,H[J]=u.isLegendInset?10:g,E[a]=D,D+=n}var g,h,i=0===e,j=e===a.length-1,k=d(b,c),l=k.width+C+(!j||u.isLegendRight||u.isLegendInset?y:0),m=k.height+x,n=u.isLegendRight||u.isLegendInset?m:l,o=u.isLegendRight||u.isLegendInset?u.getLegendHeight():u.getLegendWidth();return i&&(D=0,J=0,z=0,A=0),v.legend_show&&!u.isLegendToShow(c)?void(F[c]=G[c]=I[c]=E[c]=0):(F[c]=l,G[c]=m,(!z||l>=z)&&(z=l),(!A||m>=A)&&(A=m),h=u.isLegendRight||u.isLegendInset?A:z,void(v.legend_equally?(Object.keys(F).forEach(function(a){F[a]=z}),Object.keys(G).forEach(function(a){G[a]=A}),g=(o-h*a.length)/2,B>g?(D=0,J=0,a.forEach(function(a){f(a)})):f(c,!0)):f(c)))}var f,g,h,i,j,k,m,n,o,p,r,s,t,u=this,v=u.config,x=4,y=10,z=0,A=0,B=10,C=15,D=0,E={},F={},G={},H=[0],I={},J=0;b=b||{},n=w(b,"withTransition",!0),o=w(b,"withTransitionForTransform",!0),u.isLegendInset&&(J=v.legend_inset_step?v.legend_inset_step:a.length,u.updateLegendStep(J)),u.isLegendRight?(f=function(a){return z*I[a]},i=function(a){return H[I[a]]+E[a]}):u.isLegendInset?(f=function(a){return z*I[a]+10},i=function(a){return H[I[a]]+E[a]}):(f=function(a){return H[I[a]]+E[a]},i=function(a){return A*I[a]}),g=function(a,b){return f(a,b)+14},j=function(a,b){return i(a,b)+9},h=function(a,b){return f(a,b)},k=function(a,b){return i(a,b)-5},m=u.legend.selectAll("."+l.legendItem).data(a).enter().append("g").attr("class",function(a){return u.generateClass(l.legendItem,a)}).style("visibility",function(a){return u.isLegendToShow(a)?"visible":"hidden"}).style("cursor","pointer").on("click",function(a){v.legend_item_onclick?v.legend_item_onclick.call(u,a):u.d3.event.altKey?(u.api.hide(),u.api.show(a)):(u.api.toggle(a),u.isTargetToShow(a)?u.api.focus(a):u.api.revert())}).on("mouseover",function(a){u.d3.select(this).classed(l.legendItemFocused,!0),!u.transiting&&u.isTargetToShow(a)&&u.api.focus(a),v.legend_item_onmouseover&&v.legend_item_onmouseover.call(u,a)}).on("mouseout",function(a){u.d3.select(this).classed(l.legendItemFocused,!1),u.api.revert(),v.legend_item_onmouseout&&v.legend_item_onmouseout.call(u,a)}),m.append("text").text(function(a){return q(v.data_names[a])?v.data_names[a]:a}).each(function(a,b){e(this,a,b)}).style("pointer-events","none").attr("x",u.isLegendRight||u.isLegendInset?g:-200).attr("y",u.isLegendRight||u.isLegendInset?-200:j),m.append("rect").attr("class",l.legendItemEvent).style("fill-opacity",0).attr("x",u.isLegendRight||u.isLegendInset?h:-200).attr("y",u.isLegendRight||u.isLegendInset?-200:k),m.append("rect").attr("class",l.legendItemTile).style("pointer-events","none").style("fill",u.color).attr("x",u.isLegendRight||u.isLegendInset?g:-200).attr("y",u.isLegendRight||u.isLegendInset?-200:i).attr("width",10).attr("height",10),t=u.legend.select("."+l.legendBackground+" rect"),u.isLegendInset&&z>0&&0===t.size()&&(t=u.legend.insert("g","."+l.legendItem).attr("class",l.legendBackground).append("rect")),p=u.legend.selectAll("text").data(a).text(function(a){return q(v.data_names[a])?v.data_names[a]:a}).each(function(a,b){e(this,a,b)}),(n?p.transition():p).attr("x",g).attr("y",j),r=u.legend.selectAll("rect."+l.legendItemEvent).data(a),(n?r.transition():r).attr("width",function(a){return F[a]}).attr("height",function(a){return G[a]}).attr("x",h).attr("y",k),s=u.legend.selectAll("rect."+l.legendItemTile).data(a),(n?s.transition():s).style("fill",u.color).attr("x",f).attr("y",i),t&&(n?t.transition():t).attr("height",u.getLegendHeight()-12).attr("width",z*(J+1)+10),u.legend.selectAll("."+l.legendItem).classed(l.legendItemHidden,function(a){return!u.isTargetToShow(a)}),u.updateLegendItemWidth(z),u.updateLegendItemHeight(A),u.updateLegendStep(J),u.updateSizes(),u.updateScales(),u.updateSvgSize(),u.transformAll(o,c),u.legendHasRendered=!0},c(b,f),f.prototype.init=function(){var a=this.owner,b=a.config,c=a.main;a.axes.x=c.append("g").attr("class",l.axis+" "+l.axisX).attr("clip-path",a.clipPathForXAxis).attr("transform",a.getTranslate("x")).style("visibility",b.axis_x_show?"visible":"hidden"),a.axes.x.append("text").attr("class",l.axisXLabel).attr("transform",b.axis_rotated?"rotate(-90)":"").style("text-anchor",this.textAnchorForXAxisLabel.bind(this)),a.axes.y=c.append("g").attr("class",l.axis+" "+l.axisY).attr("clip-path",b.axis_y_inner?"":a.clipPathForYAxis).attr("transform",a.getTranslate("y")).style("visibility",b.axis_y_show?"visible":"hidden"),a.axes.y.append("text").attr("class",l.axisYLabel).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",this.textAnchorForYAxisLabel.bind(this)),a.axes.y2=c.append("g").attr("class",l.axis+" "+l.axisY2).attr("transform",a.getTranslate("y2")).style("visibility",b.axis_y2_show?"visible":"hidden"),a.axes.y2.append("text").attr("class",l.axisY2Label).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",this.textAnchorForY2AxisLabel.bind(this))},f.prototype.getXAxis=function(a,b,c,d,e,f,h){var i=this.owner,j=i.config,k={isCategory:i.isCategorized(),withOuterTick:e,tickMultiline:j.axis_x_tick_multiline,tickWidth:j.axis_x_tick_width,tickTextRotate:h?0:j.axis_x_tick_rotate,withoutTransition:f},l=g(i.d3,k).scale(a).orient(b);return i.isTimeSeries()&&d&&(d=d.map(function(a){return i.parseDate(a)})),l.tickFormat(c).tickValues(d),i.isCategorized()&&(l.tickCentered(j.axis_x_tick_centered),u(j.axis_x_tick_culling)&&(j.axis_x_tick_culling=!1)),l},f.prototype.updateXAxisTickValues=function(a,b){var c,d=this.owner,e=d.config;return(e.axis_x_tick_fit||e.axis_x_tick_count)&&(c=this.generateTickValues(d.mapTargetsToUniqueXs(a),e.axis_x_tick_count,d.isTimeSeries())),b?b.tickValues(c):(d.xAxis.tickValues(c),d.subXAxis.tickValues(c)),c},f.prototype.getYAxis=function(a,b,c,d,e,f){var h={withOuterTick:e,withoutTransition:f},i=this.owner,j=i.d3,k=i.config,l=g(j,h).scale(a).orient(b).tickFormat(c);return i.isTimeSeriesY()?l.ticks(j.time[k.axis_y_tick_time_value],k.axis_y_tick_time_interval):l.tickValues(d),l},f.prototype.getId=function(a){var b=this.owner.config;return a in b.data_axes?b.data_axes[a]:"y"},f.prototype.getXAxisTickFormat=function(){var a=this.owner,b=a.config,c=a.isTimeSeries()?a.defaultAxisTimeFormat:a.isCategorized()?a.categoryName:function(a){return 0>a?a.toFixed(0):a};return b.axis_x_tick_format&&(n(b.axis_x_tick_format)?c=b.axis_x_tick_format:a.isTimeSeries()&&(c=function(c){return c?a.axisTimeFormat(b.axis_x_tick_format)(c):""})),n(c)?function(b){return c.call(a,b)}:c},f.prototype.getTickValues=function(a,b){return a?a:b?b.tickValues():void 0},f.prototype.getXAxisTickValues=function(){return this.getTickValues(this.owner.config.axis_x_tick_values,this.owner.xAxis)},f.prototype.getYAxisTickValues=function(){return this.getTickValues(this.owner.config.axis_y_tick_values,this.owner.yAxis)},f.prototype.getY2AxisTickValues=function(){return this.getTickValues(this.owner.config.axis_y2_tick_values,this.owner.y2Axis)},f.prototype.getLabelOptionByAxisId=function(a){var b,c=this.owner,d=c.config;return"y"===a?b=d.axis_y_label:"y2"===a?b=d.axis_y2_label:"x"===a&&(b=d.axis_x_label),b},f.prototype.getLabelText=function(a){var b=this.getLabelOptionByAxisId(a);return o(b)?b:b?b.text:null},f.prototype.setLabelText=function(a,b){var c=this.owner,d=c.config,e=this.getLabelOptionByAxisId(a);o(e)?"y"===a?d.axis_y_label=b:"y2"===a?d.axis_y2_label=b:"x"===a&&(d.axis_x_label=b):e&&(e.text=b)},f.prototype.getLabelPosition=function(a,b){var c=this.getLabelOptionByAxisId(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}},f.prototype.getXAxisLabelPosition=function(){return this.getLabelPosition("x",this.owner.config.axis_rotated?"inner-top":"inner-right")},f.prototype.getYAxisLabelPosition=function(){return this.getLabelPosition("y",this.owner.config.axis_rotated?"inner-right":"inner-top")},f.prototype.getY2AxisLabelPosition=function(){return this.getLabelPosition("y2",this.owner.config.axis_rotated?"inner-right":"inner-top")},f.prototype.getLabelPositionById=function(a){return"y2"===a?this.getY2AxisLabelPosition():"y"===a?this.getYAxisLabelPosition():this.getXAxisLabelPosition()},f.prototype.textForXAxisLabel=function(){return this.getLabelText("x")},f.prototype.textForYAxisLabel=function(){return this.getLabelText("y")},f.prototype.textForY2AxisLabel=function(){return this.getLabelText("y2")},f.prototype.xForAxisLabel=function(a,b){var c=this.owner;return a?b.isLeft?0:b.isCenter?c.width/2:c.width:b.isBottom?-c.height:b.isMiddle?-c.height/2:0},f.prototype.dxForAxisLabel=function(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"},f.prototype.textAnchorForAxisLabel=function(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"},f.prototype.xForXAxisLabel=function(){return this.xForAxisLabel(!this.owner.config.axis_rotated,this.getXAxisLabelPosition())},f.prototype.xForYAxisLabel=function(){return this.xForAxisLabel(this.owner.config.axis_rotated,this.getYAxisLabelPosition())},f.prototype.xForY2AxisLabel=function(){return this.xForAxisLabel(this.owner.config.axis_rotated,this.getY2AxisLabelPosition())},f.prototype.dxForXAxisLabel=function(){return this.dxForAxisLabel(!this.owner.config.axis_rotated,this.getXAxisLabelPosition())},f.prototype.dxForYAxisLabel=function(){return this.dxForAxisLabel(this.owner.config.axis_rotated,this.getYAxisLabelPosition())},f.prototype.dxForY2AxisLabel=function(){return this.dxForAxisLabel(this.owner.config.axis_rotated,this.getY2AxisLabelPosition())},f.prototype.dyForXAxisLabel=function(){var a=this.owner,b=a.config,c=this.getXAxisLabelPosition();return b.axis_rotated?c.isInner?"1.2em":-25-this.getMaxTickWidth("x"):c.isInner?"-0.5em":b.axis_x_height?b.axis_x_height-10:"3em"},f.prototype.dyForYAxisLabel=function(){var a=this.owner,b=this.getYAxisLabelPosition();return a.config.axis_rotated?b.isInner?"-0.5em":"3em":b.isInner?"1.2em":-10-(a.config.axis_y_inner?0:this.getMaxTickWidth("y")+10)},f.prototype.dyForY2AxisLabel=function(){var a=this.owner,b=this.getY2AxisLabelPosition();return a.config.axis_rotated?b.isInner?"1.2em":"-2.2em":b.isInner?"-0.5em":15+(a.config.axis_y2_inner?0:this.getMaxTickWidth("y2")+15)},f.prototype.textAnchorForXAxisLabel=function(){var a=this.owner;return this.textAnchorForAxisLabel(!a.config.axis_rotated,this.getXAxisLabelPosition())},f.prototype.textAnchorForYAxisLabel=function(){var a=this.owner;return this.textAnchorForAxisLabel(a.config.axis_rotated,this.getYAxisLabelPosition())},f.prototype.textAnchorForY2AxisLabel=function(){var a=this.owner;return this.textAnchorForAxisLabel(a.config.axis_rotated,this.getY2AxisLabelPosition())},f.prototype.getMaxTickWidth=function(a,b){var c,d,e,f,g,h=this.owner,i=h.config,j=0;return b&&h.currentMaxTickWidths[a]?h.currentMaxTickWidths[a]:(h.svg&&(c=h.filterTargetsToShow(h.data.targets),"y"===a?(d=h.y.copy().domain(h.getYDomain(c,"y")),e=this.getYAxis(d,h.yOrient,i.axis_y_tick_format,h.yAxisTickValues,!1,!0)):"y2"===a?(d=h.y2.copy().domain(h.getYDomain(c,"y2")),e=this.getYAxis(d,h.y2Orient,i.axis_y2_tick_format,h.y2AxisTickValues,!1,!0)):(d=h.x.copy().domain(h.getXDomain(c)),e=this.getXAxis(d,h.xOrient,h.xAxisTickFormat,h.xAxisTickValues,!1,!0,!0),this.updateXAxisTickValues(c,e)),f=h.d3.select("body").append("div").classed("c3",!0),g=f.append("svg").style("visibility","hidden").style("position","fixed").style("top",0).style("left",0),g.append("g").call(e).each(function(){h.d3.select(this).selectAll("text").each(function(){var a=this.getBoundingClientRect();j<a.width&&(j=a.width)}),f.remove()})),h.currentMaxTickWidths[a]=0>=j?h.currentMaxTickWidths[a]:j,h.currentMaxTickWidths[a])},f.prototype.updateLabels=function(a){var b=this.owner,c=b.main.select("."+l.axisX+" ."+l.axisXLabel),d=b.main.select("."+l.axisY+" ."+l.axisYLabel),e=b.main.select("."+l.axisY2+" ."+l.axisY2Label);(a?c.transition():c).attr("x",this.xForXAxisLabel.bind(this)).attr("dx",this.dxForXAxisLabel.bind(this)).attr("dy",this.dyForXAxisLabel.bind(this)).text(this.textForXAxisLabel.bind(this)),(a?d.transition():d).attr("x",this.xForYAxisLabel.bind(this)).attr("dx",this.dxForYAxisLabel.bind(this)).attr("dy",this.dyForYAxisLabel.bind(this)).text(this.textForYAxisLabel.bind(this)),(a?e.transition():e).attr("x",this.xForY2AxisLabel.bind(this)).attr("dx",this.dxForY2AxisLabel.bind(this)).attr("dy",this.dyForY2AxisLabel.bind(this)).text(this.textForY2AxisLabel.bind(this))},f.prototype.getPadding=function(a,b,c,d){return m(a[b])?"ratio"===a.unit?a[b]*d:this.convertPixelsToAxisPadding(a[b],d):c},f.prototype.convertPixelsToAxisPadding=function(a,b){var c=this.owner,d=c.config.axis_rotated?c.width:c.height;return b*(a/d)},f.prototype.generateTickValues=function(a,b,c){var d,e,f,g,h,i,j,k=a;if(b)if(d=n(b)?b():b,1===d)k=[a[0]];else if(2===d)k=[a[0],a[a.length-1]];else if(d>2){for(g=d-2,e=a[0],f=a[a.length-1],h=(f-e)/(g+1),k=[e],i=0;g>i;i++)j=+e+h*(i+1),k.push(c?new Date(j):j);k.push(f)}return c||(k=k.sort(function(a,b){return a-b})),k},f.prototype.generateTransitions=function(a){var b=this.owner,c=b.axes;return{axisX:a?c.x.transition().duration(a):c.x,axisY:a?c.y.transition().duration(a):c.y,axisY2:a?c.y2.transition().duration(a):c.y2,axisSubX:a?c.subx.transition().duration(a):c.subx}},f.prototype.redraw=function(a,b){var c=this.owner;c.axes.x.style("opacity",b?0:1),c.axes.y.style("opacity",b?0:1),c.axes.y2.style("opacity",b?0:1),c.axes.subx.style("opacity",b?0:1),a.axisX.call(c.xAxis),a.axisY.call(c.yAxis),a.axisY2.call(c.y2Axis),a.axisSubX.call(c.subXAxis)},i.getClipPath=function(b){var c=a.navigator.appVersion.toLowerCase().indexOf("msie 9.")>=0;return"url("+(c?"":document.URL.split("#")[0])+"#"+b+")"},i.appendClip=function(a,b){return a.append("clipPath").attr("id",b).append("rect")},i.getAxisClipX=function(a){var b=Math.max(30,this.margin.left);return a?-(1+b):-(b-1)},i.getAxisClipY=function(a){return a?-20:-this.margin.top},i.getXAxisClipX=function(){var a=this;return a.getAxisClipX(!a.config.axis_rotated)},i.getXAxisClipY=function(){var a=this;return a.getAxisClipY(!a.config.axis_rotated)},i.getYAxisClipX=function(){var a=this;return a.config.axis_y_inner?-1:a.getAxisClipX(a.config.axis_rotated)},i.getYAxisClipY=function(){var a=this;return a.getAxisClipY(a.config.axis_rotated)},i.getAxisClipWidth=function(a){var b=this,c=Math.max(30,b.margin.left),d=Math.max(30,b.margin.right);return a?b.width+2+c+d:b.margin.left+20},i.getAxisClipHeight=function(a){return(a?this.margin.bottom:this.margin.top+this.height)+20},i.getXAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(!a.config.axis_rotated)},i.getXAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(!a.config.axis_rotated)},i.getYAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(a.config.axis_rotated)+(a.config.axis_y_inner?20:0)},i.getYAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(a.config.axis_rotated)},i.initPie=function(){var a=this,b=a.d3,c=a.config;a.pie=b.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)}),c.data_order||a.pie.sort(null)},i.updateRadius=function(){var a=this,b=a.config,c=b.gauge_width||b.donut_width;a.radiusExpanded=Math.min(a.arcWidth,a.arcHeight)/2,a.radius=.95*a.radiusExpanded,a.innerRadiusRatio=c?(a.radius-c)/a.radius:.6,a.innerRadius=a.hasType("donut")||a.hasType("gauge")?a.radius*a.innerRadiusRatio:0},i.updateArc=function(){var a=this;a.svgArc=a.getSvgArc(),a.svgArcExpanded=a.getSvgArcExpanded(),a.svgArcExpandedSub=a.getSvgArcExpanded(.98)},i.updateAngle=function(a){var b,c,d=this,e=d.config,f=!1,g=0,h=e.gauge_min,i=e.gauge_max; +return d.pie(d.filterTargetsToShow(d.data.targets)).forEach(function(b){f||b.data.id!==a.data.id||(f=!0,a=b,a.index=g),g++}),isNaN(a.startAngle)&&(a.startAngle=0),isNaN(a.endAngle)&&(a.endAngle=a.startAngle),d.isGaugeType(a.data)&&(b=Math.PI/(i-h),c=a.value<h?0:a.value<i?a.value-h:i-h,a.startAngle=-1*(Math.PI/2),a.endAngle=a.startAngle+b*c),f?a:null},i.getSvgArc=function(){var a=this,b=a.d3.svg.arc().outerRadius(a.radius).innerRadius(a.innerRadius),c=function(c,d){var e;return d?b(c):(e=a.updateAngle(c),e?b(e):"M 0 0")};return c.centroid=b.centroid,c},i.getSvgArcExpanded=function(a){var b=this,c=b.d3.svg.arc().outerRadius(b.radiusExpanded*(a?a:1)).innerRadius(b.innerRadius);return function(a){var d=b.updateAngle(a);return d?c(d):"M 0 0"}},i.getArc=function(a,b,c){return c||this.isArcType(a.data)?this.svgArc(a,b):"M 0 0"},i.transformForArcLabel=function(a){var b,c,d,e,f,g=this,h=g.updateAngle(a),i="";return h&&!g.hasType("gauge")&&(b=this.svgArc.centroid(h),c=isNaN(b[0])?0:b[0],d=isNaN(b[1])?0:b[1],e=Math.sqrt(c*c+d*d),f=g.radius&&e?(36/g.radius>.375?1.175-36/g.radius:.8)*g.radius/e:0,i="translate("+c*f+","+d*f+")"),i},i.getArcRatio=function(a){var b=this,c=b.hasType("gauge")?Math.PI:2*Math.PI;return a?(a.endAngle-a.startAngle)/c:null},i.convertToArcData=function(a){return this.addName({id:a.data.id,value:a.value,ratio:this.getArcRatio(a),index:a.index})},i.textForArcLabel=function(a){var b,c,d,e,f,g=this;return g.shouldShowArcLabel()?(b=g.updateAngle(a),c=b?b.value:null,d=g.getArcRatio(b),e=a.data.id,g.hasType("gauge")||g.meetsArcLabelThreshold(d)?(f=g.getArcLabelFormat(),f?f(c,d,e):g.defaultArcValueFormat(c,d)):""):""},i.expandArc=function(b){var c,d=this;return d.transiting?void(c=a.setInterval(function(){d.transiting||(a.clearInterval(c),d.legend.selectAll(".c3-legend-item-focused").size()>0&&d.expandArc(b))},10)):(b=d.mapToTargetIds(b),void d.svg.selectAll(d.selectorTargets(b,"."+l.chartArc)).each(function(a){d.shouldExpand(a.data.id)&&d.d3.select(this).selectAll("path").transition().duration(50).attr("d",d.svgArcExpanded).transition().duration(100).attr("d",d.svgArcExpandedSub).each(function(a){d.isDonutType(a.data)})}))},i.unexpandArc=function(a){var b=this;b.transiting||(a=b.mapToTargetIds(a),b.svg.selectAll(b.selectorTargets(a,"."+l.chartArc)).selectAll("path").transition().duration(50).attr("d",b.svgArc),b.svg.selectAll("."+l.arc).style("opacity",1))},i.shouldExpand=function(a){var b=this,c=b.config;return b.isDonutType(a)&&c.donut_expand||b.isGaugeType(a)&&c.gauge_expand||b.isPieType(a)&&c.pie_expand},i.shouldShowArcLabel=function(){var a=this,b=a.config,c=!0;return a.hasType("donut")?c=b.donut_label_show:a.hasType("pie")&&(c=b.pie_label_show),c},i.meetsArcLabelThreshold=function(a){var b=this,c=b.config,d=b.hasType("donut")?c.donut_label_threshold:c.pie_label_threshold;return a>=d},i.getArcLabelFormat=function(){var a=this,b=a.config,c=b.pie_label_format;return a.hasType("gauge")?c=b.gauge_label_format:a.hasType("donut")&&(c=b.donut_label_format),c},i.getArcTitle=function(){var a=this;return a.hasType("donut")?a.config.donut_title:""},i.updateTargetsForArc=function(a){var b,c,d=this,e=d.main,f=d.classChartArc.bind(d),g=d.classArcs.bind(d),h=d.classFocus.bind(d);b=e.select("."+l.chartArcs).selectAll("."+l.chartArc).data(d.pie(a)).attr("class",function(a){return f(a)+h(a.data)}),c=b.enter().append("g").attr("class",f),c.append("g").attr("class",g),c.append("text").attr("dy",d.hasType("gauge")?"-.1em":".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none")},i.initArc=function(){var a=this;a.arcs=a.main.select("."+l.chart).append("g").attr("class",l.chartArcs).attr("transform",a.getTranslate("arc")),a.arcs.append("text").attr("class",l.chartArcsTitle).style("text-anchor","middle").text(a.getArcTitle())},i.redrawArc=function(a,b,c){var d,e=this,f=e.d3,g=e.config,h=e.main;d=h.selectAll("."+l.arcs).selectAll("."+l.arc).data(e.arcData.bind(e)),d.enter().append("path").attr("class",e.classArc.bind(e)).style("fill",function(a){return e.color(a.data)}).style("cursor",function(a){return g.interaction_enabled&&g.data_selection_isselectable(a)?"pointer":null}).style("opacity",0).each(function(a){e.isGaugeType(a.data)&&(a.startAngle=a.endAngle=-1*(Math.PI/2)),this._current=a}),d.attr("transform",function(a){return!e.isGaugeType(a.data)&&c?"scale(0)":""}).style("opacity",function(a){return a===this._current?0:1}).on("mouseover",g.interaction_enabled?function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.expandArc(b.data.id),e.api.focus(b.data.id),e.toggleFocusLegend(b.data.id,!0),e.config.data_onmouseover(c,this))}:null).on("mousemove",g.interaction_enabled?function(a){var b=e.updateAngle(a),c=e.convertToArcData(b),d=[c];e.showTooltip(d,this)}:null).on("mouseout",g.interaction_enabled?function(a){var b,c;e.transiting||(b=e.updateAngle(a),c=e.convertToArcData(b),e.unexpandArc(b.data.id),e.api.revert(),e.revertLegend(),e.hideTooltip(),e.config.data_onmouseout(c,this))}:null).on("click",g.interaction_enabled?function(a,b){var c=e.updateAngle(a),d=e.convertToArcData(c);e.toggleShape&&e.toggleShape(this,d,b),e.config.data_onclick.call(e.api,d,this)}:null).each(function(){e.transiting=!0}).transition().duration(a).attrTween("d",function(a){var b,c=e.updateAngle(a);return c?(isNaN(this._current.startAngle)&&(this._current.startAngle=0),isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle),b=f.interpolate(this._current,c),this._current=b(0),function(c){var d=b(c);return d.data=a.data,e.getArc(d,!0)}):function(){return"M 0 0"}}).attr("transform",c?"scale(1)":"").style("fill",function(a){return e.levelColor?e.levelColor(a.data.values[0].value):e.color(a.data.id)}).style("opacity",1).call(e.endall,function(){e.transiting=!1}),d.exit().transition().duration(b).style("opacity",0).remove(),h.selectAll("."+l.chartArc).select("text").style("opacity",0).attr("class",function(a){return e.isGaugeType(a.data)?l.gaugeValue:""}).text(e.textForArcLabel.bind(e)).attr("transform",e.transformForArcLabel.bind(e)).style("font-size",function(a){return e.isGaugeType(a.data)?Math.round(e.radius/5)+"px":""}).transition().duration(a).style("opacity",function(a){return e.isTargetToShow(a.data.id)&&e.isArcType(a.data)?1:0}),h.select("."+l.chartArcsTitle).style("opacity",e.hasType("donut")||e.hasType("gauge")?1:0),e.hasType("gauge")&&(e.arcs.select("."+l.chartArcsBackground).attr("d",function(){var a={data:[{value:g.gauge_max}],startAngle:-1*(Math.PI/2),endAngle:Math.PI/2};return e.getArc(a,!0,!0)}),e.arcs.select("."+l.chartArcsGaugeUnit).attr("dy",".75em").text(g.gauge_label_show?g.gauge_units:""),e.arcs.select("."+l.chartArcsGaugeMin).attr("dx",-1*(e.innerRadius+(e.radius-e.innerRadius)/2)+"px").attr("dy","1.2em").text(g.gauge_label_show?g.gauge_min:""),e.arcs.select("."+l.chartArcsGaugeMax).attr("dx",e.innerRadius+(e.radius-e.innerRadius)/2+"px").attr("dy","1.2em").text(g.gauge_label_show?g.gauge_max:""))},i.initGauge=function(){var a=this.arcs;this.hasType("gauge")&&(a.append("path").attr("class",l.chartArcsBackground),a.append("text").attr("class",l.chartArcsGaugeUnit).style("text-anchor","middle").style("pointer-events","none"),a.append("text").attr("class",l.chartArcsGaugeMin).style("text-anchor","middle").style("pointer-events","none"),a.append("text").attr("class",l.chartArcsGaugeMax).style("text-anchor","middle").style("pointer-events","none"))},i.getGaugeLabelHeight=function(){return this.config.gauge_label_show?20:0},i.initRegion=function(){var a=this;a.region=a.main.append("g").attr("clip-path",a.clipPath).attr("class",l.regions)},i.updateRegion=function(a){var b=this,c=b.config;b.region.style("visibility",b.hasArcType()?"hidden":"visible"),b.mainRegion=b.main.select("."+l.regions).selectAll("."+l.region).data(c.regions),b.mainRegion.enter().append("g").attr("class",b.classRegion.bind(b)).append("rect").style("fill-opacity",0),b.mainRegion.exit().transition().duration(a).style("opacity",0).remove()},i.redrawRegion=function(a){var b=this,c=b.mainRegion.selectAll("rect"),d=b.regionX.bind(b),e=b.regionY.bind(b),f=b.regionWidth.bind(b),g=b.regionHeight.bind(b);return[(a?c.transition():c).attr("x",d).attr("y",e).attr("width",f).attr("height",g).style("fill-opacity",function(a){return m(a.opacity)?a.opacity:.1})]},i.regionX=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated&&"start"in a?e(a.start):0:d.axis_rotated?0:"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0},i.regionY=function(a){var b,c=this,d=c.config,e="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?0:"end"in a?e(a.end):0:d.axis_rotated&&"start"in a?c.x(c.isTimeSeries()?c.parseDate(a.start):a.start):0},i.regionWidth=function(a){var b,c=this,d=c.config,e=c.regionX(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated&&"end"in a?f(a.end):c.width:d.axis_rotated?c.width:"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.width,e>b?0:b-e},i.regionHeight=function(a){var b,c=this,d=c.config,e=this.regionY(a),f="y"===a.axis?c.y:c.y2;return b="y"===a.axis||"y2"===a.axis?d.axis_rotated?c.height:"start"in a?f(a.start):c.height:d.axis_rotated&&"end"in a?c.x(c.isTimeSeries()?c.parseDate(a.end):a.end):c.height,e>b?0:b-e},i.isRegionOnX=function(a){return!a.axis||"x"===a.axis},i.drag=function(a){var b,c,d,e,f,g,h,i,j=this,k=j.config,m=j.main,n=j.d3;j.hasArcType()||k.data_selection_enabled&&(!k.zoom_enabled||j.zoom.altDomain)&&k.data_selection_multiple&&(b=j.dragStart[0],c=j.dragStart[1],d=a[0],e=a[1],f=Math.min(b,d),g=Math.max(b,d),h=k.data_selection_grouped?j.margin.top:Math.min(c,e),i=k.data_selection_grouped?j.height:Math.max(c,e),m.select("."+l.dragarea).attr("x",f).attr("y",h).attr("width",g-f).attr("height",i-h),m.selectAll("."+l.shapes).selectAll("."+l.shape).filter(function(a){return k.data_selection_isselectable(a)}).each(function(a,b){var c,d,e,k,m,o,p=n.select(this),q=p.classed(l.SELECTED),r=p.classed(l.INCLUDED),s=!1;if(p.classed(l.circle))c=1*p.attr("cx"),d=1*p.attr("cy"),m=j.togglePoint,s=c>f&&g>c&&d>h&&i>d;else{if(!p.classed(l.bar))return;o=y(this),c=o.x,d=o.y,e=o.width,k=o.height,m=j.togglePath,s=!(c>g||f>c+e||d>i||h>d+k)}s^r&&(p.classed(l.INCLUDED,!r),p.classed(l.SELECTED,!q),m.call(j,!q,p,a,b))}))},i.dragstart=function(a){var b=this,c=b.config;b.hasArcType()||c.data_selection_enabled&&(b.dragStart=a,b.main.select("."+l.chart).append("rect").attr("class",l.dragarea).style("opacity",.1),b.dragging=!0)},i.dragend=function(){var a=this,b=a.config;a.hasArcType()||b.data_selection_enabled&&(a.main.select("."+l.dragarea).transition().duration(100).style("opacity",0).remove(),a.main.selectAll("."+l.shape).classed(l.INCLUDED,!1),a.dragging=!1)},i.selectPoint=function(a,b,c){var d=this,e=d.config,f=(e.axis_rotated?d.circleY:d.circleX).bind(d),g=(e.axis_rotated?d.circleX:d.circleY).bind(d),h=d.pointSelectR.bind(d);e.data_onselected.call(d.api,b,a.node()),d.main.select("."+l.selectedCircles+d.getTargetSelectorSuffix(b.id)).selectAll("."+l.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return d.generateClass(l.selectedCircle,c)}).attr("cx",f).attr("cy",g).attr("stroke",function(){return d.color(b)}).attr("r",function(a){return 1.4*d.pointSelectR(a)}).transition().duration(100).attr("r",h)},i.unselectPoint=function(a,b,c){var d=this;d.config.data_onunselected(b,a.node()),d.main.select("."+l.selectedCircles+d.getTargetSelectorSuffix(b.id)).selectAll("."+l.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()},i.togglePoint=function(a,b,c,d){a?this.selectPoint(b,c,d):this.unselectPoint(b,c,d)},i.selectPath=function(a,b){var c=this;c.config.data_onselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.d3.rgb(c.color(b)).brighter(.75)})},i.unselectPath=function(a,b){var c=this;c.config.data_onunselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.color(b)})},i.togglePath=function(a,b,c,d){a?this.selectPath(b,c,d):this.unselectPath(b,c,d)},i.getToggle=function(a,b){var c,d=this;return"circle"===a.nodeName?c=d.isStepType(b)?function(){}:d.togglePoint:"path"===a.nodeName&&(c=d.togglePath),c},i.toggleShape=function(a,b,c){var d=this,e=d.d3,f=d.config,g=e.select(a),h=g.classed(l.SELECTED),i=d.getToggle(a,b).bind(d);f.data_selection_enabled&&f.data_selection_isselectable(b)&&(f.data_selection_multiple||d.main.selectAll("."+l.shapes+(f.data_selection_grouped?d.getTargetSelectorSuffix(b.id):"")).selectAll("."+l.shape).each(function(a,b){var c=e.select(this);c.classed(l.SELECTED)&&i(!1,c.classed(l.SELECTED,!1),a,b)}),g.classed(l.SELECTED,!h),i(!h,g,b,c))},i.initBrush=function(){var a=this,b=a.d3;a.brush=b.svg.brush().on("brush",function(){a.redrawForBrush()}),a.brush.update=function(){return a.context&&a.context.select("."+l.brush).call(this),this},a.brush.scale=function(b){return a.config.axis_rotated?this.y(b):this.x(b)}},i.initSubchart=function(){var a=this,b=a.config,c=a.context=a.svg.append("g").attr("transform",a.getTranslate("context"));c.style("visibility",b.subchart_show?"visible":"hidden"),c.append("g").attr("clip-path",a.clipPathForSubchart).attr("class",l.chart),c.select("."+l.chart).append("g").attr("class",l.chartBars),c.select("."+l.chart).append("g").attr("class",l.chartLines),c.append("g").attr("clip-path",a.clipPath).attr("class",l.brush).call(a.brush),a.axes.subx=c.append("g").attr("class",l.axisX).attr("transform",a.getTranslate("subx")).attr("clip-path",b.axis_rotated?"":a.clipPathForXAxis)},i.updateTargetsForSubchart=function(a){var b,c,d,e,f=this,g=f.context,h=f.config,i=f.classChartBar.bind(f),j=f.classBars.bind(f),k=f.classChartLine.bind(f),m=f.classLines.bind(f),n=f.classAreas.bind(f);h.subchart_show&&(e=g.select("."+l.chartBars).selectAll("."+l.chartBar).data(a).attr("class",i),d=e.enter().append("g").style("opacity",0).attr("class",i),d.append("g").attr("class",j),c=g.select("."+l.chartLines).selectAll("."+l.chartLine).data(a).attr("class",k),b=c.enter().append("g").style("opacity",0).attr("class",k),b.append("g").attr("class",m),b.append("g").attr("class",n),g.selectAll("."+l.brush+" rect").attr(h.axis_rotated?"width":"height",h.axis_rotated?f.width2:f.height2))},i.updateBarForSubchart=function(a){var b=this;b.contextBar=b.context.selectAll("."+l.bars).selectAll("."+l.bar).data(b.barData.bind(b)),b.contextBar.enter().append("path").attr("class",b.classBar.bind(b)).style("stroke","none").style("fill",b.color),b.contextBar.style("opacity",b.initialOpacity.bind(b)),b.contextBar.exit().transition().duration(a).style("opacity",0).remove()},i.redrawBarForSubchart=function(a,b,c){(b?this.contextBar.transition().duration(c):this.contextBar).attr("d",a).style("opacity",1)},i.updateLineForSubchart=function(a){var b=this;b.contextLine=b.context.selectAll("."+l.lines).selectAll("."+l.line).data(b.lineData.bind(b)),b.contextLine.enter().append("path").attr("class",b.classLine.bind(b)).style("stroke",b.color),b.contextLine.style("opacity",b.initialOpacity.bind(b)),b.contextLine.exit().transition().duration(a).style("opacity",0).remove()},i.redrawLineForSubchart=function(a,b,c){(b?this.contextLine.transition().duration(c):this.contextLine).attr("d",a).style("opacity",1)},i.updateAreaForSubchart=function(a){var b=this,c=b.d3;b.contextArea=b.context.selectAll("."+l.areas).selectAll("."+l.area).data(b.lineData.bind(b)),b.contextArea.enter().append("path").attr("class",b.classArea.bind(b)).style("fill",b.color).style("opacity",function(){return b.orgAreaOpacity=+c.select(this).style("opacity"),0}),b.contextArea.style("opacity",0),b.contextArea.exit().transition().duration(a).style("opacity",0).remove()},i.redrawAreaForSubchart=function(a,b,c){(b?this.contextArea.transition().duration(c):this.contextArea).attr("d",a).style("fill",this.color).style("opacity",this.orgAreaOpacity)},i.redrawSubchart=function(a,b,c,d,e,f,g){var h,i,j,k=this,l=k.d3,m=k.config;k.context.style("visibility",m.subchart_show?"visible":"hidden"),m.subchart_show&&(l.event&&"zoom"===l.event.type&&k.brush.extent(k.x.orgDomain()).update(),a&&(k.brush.empty()||k.brush.extent(k.x.orgDomain()).update(),h=k.generateDrawArea(e,!0),i=k.generateDrawBar(f,!0),j=k.generateDrawLine(g,!0),k.updateBarForSubchart(c),k.updateLineForSubchart(c),k.updateAreaForSubchart(c),k.redrawBarForSubchart(i,c,c),k.redrawLineForSubchart(j,c,c),k.redrawAreaForSubchart(h,c,c)))},i.redrawForBrush=function(){var a=this,b=a.x;a.redraw({withTransition:!1,withY:a.config.zoom_rescale,withSubchart:!1,withUpdateXDomain:!0,withDimension:!1}),a.config.subchart_onbrush.call(a.api,b.orgDomain())},i.transformContext=function(a,b){var c,d=this;b&&b.axisSubX?c=b.axisSubX:(c=d.context.select("."+l.axisX),a&&(c=c.transition())),d.context.attr("transform",d.getTranslate("context")),c.attr("transform",d.getTranslate("subx"))},i.getDefaultExtent=function(){var a=this,b=a.config,c=n(b.axis_x_extent)?b.axis_x_extent(a.getXDomain(a.data.targets)):b.axis_x_extent;return a.isTimeSeries()&&(c=[a.parseDate(c[0]),a.parseDate(c[1])]),c},i.initZoom=function(){var a,b=this,c=b.d3,d=b.config;b.zoom=c.behavior.zoom().on("zoomstart",function(){a=c.event.sourceEvent,b.zoom.altDomain=c.event.sourceEvent.altKey?b.x.orgDomain():null,d.zoom_onzoomstart.call(b.api,c.event.sourceEvent)}).on("zoom",function(){b.redrawForZoom.call(b)}).on("zoomend",function(){var e=c.event.sourceEvent;e&&a.clientX===e.clientX&&a.clientY===e.clientY||(b.redrawEventRect(),b.updateZoom(),d.zoom_onzoomend.call(b.api,b.x.orgDomain()))}),b.zoom.scale=function(a){return d.axis_rotated?this.y(a):this.x(a)},b.zoom.orgScaleExtent=function(){var a=d.zoom_extent?d.zoom_extent:[1,10];return[a[0],Math.max(b.getMaxDataCount()/a[1],a[1])]},b.zoom.updateScaleExtent=function(){var a=t(b.x.orgDomain())/t(b.orgXDomain),c=this.orgScaleExtent();return this.scaleExtent([c[0]*a,c[1]*a]),this}},i.updateZoom=function(){var a=this,b=a.config.zoom_enabled?a.zoom:function(){};a.main.select("."+l.zoomRect).call(b).on("dblclick.zoom",null),a.main.selectAll("."+l.eventRect).call(b).on("dblclick.zoom",null)},i.redrawForZoom=function(){var a=this,b=a.d3,c=a.config,d=a.zoom,e=a.x;if(c.zoom_enabled&&0!==a.filterTargetsToShow(a.data.targets).length){if("mousemove"===b.event.sourceEvent.type&&d.altDomain)return e.domain(d.altDomain),void d.scale(e).updateScaleExtent();a.isCategorized()&&e.orgDomain()[0]===a.orgXDomain[0]&&e.domain([a.orgXDomain[0]-1e-10,e.orgDomain()[1]]),a.redraw({withTransition:!1,withY:c.zoom_rescale,withSubchart:!1,withEventRect:!1,withDimension:!1}),"mousemove"===b.event.sourceEvent.type&&(a.cancelClick=!0),c.zoom_onzoom.call(a.api,e.orgDomain())}},i.generateColor=function(){var a=this,b=a.config,c=a.d3,d=b.data_colors,e=v(b.color_pattern)?b.color_pattern:c.scale.category10().range(),f=b.data_color,g=[];return function(a){var b,c=a.id||a.data&&a.data.id||a;return d[c]instanceof Function?b=d[c](a):d[c]?b=d[c]:(g.indexOf(c)<0&&g.push(c),b=e[g.indexOf(c)%e.length],d[c]=b),f instanceof Function?f(b,a):b}},i.generateLevelColor=function(){var a=this,b=a.config,c=b.color_pattern,d=b.color_threshold,e="value"===d.unit,f=d.values&&d.values.length?d.values:[],g=d.max||100;return v(b.color_threshold)?function(a){var b,d,h=c[c.length-1];for(b=0;b<f.length;b++)if(d=e?a:100*a/g,d<f[b]){h=c[b];break}return h}:null},i.getYFormat=function(a){var b=this,c=a&&!b.hasType("gauge")?b.defaultArcValueFormat:b.yFormat,d=a&&!b.hasType("gauge")?b.defaultArcValueFormat:b.y2Format;return function(a,e,f){var g="y2"===b.axis.getId(f)?d:c;return g.call(b,a,e)}},i.yFormat=function(a){var b=this,c=b.config,d=c.axis_y_tick_format?c.axis_y_tick_format:b.defaultValueFormat;return d(a)},i.y2Format=function(a){var b=this,c=b.config,d=c.axis_y2_tick_format?c.axis_y2_tick_format:b.defaultValueFormat;return d(a)},i.defaultValueFormat=function(a){return m(a)?+a:""},i.defaultArcValueFormat=function(a,b){return(100*b).toFixed(1)+"%"},i.dataLabelFormat=function(a){var b,c=this,d=c.config.data_labels,e=function(a){return m(a)?+a:""};return b="function"==typeof d.format?d.format:"object"==typeof d.format?d.format[a]?d.format[a]===!0?e:d.format[a]:function(){return""}:e},i.hasCaches=function(a){for(var b=0;b<a.length;b++)if(!(a[b]in this.cache))return!1;return!0},i.addCache=function(a,b){this.cache[a]=this.cloneTarget(b)},i.getCaches=function(a){var b,c=[];for(b=0;b<a.length;b++)a[b]in this.cache&&c.push(this.cloneTarget(this.cache[a[b]]));return c};var l=i.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",focused:"c3-focused",defocused:"c3-defocused",region:"c3-region",regions:"c3-regions",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",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",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_"};i.generateClass=function(a,b){return" "+a+" "+a+this.getTargetSelectorSuffix(b)},i.classText=function(a){return this.generateClass(l.text,a.index)},i.classTexts=function(a){return this.generateClass(l.texts,a.id)},i.classShape=function(a){return this.generateClass(l.shape,a.index)},i.classShapes=function(a){return this.generateClass(l.shapes,a.id)},i.classLine=function(a){return this.classShape(a)+this.generateClass(l.line,a.id)},i.classLines=function(a){return this.classShapes(a)+this.generateClass(l.lines,a.id)},i.classCircle=function(a){return this.classShape(a)+this.generateClass(l.circle,a.index)},i.classCircles=function(a){return this.classShapes(a)+this.generateClass(l.circles,a.id)},i.classBar=function(a){return this.classShape(a)+this.generateClass(l.bar,a.index)},i.classBars=function(a){return this.classShapes(a)+this.generateClass(l.bars,a.id)},i.classArc=function(a){return this.classShape(a.data)+this.generateClass(l.arc,a.data.id)},i.classArcs=function(a){return this.classShapes(a.data)+this.generateClass(l.arcs,a.data.id)},i.classArea=function(a){return this.classShape(a)+this.generateClass(l.area,a.id)},i.classAreas=function(a){return this.classShapes(a)+this.generateClass(l.areas,a.id)},i.classRegion=function(a,b){return this.generateClass(l.region,b)+" "+("class"in a?a["class"]:"")},i.classEvent=function(a){return this.generateClass(l.eventRect,a.index)},i.classTarget=function(a){var b=this,c=b.config.data_classes[a],d="";return c&&(d=" "+l.target+"-"+c),b.generateClass(l.target,a)+d},i.classFocus=function(a){return this.classFocused(a)+this.classDefocused(a)},i.classFocused=function(a){return" "+(this.focusedTargetIds.indexOf(a.id)>=0?l.focused:"")},i.classDefocused=function(a){return" "+(this.defocusedTargetIds.indexOf(a.id)>=0?l.defocused:"")},i.classChartText=function(a){return l.chartText+this.classTarget(a.id)},i.classChartLine=function(a){return l.chartLine+this.classTarget(a.id)},i.classChartBar=function(a){return l.chartBar+this.classTarget(a.id)},i.classChartArc=function(a){return l.chartArc+this.classTarget(a.data.id)},i.getTargetSelectorSuffix=function(a){return a||0===a?("-"+a).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g,"-"):""},i.selectorTarget=function(a,b){return(b||"")+"."+l.target+this.getTargetSelectorSuffix(a)},i.selectorTargets=function(a,b){var c=this;return a=a||[],a.length?a.map(function(a){return c.selectorTarget(a,b)}):null},i.selectorLegend=function(a){return"."+l.legendItem+this.getTargetSelectorSuffix(a)},i.selectorLegends=function(a){var b=this;return a&&a.length?a.map(function(a){return b.selectorLegend(a)}):null};var m=i.isValue=function(a){return a||0===a},n=i.isFunction=function(a){return"function"==typeof a},o=i.isString=function(a){return"string"==typeof a},p=i.isUndefined=function(a){return"undefined"==typeof a},q=i.isDefined=function(a){return"undefined"!=typeof a},r=i.ceil10=function(a){return 10*Math.ceil(a/10)},s=i.asHalfPixel=function(a){return Math.ceil(a)+.5},t=i.diffDomain=function(a){return a[1]-a[0]},u=i.isEmpty=function(a){return!a||o(a)&&0===a.length||"object"==typeof a&&0===Object.keys(a).length},v=i.notEmpty=function(a){return Object.keys(a).length>0},w=i.getOption=function(a,b,c){return q(a[b])?a[b]:c},x=i.hasValue=function(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c},y=i.getPathBox=function(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}};h.focus=function(a){var b,c=this.internal;a=c.mapToTargetIds(a),b=c.svg.selectAll(c.selectorTargets(a.filter(c.isTargetToShow,c))),this.revert(),this.defocus(),b.classed(l.focused,!0).classed(l.defocused,!1),c.hasArcType()&&c.expandArc(a),c.toggleFocusLegend(a,!0),c.focusedTargetIds=a,c.defocusedTargetIds=c.defocusedTargetIds.filter(function(b){return a.indexOf(b)<0})},h.defocus=function(a){var b,c=this.internal;a=c.mapToTargetIds(a),b=c.svg.selectAll(c.selectorTargets(a.filter(c.isTargetToShow,c))),b.classed(l.focused,!1).classed(l.defocused,!0),c.hasArcType()&&c.unexpandArc(a),c.toggleFocusLegend(a,!1),c.focusedTargetIds=c.focusedTargetIds.filter(function(b){return a.indexOf(b)<0}),c.defocusedTargetIds=a},h.revert=function(a){var b,c=this.internal;a=c.mapToTargetIds(a),b=c.svg.selectAll(c.selectorTargets(a)),b.classed(l.focused,!1).classed(l.defocused,!1),c.hasArcType()&&c.unexpandArc(a),c.config.legend_show&&(c.showLegend(a.filter(c.isLegendToShow.bind(c))),c.legend.selectAll(c.selectorLegends(a)).filter(function(){return c.d3.select(this).classed(l.legendItemFocused)}).classed(l.legendItemFocused,!1)),c.focusedTargetIds=[],c.defocusedTargetIds=[]},h.show=function(a,b){var c,d=this.internal;a=d.mapToTargetIds(a),b=b||{},d.removeHiddenTargetIds(a),c=d.svg.selectAll(d.selectorTargets(a)),c.transition().style("opacity",1,"important").call(d.endall,function(){c.style("opacity",null).style("opacity",1)}),b.withLegend&&d.showLegend(a),d.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},h.hide=function(a,b){var c,d=this.internal;a=d.mapToTargetIds(a),b=b||{},d.addHiddenTargetIds(a),c=d.svg.selectAll(d.selectorTargets(a)),c.transition().style("opacity",0,"important").call(d.endall,function(){c.style("opacity",null).style("opacity",0)}),b.withLegend&&d.hideLegend(a),d.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},h.toggle=function(a,b){var c=this,d=this.internal;d.mapToTargetIds(a).forEach(function(a){d.isTargetToShow(a)?c.hide(a,b):c.show(a,b)})},h.zoom=function(a){var b=this.internal;return a&&(b.isTimeSeries()&&(a=a.map(function(a){return b.parseDate(a)})),b.brush.extent(a),b.redraw({withUpdateXDomain:!0,withY:b.config.zoom_rescale}),b.config.zoom_onzoom.call(this,b.x.orgDomain())),b.brush.extent()},h.zoom.enable=function(a){var b=this.internal;b.config.zoom_enabled=a,b.updateAndRedraw()},h.unzoom=function(){var a=this.internal;a.brush.clear().update(),a.redraw({withUpdateXDomain:!0})},h.load=function(a){var b=this.internal,c=b.config;return a.xs&&b.addXs(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){c.data_classes[b]=a.classes[b]}),"categories"in a&&b.isCategorized()&&(c.axis_x_categories=a.categories),"axes"in a&&Object.keys(a.axes).forEach(function(b){c.data_axes[b]=a.axes[b]}),"colors"in a&&Object.keys(a.colors).forEach(function(b){c.data_colors[b]=a.colors[b]}),"cacheIds"in a&&b.hasCaches(a.cacheIds)?void b.load(b.getCaches(a.cacheIds),a.done):void("unload"in a?b.unload(b.mapToTargetIds("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){b.loadFromArgs(a)}):b.loadFromArgs(a))},h.unload=function(a){var b=this.internal;a=a||{},a instanceof Array?a={ids:a}:"string"==typeof a&&(a={ids:[a]}),b.unload(b.mapToTargetIds(a.ids),function(){b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),a.done&&a.done()})},h.flow=function(a){var b,c,d,e,f,g,h,i,j=this.internal,k=[],l=j.getMaxDataCount(),n=0,o=0;if(a.json)c=j.convertJsonToData(a.json,a.keys);else if(a.rows)c=j.convertRowsToData(a.rows);else{if(!a.columns)return;c=j.convertColumnsToData(a.columns)}b=j.convertDataToTargets(c,!0),j.data.targets.forEach(function(a){var c,d,e=!1;for(c=0;c<b.length;c++)if(a.id===b[c].id){for(e=!0,a.values[a.values.length-1]&&(o=a.values[a.values.length-1].index+1),n=b[c].values.length,d=0;n>d;d++)b[c].values[d].index=o+d,j.isTimeSeries()||(b[c].values[d].x=o+d);a.values=a.values.concat(b[c].values),b.splice(c,1);break}e||k.push(a.id)}),j.data.targets.forEach(function(a){var b,c;for(b=0;b<k.length;b++)if(a.id===k[b])for(o=a.values[a.values.length-1].index+1,c=0;n>c;c++)a.values.push({id:a.id,index:o+c,x:j.isTimeSeries()?j.getOtherTargetX(o+c):o+c,value:null})}),j.data.targets.length&&b.forEach(function(a){var b,c=[];for(b=j.data.targets[0].values[0].index;o>b;b++)c.push({id:a.id,index:b,x:j.isTimeSeries()?j.getOtherTargetX(b):b,value:null});a.values.forEach(function(a){a.index+=o,j.isTimeSeries()||(a.x+=o)}),a.values=c.concat(a.values)}),j.data.targets=j.data.targets.concat(b),d=j.getMaxDataCount(),f=j.data.targets[0],g=f.values[0],q(a.to)?(n=0,i=j.isTimeSeries()?j.parseDate(a.to):a.to,f.values.forEach(function(a){a.x<i&&n++})):q(a.length)&&(n=a.length),l?1===l&&j.isTimeSeries()&&(h=(f.values[f.values.length-1].x-g.x)/2,e=[new Date(+g.x-h),new Date(+g.x+h)],j.updateXDomain(null,!0,!0,!1,e)):(h=j.isTimeSeries()?f.values.length>1?f.values[f.values.length-1].x-g.x:g.x-j.getXDomain(j.data.targets)[0]:1,e=[g.x-h,g.x],j.updateXDomain(null,!0,!0,!1,e)),j.updateTargets(j.data.targets),j.redraw({flow:{index:g.index,length:n,duration:m(a.duration)?a.duration:j.config.transition_duration,done:a.done,orgDataCount:l},withLegend:!0,withTransition:l>1,withTrimXDomain:!1,withUpdateXAxis:!0})},i.generateFlow=function(a){var b=this,c=b.config,d=b.d3;return function(){var e,f,g,h=a.targets,i=a.flow,j=a.drawBar,k=a.drawLine,m=a.drawArea,n=a.cx,o=a.cy,p=a.xv,q=a.xForText,r=a.yForText,s=a.duration,u=1,v=i.index,w=i.length,x=b.getValueOnIndex(b.data.targets[0].values,v),y=b.getValueOnIndex(b.data.targets[0].values,v+w),z=b.x.domain(),A=i.duration||s,B=i.done||function(){},C=b.generateWait(),D=b.xgrid||d.selectAll([]),E=b.xgridLines||d.selectAll([]),F=b.mainRegion||d.selectAll([]),G=b.mainText||d.selectAll([]),H=b.mainBar||d.selectAll([]),I=b.mainLine||d.selectAll([]),J=b.mainArea||d.selectAll([]),K=b.mainCircle||d.selectAll([]);b.flowing=!0,b.data.targets.forEach(function(a){a.values.splice(0,w)}),g=b.updateXDomain(h,!0,!0),b.updateXGrid&&b.updateXGrid(!0),i.orgDataCount?e=1===i.orgDataCount||x.x===y.x?b.x(z[0])-b.x(g[0]):b.isTimeSeries()?b.x(z[0])-b.x(g[0]):b.x(x.x)-b.x(y.x):1!==b.data.targets[0].values.length?e=b.x(z[0])-b.x(g[0]):b.isTimeSeries()?(x=b.getValueOnIndex(b.data.targets[0].values,0),y=b.getValueOnIndex(b.data.targets[0].values,b.data.targets[0].values.length-1),e=b.x(x.x)-b.x(y.x)):e=t(g)/2,u=t(z)/t(g),f="translate("+e+",0) scale("+u+",1)",b.hideXGridFocus(),b.hideTooltip(),d.transition().ease("linear").duration(A).each(function(){C.add(b.axes.x.transition().call(b.xAxis)),C.add(H.transition().attr("transform",f)),C.add(I.transition().attr("transform",f)),C.add(J.transition().attr("transform",f)),C.add(K.transition().attr("transform",f)),C.add(G.transition().attr("transform",f)),C.add(F.filter(b.isRegionOnX).transition().attr("transform",f)),C.add(D.transition().attr("transform",f)),C.add(E.transition().attr("transform",f)) +}).call(C,function(){var a,d=[],e=[],f=[];if(w){for(a=0;w>a;a++)d.push("."+l.shape+"-"+(v+a)),e.push("."+l.text+"-"+(v+a)),f.push("."+l.eventRect+"-"+(v+a));b.svg.selectAll("."+l.shapes).selectAll(d).remove(),b.svg.selectAll("."+l.texts).selectAll(e).remove(),b.svg.selectAll("."+l.eventRects).selectAll(f).remove(),b.svg.select("."+l.xgrid).remove()}D.attr("transform",null).attr(b.xgridAttr),E.attr("transform",null),E.select("line").attr("x1",c.axis_rotated?0:p).attr("x2",c.axis_rotated?b.width:p),E.select("text").attr("x",c.axis_rotated?b.width:0).attr("y",p),H.attr("transform",null).attr("d",j),I.attr("transform",null).attr("d",k),J.attr("transform",null).attr("d",m),K.attr("transform",null).attr("cx",n).attr("cy",o),G.attr("transform",null).attr("x",q).attr("y",r).style("fill-opacity",b.opacityForText.bind(b)),F.attr("transform",null),F.select("rect").filter(b.isRegionOnX).attr("x",b.regionX.bind(b)).attr("width",b.regionWidth.bind(b)),c.interaction_enabled&&b.redrawEventRect(),B(),b.flowing=!1})}},h.selected=function(a){var b=this.internal,c=b.d3;return c.merge(b.main.selectAll("."+l.shapes+b.getTargetSelectorSuffix(a)).selectAll("."+l.shape).filter(function(){return c.select(this).classed(l.SELECTED)}).map(function(a){return a.map(function(a){var b=a.__data__;return b.data?b.data:b})}))},h.select=function(a,b,c){var d=this.internal,e=d.d3,f=d.config;f.data_selection_enabled&&d.main.selectAll("."+l.shapes).selectAll("."+l.shape).each(function(g,h){var i=e.select(this),j=g.data?g.data.id:g.id,k=d.getToggle(this,g).bind(d),m=f.data_selection_grouped||!a||a.indexOf(j)>=0,n=!b||b.indexOf(h)>=0,o=i.classed(l.SELECTED);i.classed(l.line)||i.classed(l.area)||(m&&n?f.data_selection_isselectable(g)&&!o&&k(!0,i.classed(l.SELECTED,!0),g,h):q(c)&&c&&o&&k(!1,i.classed(l.SELECTED,!1),g,h))})},h.unselect=function(a,b){var c=this.internal,d=c.d3,e=c.config;e.data_selection_enabled&&c.main.selectAll("."+l.shapes).selectAll("."+l.shape).each(function(f,g){var h=d.select(this),i=f.data?f.data.id:f.id,j=c.getToggle(this,f).bind(c),k=e.data_selection_grouped||!a||a.indexOf(i)>=0,m=!b||b.indexOf(g)>=0,n=h.classed(l.SELECTED);h.classed(l.line)||h.classed(l.area)||k&&m&&e.data_selection_isselectable(f)&&n&&j(!1,h.classed(l.SELECTED,!1),f,g)})},h.transform=function(a,b){var c=this.internal,d=["pie","donut"].indexOf(a)>=0?{withTransform:!0}:null;c.transformTo(b,a,d)},i.transformTo=function(a,b,c){var d=this,e=!d.hasArcType(),f=c||{withTransitionForAxis:e};f.withTransitionForTransform=!1,d.transiting=!1,d.setTargetType(a,b),d.updateTargets(d.data.targets),d.updateAndRedraw(f)},h.groups=function(a){var b=this.internal,c=b.config;return p(a)?c.data_groups:(c.data_groups=a,b.redraw(),c.data_groups)},h.xgrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_x_lines=a,b.redrawWithoutRescale(),c.grid_x_lines):c.grid_x_lines},h.xgrids.add=function(a){var b=this.internal;return this.xgrids(b.config.grid_x_lines.concat(a?a:[]))},h.xgrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!0)},h.ygrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_y_lines=a,b.redrawWithoutRescale(),c.grid_y_lines):c.grid_y_lines},h.ygrids.add=function(a){var b=this.internal;return this.ygrids(b.config.grid_y_lines.concat(a?a:[]))},h.ygrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!1)},h.regions=function(a){var b=this.internal,c=b.config;return a?(c.regions=a,b.redrawWithoutRescale(),c.regions):c.regions},h.regions.add=function(a){var b=this.internal,c=b.config;return a?(c.regions=c.regions.concat(a),b.redrawWithoutRescale(),c.regions):c.regions},h.regions.remove=function(a){var b,c,d,e=this.internal,f=e.config;return a=a||{},b=e.getOption(a,"duration",f.transition_duration),c=e.getOption(a,"classes",[l.region]),d=e.main.select("."+l.regions).selectAll(c.map(function(a){return"."+a})),(b?d.transition().duration(b):d).style("opacity",0).remove(),f.regions=f.regions.filter(function(a){var b=!1;return a["class"]?(a["class"].split(" ").forEach(function(a){c.indexOf(a)>=0&&(b=!0)}),!b):!0}),f.regions},h.data=function(a){var b=this.internal.data.targets;return"undefined"==typeof a?b:b.filter(function(b){return[].concat(a).indexOf(b.id)>=0})},h.data.shown=function(a){return this.internal.filterTargetsToShow(this.data(a))},h.data.values=function(a){var b,c=null;return a&&(b=this.data(a),c=b[0]?b[0].values.map(function(a){return a.value}):null),c},h.data.names=function(a){return this.internal.clearLegendItemTextBoxCache(),this.internal.updateDataAttributes("names",a)},h.data.colors=function(a){return this.internal.updateDataAttributes("colors",a)},h.data.axes=function(a){return this.internal.updateDataAttributes("axes",a)},h.category=function(a,b){var c=this.internal,d=c.config;return arguments.length>1&&(d.axis_x_categories[a]=b,c.redraw()),d.axis_x_categories[a]},h.categories=function(a){var b=this.internal,c=b.config;return arguments.length?(c.axis_x_categories=a,b.redraw(),c.axis_x_categories):c.axis_x_categories},h.color=function(a){var b=this.internal;return b.color(a)},h.x=function(a){var b=this.internal;return arguments.length&&(b.updateTargetX(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},h.xs=function(a){var b=this.internal;return arguments.length&&(b.updateTargetXs(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},h.axis=function(){},h.axis.labels=function(a){var b=this.internal;arguments.length&&(Object.keys(a).forEach(function(c){b.axis.setLabelText(c,a[c])}),b.axis.updateLabels())},h.axis.max=function(a){var b=this.internal,c=b.config;return arguments.length?("object"==typeof a?(m(a.x)&&(c.axis_x_max=a.x),m(a.y)&&(c.axis_y_max=a.y),m(a.y2)&&(c.axis_y2_max=a.y2)):c.axis_y_max=c.axis_y2_max=a,void b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})):{x:c.axis_x_max,y:c.axis_y_max,y2:c.axis_y2_max}},h.axis.min=function(a){var b=this.internal,c=b.config;return arguments.length?("object"==typeof a?(m(a.x)&&(c.axis_x_min=a.x),m(a.y)&&(c.axis_y_min=a.y),m(a.y2)&&(c.axis_y2_min=a.y2)):c.axis_y_min=c.axis_y2_min=a,void b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})):{x:c.axis_x_min,y:c.axis_y_min,y2:c.axis_y2_min}},h.axis.range=function(a){return arguments.length?(q(a.max)&&this.axis.max(a.max),void(q(a.min)&&this.axis.min(a.min))):{max:this.axis.max(),min:this.axis.min()}},h.legend=function(){},h.legend.show=function(a){var b=this.internal;b.showLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},h.legend.hide=function(a){var b=this.internal;b.hideLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},h.resize=function(a){var b=this.internal,c=b.config;c.size_width=a?a.width:null,c.size_height=a?a.height:null,this.flush()},h.flush=function(){var a=this.internal;a.updateAndRedraw({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},h.destroy=function(){var b=this.internal;return a.clearInterval(b.intervalForObserveInserted),a.onresize=null,b.selectChart.classed("c3",!1).html(""),Object.keys(b).forEach(function(a){b[a]=null}),null},h.tooltip=function(){},h.tooltip.show=function(a){var b,c,d=this.internal;a.mouse&&(c=a.mouse),a.data?d.isMultipleX()?(c=[d.x(a.data.x),d.getYScale(a.data.id)(a.data.value)],b=null):b=m(a.data.index)?a.data.index:d.getIndexByX(a.data.x):"undefined"!=typeof a.x?b=d.getIndexByX(a.x):"undefined"!=typeof a.index&&(b=a.index),d.dispatchEvent("mouseover",b,c),d.dispatchEvent("mousemove",b,c)},h.tooltip.hide=function(){this.internal.dispatchEvent("mouseout",0)};var z;i.isSafari=function(){var b=a.navigator.userAgent;return b.indexOf("Safari")>=0&&b.indexOf("Chrome")<0},i.isChrome=function(){var b=a.navigator.userAgent;return b.indexOf("Chrome")>=0},Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),"function"==typeof define&&define.amd?define("c3",["d3"],k):"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=k:a.c3=k}(window);
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/component.json b/web/nms-public.gathering.org/old/speedometer/c3-master/component.json new file mode 100644 index 0000000..51e9f0f --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/component.json @@ -0,0 +1,19 @@ +{ + "name": "c3", + "repo": "masayuki0812/c3", + "description": "A D3-based reusable chart library", + "version": "0.4.10", + "keywords": [], + "dependencies": { + "mbostock/d3": "v3.5.0" + }, + "development": {}, + "license": "MIT", + "main": "c3.js", + "scripts": [ + "c3.js" + ], + "styles": [ + "c3.css" + ] +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/exporter/config.json b/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/exporter/config.json new file mode 100644 index 0000000..e3f812a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/exporter/config.json @@ -0,0 +1,11 @@ +{ + "js": [ + "../../bower_components/d3/d3.min.js", + "../../c3.min.js" + ], + "css": [ + "../../c3.css" + ], + + "template": "<html><head><meta charset=\"utf-8\"><style>{0}</style></head><body><div id=\"chart\"></div></body></html>" +}
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/exporter/phantom-exporter.js b/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/exporter/phantom-exporter.js new file mode 100644 index 0000000..92d849d --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/exporter/phantom-exporter.js @@ -0,0 +1,140 @@ +/** +* PNG\JPEG exporter for C3.js, version 0.2 +* (c) 2014 Yuval Bar-On +* +* usage: path/to/phantomjs output options [WxH] +* +*/ + +// useful python-styled string formatting, "hello {0}! Javascript is {1}".format("world", "awesome"); +if (!String.prototype.format) { + String.prototype.format = function() { + var args = arguments; + return this.replace(/{(\d+)}/g, function(match, number) { + return typeof args[number] != 'undefined' + ? args[number] + : match + ; + }); + }; +} + +// defaults +var page = require('webpage').create(), + fs = require('fs'), + system = require('system'), + config = JSON.parse( fs.read('config.json') ), + output, size; + +if (system.args.length < 3 ) { + console.log('Usage: phantasm.js filename html [WxH]'); + phantom.exit(1); +} else { + out = system.args[1]; + opts = JSON.parse( system.args[2] ); + + if (system.args[3]) { + var dimensions = system.args[3].split('x'), + width = dimensions[0], + height = dimensions[1]; + + function checkNum(check) { + check = parseInt(check); + if (!isNaN(check)) + return check; + return false; + } + + width = checkNum(width); + height = checkNum(height); + + if (width && height) { + page.viewportSize = { + height: height, + width: width + } + } + + // fit chart size to img size, if undefined + if (!opts.size) { + opts.size = { + "height": height, + "width": width + }; + } + } else { + // check if size is defined in chart, + // else apply defaults + page.viewportSize = { + height: (opts.size && opts.size.height) ? opts.size.height : 320, + width: (opts.size && opts.size.width ) ? opts.size.width : 710, + } + } +} + +page.onResourceRequested = function(requestData, request) { + console.log('::loading resource ', requestData['url']); +}; + +// helpful debug functions +page.onConsoleMessage = function(msg){ + console.log(msg); +}; + +page.onError = function(msg, trace) { + var msgStack = ['ERROR: ' + msg]; + + if (trace && trace.length) { + msgStack.push('TRACE:'); + trace.forEach(function(t) { + msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : '')); + }); + } + + console.error(msgStack.join('\n')); +}; + +// render page +function injectVerify(script) { + var req = page.injectJs(script); + if (!req) { + console.log( '\nError!\n' + script + ' not found!\n' ); + phantom.exit(1); + } +} + +page.onLoadFinished = function() { + console.log('::rendering'); + + for (var j in config.js) { + injectVerify(config.js[j]); + } + + page.evaluate(function(chartoptions) { + // phantomjs doesn't know how to handle .bind, so we override + Function.prototype.bind = Function.prototype.bind || function (thisp) { + var fn = this; + return function () { + return fn.apply(thisp, arguments); + }; + }; + + // generate chart + c3.generate(chartoptions); + + }, opts); + +// setting transition to 0 has proven not to work thus far, but 300ms isn't much +// so this is acceptable for now + setTimeout(function() { + page.render(out); + phantom.exit(); + }, 300); +} + +// apply css inline because that usually renders better +var css = ''; +for (var i in config.css) { + css += fs.read(config.css[i]); +} +page.content = config.template.format(css);
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/exporter/test.png b/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/exporter/test.png Binary files differnew file mode 100644 index 0000000..593b70b --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/exporter/test.png diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/js/c3ext.js b/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/js/c3ext.js new file mode 100644 index 0000000..8ff301f --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/extensions/js/c3ext.js @@ -0,0 +1,380 @@ +var c3ext = {}; +c3ext.generate = function (options) { + + if (options.zoom2 != null) { + zoom2_reducers = options.zoom2.reducers || {}; + zoom2_enabled = options.zoom2.enabled; + _zoom2_factor = options.zoom2.factor || 1; + _zoom2_maxItems = options.zoom2.maxItems; + } + + if (!zoom2_enabled) { + return c3.generate(options); + } + + + var originalData = Q.copy(options.data); + var zoom2_reducers; + var zoom2_enabled; + var _zoom2_maxItems; + + if (_zoom2_maxItems == null) { + var el = d3.select(options.bindto)[0][0]; + if (el != null) { + var availWidth = el.clientWidth; + + var pointSize = 20; + _zoom2_maxItems = Math.ceil(availWidth / pointSize); + } + if (_zoom2_maxItems == null || _zoom2_maxItems < 10) { + _zoom2_maxItems = 10; + } + } + + function onZoomChanged(e) { + refresh(); + } + + var zoom2 = c3ext.ZoomBehavior({ changed: onZoomChanged, bindto: options.bindto }); + + zoom2.enhance = function () { + _zoom2_maxItems *= 2; + var totalItems = zoom2.getZoom().totalItems; + if (_zoom2_maxItems > totalItems) + _zoom2_maxItems = totalItems; + refresh(); + } + zoom2.dehance = function () { + _zoom2_maxItems = Math.ceil(_zoom2_maxItems / 2) + 1; + refresh(); + } + + zoom2.maxItems = function () { return _zoom2_maxItems; }; + function zoomAndReduceData(list, zoomRange, func, maxItems) { + //var maxItems = 10;//Math.ceil(10 * zoomFactor); + var list2 = list.slice(zoomRange[0], zoomRange[1]); + var chunkSize = 1; + var list3 = list2; + if (list3.length > maxItems) { + var chunkSize = Math.ceil(list2.length / maxItems); + list3 = list3.splitIntoChunksOf(chunkSize).map(func); + } + //console.log("x" + getCurrentZoomLevel() + ", maxItems=" + maxItems + " chunkSize=" + chunkSize + " totalBefore=" + list2.length + ", totalAfter=" + list3.length); + return list3; + } + + function first(t) { return t[0]; } + + var getDataForZoom = function (data) { + if (data.columns == null || data.columns.length == 0) + return; + + var zoomInfo = zoom2.getZoom(); + if (zoomInfo.totalItems != data.columns[0].length - 1) { + zoom2.setOptions({ totalItems: data.columns[0].length - 1 }); + zoomInfo = zoom2.getZoom(); + } + data.columns = originalData.columns.map(function (column) { + var name = column[0]; + var reducer = zoom2_reducers[name] || first; //by default take the first + + var values = column.slice(1); + var newValues = zoomAndReduceData(values, zoomInfo.currentZoom, reducer, _zoom2_maxItems); + return [name].concat(newValues); + }); + return data; + }; + + getDataForZoom(options.data); + var chart = c3.generate(options); + var _chart_load_org = chart.load.bind(chart); + chart.zoom2 = zoom2; + chart.load = function (data) { + if (data.unload) { + unload(data.unload); + delete data.unload; + } + Q.copy(data, originalData); + refresh(); + } + chart.unload = function (names) { + unload(names); + refresh(); + } + + function unload(names) { + originalData.columns.removeAll(function (t) { names.contains(t); }); + } + + + function refresh() { + var data = Q.copy(originalData) + getDataForZoom(data); + _chart_load_org(data); + }; + + + return chart; +} + +c3ext.ZoomBehavior = function (options) { + var zoom = { __type: "ZoomBehavior" }; + + var _zoom2_factor; + var _left; + var totalItems; + var currentZoom; + var bindto = options.bindto; + var _zoomChanged = options.changed || function () { }; + var element; + var mousewheelTimer; + var deltaY = 0; + var leftRatio = 0; + + + zoom.setOptions = function (options) { + if (options == null) + options = {}; + _zoom2_factor = options.factor || 1; + _left = 0; + totalItems = options.totalItems || 0; + currentZoom = [0, totalItems]; + _zoomChanged = options.changed || _zoomChanged; + } + + zoom.setOptions(options); + + + function verifyZoom(newZoom) { + //newZoom.sort(); + if (newZoom[1] > totalItems) { + var diff = newZoom[1] - totalItems; + newZoom[0] -= diff; + newZoom[1] -= diff; + } + if (newZoom[0] < 0) { + var diff = newZoom[0] * -1; + newZoom[0] += diff; + newZoom[1] += diff; + } + if (newZoom[1] > totalItems) + newZoom[1] = totalItems; + if (newZoom[0] < 0) + newZoom[0] = 0; + } + + function zoomAndPan(zoomFactor, left) { + var itemsToShow = Math.ceil(totalItems / zoomFactor); + var newZoom = [left, left + itemsToShow]; + verifyZoom(newZoom); + currentZoom = newZoom; + onZoomChanged(); + } + + function onZoomChanged() { + if (_zoomChanged != null) + _zoomChanged(zoom.getZoom()); + } + function applyZoomAndPan() { + zoomAndPan(_zoom2_factor, _left); + } + function getItemsToShow() { + var itemsToShow = Math.ceil(totalItems / _zoom2_factor); + return itemsToShow; + } + + + zoom.getZoom = function () { + return { totalItems: totalItems, currentZoom: currentZoom.slice() }; + } + + zoom.factor = function (factor, skipDraw) { + if (arguments.length == 0) + return _zoom2_factor; + _zoom2_factor = factor; + if (_zoom2_factor < 1) + _zoom2_factor = 1; + if (skipDraw) + return; + applyZoomAndPan(); + } + zoom.left = function (left, skipDraw) { + if (arguments.length == 0) + return _left; + _left = left; + if (_left < 0) + _left = 0; + var pageSize = getItemsToShow(); + //_left += pageSize; + if (_left + pageSize > totalItems) + _left = totalItems - pageSize; + console.log({ left: _left, pageSize: pageSize }); + if (skipDraw) + return; + applyZoomAndPan(); + } + + zoom.zoomAndPanByRatio = function (zoomRatio, panRatio) { + + var pageSize = getItemsToShow(); + var leftOffset = Math.round(pageSize * panRatio); + var mouseLeft = _left + leftOffset; + zoom.factor(zoom.factor() * zoomRatio, true); + + var finalLeft = mouseLeft; + if (zoomRatio != 1) { + var pageSize2 = getItemsToShow(); + var leftOffset2 = Math.round(pageSize2 * panRatio); + finalLeft = mouseLeft - leftOffset2; + } + zoom.left(finalLeft, true); + applyZoomAndPan(); + } + + zoom.zoomIn = function () { + zoom.zoomAndPanByRatio(2, 0); + } + + zoom.zoomOut = function () { + zoom.zoomAndPanByRatio(0.5, 0); + } + + zoom.panLeft = function () { + zoom.zoomAndPanByRatio(1, -1); + } + zoom.panRight = function () { + zoom.zoomAndPanByRatio(1, 1); + } + + zoom.reset = function () { + _left = 0; + _zoom2_factor = 1; + applyZoomAndPan(); + } + + function doZoom() { + if (deltaY != 0) { + var maxDelta = 10; + var multiply = (maxDelta + deltaY) / maxDelta; + //var factor = chart.zoom2.factor()*multiply; + //factor= Math.ceil(factor*100) / 100; + console.log({ deltaY: deltaY, multiply: multiply }); + zoom.zoomAndPanByRatio(multiply, leftRatio);//0.5);//leftRatio); + deltaY = 0; + } + } + + function element_mousewheel(e) { + deltaY += e.deltaY; + leftRatio = (e.offsetX - 70) / (e.currentTarget.offsetWidth - 70); + //console.log({ "e.offsetX": e.offsetX, "e.currentTarget.offsetWidth": e.currentTarget.offsetWidth, leftRatio: leftRatio }); + mousewheelTimer.set(150); + e.preventDefault(); + } + + if (bindto != null) { + element = $(options.bindto); + if (element.mousewheel) { + mousewheelTimer = new Timer(doZoom); + element.mousewheel(element_mousewheel); + } + } + + return zoom; + +} + +if (typeof (Q) == "undefined") { + var Q = function () { + }; + + Q.copy = function (src, target, options, depth) { + ///<summary>Copies an object into a target object, recursively cloning any object or array in the way, overwrite=true will overwrite a primitive field value even if exists</summary> + ///<param name="src" /> + ///<param name="target" /> + ///<param name="options" type="Object">{ overwrite:false }</param> + ///<returns type="Object">The copied object</returns> + if (depth == null) + depth = 0; + if (depth == 100) { + console.warn("Q.copy is in depth of 100 - possible circular reference") + } + options = options || { overwrite: false }; + if (src == target || src == null) + return target; + if (typeof (src) != "object") { + if (options.overwrite || target == null) + return src; + return target; + } + if (typeof (src.clone) == "function") { + if (options.overwrite || target == null) + return src.clone(); + return target; + } + if (target == null) { + if (src instanceof Array) + target = []; + else + target = {}; + } + + if (src instanceof Array) { + for (var i = 0; i < src.length; i++) { + var item = src[i]; + var item2 = target[i]; + item2 = Q.copy(item, item2, options, depth + 1); + target[i] = item2; + } + target.splice(src.length, target.length - src.length); + return target; + } + for (var p in src) { + var value = src[p]; + var value2 = target[p]; + value2 = Q.copy(value, value2, options, depth + 1); + target[p] = value2; + } + return target; + } +} +if (typeof (Timer) == "undefined") { + var Timer = function (action, ms) { + this.action = action; + if (ms != null) + this.set(ms); + } + + Timer.prototype.set = function (ms) { + if (ms == null) + ms = this._ms; + else + this._ms = ms; + this.clear(); + if (ms == null) + return; + this.timeout = window.setTimeout(this.onTick.bind(this), ms); + } + + Timer.prototype.onTick = function () { + this.clear(); + this.action(); + } + + Timer.prototype.clear = function (ms) { + if (this.timeout == null) + return; + window.clearTimeout(this.timeout); + this.timeout = null; + } +} +if (typeof(Array.prototype.splitIntoChunksOf)=="undefined") { + Array.prototype.splitIntoChunksOf = function (countInEachChunk) { + var chunks = Math.ceil(this.length / countInEachChunk); + var list = []; + for (var i = 0; i < this.length; i += countInEachChunk) { + list.push(this.slice(i, i + countInEachChunk)); + } + return list; + } +}
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/bootstrap.min.css b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/bootstrap.min.css new file mode 100644 index 0000000..4cc4e7a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/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/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/c3.css b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/c3.css new file mode 120000 index 0000000..4052640 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/c3.css @@ -0,0 +1 @@ +../../c3.css
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/index.css b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/index.css new file mode 100644 index 0000000..f38c901 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/index.css @@ -0,0 +1,12 @@ +.row { + margin-left: 8px; +} +.row a { + display: block; + text-align: left; + font-size: 1.2em; + line-height: 1.8; +} +.row h3 { + color: #777; +}
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/style.css b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/style.css new file mode 100644 index 0000000..9abe27b --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/css/style.css @@ -0,0 +1,9 @@ + +body { + text-align: center; +} + +#chart { + width: 720px; + margin: 24px auto; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test.csv b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test.csv new file mode 100644 index 0000000..dea2e16 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/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/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test.json b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test.json new file mode 100644 index 0000000..7486b75 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test.json @@ -0,0 +1,5 @@ +{ + "data1": [120, 140, 170, 150, 180], + "data2": [80, 50, 100, 70, 120], + "data3": [200, 210, 250, 300, 280] +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test.tsv b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test.tsv new file mode 100644 index 0000000..1fcab88 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test.tsv @@ -0,0 +1,6 @@ +data1 data2 data3 +520 380 100 +540 350 110 +570 400 150 +550 370 200 +580 420 180
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test2.csv b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test2.csv new file mode 100644 index 0000000..ae1a48a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/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/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test2_ts.csv b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test2_ts.csv new file mode 100644 index 0000000..2b8d00e --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test2_ts.csv @@ -0,0 +1,6 @@ +x,data1,data2,data3 +2013-04-01,20,180,400 +2013-04-02,40,150,310 +2013-04-03,70,120,470 +2013-04-04,50,170,400 +2013-04-05,80,200,380
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test3.csv b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test3.csv new file mode 100644 index 0000000..2aabb04 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test3.csv @@ -0,0 +1,4 @@ +x,download,loading +www.hogehoge.com,30,19 +www.aaaa.com,30,13 +www.bb.com,20,24 diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test_2.json b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test_2.json new file mode 100644 index 0000000..ed18b2f --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test_2.json @@ -0,0 +1,5 @@ +{ + "data1": [20, 40, 70, 50, 80, 30], + "data2": [180, 150, 200, 170, 220, 400], + "data3": [1200, 1210, 1250, 1300, 1280, 1000] +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test_3.json b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test_3.json new file mode 100644 index 0000000..c08c9c7 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test_3.json @@ -0,0 +1,6 @@ +[ + { "id": 1, "name": "abc", "data1": 1200, "data2": 500 }, + { "id": 2, "name": "efg", "data1": 900, "data2": 600 }, + { "id": 3, "name": "pqr", "data1": 1150, "data2": 300 }, + { "id": 4, "name": "xyz", "data1": 1020, "data2": 900 } +] diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test_ts.csv b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test_ts.csv new file mode 100644 index 0000000..5bfbd34 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/data/c3_test_ts.csv @@ -0,0 +1,6 @@ +x,data1,data2,data3 +2012-12-31,120,80,200 +2013-01-01,140,50,210 +2013-01-02,170,100,250 +2013-01-03,150,70,300 +2013-01-04,180,120,280
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/index.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/index.html new file mode 100644 index 0000000..7f2c06a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/index.html @@ -0,0 +1,481 @@ +<html> + <head> + <link href="./css/bootstrap.min.css" rel="stylesheet"> + <link href="./css/index.css" rel="stylesheet"> + </head> + <body> + <div class="container"> + <div class="section"> + <h2># <span>Chart Type</span></h2> + <div> + <div class="row"> + <div class="col-md-4"> + <h3>Line Chart</h3> + <a href="./samples/simple.html"> + Line chart with ordinary data + </a> + <a href="./samples/chart_spline.html"> + Spline chart with ordinary data + </a> + <a href="./samples/chart_step.html"> + Step chart with ordinary data + </a> + </div> + <div class="col-md-4"> + <h3>Area Chart</h3> + <a href="./samples/chart_area.html"> + Area chart with ordinary data + </a> + <a href="./samples/chart_area_spline.html"> + Area-spline chart with ordinary data + </a> + <a href="./samples/chart_area_step.html"> + Area-step chart with ordinary data + </a> + <a href="./samples/chart_area_stacked.html"> + Stacked Area chart with ordinary data + </a> + <a href="./samples/chart_area_spline_stacked.html"> + Stacked Area-spline chart with ordinary data + </a> + <a href="./samples/chart_area_step_stacked.html"> + Stacked Area-step chart with ordinary data + </a> + </div> + <div class="col-md-4"> + <h3>Bar Chart</h3> + <a href="./samples/chart_bar.html"> + Bar chart with ordinary data + </a> + <a href="./samples/chart_bar_stacked.html"> + Stacked Bar chart with ordinary data + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Pie Chart</h3> + <a href="./samples/chart_pie.html"> + Pie chart with ordinary data + </a> + <a href="./samples/chart_pie_sort.html"> + Pie chart with/without sort + </a> + </div> + <div class="col-md-4"> + <h3>Donut Chart</h3> + <a href="./samples/chart_donut.html"> + Donut chart with ordinary data + </a> + </div> + <div class="col-md-4"> + <h3>Gauge Chart</h3> + <a href="./samples/chart_gauge.html"> + Gauge chart with ordinary data + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Scatter Chart</h3> + <a href="./samples/chart_scatter.html"> + Scatter chart with ordinary data + </a> + </div> + <div class="col-md-4"> + <h3>Combination Chart</h3> + <a href="./samples/chart_combination.html"> + Combination chart with ordinary data + </a> + </div> + </div> + </div> + </div> + + <div class="section"> + <h2># <span>Axes</span></h2> + <div> + <div class="row"> + <div class="col-md-4"> + <h3>Timeseries Axis</h3> + <a href="./samples/timeseries.html"> + Line chart with timeseries data + </a> + <a href="./samples/timeseries_descendent.html"> + Line chart with descendent timeseries data + </a> + <a href="./samples/timeseries_raw.html"> + Line chart with timeseries data as Number + </a> + <a href="./samples/timeseries_date.html"> + Line chart with timeseries data as Date object + </a> + </div> + <div class="col-md-4"> + <h3>Category Axis</h3> + <a href="./samples/categorized.html"> + Chart with category axis + </a> + <a href="./samples/custom_x_categorized.html"> + Chart with category data on category axis + </a> + </div> + <div class="col-md-4"> + <h3>Additional Axis</h3> + <a href="./samples/axes_y2.html"> + Add y2 axis + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Axis Range</h3> + <a href="./samples/axes_range.html"> + Set range of axis + </a> + </div> + <div class="col-md-4"> + <h3>Axis Padding</h3> + <a href="./samples/axes_padding.html"> + Set padding of axis + </a> + </div> + <div class="col-md-4"> + <h3>X Axis Tick</h3> + <a href="./samples/axes_x_tick_values.html"> + Set values for x axis + </a> + <a href="./samples/axes_x_tick_culling.html"> + Set culling for x axis + </a> + <a href="./samples/axes_x_tick_fit.html"> + Set fitting for x axis + </a> + <a href="./samples/axes_x_tick_rotate.html"> + Set rotation for x axis + </a> + <a href="./samples/axes_x_range_timeseries.html"> + Set range in timeseries for x axis + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Default Y Domain</h3> + <a href="./samples/axes_y_default.html"> + Set default y domain + </a> + </div> + <div class="col-md-4"> + <h3>Y Domain</h3> + <a href="./samples/domain_y.html"> + Update y domain automatically + </a> + </div> + <div class="col-md-4"> + <h3>Default X Extent</h3> + <a href="./samples/axes_x_extent.html"> + Set default x extent + </a> + </div> + </div> + </div> + </div> + + <div class="section"> + <h2># <span>Data</span></h2> + <div> + <div class="row"> + <div class="col-md-4"> + <h3>Input Data</h3> + <a href="./samples/data_columned.html"> + Columned data + </a> + <a href="./samples/data_rowed.html"> + Rowed data + </a> + <a href="./samples/data_json.html"> + JSON data + </a> + <a href="./samples/data_url.html"> + Data from URL + </a> + <a href="./samples/data_hide.html"> + Hide data when init + </a> + </div> + <div class="col-md-4"> + <h3>Load Data</h3> + <a href="./samples/data_load.html"> + Load ordinary data + </a> + <a href="./samples/data_load_timeseries.html"> + Load timeseries data + </a> + </div> + <div class="col-md-4"> + <h3>Custom X</h3> + <a href="./samples/custom_x_scale.html"> + Custom x for all data + </a> + <a href="./samples/custom_xs_scale.html"> + Custom x for each data + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Data Label</h3> + <a href="./samples/data_label.html"> + Show label on data + </a> + <a href="./samples/data_label_format.html"> + Show label on data with format + </a> + </div> + <div class="col-md-4"> + <h3>Data Region</h3> + <a href="./samples/data_region.html"> + Set region of data + </a> + <a href="./samples/data_region_timeseries.html"> + Set region of timeseries data + </a> + </div> + </div> + </div> + </div> + + <div class="section"> + <h2># <span>Components</span></h2> + <div> + <div class="row"> + <div class="col-md-4"> + <h3>Grid</h3> + <a href="./samples/grids.html"> + Show x/y grids + </a> + <a href="./samples/grids_timeseries.html"> + Show x/y grids with timeseries + </a> + <a href="./samples/grid_x_lines.html"> + Show optional x grids + </a> + <a href="./samples/grid_x_lines_timeseries.html"> + Show optional x grids with timeseries + </a> + <a href="./samples/grid_focus.html"> + Hide focus grid + </a> + </div> + <div class="col-md-4"> + <h3>Region</h3> + <a href="./samples/regions.html"> + Show regions + </a> + <a href="./samples/regions_timeseries.html"> + Show regions with timeseries + </a> + </div> + <div class="col-md-4"> + <h3>Legend</h3> + <a href="./samples/legend.html"> + Show legend + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Tooltip</h3> + <a href="./samples/tooltip_show.html"> + Show tooltip + </a> + <a href="./samples/tooltip_grouped.html"> + Show tooltip as each data + </a> + </div> + </div> + </div> + </div> + + <div class="section"> + <h2># <span>Chart Option</span></h2> + <div> + <div class="row"> + <div class="col-md-4"> + <h3>Bind</h3> + <a href="./samples/bindto.html"> + Specify the element binded + </a> + </div> + <div class="col-md-4"> + <h3>Padding</h3> + <a href="./samples/padding.html"> + Change padding of chart + </a> + <a href="./samples/padding_update.html"> + Auto padding when chart updated + </a> + </div> + <div class="col-md-4"> + <h3>Empty Data</h3> + <a href="./samples/emptydata.html"> + Show text when empty data + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Point</h3> + <a href="./samples/point_r.html"> + Change radius of data point + </a> + </div> + <div class="col-md-4"> + <h3>Bar</h3> + <a href="./samples/bar_zerobased.html"> + Disable zero-based y domain + </a> + </div> + <div class="col-md-4"> + <h3>Area</h3> + <a href="./samples/area_zerobased.html"> + Disable zero-based y domain + </a> + </div> + </div> + </div> + </div> + + <div class="section"> + <h2># <span>Interaction</span></h2> + <div> + <div class="row"> + <div class="col-md-4"> + <h3>Zoom</h3> + <a href="./samples/zoom.html"> + Enable zoom + </a> + <a href="./samples/zoom.html"> + Zoom on category axis + </a> + <a href="./samples/zoom_reduction.html"> + Zoom with reduction + </a> + <a href="./samples/zoom_onzoom.html"> + Callback on zoom + </a> + </div> + <div class="col-md-4"> + <h3>Subchart</h3> + <a href="./samples/subchart.html"> + Show subchart + </a> + <a href="./samples/subchart_onbrush.html"> + Callback on brush + </a> + </div> + <div class="col-md-4"> + <h3>Selection</h3> + <a href="./samples/selection.html"> + Select data + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Disable Interaction</h3> + <a href="./samples/interaction_enabled.html"> + Disable interaction + </a> + </div> + </div> + </div> + </div> + + <div class="section"> + <h2># <span>API</span></h2> + <div> + <div class="row"> + <div class="col-md-4"> + <h3>Flow</h3> + <a href="./samples/api_flow.html"> + Flow ordinary data + </a> + <a href="./samples/api_flow_timeseries.html"> + Flow timeseries data + </a> + </div> + <div class="col-md-4"> + <h3>Axis</h3> + <a href="./samples/api_axis_range.html"> + Update axis range + </a> + <a href="./samples/api_axis_label.html"> + Update axis label + </a> + </div> + <div class="col-md-4"> + <h3>Grid</h3> + <a href="./samples/api_xgrid_lines.html"> + Update x grid lines + </a> + <a href="./samples/api_ygrid_lines.html"> + Update y grid lines + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Legend</h3> + <a href="./samples/api_legend.html"> + Update legend + </a> + </div> + <div class="col-md-4"> + <h3>Transform</h3> + <a href="./samples/api_transform.html"> + Transform chart + </a> + </div> + <div class="col-md-4"> + <h3>Element</h3> + <a href="./samples/element.html"> + Access svg element of chart + </a> + </div> + </div> + <div class="row"> + <div class="col-md-4"> + <h3>Data</h3> + <a href="./samples/api_data_colors.html"> + Update data color + </a> + </div> + <div class="col-md-4"> + <h3>Tooltip</h3> + <a href="./samples/api_tooltip_show.html"> + Show tooltip programmatically + </a> + </div> + </div> + </div> + </div> + + <div class="section"> + <h2># <span>Other Library</span></h2> + <div> + <div class="row"> + <div class="col-md-4"> + <h3>RequireJS</h3> + <a href="./samples/requirejs.html"> + Load by RequireJS + </a> + </div> + </div> + </div> + </div> + + </div> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/c3.js b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/c3.js new file mode 120000 index 0000000..644b352 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/c3.js @@ -0,0 +1 @@ +../../c3.js
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/c3.min.js b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/c3.min.js new file mode 120000 index 0000000..a221dd2 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/c3.min.js @@ -0,0 +1 @@ +../../c3.min.js
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/extensions b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/extensions new file mode 120000 index 0000000..4761652 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/extensions @@ -0,0 +1 @@ +../../extensions/js
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/require.js b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/require.js new file mode 100644 index 0000000..e599a6a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/require.js @@ -0,0 +1,36 @@ +/* + RequireJS 2.1.11 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. + Available via the MIT or new BSD license. + see: http://github.com/jrburke/requirejs for details +*/ +var requirejs,require,define; +(function(ca){function G(b){return"[object Function]"===M.call(b)}function H(b){return"[object Array]"===M.call(b)}function v(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function U(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function s(b,c){return ga.call(b,c)}function j(b,c){return s(b,c)&&b[c]}function B(b,c){for(var d in b)if(s(b,d)&&c(b[d],d))break}function V(b,c,d,g){c&&B(c,function(c,h){if(d||!s(b,h))g&&"object"===typeof c&&c&&!H(c)&&!G(c)&&!(c instanceof +RegExp)?(b[h]||(b[h]={}),V(b[h],c,d,g)):b[h]=c});return b}function t(b,c){return function(){return c.apply(b,arguments)}}function da(b){throw b;}function ea(b){if(!b)return b;var c=ca;v(b.split("."),function(b){c=c[b]});return c}function C(b,c,d,g){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=g;d&&(c.originalError=d);return c}function ha(b){function c(a,e,b){var f,n,c,d,g,h,i,I=e&&e.split("/");n=I;var m=l.map,k=m&&m["*"];if(a&&"."===a.charAt(0))if(e){n= +I.slice(0,I.length-1);a=a.split("/");e=a.length-1;l.nodeIdCompat&&R.test(a[e])&&(a[e]=a[e].replace(R,""));n=a=n.concat(a);d=n.length;for(e=0;e<d;e++)if(c=n[e],"."===c)n.splice(e,1),e-=1;else if(".."===c)if(1===e&&(".."===n[2]||".."===n[0]))break;else 0<e&&(n.splice(e-1,2),e-=2);a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if(b&&m&&(I||k)){n=a.split("/");e=n.length;a:for(;0<e;e-=1){d=n.slice(0,e).join("/");if(I)for(c=I.length;0<c;c-=1)if(b=j(m,I.slice(0,c).join("/")))if(b=j(b,d)){f=b; +g=e;break a}!h&&(k&&j(k,d))&&(h=j(k,d),i=e)}!f&&h&&(f=h,g=i);f&&(n.splice(0,g,f),a=n.join("/"))}return(f=j(l.pkgs,a))?f:a}function d(a){z&&v(document.getElementsByTagName("script"),function(e){if(e.getAttribute("data-requiremodule")===a&&e.getAttribute("data-requirecontext")===i.contextName)return e.parentNode.removeChild(e),!0})}function g(a){var e=j(l.paths,a);if(e&&H(e)&&1<e.length)return e.shift(),i.require.undef(a),i.require([a]),!0}function u(a){var e,b=a?a.indexOf("!"):-1;-1<b&&(e=a.substring(0, +b),a=a.substring(b+1,a.length));return[e,a]}function m(a,e,b,f){var n,d,g=null,h=e?e.name:null,l=a,m=!0,k="";a||(m=!1,a="_@r"+(M+=1));a=u(a);g=a[0];a=a[1];g&&(g=c(g,h,f),d=j(p,g));a&&(g?k=d&&d.normalize?d.normalize(a,function(a){return c(a,h,f)}):c(a,h,f):(k=c(a,h,f),a=u(k),g=a[0],k=a[1],b=!0,n=i.nameToUrl(k)));b=g&&!d&&!b?"_unnormalized"+(Q+=1):"";return{prefix:g,name:k,parentMap:e,unnormalized:!!b,url:n,originalName:l,isDefine:m,id:(g?g+"!"+k:k)+b}}function q(a){var e=a.id,b=j(k,e);b||(b=k[e]=new i.Module(a)); +return b}function r(a,e,b){var f=a.id,n=j(k,f);if(s(p,f)&&(!n||n.defineEmitComplete))"defined"===e&&b(p[f]);else if(n=q(a),n.error&&"error"===e)b(n.error);else n.on(e,b)}function w(a,e){var b=a.requireModules,f=!1;if(e)e(a);else if(v(b,function(e){if(e=j(k,e))e.error=a,e.events.error&&(f=!0,e.emit("error",a))}),!f)h.onError(a)}function x(){S.length&&(ia.apply(A,[A.length,0].concat(S)),S=[])}function y(a){delete k[a];delete W[a]}function F(a,e,b){var f=a.map.id;a.error?a.emit("error",a.error):(e[f]= +!0,v(a.depMaps,function(f,c){var d=f.id,g=j(k,d);g&&(!a.depMatched[c]&&!b[d])&&(j(e,d)?(a.defineDep(c,p[d]),a.check()):F(g,e,b))}),b[f]=!0)}function D(){var a,e,b=(a=1E3*l.waitSeconds)&&i.startTime+a<(new Date).getTime(),f=[],c=[],h=!1,k=!0;if(!X){X=!0;B(W,function(a){var i=a.map,m=i.id;if(a.enabled&&(i.isDefine||c.push(a),!a.error))if(!a.inited&&b)g(m)?h=e=!0:(f.push(m),d(m));else if(!a.inited&&(a.fetched&&i.isDefine)&&(h=!0,!i.prefix))return k=!1});if(b&&f.length)return a=C("timeout","Load timeout for modules: "+ +f,null,f),a.contextName=i.contextName,w(a);k&&v(c,function(a){F(a,{},{})});if((!b||e)&&h)if((z||fa)&&!Y)Y=setTimeout(function(){Y=0;D()},50);X=!1}}function E(a){s(p,a[0])||q(m(a[0],null,!0)).init(a[1],a[2])}function K(a){var a=a.currentTarget||a.srcElement,e=i.onScriptLoad;a.detachEvent&&!Z?a.detachEvent("onreadystatechange",e):a.removeEventListener("load",e,!1);e=i.onScriptError;(!a.detachEvent||Z)&&a.removeEventListener("error",e,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function L(){var a; +for(x();A.length;){a=A.shift();if(null===a[0])return w(C("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));E(a)}}var X,$,i,N,Y,l={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},k={},W={},aa={},A=[],p={},T={},ba={},M=1,Q=1;N={require:function(a){return a.require?a.require:a.require=i.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?p[a.map.id]=a.exports:a.exports=p[a.map.id]={}},module:function(a){return a.module? +a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return j(l.config,a.map.id)||{}},exports:a.exports||(a.exports={})}}};$=function(a){this.events=j(aa,a.id)||{};this.map=a;this.shim=j(l.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};$.prototype={init:function(a,e,b,f){f=f||{};if(!this.inited){this.factory=e;if(b)this.on("error",b);else this.events.error&&(b=t(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback= +b;this.inited=!0;this.ignore=f.ignore;f.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,e){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=e)},fetch:function(){if(!this.fetched){this.fetched=!0;i.startTime=(new Date).getTime();var a=this.map;if(this.shim)i.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],t(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a= +this.map.url;T[a]||(T[a]=!0,i.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,e,b=this.map.id;e=this.depExports;var f=this.exports,c=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(G(c)){if(this.events.error&&this.map.isDefine||h.onError!==da)try{f=i.execCb(b,c,e,f)}catch(d){a=d}else f=i.execCb(b,c,e,f);this.map.isDefine&&void 0===f&&((e=this.module)?f=e.exports:this.usingExports&& +(f=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",w(this.error=a)}else f=c;this.exports=f;if(this.map.isDefine&&!this.ignore&&(p[b]=f,h.onResourceLoad))h.onResourceLoad(i,this.map,this.depMaps);y(b);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a= +this.map,b=a.id,d=m(a.prefix);this.depMaps.push(d);r(d,"defined",t(this,function(f){var d,g;g=j(ba,this.map.id);var J=this.map.name,u=this.map.parentMap?this.map.parentMap.name:null,p=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(f.normalize&&(J=f.normalize(J,function(a){return c(a,u,!0)})||""),f=m(a.prefix+"!"+J,this.map.parentMap),r(f,"defined",t(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),g=j(k,f.id)){this.depMaps.push(f); +if(this.events.error)g.on("error",t(this,function(a){this.emit("error",a)}));g.enable()}}else g?(this.map.url=i.nameToUrl(g),this.load()):(d=t(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),d.error=t(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];B(k,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),d.fromText=t(this,function(f,c){var g=a.name,J=m(g),k=O;c&&(f=c);k&&(O=!1);q(J);s(l.config,b)&&(l.config[g]=l.config[b]);try{h.exec(f)}catch(j){return w(C("fromtexteval", +"fromText eval for "+b+" failed: "+j,j,[b]))}k&&(O=!0);this.depMaps.push(J);i.completeLoad(g);p([g],d)}),f.load(a.name,p,d,l))}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){W[this.map.id]=this;this.enabling=this.enabled=!0;v(this.depMaps,t(this,function(a,b){var c,f;if("string"===typeof a){a=m(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=j(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;r(a,"defined",t(this,function(a){this.defineDep(b, +a);this.check()}));this.errback&&r(a,"error",t(this,this.errback))}c=a.id;f=k[c];!s(N,c)&&(f&&!f.enabled)&&i.enable(a,this)}));B(this.pluginMaps,t(this,function(a){var b=j(k,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){v(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:l,contextName:b,registry:k,defined:p,urlFetched:T,defQueue:A,Module:$,makeModuleMap:m, +nextTick:h.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=l.shim,c={paths:!0,bundles:!0,config:!0,map:!0};B(a,function(a,b){c[b]?(l[b]||(l[b]={}),V(l[b],a,!0,!0)):l[b]=a});a.bundles&&B(a.bundles,function(a,b){v(a,function(a){a!==b&&(ba[a]=b)})});a.shim&&(B(a.shim,function(a,c){H(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);b[c]=a}),l.shim=b);a.packages&&v(a.packages,function(a){var b, +a="string"===typeof a?{name:a}:a;b=a.name;a.location&&(l.paths[b]=a.location);l.pkgs[b]=a.name+"/"+(a.main||"main").replace(ja,"").replace(R,"")});B(k,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=m(b))});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ca,arguments));return b||a.exports&&ea(a.exports)}},makeRequire:function(a,e){function g(f,c,d){var j,l;e.enableBuildCallback&&(c&&G(c))&&(c.__requireJsBuild= +!0);if("string"===typeof f){if(G(c))return w(C("requireargs","Invalid require call"),d);if(a&&s(N,f))return N[f](k[a.id]);if(h.get)return h.get(i,f,a,g);j=m(f,a,!1,!0);j=j.id;return!s(p,j)?w(C("notloaded",'Module name "'+j+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):p[j]}L();i.nextTick(function(){L();l=q(m(null,a));l.skipMap=e.skipMap;l.init(f,c,d,{enabled:!0});D()});return g}e=e||{};V(g,{isBrowser:z,toUrl:function(b){var e,d=b.lastIndexOf("."),g=b.split("/")[0];if(-1!== +d&&(!("."===g||".."===g)||1<d))e=b.substring(d,b.length),b=b.substring(0,d);return i.nameToUrl(c(b,a&&a.id,!0),e,!0)},defined:function(b){return s(p,m(b,a,!1,!0).id)},specified:function(b){b=m(b,a,!1,!0).id;return s(p,b)||s(k,b)}});a||(g.undef=function(b){x();var c=m(b,a,!0),e=j(k,b);d(b);delete p[b];delete T[c.url];delete aa[b];U(A,function(a,c){a[0]===b&&A.splice(c,1)});e&&(e.events.defined&&(aa[b]=e.events),y(b))});return g},enable:function(a){j(k,a.id)&&q(a).enable()},completeLoad:function(a){var b, +c,f=j(l.shim,a)||{},d=f.exports;for(x();A.length;){c=A.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);E(c)}c=j(k,a);if(!b&&!s(p,a)&&c&&!c.inited){if(l.enforceDefine&&(!d||!ea(d)))return g(a)?void 0:w(C("nodefine","No define call for "+a,null,[a]));E([a,f.deps||[],f.exportsFn])}D()},nameToUrl:function(a,b,c){var f,d,g;(f=j(l.pkgs,a))&&(a=f);if(f=j(ba,a))return i.nameToUrl(f,b,c);if(h.jsExtRegExp.test(a))f=a+(b||"");else{f=l.paths;a=a.split("/");for(d=a.length;0<d;d-=1)if(g=a.slice(0, +d).join("/"),g=j(f,g)){H(g)&&(g=g[0]);a.splice(0,d,g);break}f=a.join("/");f+=b||(/^data\:|\?/.test(f)||c?"":".js");f=("/"===f.charAt(0)||f.match(/^[\w\+\.\-]+:/)?"":l.baseUrl)+f}return l.urlArgs?f+((-1===f.indexOf("?")?"?":"&")+l.urlArgs):f},load:function(a,b){h.load(i,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||ka.test((a.currentTarget||a.srcElement).readyState))P=null,a=K(a),i.completeLoad(a.id)},onScriptError:function(a){var b=K(a);if(!g(b.id))return w(C("scripterror", +"Script error for: "+b.id,a,[b.id]))}};i.require=i.makeRequire();return i}var h,x,y,D,K,E,P,L,q,Q,la=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ma=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,R=/\.js$/,ja=/^\.\//;x=Object.prototype;var M=x.toString,ga=x.hasOwnProperty,ia=Array.prototype.splice,z=!!("undefined"!==typeof window&&"undefined"!==typeof navigator&&window.document),fa=!z&&"undefined"!==typeof importScripts,ka=z&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/, +Z="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),F={},r={},S=[],O=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(G(requirejs))return;r=requirejs;requirejs=void 0}"undefined"!==typeof require&&!G(require)&&(r=require,require=void 0);h=requirejs=function(b,c,d,g){var u,m="_";!H(b)&&"string"!==typeof b&&(u=b,H(c)?(b=c,c=d,d=g):b=[]);u&&u.context&&(m=u.context);(g=j(F,m))||(g=F[m]=h.s.newContext(m));u&&g.configure(u);return g.require(b,c,d)};h.config=function(b){return h(b)}; +h.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=h);h.version="2.1.11";h.jsExtRegExp=/^\/|:|\?|\.js$/;h.isBrowser=z;x=h.s={contexts:F,newContext:ha};h({});v(["toUrl","undef","defined","specified"],function(b){h[b]=function(){var c=F._;return c.require[b].apply(c,arguments)}});if(z&&(y=x.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0]))y=x.head=D.parentNode;h.onError=da;h.createNode=function(b){var c= +b.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");c.type=b.scriptType||"text/javascript";c.charset="utf-8";c.async=!0;return c};h.load=function(b,c,d){var g=b&&b.config||{};if(z)return g=h.createNode(g,c,d),g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&0>g.attachEvent.toString().indexOf("[native code"))&&!Z?(O=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)): +(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=d,L=g,D?y.insertBefore(g,D):y.appendChild(g),L=null,g;if(fa)try{importScripts(d),b.completeLoad(c)}catch(j){b.onError(C("importscripts","importScripts failed for "+c+" at "+d,j,[c]))}};z&&!r.skipDataMain&&U(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(K=b.getAttribute("data-main"))return q=K,r.baseUrl||(E=q.split("/"),q=E.pop(),Q=E.length?E.join("/")+"/":"./",r.baseUrl= +Q),q=q.replace(R,""),h.jsExtRegExp.test(q)&&(q=K),r.deps=r.deps?r.deps.concat(q):[q],!0});define=function(b,c,d){var g,h;"string"!==typeof b&&(d=c,c=b,b=null);H(c)||(d=c,c=null);!c&&G(d)&&(c=[],d.length&&(d.toString().replace(la,"").replace(ma,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(O){if(!(g=L))P&&"interactive"===P.readyState||U(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),g=P;g&&(b|| +(b=g.getAttribute("data-requiremodule")),h=F[g.getAttribute("data-requirecontext")])}(h?h.defQueue:S).push([b,c,d])};define.amd={jQuery:!0};h.exec=function(b){return eval(b)};h(r)}})(this); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/samples/plugin.js b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/samples/plugin.js new file mode 100644 index 0000000..e5a0718 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/samples/plugin.js @@ -0,0 +1,13 @@ +c3.chart.internal.fn.isTimeSeries = function () { + console.log('custom isTimeSeries'); + return false; +}; +c3.chart.internal.fn.additionalConfig.test1 = undefined; +c3.chart.internal.fn.additionalConfig.test2 = undefined; + +c3.chart.fn.hoge = function () { + console.log("hoge()", this.internal.isTimeSeries()); +}; +c3.chart.fn.test = function () { + console.log('test()', this.internal.config.test1); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/samples/requirejs.js b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/samples/requirejs.js new file mode 100644 index 0000000..95f5a7d --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/samples/requirejs.js @@ -0,0 +1,18 @@ +require.config({ + baseUrl: '/js', + paths: { + d3: "http://d3js.org/d3.v3.min" + } +}); + +require(["d3", "c3"], function(d3, c3) { + + window.chart = c3.generate({ + data: { + columns: [ + ['sample', 30, 200, 100, 400, 150, 250] + ] + } + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/samples/zoom_reduction.js b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/samples/zoom_reduction.js new file mode 100644 index 0000000..0c12921 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/js/samples/zoom_reduction.js @@ -0,0 +1,81 @@ +var chart; +function refresh() { + if (suspendRefresh) + return; + chart.load({ + columns: [ + ["Value"].concat(zoom(column, currentZoom, "t=>Math.round(t.avg())".toLambda())), + ["xColumn"].concat(zoom(xColumn, currentZoom, "t=>t[0]".toLambda())), + ] + }); +} + +function getChart() { + return chart; +} +function main() { + var last = 0; + var max = 10000; + var column = Array.generate(max, function (i) { + return last += Math.randomInt(-10, 10); + }); + var xColumn = Array.generateNumbers(0, max); + var options = { + bindto: "#divChart", + data: { + columns: [ + ["Value"].concat(column), + ["x"].concat(xColumn), + ], + type: "line", + x: "x" + }, + zoom2: { + enabled: true, + } + }; + chart = c3ext.generate(options); + + window.setInterval(refreshStatus, 1000); + + function refreshStatus() { + var zoomInfo = chart.zoom2.getZoom(); + var info = { + reduced: chart.zoom2.maxItems(), + actual: (zoomInfo.currentZoom[1] - zoomInfo.currentZoom[0]), + range: zoomInfo.currentZoom[0] + "-" + zoomInfo.currentZoom[1], + total: zoomInfo.totalItems + }; + $("#status").text(JSON.stringify(info, null, " ")); + } + +}; + +if (typeof (Array.generate) == "undefined") { + Array.generate = function (length, generator) { + var list = new Array(length); + for (var i = 0; i < length; i++) { + list[i] = generator(i); + } + return list; + } +} +if (typeof (Math.randomInt) == "undefined") { + Math.randomInt = function (min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } +} +if (typeof (Array.generateNumbers) == "undefined") { + Array.generateNumbers = function (from, until) { + if (arguments.length == 1) { + until = from; + from = 0; + } + var length = until - from; + var list = new Array(length); + for (var i = 0; i < length; i++) { + list[i] = i + from; + } + return list; + } +}
\ No newline at end of file diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_axis_label.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_axis_label.html new file mode 100644 index 0000000..b53de6a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_axis_label.html @@ -0,0 +1,70 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data1: 'y', + data2: 'y2', + } + }, + axis: { + x: { + label: 'X Label' + }, + y: { + label: { + text: 'Y Axis Label', + position: 'outer-middle' + } + }, + y2: { + show: true, + label: { + text: 'Y2 Axis Label', + position: 'outer-middle' + } + } + }, + tooltip: { +// enabled: false + }, + zoom: { +// enabled: true + }, + subchart: { +// show: true + } + }); + + setTimeout(function () { + chart.axis.labels({ + x: 'New X Axis Label', + y: 'New Y Axis Label', + y2: 'New Y2 Axis Label', + }); + }, 1000); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 100, 300, 600, 200, 400, 500] + ] + }); + chart.axis.labels({y: 'New Y Axis Label Again'}); + }, 2000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_axis_range.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_axis_range.html new file mode 100644 index 0000000..daa7843 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_axis_range.html @@ -0,0 +1,81 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data1: 'y', + data2: 'y2', + } + }, + axis: { + x: { + label: 'X Label' + }, + y: { + label: { + text: 'Y Axis Label', + position: 'outer-middle' + } + }, + y2: { + show: true, + label: { + text: 'Y2 Axis Label', + position: 'outer-middle' + } + } + }, + tooltip: { +// enabled: false + }, + zoom: { +// enabled: true + }, + subchart: { +// show: true + } + }); + + setTimeout(function () { + chart.axis.max(500); + }, 1000); + + setTimeout(function () { + chart.axis.min(-500); + }, 2000); + + setTimeout(function () { + chart.axis.max({y: 600, y2: 100}); + }, 3000); + + setTimeout(function () { + chart.axis.min({y: -600, y2: -100}); + }, 4000); + + setTimeout(function () { + chart.axis.range({max: 1000, min: -1000}); + }, 5000); + + setTimeout(function () { + chart.axis.range({min: {y: 1000}, max: {y: 2000}}); + }, 6000); + + setTimeout(function () { + chart.axis.range({max: {y: 600, y2: 100}, min: {y: -100, y2: 0}}); + }, 7000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_category.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_category.html new file mode 100644 index 0000000..143c31d --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_category.html @@ -0,0 +1,48 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + <div id="message"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + data: { + x: 'x', + columns: [ + ['x', '1e-3', '1e-2', '1'], + ['data1', 30, 200, 100, 400, 150, 250, 50, 100, 250] + ] + }, + axis: { + x: { + type: 'categorized' + } + } + }); + + setTimeout(function () { + d3.select('#message').node().innerHTML = "chart.categories() =>" + chart.categories(); + }, 1000); + + setTimeout(function () { + chart.categories(['updated 1', 'updated 2', 'updated 3', 'updated 4']); + d3.select('#message').node().innerHTML = ""; + }, 2000); + + setTimeout(function () { + d3.select('#message').node().innerHTML = "chart.category(1) =>" + chart.category(1); + }, 3000); + + setTimeout(function () { + chart.category(1, 'UPDATED 1'); + d3.select('#message').node().innerHTML = ""; + }, 4000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_data_colors.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_data_colors.html new file mode 100644 index 0000000..755341a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_data_colors.html @@ -0,0 +1,33 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + }, + axis: { + x: { + type: 'category' + } + } + }); + + setTimeout(function () { + chart.data.colors({data1: '#000'}); + }, 1000); + + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_flow.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_flow.html new file mode 100644 index 0000000..363faf5 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_flow.html @@ -0,0 +1,223 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + <style> + .c3-region-1 { + fill: #dd3333; + fill-opacity: 0.8 + } + </style> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var padding = {}, types = {}, chart, generate = function () { return c3.generate({ + data: { + columns: [ + ['data1'], + ['data2'], + ], + types: types, + labels: true + }, + bar: { + width: 10 + }, + axis: { + x: { + padding: padding + }, + y: { +/* + min: -100, + max: 1000 +*/ + } + }, + grid: { + x: { + show: true, + lines: [{value: 3, text:'Label 3'}, {value: 4.5, text: 'Label 4.5'}] + }, + y: { + show: true + } + }, + regions: [ + {start:2, end:4, class:'region1'}, + {start:100, end:200, axis:'y'}, + ], + }); + }; + + function run() { + + chart = generate(); + + setTimeout(function () { + // Load only one data + chart.flow({ + rows: [ + ['data1', 'data2', 'data3'], + [500, 100, 200], + [200, null, null], + [100, 50, null] + ], + duration: 1500, + + done: function () { + // Load 2 data without data2 and remove 1 data + chart.flow({ + columns: [ + ['data1', 200, 300], + ['data3', 100, 100] + ], + length: 0, + duration: 1500, + + done: function () { + chart.flow({ + columns: [ + ['data1', 200, 300], + ['data2', 200, 300], + ['data3', 100, 100] + ], + length: 2, + duration: 1500, + done: function () { + + chart.flow({ + columns: [ + ['data1', 500], + ['data2', 100], + ['data3', 200] + ], + length: 1, + duration: 1500, + }); + } + + }); + }// done + + }); + }, + + }); + }, 1000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['data1', 250], + ['data2', 350], + ['data3', 150] + ], + length: 0 + }); + }, 9000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['data1', 100], + ['data2', 50], + ['data3', 300] + ], + length: 2 + }); + }, 10000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['data1', 600], + ['data2', 400], + ['data3', 500] + ], + to: 2, + }); + }, 11000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['data1', 100], + ['data2', 200], + ['data3', 300] + ] + }); + }, 12000); + + setTimeout(function () { + chart = generate(); + }, 13000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['data1', 500, 100], + ['data2', 100, 200], + ['data3', 200, 300], + ], + duration: 1500, + done: function () { + chart.flow({ + columns: [ + ['data1', 200], + ['data3', 100] + ], +// duration: 1000, + length: 1 + }); + }, + }); + }, 14000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['data1', 200], + ['data2', 300], + ['data3', 100] + ], + to: 1, + }); + }, 18000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['data1', 200], + ['data2', 300], + ['data3', 400] + ] + }); + }, 19000); + + } + + run(); + + // Test for no padding + setTimeout(function () { + padding = {left: 0, right: 0}; + run(); + }, 22000); + + // Test for other chart types + setTimeout(function () { + types = { + data2: 'area', + data3: 'bar', + }; + run(); + }, 45000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_flow_timeseries.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_flow_timeseries.html new file mode 100644 index 0000000..216d7e4 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_flow_timeseries.html @@ -0,0 +1,173 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var padding = {}, types = {}; + + var generate = function () { return c3.generate({ + data: { + x: 'x', + columns: [ + ['x', ], + ['data1', ], + ['data2', ], +// ['x', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-10', '2013-01-11', '2013-01-12'], +// ['data1', 30, 200, 100, 400, 150, 250], +// ['data2', 310, 400, 200, 100, 450, 150], +// ['data3', 310, 400, 200, 100, null, 150], + ], + types: types, +// labels: true + }, + bar: { + width: 10 + }, + axis: { + x: { + type: 'timeseries', + tick: { + format: '%m/%d', + }, + padding: padding + }, + y: { +/* + min: -100, + max: 1000 +*/ + } + }, +/* not supported yet + grid: { + x: { + show: true + }, + y: { + show: true + } + } +*/ + }); }, chart; + + function run() { + + chart = generate(); + + setTimeout(function () { + chart.flow({ + columns: [ + ['x', '2013-01-21'], + ['data1', 500], + ['data3', 200], + ], + duration: 1500 + }); + }, 1000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['x', '2013-02-01', '2013-02-08', '2013-02-15'], + ['data1', 200, 400, 300], + ['data2', 100, 300, 200], + ['data3', 100, 200, 50] + ], + length: 1, + duration: 1500 + }); + }, 4000); + + setTimeout(function () { + console.log("Flow 1"); + chart.flow({ + columns: [ + ['x', '2013-03-01', '2013-03-08'], + ['data1', 200, 500], + ['data2', 300, 400], + ['data3', 400, 200] + ], + to: '2013-02-08', + duration: 1500 + }); + }, 7000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['x', '2013-03-15', '2013-05-01'], + ['data1', 200, 500], + ['data2', 300, 400], + ['data3', 400, 200] + ], + length: 0, + duration: 1500 + }); + }, 10000); + + setTimeout(function () { + chart = generate(); + }, 14000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['x', '2013-01-21', '2013-01-25', '2013-01-26'], + ['data1', 500, 300, 100], + ['data3', 200, 150, null], + ], + duration: 1500 + }); + }, 15000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['x', '2013-02-01'], + ['data1', 200], + ['data2', 100], + ['data3', 100] + ], + length: 0, + duration: 1500 + }); + }, 18000); + + setTimeout(function () { + chart.flow({ + columns: [ + ['x', '2013-03-01'], + ['data1', 200], + ['data2', 300], + ['data3', 400] + ], + to: '2013-02-01', + duration: 1500 + }); + }, 21000); + }; + + run(); + + setTimeout(function () { + padding = {left: 0, right: 0}; + run(); + }, 25000); + + setTimeout(function () { + types = { + data2: 'area', + data3: 'bar', + } + run(); + }, 50000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_legend.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_legend.html new file mode 100644 index 0000000..dfc6994 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_legend.html @@ -0,0 +1,136 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var columns = []; + for (var i = 0; i < 5; i++ ) { + columns[i] = ['datahogehogeohgeohoge' + i, 10 * i, 20 * i, 30 * i]; + } + + var chart = c3.generate({ + data: { + columns: columns, + }, + axis: { + x: { + type: 'category' + } + } + }); + + setTimeout(function () { + chart.legend.hide(); + }, 1000); + + setTimeout(function () { + chart = c3.generate({ + data: { + columns: columns, + }, + axis: { + x: { + type: 'category' + } + }, + legend: { + position: 'right' + } + }); + }, 2000); + + setTimeout(function () { + chart.legend.hide(); + }, 3000); + + setTimeout(function () { + chart = c3.generate({ + data: { + columns: columns, + }, + axis: { + rotated: true + } + }); + }, 4000); + + setTimeout(function () { + chart.legend.hide(); + }, 5000); + + setTimeout(function () { + chart = c3.generate({ + data: { + columns: columns, + }, + legend: { + position: 'right' + }, + axis: { + rotated: true + } + }); + }, 6000); + + setTimeout(function () { + chart.legend.hide(); + }, 7000); + + setTimeout(function () { + chart = c3.generate({ + data: { + columns: columns, + }, + legend: { + show: false + } + }); + }, 8000); + + setTimeout(function () { + chart.legend.show(); + }, 9000); + + setTimeout(function () { + chart = c3.generate({ + data: { + columns: columns, + }, + legend: { + show: false + }, + axis: { + rotated: true + } + }); + }, 10000); + + setTimeout(function () { + chart.legend.show(); + }, 11000); + + setTimeout(function () { + chart = c3.generate({ + data: { + columns: columns, + }, + legend: { + position: 'right', + show: false + } + }); + }, 12000); + + setTimeout(function () { + chart.legend.show(); + }, 13000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_tooltip_show.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_tooltip_show.html new file mode 100644 index 0000000..b4a82b5 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_tooltip_show.html @@ -0,0 +1,38 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + } + }); + + setTimeout(function () { + chart.tooltip.show({ x: 1 }); + }, 1000); + + setTimeout(function () { + chart.tooltip.show({ index: 3 }); + }, 2000); + + setTimeout(function () { + chart.tooltip.show({ data: {x: 2} }); + }, 3000); + + setTimeout(function () { + chart.tooltip.hide(); + }, 4000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_transform.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_transform.html new file mode 100644 index 0000000..4a85426 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_transform.html @@ -0,0 +1,70 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + }, + }); + + setTimeout(function () { + chart.transform('bar'); + }, 1000); + + setTimeout(function () { + chart.transform('pie'); + }, 2000); + + setTimeout(function () { + chart.transform('donut'); + }, 3000); + + setTimeout(function () { + chart.transform('area'); + }, 4000); + + setTimeout(function () { + chart.transform('spline'); + }, 5000); + + setTimeout(function () { + chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data1_x', 50, 20, 10, 40, 15, 25], + ['data2_x', 30, 200, 100, 400, 150, 250], + ], + xs: { + data1: 'data1_x', + data2: 'data2_x', + }, + type: 'scatter' + }, + }); + }, 7000); + + setTimeout(function () { + chart.transform('pie'); + }, 8000); + + setTimeout(function () { + chart.transform('scatter'); + }, 9000); + + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_xgrid_lines.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_xgrid_lines.html new file mode 100644 index 0000000..661d111 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_xgrid_lines.html @@ -0,0 +1,125 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var axis_rotated = false, axis_x_type = ""; + + var generate = function () { return c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['sample', 30, 200, 100, 400, 150, 250] + ] + }, + axis: { + rotated: axis_rotated, + x: { + type: axis_x_type + } + }, + grid: { + x: { +// lines: [{value: 3, text:'Label 3'}, {value: 4.5, text: 'Label 4.5'}] + } + } + }); }, chart = generate(); + + var queue = [ + function () { + chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]); + }, + function () { + chart.xgrids([{value: 2, text:'Label 2'}]); + }, + function () { + chart.xgrids.add([{value: 3, text:'Label 3', class:'hoge'}]); + }, + function () { + chart.xgrids.remove({value:2}); + }, + function () { + chart.xgrids.remove({class:'hoge'}); + }, + function () { + chart.xgrids.remove([{value: 1}, {value: 4}]); + }, + function () { + chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]); + }, + function () { + chart.xgrids.remove(); + }, + function () { + axis_rotated = true; + chart = generate(); + }, + function () { + chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]); + }, + function () { + chart.xgrids([{value: 2, text:'Label 2'}]); + }, + function () { + chart.xgrids.add([{value: 3, text:'Label 3', class:'hoge'}]); + }, + function () { + chart.xgrids.remove({value:2}); + }, + function () { + chart.xgrids.remove({class:'hoge'}); + }, + function () { + chart.xgrids.remove([{value: 1}, {value: 4}]); + }, + function () { + chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]); + }, + function () { + chart.xgrids.remove(); + }, + function () { + axis_rotated = false; + axis_x_type = 'category'; + chart = generate(); + }, + function () { + chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]); + }, + function () { + chart.xgrids([{value: 2, text:'Label 2'}]); + }, + function () { + chart.xgrids.add([{value: 3, text:'Label 3', class:'hoge'}]); + }, + function () { + chart.xgrids.remove({value:2}); + }, + function () { + chart.xgrids.remove({class:'hoge'}); + }, + function () { + chart.xgrids.remove([{value: 1}, {value: 4}]); + }, + function () { + chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]); + }, + function () { + chart.xgrids.remove(); + }, + ]; + + var i = 0; + queue.forEach(function (f) { + setTimeout(f, 1000 * i++); + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_ygrid_lines.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_ygrid_lines.html new file mode 100644 index 0000000..57784ed --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/api_ygrid_lines.html @@ -0,0 +1,50 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['sample', 30, 200, 100, 400, 150, 250] + ] + }, + axis: { +// rotated: true, + }, + grid: { + y: { +// lines: [{value: 30, text:'Label 30'}, {value: 250, text: 'Label 250'}] + } + } + }); + + setTimeout(function () { + chart.ygrids([{value: 130, text:'Label 130'}, {value: 50, text: 'Label 50'}]); + }, 1000); + + setTimeout(function () { + chart.ygrids([{value: 130, text:'Label 130', class: 'hoge'}]); + }, 2000); + + setTimeout(function () { + chart.ygrids.add([{value: 230, text:'Label 230', class: 'hoge'}]); + }, 3000); + + setTimeout(function () { + chart.ygrids.remove({value: 230}); + }, 4000); + + setTimeout(function () { + chart.ygrids.remove({class: 'hoge'}); + }, 5000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/area_zerobased.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/area_zerobased.html new file mode 100644 index 0000000..f7975c9 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/area_zerobased.html @@ -0,0 +1,25 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 1030, 1200, 1100, 1400, 1150, 1250], + ['data2', 2130, 2100, 2140, 2200, 2150, 1850] + ], + type: 'area', + }, + area: { + zerobased: false + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_padding.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_padding.html new file mode 100644 index 0000000..c562a4a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_padding.html @@ -0,0 +1,62 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 300, 2000, 1000, 4000, 1500, 2500], + ], + axes: { + data2: 'y2' + } + }, + axis: { + y: { + padding: { + top: 0.1, + bottom: 0.1, + unit: 'ratio' + } + }, + y2: { + show: true, + padding: { + top: 200, + bottom: 200, + } + } + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', 3000, 20000, 10000, 40000, 15000, 25000], + ], + }, + axis: { + y: { + padding: { + top: 0.1, + bottom: 0.1, + unit: 'ratio' + } + } + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_range.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_range.html new file mode 100644 index 0000000..732200a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_range.html @@ -0,0 +1,87 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['sample', 100, 200, 100, 400, 150, 250] + ], + }, + axis: { + x: { + min: -10, + max: 10, + } + }, + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + x: 'x', + columns: [ + ['x', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06'], + ['sample', 100, 200, 100, 400, 150, 250] + ], + }, + axis: { + x: { + type: 'timeseries', + min: new Date('2012-12-20'), + max: '2013-03-01', + tick : { + format : "%Y-%m-%d %H:%M:%S" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format + } + } + } + }); + + setTimeout(function () { + chart1.axis.max({x: 20}); + }, 1000); + + setTimeout(function () { + chart1.axis.min({x: -5}); + }, 2000); + + setTimeout(function () { + chart1.axis.range({max: {x: 5}, min: {x: 0}}); + }, 3000); + + setTimeout(function () { + chart2.axis.max({x: new Date('2013-02-01')}); + }, 1000); + + setTimeout(function () { + chart2.axis.min({x: new Date('2012-12-01')}); + }, 2000); + + setTimeout(function () { + chart2.axis.range({max: {x: '2013-01-06'}, min: {x: '2013-01-01'}}); + }, 3000); + + setTimeout(function () { + chart2.axis.max({y: 1000}); + }, 4000); + + setTimeout(function () { + chart2.axis.min({y: -1000}); + }, 5000); + + setTimeout(function () { + chart2.axis.range({max: {y: 400}, min: {y: 0}}); + }, 6000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_extent.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_extent.html new file mode 100644 index 0000000..b433824 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_extent.html @@ -0,0 +1,76 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 100, 200, 50, 300, 400, 290], + ['data2', 10, 20, 50, 30, 10, 100], + ], + }, + axis: { + x: { + extent: [2, 4.5] + } + }, + subchart: { + show: true + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + x: 'x', + columns: [ + ['x', '2014-01-01', '2014-02-01', '2014-03-01', '2014-04-01', '2014-05-01', '2014-06-01'], + ['data1', 100, 200, 50, 300, 400, 290], + ['data2', 10, 20, 50, 30, 10, 100], + ], + }, + axis: { + x: { + type: 'timeseries', + extent: ['2014-03-01', '2014-04-20'] + } + }, + subchart: { + show: true + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', 100, 200, 50, 300, 400, 290], + ['data2', 10, 20, 50, 30, 10, 100], + ], + }, + axis: { + x: { + extent: [1, 4.2] + } + }, + zoom: { + enabled: true + }, + subchart: { + show: true + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_localtime.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_localtime.html new file mode 100644 index 0000000..3b5813e --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_localtime.html @@ -0,0 +1,137 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var data, axis_x_localtime; + + var data1 = { + x : 'date', + columns: [ + ['date', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05'], + ['sample', 30, 200, 100, 400, 150], + ['sample2', 130, 300, 200, 450, 250] + ] + }; + + var data2 = { + x : 'date', + columns: [ + ['date', 1356966000000, 1357052400000, 1357138800000, 1357225200000, 1357311600000], + ['sample', 30, 200, 100, 400, 150], + ['sample2', 130, 300, 200, 450, 250] + ] + }; + + var data3 = { + x : 'date', + columns: [ + ['date', new Date(1356966000000), new Date(1357052400000), new Date(1357138800000), new Date(1357225200000), new Date(1357311600000)], + ['sample', 30, 200, 100, 400, 150], + ['sample2', 130, 300, 200, 450, 250] + ] + }; + + var data4 = { + x : 'date', + x_format : '%Y%m%d', + columns: [ + ['date', '20130101', '20130102', '20130103', '20130104', '20130105'], + ['sample', 1030, 1200, 1100, 1400, 1150], + ['sample2', 130, 300, 200, 450, 250] + ] + }; + + var data5 = { + x : 'date', + x_format : '%Y%m%d %H:%M:%S', + columns: [ + ['date', '20130101 00:00:00', '20130102 00:00:00', '20130103 00:00:00', '20130104 00:00:00', '20130105 00:00:00'], + ['sample', 30, 200, 100, 400, 150], + ['sample2', 1130, 1300, 1200, 1450, 1250] + ] + }; + + var generate = function () { return c3.generate({ + bindto: '#chart', + data: data, + axis : { + x : { + type : 'timeseries', + tick : { + format : "%Y-%m-%d %H:%M:%S" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format + }, + localtime: axis_x_localtime + } + } + }); }; + + setTimeout(function () { + data = data1; + axis_x_localtime = true; + chart = generate(); + }, 1000); + + setTimeout(function () { + data = data1; + axis_x_localtime = false; + chart = generate(); + }, 2000); + + setTimeout(function () { + data = data2; + axis_x_localtime = true; + chart = generate(); + }, 3000); + + setTimeout(function () { + data = data2; + axis_x_localtime = false; + chart = generate(); + }, 4000); + + setTimeout(function () { + data = data3; + axis_x_localtime = true; + chart = generate(); + }, 5000); + + setTimeout(function () { + data = data3; + axis_x_localtime = false; + chart = generate(); + }, 6000); + + setTimeout(function () { + data = data4; + axis_x_localtime = true; + chart = generate(); + }, 7000); + + setTimeout(function () { + data = data4; + axis_x_localtime = false; + chart = generate(); + }, 8000); + + setTimeout(function () { + data = data5; + axis_x_localtime = true; + chart = generate(); + }, 9000); + + setTimeout(function () { + data = data5; + axis_x_localtime = false; + chart = generate(); + }, 10000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_range_timeseries.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_range_timeseries.html new file mode 100644 index 0000000..4b98bb9 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_range_timeseries.html @@ -0,0 +1,57 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + "bindto": "#chart1", + "axis": { + "x": { + "type": "timeseries", + "min": 1401879600000, + "max": 1401969600000, + } + }, + "data": { + "type": "line", + "columns": [ + ["epoch", 1401879600000, 1401883200000, 1401886800000], + ["y", 1955, 2419, 2262] + ], + "xs": { + "y": "epoch" + } + } + }); + + var chart2 = c3.generate({ + "bindto": "#chart2", + "axis": { + "x": { + "type": "timeseries", + "min": new Date(1401879600000), + "max": new Date(1401969600000), + } + }, + "data": { + "type": "line", + "columns": [ + ["epoch", 1401879600000, 1401883200000, 1401886800000], + ["y", 1955, 2419, 2262] + ], + "xs": { + "y": "epoch" + } + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_culling.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_culling.html new file mode 100644 index 0000000..f0f54ca --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_culling.html @@ -0,0 +1,39 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + }, + axis: { + x: { + tick: { + culling: { + max: 2 + } + } + } + }, + tooltip: { +// enabled: false + }, + zoom: { +// enabled: true + }, + subchart: { +// show: true + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_fit.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_fit.html new file mode 100644 index 0000000..5f8ed36 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_fit.html @@ -0,0 +1,35 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + x: 'x', + columns: [ + ['x', '2013-10-31', '2013-11-30', '2013-12-31', '2014-01-31', '2014-02-28'], +// ['x', 30, 70, 150, 200, 350], + ['sample', 30, 200, 100, 400, 150], + ['sample2', 130, 300, 200, 500, 250] + ] + }, + axis : { + x : { + type : 'timeseries', + tick: { + fit: true + } + } + }, + subchart: { +// show: true + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_rotate.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_rotate.html new file mode 100644 index 0000000..9cfb531 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_rotate.html @@ -0,0 +1,55 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250, 100, 600], + ['data2', 50, 20, 10, 40, 15, 25], + ] + }, + axis: { +// rotated: true, + x: { + tick: { + format: function () { return "hogehogehogehogehoge"; }, + rotate: 30, + }, + label: { + text: 'Hogehoge', + position: 'outer-middle' + }, + height: 90, + }, + y: { + label: { + text: 'Y Label', + position: 'outer-center' + } + } + }, + subchart: { + show: true + } + }); + + setTimeout(function () { + chart.load({ + columns: [ +// ['data1', 30, 200, 100, 400, 150, 250, 100, 400], + ['data1', 1030, 2000, 1000, 1400, 1500, 1250, 1100, 140000], + ] + }) + }, 1000); + + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_values.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_values.html new file mode 100644 index 0000000..c8922e6 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_x_tick_values.html @@ -0,0 +1,55 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + }, + axis: { + x : { + tick: { + values: [2, 4] + } + } + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + x : 'date', + xFormat : '%Y%m%d', + columns: [ + ['date', '20130101', '20130102', '20130103', '20130104', '20130105', '20130106'], + ['sample', 30, 200, 100, 400, 150, 250], + ['sample2', 130, 300, 200, 450, 250, 350] + ] + }, + axis : { + x : { + type : 'timeseries', + tick : { + format : "%e %b %y", // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format + values: ['20130103', '20130104'] + } + } + } + }); + + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_y2.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_y2.html new file mode 100644 index 0000000..e146c6c --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_y2.html @@ -0,0 +1,30 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data1: 'y', + data2: 'y2' + } + }, + axis: { + y2: { + show: true + } + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_y_default.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_y_default.html new file mode 100644 index 0000000..50119eb --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/axes_y_default.html @@ -0,0 +1,26 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1'], + ['data2'], + ], + }, + axis: { + y: { + default: [-100, 100] + } + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/bar_zerobased.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/bar_zerobased.html new file mode 100644 index 0000000..55d02a8 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/bar_zerobased.html @@ -0,0 +1,25 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 1030, 1200, 1100, 1400, 1150, 1250], + ['data2', 2130, 2100, 2140, 2200, 2150, 1850] + ], + type: 'bar', + }, + bar: { + zerobased: false + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/bindto.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/bindto.html new file mode 100644 index 0000000..14e813d --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/bindto.html @@ -0,0 +1,41 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart1" style="height:300px;"></div> + <div class="chart2" style="height:150px;"></div> + <div class="chart3" style="height:150px;"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 130, 210, 120, 440, 250, 350] + ] + } + }); + + var chart2 = c3.generate({ + bindto: '.chart2', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250] + ] + } + }); + + var chart3 = c3.generate({ + bindto: document.getElementsByClassName('chart3')[0], + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250] + ] + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/categorized.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/categorized.html new file mode 100644 index 0000000..0e4a1b5 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/categorized.html @@ -0,0 +1,54 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + x: 'x', + columns: [ + ['x', '1e-3', '1e-2', '1'], + ['data1', 30, 200, 100, 400, 150, 250, 50, 100, 250] + ] + }, + axis: { + x: { + type: 'categorized' + } + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250, 50, 100, 250] + ] + }, + axis: { + x: { + categories: ['1e-3', '1e-2', '1e-1', '0', 'hoge'], + type: 'categorized' + } + } + }); + + setTimeout(function () { + chart1.load({columns:[['data2', 30, 20, 50, 40, 60, 50, 100, 200, 300,100]]}); + }, 1000); + + setTimeout(function () { + chart2.load({columns:[['data2', 30, 20, 50, 40, 60, 50, 100, 200, 300,100]]}); + }, 2000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area.html new file mode 100644 index 0000000..04ec6bd --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area.html @@ -0,0 +1,88 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <h3>Zerobased</h3> + <div id="chart1"></div> + <h3>Not zerobased because of axis.y.min</h3> + <div id="chart2"></div> + <h3>Zerobased</h3> + <div id="chart3"></div> + <h3>Not zerobased because of axis.y.min</h3> + <div id="chart4"></div> + <h3>+/- vaulues</h3> + <div id="chart5"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 0], + ['data2', 130, 100, 140, 200, 150, 50] + ], + type: 'area' + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 0], + ['data2', 130, 100, 140, 200, 150, 50] + ], + type: 'area' + }, + axis: { + y: { + min: 100, + } + }, + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', -300, -350, -300, 0, 0, 0], + ['data2', -130, -100, -140, -200, -150, -50] + ], + type: 'area' + } + }); + + var chart4 = c3.generate({ + bindto: '#chart4', + data: { + columns: [ + ['data1', -300, -350, -300, 0, 0, 0], + ['data2', -130, -100, -140, -200, -150, -50] + ], + type: 'area' + }, + axis: { + y: { + max: -100, + } + } + }); + + var chart5 = c3.generate({ + bindto: '#chart5', + data: { + columns: [ + ['data1', -300, 350, -300, 0, 0, 0], + ['data2', -130, -100, 140, -200, 150, -50] + ], + type: 'area' + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_spline.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_spline.html new file mode 100644 index 0000000..836474a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_spline.html @@ -0,0 +1,49 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 0], + ['data2', 130, 100, 140, 200, 150, 50] + ], + type: 'area-spline' + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', -300, -350, -300, 0, 0, 0], + ['data2', -130, -100, -140, -200, -150, -50] + ], + type: 'area-spline' + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', -300, 350, -300, 0, 0, 0], + ['data2', -130, -100, 140, -200, 150, -50] + ], + type: 'area-spline' + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_spline_stacked.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_spline_stacked.html new file mode 100644 index 0000000..a5448cb --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_spline_stacked.html @@ -0,0 +1,52 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 100], + ['data2', 130, 0, 140, 200, 0, 50], + ], + type: 'area-spline', + groups: [['data1', 'data2']], + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', -300, -350, -300, 0, 0, -100], + ['data2', -130, 0, -140, -200, 0, -50] + ], + type: 'area-spline', + groups: [['data1', 'data2']], + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', -300, 350, -300, 0, 0, 100], + ['data2', -130, 0, 140, -200, 150, -50] + ], + type: 'area-spline', + groups: [['data1', 'data2']], + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_stacked.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_stacked.html new file mode 100644 index 0000000..9830d94 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_stacked.html @@ -0,0 +1,52 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 100], + ['data2', 130, 0, 140, 200, 0, 50], + ], + type: 'area', + groups: [['data1', 'data2']], + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', -300, -350, -300, 0, 0, -100], + ['data2', -130, 0, -140, -200, 0, -50] + ], + type: 'area', + groups: [['data1', 'data2']], + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', -300, 350, -300, 0, 0, 100], + ['data2', -130, 0, 140, -200, 150, -50] + ], + type: 'area', + groups: [['data1', 'data2']], + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_step.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_step.html new file mode 100644 index 0000000..2ba7a27 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_step.html @@ -0,0 +1,49 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 0], + ['data2', 130, 100, 140, 200, 150, 50] + ], + type: 'area-step' + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', -300, -350, -300, 0, 0, 0], + ['data2', -130, -100, -140, -200, -150, -50] + ], + type: 'area-step' + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', -300, 350, -300, 0, 0, 0], + ['data2', -130, -100, 140, -200, 150, -50] + ], + type: 'area-step' + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_step_stacked.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_step_stacked.html new file mode 100644 index 0000000..ce470e4 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_area_step_stacked.html @@ -0,0 +1,52 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 0], + ['data2', 130, 100, 140, 200, 150, 50] + ], + type: 'area-step', + groups: [['data1', 'data2']], + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', -300, -350, -300, 0, 0, 0], + ['data2', -130, -100, -140, -200, -150, -50] + ], + type: 'area-step', + groups: [['data1', 'data2']], + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', -300, 350, -300, 0, 0, 0], + ['data2', -130, -100, 140, -200, 150, -50] + ], + type: 'area-step', + groups: [['data1', 'data2']], + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_bar.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_bar.html new file mode 100644 index 0000000..1f19af7 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_bar.html @@ -0,0 +1,38 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 1030, 1200, 1100, 1400, 1150, 1250], + ['data2', 2130, 2100, 2140, 2200, 2150, 1850] +// ['data1', 30, 200, 100, 400, 150, 250], +// ['data2', 130, 100, 140, 200, 150, 50] + ], + type: 'bar', + onclick: function (d, element) { console.log("onclick", d, element); }, + onmouseover: function (d) { console.log("onmouseover", d); }, + onmouseout: function (d) { console.log("onmouseout", d); } + }, + axis: { + x: { + type: 'categorized' + } + }, + bar: { + width: { + ratio: 0.3, +// max: 30 + }, + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_bar_stacked.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_bar_stacked.html new file mode 100644 index 0000000..d47fdd7 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_bar_stacked.html @@ -0,0 +1,91 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var axis_x_type = 'category', + axis_rotated = false; + + var generate = function () { return c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 200, 400, 150, -250], + ['data2', 130, -100, 100, 200, 150, 50], + ['data3', 230, -200, 200, 0, 250, 250] + ], + type: 'bar', + groups: [ + ['data1', 'data2'] + ] + }, + axis: { + x: { + type: axis_x_type + }, + rotated: axis_rotated + }, + grid: { + y: { + lines: [{value:0}] + } + }, + }); }, chart = generate(); + + function update1() { + chart.groups([['data1', 'data2', 'data3']]) + } + + function update2() { + chart.load({ + columns: [['data4', 100, 50, 150, -200, 300, -100]] + }); + } + + function update3() { + chart.groups([['data1', 'data2', 'data3', 'data4']]) + } + + + setTimeout(update1, 1000); + setTimeout(update2, 2000); + setTimeout(update3, 3000); + + + setTimeout(function () { + axis_rotated = true; + chart = generate(); + }, 4000); + setTimeout(update1, 5000); + setTimeout(update2, 6000); + setTimeout(update3, 7000); + + + setTimeout(function () { + axis_x_type = ''; + axis_rotated = false; + chart = generate(); + }, 8000); + setTimeout(update1, 9000); + setTimeout(update2, 10000); + setTimeout(update3, 11000); + + + setTimeout(function () { + axis_x_type = ''; + axis_rotated = true; + chart = generate(); + }, 12000); + setTimeout(update1, 13000); + setTimeout(update2, 14000); + setTimeout(update3, 15000); + + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_combination.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_combination.html new file mode 100644 index 0000000..42eb59a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_combination.html @@ -0,0 +1,41 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.min.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 20, 50, 40, 60, 50], + ['data2', 200, 130, 90, 240, 130, 220], + ['data3', 300, 200, 160, 400, 250, 250], + ['data4', 200, 130, 90, 240, 130, 220], + ['data5', 130, 120, 150, 140, 160, 150], + ['data6', 90, 70, 20, 50, 60, 120], + ], + types: { + data1: 'bar', + data2: 'bar', + data3: 'spline', + data4: 'line', + data5: 'bar', + data6: 'area' + }, + groups: [ + ['data1','data2'] + ] + }, + axis: { + x: { + type: 'categorized' + } + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_donut.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_donut.html new file mode 100644 index 0000000..d8453d3 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_donut.html @@ -0,0 +1,60 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ +// ["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2], + ["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3], + ["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8], + ["setosa", 30], +// ["versicolor", 40], +// ["virginica", 50], + ], + type : 'donut', + onmouseover: function (d, i) { console.log("onmouseover", d, i, this); }, + onmouseout: function (d, i) { console.log("onmouseout", d, i, this); }, + onclick: function (d, i) { console.log("onclick", d, i, this); }, + order: null // set null to disable sort of data. desc is the default. + }, + axis: { + x: { + label: 'Sepal.Width' + }, + y: { + label: 'Petal.Width' + } + }, + donut: { + label: { +// format: function (d, ratio) { return ""; } + }, + title: "Iris Petal Width", + width: 70 + } + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 30, 20, 50, 40, 60, 50], + ] + }); + }, 1000); + + setTimeout(function () { + chart.unload({ + ids: 'virginica' + }); + }, 2000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_gauge.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_gauge.html new file mode 100644 index 0000000..a650135 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_gauge.html @@ -0,0 +1,181 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + [ 'data', 91.4 ] + ], + type: 'gauge', + onmouseover: function (d, i) { console.log("onmouseover", d, i, this); }, + onmouseout: function (d, i) { console.log("onmouseout", d, i, this); }, + onclick: function (d, i) { console.log("onclick", d, i, this); }, + }, + gauge: { + label: { +// format: function(value, ratio) { +// return value; +// }, +// show: false // to turn off the min/max labels. + }, +// min: 0, // 0 is default, //can handle negative min e.g. vacuum / voltage / current flow / rate of change +// max: 100, // 100 is default +// units: ' %', +// width: 39 // for adjusting arc thickness + }, + color: { + pattern: ['#FF0000', '#F6C600', '#60B044'], // the three color levels for the percentage values. + threshold: { +// unit: 'value', // percentage is default +// max: 200, // 100 is default + values: [30, 60, 90] // alternate first value is 'value' + } + } + }); + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data', 75.0] + ], + type: 'gauge', + }, + gauge: { + min: 50, + max: 100 + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data', 0.0] + ], + type: 'gauge', + }, + gauge: { + min: -100, + max: 100 + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data', -75.0] + ], + type: 'gauge', + }, + gauge: { + min: -100, + max: -50 + } + }); + + var cycleDemo = function () { + + setTimeout(function () { + d3.select('#chart .c3-chart-arcs-background') + .transition() + .style('fill', '#333'); + }, 1000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 10 ]] + }); + }, 2000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 50 ]] + }); + }, 3000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 91.4 ]] + }); + }, 4000); + + setTimeout(function () { + d3.select('#chart .c3-chart-arcs-background') + .transition() + .style('fill', '#e0e0e0'); + }, 5000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 0 ]] + }); + }, 6000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 50 ]] + }); + }, 7000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 91.4 ]] + }); + }, 8000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 0 ]] + }); + }, 9000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 50 ]] + }); + }, 10000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 91.4 ]] + }); + }, 11000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 0 ]] + }); + }, 12000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 50 ]] + }); + }, 13000); + + setTimeout(function () { + chart.load({ + columns: [[ 'data', 91.4 ]] + }); + }, 14000); + + } + + cycleDemo(); + +// setInterval(cycleDemo, 30000); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_pie.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_pie.html new file mode 100644 index 0000000..e9b7ccb --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_pie.html @@ -0,0 +1,52 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ +// ["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2], + ["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3], + ["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8], + ["setosa", 30], +// ["versicolor", 40], +// ["virginica", 50], + ], + type : 'pie', + onmouseover: function (d, i) { console.log("onmouseover", d, i, this); }, + onmouseout: function (d, i) { console.log("onmouseout", d, i, this); }, + onclick: function (d, i) { console.log("onclick", d, i, this); }, + }, + axis: { + x: { + label: 'Sepal.Width' + }, + y: { + label: 'Petal.Width' + } + } + }); + + setTimeout(function () { + chart.load({ + columns: [ + ["setosa", 130], + ] + }); + }, 1000); + + setTimeout(function () { + chart.unload({ + ids: 'virginica' + }); + }, 2000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_pie_sort.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_pie_sort.html new file mode 100644 index 0000000..ca875b8 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_pie_sort.html @@ -0,0 +1,93 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var sort = true; + + var generate = function () { return c3.generate({ + data: { + columns: [ +// ["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2], + ["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3], + ["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8], + ["setosa", 30], +// ["versicolor", 40], +// ["virginica", 50], + ], + type : 'pie', + }, + axis: { + x: { + label: 'Sepal.Width' + }, + y: { + label: 'Petal.Width' + } + }, + pie: { + sort: sort, + onmouseover: function (d, i) { console.log(d, i); }, + onmouseout: function (d, i) { console.log(d, i); }, + onclick: function (d, i) { console.log(d, i); }, + } + }); }, chart = generate(); + + setTimeout(function () { + chart.load({ + columns: [ + ["setosa", 130], + ] + }); + }, 1000); + + setTimeout(function () { + chart.unload({ + ids: 'virginica' + }); + }, 2000); + + setTimeout(function () { + chart.load({ + columns: [ + ["new data", 300], + ] + }); + }, 3000); + + setTimeout(function () { + sort = false; + chart = generate(); + }, 4000); + + setTimeout(function () { + chart.load({ + columns: [ + ["setosa", 130], + ] + }); + }, 5000); + + setTimeout(function () { + chart.unload({ + ids: 'virginica' + }); + }, 6000); + + setTimeout(function () { + chart.load({ + columns: [ + ["new data", 300], + ] + }); + }, 7000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_scatter.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_scatter.html new file mode 100644 index 0000000..0afe1da --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_scatter.html @@ -0,0 +1,42 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + xs: { + setosa: 'setosa_x', + versicolor: 'versicolor_x', + virginica: 'virginica_x' + }, + columns: [ + ["setosa_x", 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.4, 3.0, 3.0, 4.0, 4.4, 3.9, 3.5, 3.8, 3.8, 3.4, 3.7, 3.6, 3.3, 3.4, 3.0, 3.4, 3.5, 3.4, 3.2, 3.1, 3.4, 4.1, 4.2, 3.1, 3.2, 3.5, 3.6, 3.0, 3.4, 3.5, 2.3, 3.2, 3.5, 3.8, 3.0, 3.8, 3.2, 3.7, 3.3], + ["versicolor_x", 3.2, 3.2, 3.1, 2.3, 2.8, 2.8, 3.3, 2.4, 2.9, 2.7, 2.0, 3.0, 2.2, 2.9, 2.9, 3.1, 3.0, 2.7, 2.2, 2.5, 3.2, 2.8, 2.5, 2.8, 2.9, 3.0, 2.8, 3.0, 2.9, 2.6, 2.4, 2.4, 2.7, 2.7, 3.0, 3.4, 3.1, 2.3, 3.0, 2.5, 2.6, 3.0, 2.6, 2.3, 2.7, 3.0, 2.9, 2.9, 2.5, 2.8], + ["virginica_x", 3.3, 2.7, 3.0, 2.9, 3.0, 3.0, 2.5, 2.9, 2.5, 3.6, 3.2, 2.7, 3.0, 2.5, 2.8, 3.2, 3.0, 3.8, 2.6, 2.2, 3.2, 2.8, 2.8, 2.7, 3.3, 3.2, 2.8, 3.0, 2.8, 3.0, 2.8, 3.8, 2.8, 2.8, 2.6, 3.0, 3.4, 3.1, 3.0, 3.1, 3.1, 3.1, 2.7, 3.2, 3.3, 3.0, 2.5, 3.0, 3.4, 3.0], + ["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2], + ["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3], + ["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8], + ], + type : 'scatter', + }, + axis: { + x: { + label: 'Sepal.Width', + tick: { + fit: false + } + }, + y: { + label: 'Petal.Width' + } + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_spline.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_spline.html new file mode 100644 index 0000000..731133d --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_spline.html @@ -0,0 +1,25 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.min.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 140, 200, 150, 50] + ], + types: { + data1: 'spline', + data2: 'spline' + } + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_step.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_step.html new file mode 100644 index 0000000..fb32067 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_step.html @@ -0,0 +1,38 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 0], +// ['data2', 130, 100, 140, 200, 150, 50] + ], + types: { + data1: 'step', + data2: 'area-step' + }, + onclick: function (d) { console.log('clicked', d); } + }, + subchart: { + show: true + }, + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['data2', 130, 100, 140, 200, 150, 50] + ] + }); + }, 1000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_step_category.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_step_category.html new file mode 100644 index 0000000..4be84a8 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/chart_step_category.html @@ -0,0 +1,50 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + x: 'x', + columns: [ + ['x', 'hogehoge', 'aaa', 'aaaaaa', 'a', 'b'], + ['data1', 300, 350, 300, 0, 0, 0], +// ['data2', 130, 100, 140, 200, 150, 50] + ], + types: { + data1: 'step', + data2: 'area-step' + }, + empty: { + abort: false, + label: { + text: 'hoge' + } + } + }, + axis: { + x: { + type: 'categorized' + } + }, + subchart: { + show: true + }, + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['data2', 130, 100, 140, 200, 150, 50] + ] + }); + }, 1000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/custom_x_categorized.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/custom_x_categorized.html new file mode 100644 index 0000000..460bcf8 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/custom_x_categorized.html @@ -0,0 +1,86 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + x : 'x', + columns: [ + ['x', 'www.google.com', 'www.amazon.com', 'www.facebook.com', 'www.apple.com'], + ['download', 30, 200, 100, 400], + ['loading', 90, 100, 140, 200], + ], + groups: [ + ['download', 'loading'] + ], + type: 'bar' + }, + axis: { + x: { + type: 'categorized', + label: 'X Label' + }, + y: { + label: { + text: 'Y Label', + position: 'outer-middle' + } + } + } + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['x', 'www.yahoo.com', 'www.rakuten.com', 'www.mixi.com', 'www.sony.com'], + ['download', 130, 300, 200, 470], + ['loading', 190, 130, 240, 340], + ], + }); + }, 1000); + + setTimeout(function () { + chart.load({ + columns: [ + ['x', 'www.hogehoge.com', 'www.aaaa.com', 'www.aaaa.com'], + ['download', 130, 300, 200], + ['loading', 190, 130, 240], + ], + }); + }, 2000); + + setTimeout(function () { + chart.load({ + columns: [ + ['x', 'www.yahoo.com', 'www.rakuten.com', 'www.mixi.com', 'www.sony.com'], + ['download', 130, 300, 200, 470], + ['loading', 190, 130, 240, 340], + ], + }); + }, 3000); + + setTimeout(function () { + chart.load({ + columns: [ + ['download', 30, 30, 20, 170], + ['loading', 90, 30, 40, 40], + ], + }); + }, 4000); + + setTimeout(function () { + chart.load({ + url: '/data/c3_test3.csv' + }); + }, 5000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/custom_x_scale.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/custom_x_scale.html new file mode 100644 index 0000000..7945ee8 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/custom_x_scale.html @@ -0,0 +1,59 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + x : 'x', + columns: [ + ['x', 100, 120, 130, 200, 240, 500], + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 300, 200, 250, 350], + ], + selection: { + enabled: true + }, + onmouseover: function (d) { console.log("onmouseover", d); }, + onmouseout: function (d) { console.log("onmouseout", d); } + }, + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 100, 210, 150, 200, 100, 150], + ] + }); + }, 1000); + + setTimeout(function () { + chart.x([200, 210, 350, 400, 550, 750]); + }, 2000); + + setTimeout(function () { + chart.load({ + columns: [ + ['data3', 300, 410, 350, 400, 500, 350], + ] + }); + }, 3000); + + setTimeout(function () { + chart.load({ + columns: [ + ['x', 130, 140, 200, 300, 450, 550], + ['sample', 200, 350, 100, 200, 50, 100] + ] + }) + }, 4000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/custom_xs_scale.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/custom_xs_scale.html new file mode 100644 index 0000000..0364c10 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/custom_xs_scale.html @@ -0,0 +1,64 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + xs : { + 'data1': 'x1', + 'data2': 'x2', + }, + columns: [ + ['x1', 100, 120, 130, 200, 240, 500], + ['x2', 150, 220, 230, 400, 540, 600, 800], + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 300, 200, 250, 350, 100], + ], + selection: { + enabled: true + }, + onclick: function (d) { console.log("onclick", d); }, + onmouseover: function (d) { console.log("onmouseover", d); }, + onmouseout: function (d) { console.log("onmouseout", d); } + } + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 100, 210, 150, null, 200, 150], + ['data2', 200, 310, 50, 400, 120, 250, 10], + ] + }); + }, 1000); + + setTimeout(function () { + chart.load({ + columns: [ + ['x2', 150, 220, 230, 400, 540, 600, 800], + ['data2', 200, 310, 50, 400, 120, 250, 10], + ['data3', 300, 410, 350, 600, 420, 550, 310], + ], + xs: { + data3: 'x2' + } + }); + }, 2000); + + setTimeout(function () { + chart.xs({ + 'data1': [200, 210, 350, 400, 600, 750], + 'data2': [200, 210, 350, 400, 550, 750, 900] + }); + }, 3000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_columned.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_columned.html new file mode 100644 index 0000000..9bc280c --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_columned.html @@ -0,0 +1,22 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.min.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 20, 50, 40, 60, 50], + ['data2', 200, 130, 90, 240, 130, 220], + ['data3', 300, 200, 160, 400, 250, 250] + ] + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_hide.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_hide.html new file mode 100644 index 0000000..fb3469b --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_hide.html @@ -0,0 +1,24 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.min.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 20, 50, 40, 60, 50], + ['data2', 200, 130, 90, 240, 130, 220], + ['data3', 300, 200, 160, 400, 250, 250] + ], +// hide: ['data1', 'data3'] + hide: true // hide all data + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_json.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_json.html new file mode 100644 index 0000000..522fb93 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_json.html @@ -0,0 +1,90 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + data: { + json: { + data1: [30, 20, 50, 40, 60, 50], + data2: [200, 130, 90, 240, 130, 220], + data3: [300, 200, 160, 400, 250, 250] + } + } + }); + + setTimeout(function () { + chart = c3.generate({ + data: { + json: [{ + "date": "2014-06-03", + "443": "3000", + "995": "500" + }, { + "date": "2014-06-04", + "443": "1000", + }, { + "date": "2014-06-05", + "443": "5000", + "995": "1000" + }], + keys: { + x: 'date', + value: [ "443", "995" ] + } + }, + axis: { + x: { + type: "category" + } + } + }); + }, 1000); + + setTimeout(function () { + chart = c3.generate({ + data: { +// x: 'name', + json: [ + { id: 1, name: 'abc', visits: 200 }, + { id: 2, name: 'efg', visits: 400 }, + { id: 3, name: 'pqr', visits: 150 }, + { id: 4, name: 'xyz', visits: 420 }, + ], + keys: { + x: 'name', + value: ['visits'], + } + }, + axis: { + x: { + type: 'categorized' + } + } + }); + }, 2000); + + setTimeout(function () { + chart.load({ + json: [ + { id: 1, name: 'abc', visits: 1200 }, + { id: 2, name: 'efg', visits: 900 }, + { id: 3, name: 'pqr', visits: 1150 }, + { id: 4, name: 'xyz', visits: 1020 }, + ], + keys: { + x: 'name', + value: ['visits'], + } + }); + }, 3000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_label.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_label.html new file mode 100644 index 0000000..e8cc05c --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_label.html @@ -0,0 +1,225 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + <div id="chart4"></div> + <div id="chart5"></div> + <div id="chart6"></div> + <div id="chart7"></div> + <div id="chart8"></div> + <div id="chart9" style="width:33%;"></div> + <div id="chart10"></div> + <div id="chart11"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 190, 200, 190, null], + ], + type: 'bar', + labels: { + format: function (v, id) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', -190, -200, -190, null], + ], + type: 'bar', + labels: { + format: function (v, id) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', -190, 200, 190, null], + ], + type: 'bar', + labels: { + format: function (v, id) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + } + }); + + var chart4 = c3.generate({ + bindto: '#chart4', + data: { + columns: [ + ['data1', 190, 200, 190, null], + ], + type: 'bar', + labels: { + format: function (v, id) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + }, + axis: { + rotated: true + } + }); + + var chart5 = c3.generate({ + bindto: '#chart5', + data: { + columns: [ + ['data1', -190, -200, -190, null], + ], + type: 'bar', + labels: { + format: function (v, id) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + }, + axis: { + rotated: true + } + }); + + var chart6 = c3.generate({ + bindto: '#chart6', + data: { + columns: [ + ['data1', -190, 200, 190, null], + ], + type: 'bar', + labels: { + format: function (v, id) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + }, + axis: { + rotated: true + } + }); + + var chart7 = c3.generate({ + bindto: '#chart7', + data: { + columns: [ + ['data1', 30, 200, 100, 500, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 250, 220, 210, 240, 215, 225] + ], + groups: [['data1', 'data2', 'data3']], + labels: true, + type: 'bar', + }, + axis: { + rotated: true + } + }); + + var chart8 = c3.generate({ + bindto: '#chart8', + data: { + columns: [ + ['data1', -30, -200, -100, -500, -150, -250], + ['data2', -50, -20, -10, -40, -15, -25], + ['data3', -250, -220, -210, -240, -215, -225] + ], + groups: [['data1', 'data2', 'data3']], + labels: true, + type: 'bar', + }, + axis: { + rotated: true + } + }); + + var chart9 = c3.generate({ + bindto: '#chart9', + data: { + columns: [ + ['data1', -19000000000000, 200, 19000000000000, null], + ], + type: 'bar', + labels: { + format: function (v, id) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + }, + axis: { + rotated: true + } + }); + + var chart10 = c3.generate({ + bindto: '#chart10', + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 100], + ['data2', 130, 0, 140, 200, 0, 50], + ['data3', 130, 0, 140, 200, 0, 50], + ['data4', 130, 0, 140, 200, 0, 50], + ], + type: 'area', + groups: [['data1', 'data2', 'data3', 'data4']], + labels: true + } + }); + + var chart11 = c3.generate({ + bindto: '#chart11', + data: { + columns: [ + ['data1', 300, 350, 300, 0, 0, 100], + ['data2', 130, 0, 140, 200, 0, 50], + ['data3', 130, 0, 140, 200, 0, 50], + ['data4', 130, 0, 140, 200, 0, 50], + ], + groups: [['data1', 'data2', 'data3', 'data4']], + labels: true + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_label_format.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_label_format.html new file mode 100644 index 0000000..1fe0566 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_label_format.html @@ -0,0 +1,46 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + labels: { +// format: function (v, id) { return "Default Format on " + id; }, + format: { + data1: function (v, id) { return "data1 Format"; }, + data2: function (v, id) { return "data2 Format"; } + } + }, + axes: { + data1: 'y', + data2: 'y2', + } + }, + axis: { + y2: { + show: true + } + }, + tooltip: { +// enabled: false + }, + zoom: { +// enabled: true + }, + subchart: { +// show: true + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_load.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_load.html new file mode 100644 index 0000000..356383d --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_load.html @@ -0,0 +1,131 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + data: { + url: '/data/c3_test.csv', + labels: true, + filter: function (t) { + return t.id !== 'data1'; + } + }, + subchart: { + show: true + }, + zoom: { + enabled: true + }, + transition: { + duration: 500 + } + }); + + var queue = [ + function () { + chart.load({ + url: '/data/c3_test2.csv', + filter: function (t) { + return t.id !== 'data1'; + } + }); + }, + function () { + chart.load({ + rows: [ + ['data4', 'data5', 'data6'], + [90, 120, 300], + [40, 160, 240], + [50, 200, 290], + [120, 160, 230], + [80, 130, 300], + [90, 220, 320], + [1090, 1220, 1320], + ] + }); + }, + function () { + chart.unload({ + ids: ['data4', 'data5'] + }); + }, + function () { + chart.unload({ + ids: 'data6' + }); + }, + function () { + chart.load({ + columns:[ + ['data1', 30, 20, 50, 40, 60, 50, 100, 200], + ['data7', 230, 220, 250, 240, 260, 250, 300, 400] + ] + }); + }, + function () { + chart.load({ + json: { + data1: [1030, 1020, 1050, 1040, 1060, 1050, 1100, 1200], + data7: [430, 420, 450, 440, 460, 550, 400, 200] + } + }); + }, + function () { + chart.load({ + columns: [ + ['data8', 30, 20, 50, 40, 60, 50], + ], + unload: true, + }); + }, + function () { + chart.load({ + columns: [ + ['data9', 130, 120, 150, 140, 160, 150], + ], + unload: ['data7', 'data8'], + }); + }, + function () { + chart.load({ + unload: ['data1', 'data2'], + }); + }, + function () { + chart.unload(); + }, + function () { + chart.load({ + rows: [ + ['data1', 'data2', 'data3'], + [90, 120, 300], + [40, 160, 240], + [50, 200, 290], + [120, 160, 230], + [80, 130, 300], + [90, 220, 320], + ] + }); + }, + function () { + chart.unload({ + ids: ['data2', 'data3'] + }); + }, + ]; + + var i = 0; + queue.forEach(function (f) { + setTimeout(f, 1500 * i++); + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_load_timeseries.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_load_timeseries.html new file mode 100644 index 0000000..947db37 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_load_timeseries.html @@ -0,0 +1,55 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + x: 'x', + url: '/data/c3_test_ts.csv', + labels: true + }, + axis: { + x: { + type: 'timeseries' + } + }, + subchart: { + show: true + }, + zoom: { + enabled: true + }, + }); + + setTimeout(function () { + chart.load({ + url: '/data/c3_test2_ts.csv' + }); + }, 1000); + + setTimeout(function () { + chart.unload({ + ids: 'data2' + }); + }, 2000); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 30, 20, 50, 40, 60, 50], + ], + unload: true, +// unload: ['data2', 'data3'], +// unload: ['data2'] + }); + }, 3000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_region.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_region.html new file mode 100644 index 0000000..94789e3 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_region.html @@ -0,0 +1,25 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['sample', 30, 200, 100, 400, 150, 250] + ], + regions: { + sample: [{start:1, end:3}] + } + }, + regions: [{start:1, end:3}], + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_region_timeseries.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_region_timeseries.html new file mode 100644 index 0000000..8e154b5 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_region_timeseries.html @@ -0,0 +1,34 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + x : 'date', + xFormat : '%Y%m%d', + columns: [ +// ['x', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06'], + ['date', '20130101', '20130102', '20130103', '20130104', '20130105', '20130106'], + ['sample', 30, 200, 100, 400, 150, 250] + ], + regions: { + sample: [{start:'20130103', end:'20130105'}] + } + }, + regions: [{start:'20130103', end:'20130105'}], + axis : { + x : { + type : 'timeseries' + } + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_rowed.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_rowed.html new file mode 100644 index 0000000..fd8fcfd --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_rowed.html @@ -0,0 +1,26 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.min.js"></script> + <script> + var chart = c3.generate({ + data: { + rows: [ + ['data1', 'data2', 'data3'], + [90, 120, 300], + [40, 160, 240], + [50, 200, 290], + [120, 160, 230], + [80, 130, 300], + [90, 220, 320], + ] + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_url.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_url.html new file mode 100644 index 0000000..95b6eb6 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/data_url.html @@ -0,0 +1,59 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + data: { + url: '/data/c3_test.csv' + } + }); + + setTimeout(function () { + chart.load({ + url: '/data/c3_test2.csv', + }); + }, 1000); + + setTimeout(function () { + chart.load({ + url: '/data/c3_test.tsv', + mimeType: 'tsv' + }); + }, 2000); + + setTimeout(function () { + chart = c3.generate({ + data: { + url: '/data/c3_test.json', + mimeType: 'json' + } + }); + }, 3000); + + setTimeout(function () { + chart.load({ + url: '/data/c3_test_2.json', + mimeType: 'json' + }); + }, 4000); + + setTimeout(function () { + chart.load({ + url: '/data/c3_test_3.json', + mimeType: 'json', + keys: { + value: ['data1', 'data2'] + } + }); + }, 5000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/domain_y.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/domain_y.html new file mode 100644 index 0000000..95c91ce --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/domain_y.html @@ -0,0 +1,71 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <button id="btn1">Bar</button> + <button id="btn2">Line</button> + <button id="btn3">Area</button> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var normalData = { + columns: [ + ['data1', -1030, -1200, 1000], + ['data2', -1150, -220, -1110] + ], + labels: true, + }, + allPositiveData = { + columns: [ + ['data1', 1030, 1200, 1100], + ['data2', 2050, 2020, 2010] + ], + labels: true, + }, + allNegativeData = { + columns: [ + ['data1', -1030, -2200, -2100], + ['data2', -1150, -2010, -1200] + ], + labels: true, + } + + var chart1 = c3.generate({ + bindto: '#chart1', + data: normalData + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: allPositiveData + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: allNegativeData + }); + + d3.select('#btn1').on('click', function () { + chart1.transform('bar'); + chart2.transform('bar'); + chart3.transform('bar'); + }); + d3.select('#btn2').on('click', function () { + chart1.transform('line'); + chart2.transform('line'); + chart3.transform('line'); + }); + d3.select('#btn3').on('click', function () { + chart1.transform('area'); + chart2.transform('area'); + chart3.transform('area'); + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/element.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/element.html new file mode 100644 index 0000000..1c28bd9 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/element.html @@ -0,0 +1,37 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + data: { + columns: [ + ['sample', 30, 200, 100, null, 150, 250] + ], + }, + }); + + var chart2 = c3.generate({ + data: { + columns: [ + ['sample', 30, 200, 100, null, 150, 250] + ], + type: 'bar' + } + }); + + document.getElementById('chart1').appendChild(chart1.element); + + $('#chart2').append(chart2.element); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/emptydata.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/emptydata.html new file mode 100644 index 0000000..10bd55f --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/emptydata.html @@ -0,0 +1,37 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + data: { + columns: [ +// ['data1', 100, 200], + ], + empty: { + label: { + text: 'No Data' + } + } + }, + subchart: { + show: true + } + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 100, 200], + ], + }); + }, 1000); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grid_focus.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grid_focus.html new file mode 100644 index 0000000..ec6bd97 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grid_focus.html @@ -0,0 +1,29 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 300, 200, 300, 250, 150] + ] + }, + grid: { + focus: { + show: false + } + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grid_x_lines.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grid_x_lines.html new file mode 100644 index 0000000..975a641 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grid_x_lines.html @@ -0,0 +1,66 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250] + ], + type: 'bar' + }, + grid: { + x: { + show: true, + lines: [{ + value: 2, + text: 'Label 2', + class: 'lineFor2' + }] + }, + y: { + show: true, + } + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + x : 'x', + columns: [ + ['x', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05'], + ['sample', 30, 200, 100, 400, 150] + ], + }, + axis : { + x : { + type : 'timeseries' + } + }, + grid: { + x: { + lines: [{ + value: '2013-01-04', + text: '2013/01/04', + class: 'lineFor20130104' + }] + }, + lines: { + front: false + } + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grid_x_lines_timeseries.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grid_x_lines_timeseries.html new file mode 100644 index 0000000..d3517ad --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grid_x_lines_timeseries.html @@ -0,0 +1,73 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + "bindto": "#chart1", + "axis": { + "x": { + "type": "timeseries", + "tick": { + format: '%Y-%m-%d %H:%M:%S' + } + } + }, + "grid": { + "x": { + "lines": [ + { "value": 1401883200000, "text": new Date(1401883200000), "color": "#f00" }, + ] + } + }, + "data": { + "type": "line", + "columns": [ + ["epoch", 1401879600000, 1401883200000, 1401886800000], + ["y", 1955, 2419, 2262] + ], + "xs": { + "y": "epoch" + } + } + }); + + var chart2 = c3.generate({ + "bindto": "#chart2", + "axis": { + "x": { + "type": "timeseries", + "tick": { + format: '%Y-%m-%d %H:%M:%S' + } + } + }, + "grid": { + "x": { + "lines": [ + { "value": new Date(1401883200000), "text": new Date(1401883200000), "color": "#f00" }, + ] + } + }, + "data": { + "type": "line", + "columns": [ + ["epoch", 1401879600000, 1401883200000, 1401886800000], + ["y", 1955, 2419, 2262] + ], + "xs": { + "y": "epoch" + } + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grids.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grids.html new file mode 100644 index 0000000..e0df334 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grids.html @@ -0,0 +1,111 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + <div id="chart4"></div> + <div id="chart5"></div> + <div id="chart6"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var smallData = [['sample', 30, 200, 100, 400, 150, 250]], + bigData = [['sample', 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250]]; + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: smallData + }, + grid: { + x: { + show: true + }, + } + }); + + c3.generate({ + bindto: '#chart2', + data: { + columns: smallData + }, + grid: { + y: { + show: true + } + } + }); + + c3.generate({ + bindto: '#chart3', + data: { + columns: smallData + }, + axis: { + rotated: true, + }, + grid: { + x: { + show: true + }, + } + }); + + c3.generate({ + bindto: '#chart4', + data: { + columns: smallData + }, + axis: { + rotated: true, + }, + grid: { + y: { + show: true + } + } + }); + + c3.generate({ + bindto: '#chart5', + data: { + columns: bigData + }, + grid: { + x: { + show: true + }, + y: { + show: true + } + } + }); + + c3.generate({ + bindto: '#chart6', + data: { + columns: bigData + }, + axis: { + x: { + type: 'category' + } + }, + grid: { + x: { + show: true + }, + y: { + show: true + } + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grids_timeseries.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grids_timeseries.html new file mode 100644 index 0000000..53095b0 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/grids_timeseries.html @@ -0,0 +1,89 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var smallData = [ + ['x', '2014-01-01', '2014-02-01', '2014-03-01', '2014-04-01', '2014-05-01', '2014-06-01'], + ['sample', 30, 200, 100, 400, 150, 250] + ], + bigData = [ + ['x', '2014-01-01', '2014-02-01', '2014-03-01', '2014-04-01', '2014-05-01', '2014-06-01', '2014-07-01', '2014-08-01', '2014-09-01', '2014-10-01', '2014-11-01', '2014-12-01'], + ['sample', 30, 200, 100, 400, 150, 250, 30, 200, 100, 400, 150, 250] + ]; + + c3.generate({ + bindto: '#chart1', + data: { + x: 'x', + columns: smallData + }, + axis: { + x: { + type: 'timeseries', + tick: { + format: "%Y-%m-%d %H:%M:%S" + } + } + }, + grid: { + x: { + show: true, + }, + } + }); + + c3.generate({ + bindto: '#chart2', + data: { + x: 'x', + columns: smallData + }, + axis: { + rotated: true, + x: { + type: 'timeseries', + tick: { + format: "%Y-%m-%d %H:%M:%S" + } + } + }, + grid: { + x: { + show: true, + }, + } + }); + + c3.generate({ + bindto: '#chart3', + data: { + x: 'x', + columns: bigData + }, + axis: { + x: { + type: 'timeseries', + tick: { + format: "%Y-%m-%d %H:%M:%S" + } + } + }, + grid: { + x: { + show: true + } + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/interaction_enabled.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/interaction_enabled.html new file mode 100644 index 0000000..9e77fea --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/interaction_enabled.html @@ -0,0 +1,25 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + }, + interaction: { + enabled: false + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/legend.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/legend.html new file mode 100644 index 0000000..92c99ae --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/legend.html @@ -0,0 +1,87 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + <div id="chart4"></div> + <div id="chart5"></div> + <div id="chart6"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var columns = []; + for (var i = 0; i < 28; i++ ) { + columns[i] = ['datahogehogeohgeohoge' + i, 10 * i, 20 * i]; + } + + c3.generate({ + bindto: '#chart1', + data: { + columns: columns, + }, + }); + + c3.generate({ + bindto: '#chart2', + data: { + columns: columns, + }, + legend: { + position: 'right' + }, + }); + + c3.generate({ + bindto: '#chart3', + data: { + columns: columns, + }, + legend: { + position: 'inset', + }, + }); + + c3.generate({ + bindto: '#chart4', + data: { + columns: columns, + }, + axis: { + rotated: true, + }, + }); + + c3.generate({ + bindto: '#chart5', + data: { + columns: columns, + }, + legend: { + position: 'right' + }, + axis: { + rotated: true, + }, + }); + + c3.generate({ + bindto: '#chart6', + data: { + columns: columns, + }, + legend: { + position: 'inset' + }, + axis: { + rotated: true, + }, + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/padding.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/padding.html new file mode 100644 index 0000000..e9f0026 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/padding.html @@ -0,0 +1,138 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> +<style type="text/css"> +<!-- +.c3 svg { +/* font-size: 13px;*/ +} +--> +</style> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + <div id="chart4"></div> + <div id="chart5"></div> + <div id="chart6"></div> + <div id="chart7"></div> + <div id="chart8"></div> + <div id="chart9"></div> + <div id="chart10"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var option = { + padding: { + top: 50, + right: 200, + bottom: 50, + left: 200, + }, + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 200, 100, 150, 150] + ], + axes: { + data2: 'y2' + }, + }, + axis: { + rotated: true, + y: { + label: { + text: 'Y Label', + position: 'outer-center' + } + }, + y2: { + show: true, + label: { + text: 'Y2 Label', + position: 'outer-center' + } + } + }, + legend: { + position: 'bottom' + }, + subchart: { + show: false + }, + grid: { + x: { + show: true, + }, + y: { + show: true, + } + } + }; + + + option.bindto = '#chart1'; + var chart1 = c3.generate(option); + + option.bindto = '#chart2'; + option.legend.position = 'right' + var chart2 = c3.generate(option); + + option.bindto = '#chart3'; + option.legend.position = 'bottom'; + option.subchart.show = true; + var chart3 = c3.generate(option); + + option.bindto = '#chart4'; + option.legend.position = 'right'; + option.subchart.show = true; + var chart4 = c3.generate(option); + + option.bindto = '#chart5'; + option.padding = { + top: 0, + right: 0, + bottom: 0, + left: 0, + }; + option.subchart.show = false; + option.legend.position = 'bottom'; + var chart5 = c3.generate(option); + + + option.axis.rotated = false; + + option.bindto = '#chart6'; + var chart6 = c3.generate(option); + + option.bindto = '#chart7'; + option.legend.position = 'right' + var chart7 = c3.generate(option); + + option.bindto = '#chart8'; + option.legend.position = 'bottom'; + option.subchart.show = true; + var chart8 = c3.generate(option); + + option.bindto = '#chart9'; + option.legend.position = 'right'; + option.subchart.show = true; + var chart9 = c3.generate(option); + + option.bindto = '#chart10'; + option.padding = { + top: 0, + right: 0, + bottom: 0, + left: 0, + }; + option.subchart.show = false; + option.legend.position = 'bottom'; + var chart10 = c3.generate(option); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/padding_update.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/padding_update.html new file mode 100644 index 0000000..37071d9 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/padding_update.html @@ -0,0 +1,88 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var axis_rotated = true; + + var generate = function () { return c3.generate({ + data: { + x: 'x', + columns: [ + ['x', '2014-01-01', '2014-02-01', '2014-03-01', '2014-04-01'], + ['data1', 190, 200, 190, null], + ], + type: 'bar', + labels: { + format: function (v, id) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + }, + axis: { + x: { + type: 'categorized' + }, + rotated: axis_rotated + }, + }); }, chart = generate(); + + setTimeout(function () { + chart.hide(); + }, 1000); + + setTimeout(function () { + chart.show(); + }, 2000); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 300, 350, 100] + ], + categories: ['2014-01-01 10:10:10', '2014-02-01 12:30:00', '2014-03-01 16:30:00'] + }); + }, 3000); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 50, 100, 150] + ], + categories: ['2014', '2015', '2016'] + }); + }, 4000); + + setTimeout(function () { + axis_rotated = false; + chart = generate(); + }, 5000); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 300, 350, 100000] + ], + }); + }, 6000); + + setTimeout(function () { + chart.load({ + columns: [ + ['data1', 50, 100, 150] + ], + }); + }, 7000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/plugin.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/plugin.html new file mode 100644 index 0000000..cba5227 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/plugin.html @@ -0,0 +1,27 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + +<!-- <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>--> + <script src="/js/d3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script src="/js/samples/plugin.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + onclick: function (d, element) { console.log("onclick", d, element); }, + onmouseover: function (d) { console.log("onmouseover", d); }, + onmouseout: function (d) { console.log("onmouseout", d); }, + }, + test1: 'TEST1', + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/point_r.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/point_r.html new file mode 100644 index 0000000..46ee3ec --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/point_r.html @@ -0,0 +1,28 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.min.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 300, 200, 600, 250, 150] + ], + }, + point: { +// r: 10 + r: function (d) { + return d.id === 'data2' ? 10 : 2.5; + } + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/regions.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/regions.html new file mode 100644 index 0000000..0546383 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/regions.html @@ -0,0 +1,87 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['sample', 30, 200, 100, 400, 150, 250, 300] + ] + }, + axis: { + rotated: true, + y2: { +// show: true, + } + }, + regions: [ + {end:1,class:'region1'}, + {start:2,end:4,class:'region1'}, + {start:5,class:'region1'}, + {end:50,axis:'y'}, + {start:100,end:200,axis:'y'}, + {start:300,axis:'y'}, + ], + zoom: { +// enabled: true + } + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['sample', -100, 200, 50, 100, 400, 299] + ] + }); + }, 1000); + + setTimeout(function () { + chart.regions([]); + }, 2000); + + setTimeout(function () { + chart.regions([{start:0.5,end:2.5}]); + }, 3000); + + setTimeout(function () { + chart.regions.add([{start:4.5}]); + }, 4000); + + setTimeout(function () { + chart.regions.add([{start:3,end:3.5,class:"region1"}, {start:4,end:4.5,class:"region2"}]); + }, 5000); + + setTimeout(function () { + chart.regions.remove({classes:['region1', 'region2'], duration: 0}); + }, 6000); + + setTimeout(function () { + chart.regions.add([ + {start:3,end:3.5,class:"region3 hoge"}, + {start:4,end:4.5,class:"region4 hoge"}, + {start:0,end:0.5,class:"region5 hogehoge"}, + ]); + }, 7000); + + setTimeout(function () { + chart.regions.remove({classes:['hoge'], duration: 500}); + }, 8000); + + setTimeout(function () { + chart.regions.remove({classes:['hogehoge']}); + }, 9000); + + setTimeout(function () { + chart.regions.remove({}); + }, 10000); + + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/regions_timeseries.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/regions_timeseries.html new file mode 100644 index 0000000..b3fcd23 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/regions_timeseries.html @@ -0,0 +1,49 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + +var chart = c3.generate({ + data: { + x: 'date', + columns: [ + ['date', '2014-01-01', '2014-01-10', '2014-01-20', '2014-01-30', '2014-02-01'], + ['sample', 30, 200, 100, 400, 150, 250] + ] + }, + axis: { + x: { + type: 'timeseries', + tick: { + format: '%Y%m%d %H:%M:%S' + } + }, + }, + regions: [ + {start: '2014-01-05', end: '2014-01-10'}, +// {start: new Date('2014-01-10'), end: new Date('2014-01-15')}, + {start: 1390608000000, end: 1391040000000} + ] +}); + +setTimeout(function () { + chart.load({ + columns: [ + ['date', +new Date('2014-01-01'), +new Date('2014-01-10'), +new Date('2014-03-01')], + ['sample', 100, 200, 300] + ] + }); + chart.regions([ + {start: +new Date('2014-01-10'), end: +new Date('2014-01-15')} + ]); +}, 1000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/requirejs.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/requirejs.html new file mode 100644 index 0000000..001aee7 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/requirejs.html @@ -0,0 +1,9 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + <script data-main="/js/samples/requirejs.js" src="/js/require.js"></script> + </head> + <body> + <div id="chart"></div> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/selection.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/selection.html new file mode 100644 index 0000000..9fc6811 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/selection.html @@ -0,0 +1,173 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + grouped => true, multiple => true + <div id="chart1"></div> + + grouped => true, multiple => true, tooltip.grouped = false + <div id="chart1-1"></div> + + grouped => true, multiple => false + <div id="chart2"></div> + + grouped => true, multiple => false, tooltip.grouped = false + <div id="chart2-1"></div> + + grouped => false, multiple => true + <div id="chart3"></div> + + grouped => false, multiple => true, tooltip.grouped = false + <div id="chart3-1"></div> + + grouped => false, multiple => false + <div id="chart4"></div> + + grouped => false, multiple => false, tooltip.grouped = false + <div id="chart4-1"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + selection: { + enabled: true, + grouped: true, + multiple: true, + }, + onclick: function (d, element) { console.log("onclick", d, element); }, + onselected: function (d, element) { console.log("onselected", d, element); }, + onunselected: function (d, element) { console.log("onunselected", d, element); }, + ondragstart: function () { console.log("ondragstart"); }, + ondragend: function () { console.log("ondragend"); }, + }, + }); + + var chart11 = c3.generate({ + bindto: '#chart1-1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + selection: { + enabled: true, + grouped: true, + multiple: true, + }, + }, + tooltip: { + grouped: false + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + selection: { + enabled: true, + grouped: true, + multiple: false, + } + } + }); + + var chart21 = c3.generate({ + bindto: '#chart2-1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + selection: { + enabled: true, + grouped: true, + multiple: false, + } + }, + tooltip: { + grouped: false + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + selection: { + enabled: true, + grouped: false, + multiple: true, + } + } + }); + + var chart31 = c3.generate({ + bindto: '#chart3-1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + selection: { + enabled: true, + grouped: false, + multiple: true, + } + }, + tooltip: { + grouped: false + } + }); + + var chart4 = c3.generate({ + bindto: '#chart4', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + selection: { + enabled: true, + grouped: false, + multiple: false, + } + } + }); + + var chart41 = c3.generate({ + bindto: '#chart4-1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + selection: { + enabled: true, + grouped: false, + multiple: false, + } + }, + tooltip: { + grouped: false + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/simple.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/simple.html new file mode 100644 index 0000000..0aeb681 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/simple.html @@ -0,0 +1,24 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + onclick: function (d, element) { console.log("onclick", d, element); }, + onmouseover: function (d) { console.log("onmouseover", d); }, + onmouseout: function (d) { console.log("onmouseout", d); }, + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/subchart.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/subchart.html new file mode 100644 index 0000000..e068043 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/subchart.html @@ -0,0 +1,67 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + <div id="chart3"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + labels: true + }, + subchart: { + show: true + }, + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + labels: true + }, + subchart: { + show: true + }, + axis: { + rotated: true + } + }); + + var chart3 = c3.generate({ + bindto: '#chart3', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + labels: true + }, + axis: { + x: { + default: [3, 5] + } + }, + subchart: { + show: true + }, + }); + + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/subchart_onbrush.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/subchart_onbrush.html new file mode 100644 index 0000000..2cd2158 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/subchart_onbrush.html @@ -0,0 +1,57 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + x : 'x', + columns: [ + ['x', '2013-01-01', '2013-02-01', '2013-03-01', '2013-04-01', '2013-05-01'], + ['sample', 30, 200, 100, 400, 150], + ['sample2', 130, 300, 200, 450, 250] + ] + }, + axis : { + x : { + type : 'timeseries', + tick : { + format : "%Y-%m-%d" + } + } + }, + subchart: { + show: true, + onbrush: function (domain) { + console.log(this, domain); + } + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['sample', 30, 200, 100, 400, 150], + ['sample2', 130, 300, 200, 450, 250] + ] + }, + subchart: { + show: true, + onbrush: function (domain) { + console.log(this, domain); + } + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries.html new file mode 100644 index 0000000..af1265c --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries.html @@ -0,0 +1,54 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + x : 'date', + xFormat : '%Y%m%d', + columns: [ +// ['x', '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06'], + ['date', '20130101', '20130102', '20130103', '20130104', '20130105', '20130106'], + ['sample', 30, 200, 100, 400, 150, 250], + ['sample2', 130, 300, 200, 450, 250, 350] + ] + }, + axis : { + x : { + type : 'timeseries', + tick : { +// format : "%m/%d" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format + format : "%e %b %y" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format + } + } + } + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['sample', 200, 130, 90, 240, 130, 100], + ['sample2', 300, 200, 160, 400, 250, 250] + ] + }); + }, 1000); + + setTimeout(function () { + chart.load({ + columns: [ + ['date', '20140101', '20140201', '20140301', '20140401', '20140501', '20140601'], + ['sample', 500, 630, 690, 440, 630, 900], + ['sample2', 400, 600, 460, 200, 350, 450] + ] + }); + }, 2000); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries_date.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries_date.html new file mode 100644 index 0000000..ceb8e2f --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries_date.html @@ -0,0 +1,64 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + x : 'x', + xFormat : '%Y%m%d', + columns: [ + ['x', new Date('2013-01-01T00:00:00Z'), new Date('2013-01-02T00:00:00Z'), new Date('2013-01-03T00:00:00Z'), new Date('2013-01-04T00:00:00Z'), new Date('2013-01-05T00:00:00Z'), new Date('2013-01-06T00:00:00Z')], + ['sample', 30, 200, 100, 400, 150, 250], + ['sample2', 130, 300, 200, 450, 250, 350] + ] + }, + axis : { + x : { + type : 'timeseries', + tick : { +// format : "%m/%d" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format + format : "%e %b %y" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format + } + } + } + }); + + setTimeout(function () { + chart.load({ + columns: [ + ['sample', 200, 130, 90, 240, 130, 100], + ['sample2', 300, 200, 160, 400, 250, 250] + ] + }); + }, 1000); + + setTimeout(function () { + chart.load({ + columns: [ + ['x', '20140101', '20140201', '20140301', '20140401', '20140501', '20140601'], + ['sample', 500, 630, 690, 440, 630, 900], + ['sample2', 400, 600, 460, 200, 350, 450] + ] + }); + }, 2000); + + setTimeout(function () { + chart.load({ + columns: [ + ['x', new Date('2014-01-02T00:00:00Z'), new Date('2014-02-02T00:00:00Z'), new Date('2014-03-02T00:00:00Z'), new Date('2014-04-02T00:00:00Z'), new Date('2014-05-02T00:00:00Z'), new Date('2014-06-02T00:00:00Z')], + ['sample', 500, 630, 690, 440, 630, 900], + ['sample2', 400, 600, 460, 200, 350, 450] + ] + }); + }, 3000); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries_descendent.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries_descendent.html new file mode 100644 index 0000000..58246f6 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries_descendent.html @@ -0,0 +1,72 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> +<!-- <script src="/js/c3.min.0.1.35.js"></script>--> + <script> + + var dates = ['date', + 1401908040000, + 1401907980000, + 1401907920000, + 1401907860000, + 1401907800000, + 1401907740000, + 1401907680000, + 1401907620000, + 1401907560000, + 1401907500000 + ]; + + var chart = c3.generate({ + bindto: '#chart', + data: { + x : 'date', + columns: [ + dates, + ['data1', 30, 200, 100, 400, 150, 250, 30, 200, 100, 400], + ['data2', 130, 300, 200, 450, 250, 350, 130, 300, 200, 450] + ], + types: { + data1: 'bar', + } + }, + axis : { + x : { + type : 'timeseries', + tick : { + format : "%Y-%m-%d %H:%M:%S" + } + } + } + }); + +/* + setTimeout(function () { + chart.load({ + columns: [ + ['sample', 200, 130, 90, 240, 130, 100], + ['sample2', 300, 200, 160, 400, 250, 250] + ] + }); + }, 1000); + + setTimeout(function () { + chart.load({ + columns: [ + ['date', '20140101', '20140201', '20140301', '20140401', '20140501', '20140601'], + ['sample', 500, 630, 690, 440, 630, 900], + ['sample2', 400, 600, 460, 200, 350, 450] + ] + }); + }, 2000); + +*/ + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries_raw.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries_raw.html new file mode 100644 index 0000000..06d61f3 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/timeseries_raw.html @@ -0,0 +1,52 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var rows = [["x","Views","GMV"]]; + rows = rows.concat([[1398709800000,780,136], + [1398450600000,812,134], + [1399401000000,784,154], + [1399228200000,786,135], + [1399573800000,802,131], + [1399487400000,773,166], + [1399314600000,787,146], + [1399919400000,1496,309], + [1399833000000,767,138], + [1399746600000,797,141], + [1399660200000,796,146], + [1398623400000,779,143], + [1399055400000,794,140], + [1398969000000,791,140], + [1398882600000,825,107], + [1399141800000,786,136], + [1398537000000,773,143], + [1398796200000,783,154], + [1400005800000,1754,284]].sort(function (a, b) { + return a[0] - b[0]; + })); + + var chart = c3.generate({ + bindto: '#chart', + data: { + x : 'x', + rows: rows + }, + axis : { + x : { + type : 'timeseries', + tick : { + format : "%Y-%m-%d" // https://github.com/mbostock/d3/wiki/Time-Formatting#wiki-format + } + } + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/tooltip_grouped.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/tooltip_grouped.html new file mode 100644 index 0000000..6f77562 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/tooltip_grouped.html @@ -0,0 +1,26 @@ +<html> + <head> + <link href="/css/c3.css" rel="stylesheet" type="text/css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + }, + tooltip: { + grouped: false + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/tooltip_show.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/tooltip_show.html new file mode 100644 index 0000000..3449553 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/tooltip_show.html @@ -0,0 +1,32 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.min.js"></script> + <script> + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 60] + ] + }, + tooltip: { + init: { + show: true, + x: 2, + position: { + top: '145px', + left: '290px' + } + } + } + }); + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom.html new file mode 100644 index 0000000..73af5ab --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom.html @@ -0,0 +1,71 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <button onclick="load()">Load</button> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + columns: [ + generateData(100) + ], + }, + axis: { + x: { + default: [30, 60] + } + }, + zoom: { + enabled: true, + onzoomstart: function (event) { + console.log("onzoomstart", event); + }, + onzoomend: function (domain) { + console.log("onzoomend", domain); + }, + }, + subchart: { show: true } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + generateData(100) + ], + }, + axis: { + x: { + default: [30, 60] + } + }, + zoom: { enabled: true }, + }); + + function load() { + chart1.load({ + columns: [ + generateData(Math.random() * 1000) + ], + }); + } + + function generateData(n) { + var column = ['sample']; + for (var i = 0; i < n; i++) { + column.push(Math.random() * 500); + } + return column; + } + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom_category.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom_category.html new file mode 100644 index 0000000..e8e7e24 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom_category.html @@ -0,0 +1,47 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart"></div> + <button onclick="load()">Load</button> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart = c3.generate({ + bindto: '#chart', + data: { + columns: [ + generateData(100) + ], + }, + axis: { + x: { + type: 'category' + } + }, + zoom: { enabled: true }, + subchart: { show: true } + }); + + function load() { + chart.load({ + columns: [ + generateData(Math.random() * 1000) + ], + }); + } + + function generateData(n) { + var column = ['sample']; + for (var i = 0; i < n; i++) { + column.push(Math.random() * 500); + } + return column; + } + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom_onzoom.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom_onzoom.html new file mode 100644 index 0000000..f79e5ba --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom_onzoom.html @@ -0,0 +1,57 @@ +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/c3.css"> + </head> + <body> + <div id="chart1"></div> + <div id="chart2"></div> + + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script> + + var chart1 = c3.generate({ + bindto: '#chart1', + data: { + x : 'x', + columns: [ + ['x', '2013-01-01', '2013-02-01', '2013-03-01', '2013-04-01', '2013-05-01'], + ['sample', 30, 200, 100, 400, 150], + ['sample2', 130, 300, 200, 450, 250] + ] + }, + axis : { + x : { + type : 'timeseries', + tick : { + format : "%Y-%m-%d" + } + } + }, + zoom: { + enabled: true, + onzoom: function (domain) { + console.log(this, domain); + } + } + }); + + var chart2 = c3.generate({ + bindto: '#chart2', + data: { + columns: [ + ['sample', 30, 200, 100, 400, 150], + ['sample2', 130, 300, 200, 450, 250] + ] + }, + zoom: { + enabled: true, + onzoom: function (domain) { + console.log(this, domain); + } + } + }); + + </script> + </body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom_reduction.html b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom_reduction.html new file mode 100644 index 0000000..4a9873a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/htdocs/samples/zoom_reduction.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <title>c3ext</title> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="shortcut icon" href="/images/logo_128.ico" /> + <link href="/css/c3.css" rel="stylesheet" /> + <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script> + <script src="https://rawgithub.com/brandonaaron/jquery-mousewheel/master/jquery.mousewheel.min.js"></script> + <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> + <script src="/js/c3.js"></script> + <script src="/js/extensions/c3ext.js"></script> + <script src="/js/samples/zoom_reduction.js"></script> +</head> +<body onload="main()"> + <div class="container-fluid"> + <h1>C3 DataSet Reduction by Zoom Level</h1> + <h2>Hackathon May 2014</h2> + <h4>By Dan-el Khen</h4> + <p>Rendering graphs in the browser has many advantages, the downside is that takes a long time to render when having large datasets. </p> + <p>This feature allows you reduces the dataset according to your current zoom level. + It allows the developer to implement the reduction algorithm in a simple function that accepts an array of values, and returns a reduced single value. + The default reducer will take the first item, but avg/sum/first/last or any other algorithm is simple to implement. + </p> + <h3>Example</h3> + <p> + In the following example, we'll render 10K data points, each time we'll reduce those to about 100 items (depending on available size on your screen), + when zooming in, the resolution of the data will be better and more accurate. This would help in showing the big picture, even when the amount of data is bigger than the numbers of pixels on the screen. + </p> + <p>Click on the buttons or scroll with your mouse wheel inside the graph to zoom and/or pan.</p> + <pre id="status"></pre> + <div> + <button onclick="chart.zoom2.zoomIn()">zoomIn</button> + <button onclick="chart.zoom2.zoomOut()">zoomOut</button> + <button onclick="chart.zoom2.panLeft()">panLeft</button> + <button onclick="chart.zoom2.panRight()">panRight</button> + <button onclick="chart.zoom2.enhance()">enhance</button> + <button onclick="chart.zoom2.dehance()">dehance</button> + <button onclick="chart.zoom2.reset()">reset</button> + </div> + <div id="divChart" style="height:300px"></div> + <h3>Notes</h3> + <p>Only 'columns' data format is supported for now.</p> + </div> +</body> +</html> diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/package.json b/web/nms-public.gathering.org/old/speedometer/c3-master/package.json new file mode 100644 index 0000000..b9d1408 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/package.json @@ -0,0 +1,36 @@ +{ + "name": "c3", + "version": "0.4.10", + "description": "D3-based reusable chart library", + "main": "c3.js", + "scripts": { + "test": "grunt" + }, + "repository": { + "type": "git", + "url": "git://github.com/masayuki0812/c3.git" + }, + "keywords": [ + "d3", + "chart", + "graph" + ], + "author": "Masayuki Tanaka", + "license": "MIT", + "gitHead": "84e03109d9a590f9c8ef687c03d751f666080c6f", + "readmeFilename": "README.md", + "dependencies": { + "d3": "<=3.5.0" + }, + "devDependencies": { + "grunt": "^0.4.5", + "grunt-contrib-concat": "~0.5.0", + "grunt-contrib-cssmin": "^0.10.0", + "grunt-contrib-jasmine": "~0.8.0", + "grunt-contrib-jshint": "~0.10.0", + "grunt-contrib-uglify": "~0.4.0", + "grunt-contrib-watch": "^0.6.1", + "grunt-sass": "^0.17.0", + "load-grunt-tasks": "~0.2.0" + } +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.axis-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.axis-spec.js new file mode 100644 index 0000000..5764f73 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.axis-spec.js @@ -0,0 +1,54 @@ +describe('c3 api axis', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('axis.labels', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100], + ['data2', 50, 20, 10] + ], + axes: { + data1: 'y', + data2: 'y2' + } + }, + axis: { + y: { + label: 'Y Axis Label' + }, + y2: { + show: true, + label: 'Y2 Axis Label' + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should update y axis label', function () { + chart.axis.labels({y: 'New Y Axis Label'}); + var label = d3.select('.c3-axis-y-label'); + expect(label.text()).toBe('New Y Axis Label'); + expect(label.attr('dx')).toBe('-0.5em'); + expect(label.attr('dy')).toBe('1.2em'); + }); + + it('should update y axis label', function () { + chart.axis.labels({y2: 'New Y2 Axis Label'}); + var label = d3.select('.c3-axis-y2-label'); + expect(label.text()).toBe('New Y2 Axis Label'); + expect(label.attr('dx')).toBe('-0.5em'); + expect(label.attr('dy')).toBe('-0.5em'); + }); + + }); +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.data-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.data-spec.js new file mode 100644 index 0000000..60881cb --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.data-spec.js @@ -0,0 +1,164 @@ +describe('c3 api data', function () { + 'use strict'; + + var chart; + + var args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 5000, 2000, 1000, 4000, 1500, 2500] + ], + names: { + data1: 'Data Name 1', + data2: 'Data Name 2' + }, + colors: { + data1: '#FF0000', + data2: '#00FF00' + }, + axes: { + data1: 'y', + data2: 'y2' + } + }, + axis: { + y2: { + show: true + } + } + }; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('data()', function () { + + it('should return all of data if no argument given', function () { + var results = chart.data(), + expected = ['data1', 'data2']; + results.forEach(function (result, i) { + expect(result.id).toBe(expected[i]); + }); + }); + + it('should return specifid data if string argument given', function () { + var results = chart.data('data1'); + expect(results.length).toBe(1); + expect(results[0].id).toBe('data1'); + }); + + it('should return specifid data if array argument given', function () { + var results = chart.data(['data1', 'data2']); + expect(results.length).toBe(2); + expect(results[0].id).toBe('data1'); + expect(results[1].id).toBe('data2'); + }); + + }); + + describe('data.shown()', function () { + + it('should return only shown targets', function () { + var results; + chart.hide('data1'); + results = chart.data.shown(); + expect(results.length).toBe(1); + expect(results[0].id).toBe('data2'); + }); + + }); + + describe('data.values()', function () { + + it('should return values for specified target', function () { + var values = chart.data.values('data1'), + expectedValues = [30, 200, 100, 400, 150, 250]; + expect(values.length).toBe(6); + values.forEach(function (v, i) { + expect(v).toBe(expectedValues[i]); + }); + }); + + it('should return null when no args', function () { + var values = chart.data.values(); + expect(values).toBeNull(); + }); + + }); + + describe('data.names()', function () { + + it('should return data.names specified as argument', function () { + var results = chart.data.names(); + expect(results.data1).toBe('Data Name 1'); + expect(results.data2).toBe('Data Name 2'); + }); + + it('should return data.names specified as api', function () { + var results = chart.data.names({ + data1: 'New Data Name 1', + data2: 'New Data Name 2' + }); + expect(results.data1).toBe('New Data Name 1'); + expect(results.data2).toBe('New Data Name 2'); + }); + + it('should set data.names specified as api', function () { + expect(d3.select('.c3-legend-item-data1 text').text()).toBe("New Data Name 1"); + expect(d3.select('.c3-legend-item-data2 text').text()).toBe("New Data Name 2"); + }); + + }); + + describe('data.colors()', function () { + + it('should return data.colors specified as argument', function () { + var results = chart.data.colors(); + expect(results.data1).toBe('#FF0000'); + expect(results.data2).toBe('#00FF00'); + }); + + it('should return data.colors specified as api', function () { + var results = chart.data.colors({ + data1: '#00FF00', + data2: '#FF0000' + }); + expect(results.data1).toBe('#00FF00'); + expect(results.data2).toBe('#FF0000'); + }); + + it('should set data.colors specified as api', function () { + expect(d3.select('.c3-line-data1').style('stroke')).toBe("#00ff00"); + expect(d3.select('.c3-line-data2').style('stroke')).toBe("#ff0000"); + expect(d3.select('.c3-legend-item-data1 .c3-legend-item-tile').style('fill')).toBe("#00ff00"); + expect(d3.select('.c3-legend-item-data2 .c3-legend-item-tile').style('fill')).toBe("#ff0000"); + }); + + }); + + describe('data.axes()', function () { + + it('should return data.axes specified as argument', function () { + var results = chart.data.axes(); + expect(results.data1).toBe('y'); + expect(results.data2).toBe('y2'); + expect(d3.select('.c3-axis-y g.tick text').text()).toBe('0'); + expect(d3.select('.c3-axis-y2 g.tick text').text()).toBe('1000'); + }); + + it('should return data.axes specified as api', function () { + var results = chart.data.axes({ + data1: 'y2', + data2: 'y' + }); + expect(results.data1).toBe('y2'); + expect(results.data2).toBe('y'); + expect(d3.select('.c3-axis-y g.tick text').text()).toBe('1000'); + expect(d3.select('.c3-axis-y2 g.tick text').text()).toBe('0'); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.focus-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.focus-spec.js new file mode 100644 index 0000000..df64e80 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.focus-spec.js @@ -0,0 +1,441 @@ +describe('c3 api focus', function () { + 'use strict'; + + var chart; + + var args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400], + ['data2', 1000, 800, 500, 2000], + ['data3', 5000, 2000, 1000, 4000] + ] + } + }; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('focus', function () { + + it('should focus all targets', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.focus(); + setTimeout(function () { + var targets = main.select('.c3-chart-line.c3-target'), + legendItems = legend.select('.c3-legend-item'); + targets.each(function () { + var line = d3.select(this); + expect(line.classed('c3-focused')).toBeTruthy(); + }); + legendItems.each(function () { + var item = d3.select(this); + expect(item.classed('c3-legend-item-focused')).toBeTruthy(); + }); + done(); + }, 1000); + }); + + it('should focus one target', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.focus('data2'); + setTimeout(function () { + var targets = { + data1: main.select('.c3-chart-line.c3-target.c3-target-data1'), + data2: main.select('.c3-chart-line.c3-target.c3-target-data2'), + data3: main.select('.c3-chart-line.c3-target.c3-target-data3') + }, + legendItems = { + data1: legend.select('.c3-legend-item-data1'), + data2: legend.select('.c3-legend-item-data2'), + data3: legend.select('.c3-legend-item-data3') + }; + expect(targets.data1.classed('c3-focused')).toBeFalsy(); + expect(targets.data2.classed('c3-focused')).toBeTruthy(); + expect(targets.data3.classed('c3-focused')).toBeFalsy(); + expect(legendItems.data1.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data2.classed('c3-legend-item-focused')).toBeTruthy(); + expect(legendItems.data3.classed('c3-legend-item-focused')).toBeFalsy(); + done(); + }, 1000); + }); + + it('should focus multiple targets', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.focus(['data1', 'data2']); + setTimeout(function () { + var targets = { + data1: main.select('.c3-chart-line.c3-target.c3-target-data1'), + data2: main.select('.c3-chart-line.c3-target.c3-target-data2'), + data3: main.select('.c3-chart-line.c3-target.c3-target-data3') + }, + legendItems = { + data1: legend.select('.c3-legend-item-data1'), + data2: legend.select('.c3-legend-item-data2'), + data3: legend.select('.c3-legend-item-data3') + }; + expect(targets.data1.classed('c3-focused')).toBeTruthy(); + expect(targets.data2.classed('c3-focused')).toBeTruthy(); + expect(targets.data3.classed('c3-focused')).toBeFalsy(); + expect(legendItems.data1.classed('c3-legend-item-focused')).toBeTruthy(); + expect(legendItems.data2.classed('c3-legend-item-focused')).toBeTruthy(); + expect(legendItems.data3.classed('c3-legend-item-focused')).toBeFalsy(); + done(); + }, 1000); + }); + + }); + + describe('defocus', function () { + + it('should defocus all targets', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.defocus(); + setTimeout(function () { + var targets = main.select('.c3-chart-line.c3-target'), + legendItems = legend.select('.c3-legend-item'); + targets.each(function () { + var line = d3.select(this); + expect(line.classed('c3-focused')).toBeFalsy(); + expect(line.classed('c3-defocused')).toBeTruthy(); + }); + legendItems.each(function () { + var item = d3.select(this); + expect(item.classed('c3-legend-item-focused')).toBeFalsy(); + expect(+item.style('opacity')).toBeCloseTo(0.3); + }); + done(); + }, 1000); + }); + + it('should defocus one target', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.defocus('data2'); + setTimeout(function () { + var targets = { + data1: main.select('.c3-chart-line.c3-target.c3-target-data1'), + data2: main.select('.c3-chart-line.c3-target.c3-target-data2'), + data3: main.select('.c3-chart-line.c3-target.c3-target-data3') + }, + legendItems = { + data1: legend.select('.c3-legend-item-data1'), + data2: legend.select('.c3-legend-item-data2'), + data3: legend.select('.c3-legend-item-data3') + }; + expect(targets.data1.classed('c3-defocused')).toBeFalsy(); + expect(targets.data2.classed('c3-defocused')).toBeTruthy(); + expect(targets.data3.classed('c3-defocused')).toBeFalsy(); + expect(legendItems.data1.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data2.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data3.classed('c3-legend-item-focused')).toBeFalsy(); + expect(+legendItems.data1.style('opacity')).toBeCloseTo(1); + expect(+legendItems.data2.style('opacity')).toBeCloseTo(0.3); + expect(+legendItems.data3.style('opacity')).toBeCloseTo(1); + done(); + }, 1000); + }); + + it('should defocus multiple targets', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.defocus(['data1', 'data2']); + setTimeout(function () { + var targets = { + data1: main.select('.c3-chart-line.c3-target.c3-target-data1'), + data2: main.select('.c3-chart-line.c3-target.c3-target-data2'), + data3: main.select('.c3-chart-line.c3-target.c3-target-data3') + }, + legendItems = { + data1: legend.select('.c3-legend-item-data1'), + data2: legend.select('.c3-legend-item-data2'), + data3: legend.select('.c3-legend-item-data3') + }; + expect(targets.data1.classed('c3-defocused')).toBeTruthy(); + expect(targets.data2.classed('c3-defocused')).toBeTruthy(); + expect(targets.data3.classed('c3-defocused')).toBeFalsy(); + expect(legendItems.data1.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data2.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data3.classed('c3-legend-item-focused')).toBeFalsy(); + expect(+legendItems.data1.style('opacity')).toBeCloseTo(0.3); + expect(+legendItems.data2.style('opacity')).toBeCloseTo(0.3); + expect(+legendItems.data3.style('opacity')).toBeCloseTo(1); + done(); + }, 1000); + }); + + it('should defocus multiple targets after focused', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.focus(); + setTimeout(function () { + chart.defocus(['data1', 'data2']); + setTimeout(function () { + var targets = { + data1: main.select('.c3-chart-line.c3-target.c3-target-data1'), + data2: main.select('.c3-chart-line.c3-target.c3-target-data2'), + data3: main.select('.c3-chart-line.c3-target.c3-target-data3') + }, + legendItems = { + data1: legend.select('.c3-legend-item-data1'), + data2: legend.select('.c3-legend-item-data2'), + data3: legend.select('.c3-legend-item-data3') + }; + expect(targets.data1.classed('c3-defocused')).toBeTruthy(); + expect(targets.data2.classed('c3-defocused')).toBeTruthy(); + expect(targets.data3.classed('c3-defocused')).toBeFalsy(); + expect(legendItems.data1.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data2.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data3.classed('c3-legend-item-focused')).toBeTruthy(); + expect(+legendItems.data1.style('opacity')).toBeCloseTo(0.3); + expect(+legendItems.data2.style('opacity')).toBeCloseTo(0.3); + expect(+legendItems.data3.style('opacity')).toBeCloseTo(1); + done(); + }, 1000); + }, 1000); + }); + + }); + + describe('revert', function () { + + it('should revert all targets after focus', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.focus(); + setTimeout(function () { + chart.revert(); + setTimeout(function () { + var targets = main.select('.c3-chart-line.c3-target'), + legendItems = legend.select('.c3-legend-item'); + targets.each(function () { + var line = d3.select(this); + expect(line.classed('c3-focused')).toBeFalsy(); + }); + legendItems.each(function () { + var item = d3.select(this); + expect(item.classed('c3-legend-item-focused')).toBeFalsy(); + expect(+item.style('opacity')).toBeCloseTo(1); + }); + done(); + }, 1000); + }, 1000); + }); + + it('should revert all targets after defocus', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.defocus(); + setTimeout(function () { + chart.revert(); + setTimeout(function () { + var targets = main.select('.c3-chart-line.c3-target'), + legendItems = legend.select('.c3-legend-item'); + targets.each(function () { + var line = d3.select(this); + expect(line.classed('c3-defocused')).toBeFalsy(); + }); + legendItems.each(function () { + var item = d3.select(this); + expect(item.classed('c3-legend-item-focused')).toBeFalsy(); + expect(+item.style('opacity')).toBeCloseTo(1); + }); + done(); + }, 1000); + }, 1000); + }); + + it('should revert one target after focus', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.focus(); + setTimeout(function () { + chart.revert('data2'); + setTimeout(function () { + var targets = { + data1: main.select('.c3-chart-line.c3-target.c3-target-data1'), + data2: main.select('.c3-chart-line.c3-target.c3-target-data2'), + data3: main.select('.c3-chart-line.c3-target.c3-target-data3') + }, + legendItems = { + data1: legend.select('.c3-legend-item-data1'), + data2: legend.select('.c3-legend-item-data2'), + data3: legend.select('.c3-legend-item-data3') + }; + expect(targets.data1.classed('c3-focused')).toBeTruthy(); + expect(targets.data2.classed('c3-focused')).toBeFalsy(); + expect(targets.data3.classed('c3-focused')).toBeTruthy(); + expect(+legendItems.data1.style('opacity')).toBeCloseTo(1); + expect(+legendItems.data2.style('opacity')).toBeCloseTo(1); + expect(+legendItems.data3.style('opacity')).toBeCloseTo(1); + expect(legendItems.data1.classed('c3-legend-item-focused')).toBeTruthy(); + expect(legendItems.data2.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data3.classed('c3-legend-item-focused')).toBeTruthy(); + done(); + }, 1000); + }, 1000); + }); + + it('should revert one target after defocus', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.defocus(); + setTimeout(function () { + chart.revert('data2'); + setTimeout(function () { + var targets = { + data1: main.select('.c3-chart-line.c3-target.c3-target-data1'), + data2: main.select('.c3-chart-line.c3-target.c3-target-data2'), + data3: main.select('.c3-chart-line.c3-target.c3-target-data3') + }, + legendItems = { + data1: legend.select('.c3-legend-item-data1'), + data2: legend.select('.c3-legend-item-data2'), + data3: legend.select('.c3-legend-item-data3') + }; + expect(targets.data1.classed('c3-defocused')).toBeTruthy(); + expect(targets.data2.classed('c3-defocused')).toBeFalsy(); + expect(targets.data3.classed('c3-defocused')).toBeTruthy(); + expect(+legendItems.data1.style('opacity')).toBeCloseTo(0.3); + expect(+legendItems.data2.style('opacity')).toBeCloseTo(1); + expect(+legendItems.data3.style('opacity')).toBeCloseTo(0.3); + expect(legendItems.data1.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data2.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data3.classed('c3-legend-item-focused')).toBeFalsy(); + done(); + }, 1000); + }, 1000); + }); + + it('should focus multiple targets after focus', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.focus(); + setTimeout(function () { + chart.revert(['data1', 'data2']); + setTimeout(function () { + var targets = { + data1: main.select('.c3-chart-line.c3-target.c3-target-data1'), + data2: main.select('.c3-chart-line.c3-target.c3-target-data2'), + data3: main.select('.c3-chart-line.c3-target.c3-target-data3') + }, + legendItems = { + data1: legend.select('.c3-legend-item-data1'), + data2: legend.select('.c3-legend-item-data2'), + data3: legend.select('.c3-legend-item-data3') + }; + expect(targets.data1.classed('c3-focused')).toBeFalsy(); + expect(targets.data2.classed('c3-focused')).toBeFalsy(); + expect(targets.data3.classed('c3-focused')).toBeTruthy(); + expect(+legendItems.data1.style('opacity')).toBeCloseTo(1); + expect(+legendItems.data2.style('opacity')).toBeCloseTo(1); + expect(+legendItems.data3.style('opacity')).toBeCloseTo(1); + expect(legendItems.data1.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data2.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data3.classed('c3-legend-item-focused')).toBeTruthy(); + done(); + }, 1000); + }, 1000); + }); + + it('should focus multiple targets after defocus', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.defocus(); + setTimeout(function () { + chart.revert(['data1', 'data2']); + setTimeout(function () { + var targets = { + data1: main.select('.c3-chart-line.c3-target.c3-target-data1'), + data2: main.select('.c3-chart-line.c3-target.c3-target-data2'), + data3: main.select('.c3-chart-line.c3-target.c3-target-data3') + }, + legendItems = { + data1: legend.select('.c3-legend-item-data1'), + data2: legend.select('.c3-legend-item-data2'), + data3: legend.select('.c3-legend-item-data3') + }; + expect(targets.data1.classed('c3-defocused')).toBeFalsy(); + expect(targets.data2.classed('c3-defocused')).toBeFalsy(); + expect(targets.data3.classed('c3-defocused')).toBeTruthy(); + expect(+legendItems.data1.style('opacity')).toBeCloseTo(1); + expect(+legendItems.data2.style('opacity')).toBeCloseTo(1); + expect(+legendItems.data3.style('opacity')).toBeCloseTo(0.3); + expect(legendItems.data1.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data2.classed('c3-legend-item-focused')).toBeFalsy(); + expect(legendItems.data3.classed('c3-legend-item-focused')).toBeFalsy(); + done(); + }, 1000); + }, 1000); + }); + + }); + + describe('when legend.show = false', function () { + + it('should update args to hide legend', function () { + args.legend = { + show: false + }; + expect(true).toBeTruthy(); + }); + + it('should focus all targets without showing legend', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.focus(); + setTimeout(function () { + var targets = main.select('.c3-chart-line.c3-target'), + legendItems = legend.select('.c3-legend-item'); + targets.each(function () { + var line = d3.select(this); + expect(line.classed('c3-focused')).toBeTruthy(); + }); + expect(legendItems.size()).toBeCloseTo(0); + done(); + }, 1000); + }); + + it('should defocus all targets without showing legend', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.defocus(); + setTimeout(function () { + var targets = main.select('.c3-chart-line.c3-target'), + legendItems = legend.select('.c3-legend-item'); + targets.each(function () { + var line = d3.select(this); + expect(line.classed('c3-defocused')).toBeTruthy(); + }); + expect(legendItems.size()).toBeCloseTo(0); + done(); + }, 1000); + }); + + it('should revert all targets after focus', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.focus(); + setTimeout(function () { + chart.revert(); + setTimeout(function () { + var targets = main.select('.c3-chart-line.c3-target'), + legendItems = legend.select('.c3-legend-item'); + targets.each(function () { + var line = d3.select(this); + expect(line.classed('c3-focused')).toBeFalsy(); + }); + expect(legendItems.size()).toBeCloseTo(0); + done(); + }, 1000); + }, 1000); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.grid-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.grid-spec.js new file mode 100644 index 0000000..ebaeee6 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.grid-spec.js @@ -0,0 +1,119 @@ +describe('c3 api grid', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('ygrid.add and ygrid.remove', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250] + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should update y grids', function (done) { + var main = chart.internal.main, + expectedGrids = [ + { + value: 100, + text: 'Pressure Low' + }, + { + value: 200, + text: 'Pressure High' + } + ], + grids; + + // Call ygrids.add + chart.ygrids.add(expectedGrids); + setTimeout(function () { + grids = main.selectAll('.c3-ygrid-line'); + expect(grids.size()).toBe(expectedGrids.length); + grids.each(function (d, i) { + var y = +d3.select(this).select('line').attr('y1'), + text = d3.select(this).select('text').text(), + expectedY = Math.round(chart.internal.y(expectedGrids[i].value)), + expectedText = expectedGrids[i].text; + expect(y).toBe(expectedY); + expect(text).toBe(expectedText); + }); + + // Call ygrids.remove + chart.ygrids.remove(expectedGrids); + setTimeout(function () { + grids = main.selectAll('.c3-ygrid-line'); + expect(grids.size()).toBe(0); + }, 500); + + }, 500); + + setTimeout(function () { + done(); + }, 1200); + }); + + it("should update x ygrids even if it's zoomed", function (done) { + var main = chart.internal.main, + expectedGrids = [ + { + value: 0, + text: 'Pressure Low' + }, + { + value: 1, + text: 'Pressure High' + } + ], + grids, domain; + + chart.zoom([0, 2]); + setTimeout(function () { + + // Call xgrids + chart.xgrids(expectedGrids); + setTimeout(function () { + grids = main.selectAll('.c3-xgrid-line'); + expect(grids.size()).toBe(expectedGrids.length); + grids.each(function (d, i) { + var x = +d3.select(this).select('line').attr('x1'), + text = d3.select(this).select('text').text(), + expectedX = Math.round(chart.internal.x(expectedGrids[i].value)), + expectedText = expectedGrids[i].text; + expect(x).toBe(expectedX); + expect(text).toBe(expectedText); + }); + + // check if it was not rescaled + domain = chart.internal.y.domain(); + expect(domain[0]).toBeLessThan(0); + expect(domain[1]).toBeGreaterThan(400); + + // Call xgrids.remove + chart.xgrids.remove(expectedGrids); + setTimeout(function () { + grids = main.selectAll('.c3-xgrid-line'); + expect(grids.size()).toBe(0); + }, 500); // for xgrids.remove() + + }, 500); // for xgrids() + + }, 500); // for zoom + + setTimeout(function () { + done(); + }, 1700); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.load-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.load-spec.js new file mode 100644 index 0000000..fbea981 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.load-spec.js @@ -0,0 +1,121 @@ +describe('c3 api load', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('indexed data', function () { + + describe('as column', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 5000, 2000, 1000, 4000, 1500, 2500] + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should load additional data', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.load({ + columns: [ + ['data3', 800, 500, 900, 500, 1000, 700] + ] + }); + setTimeout(function () { + var target = main.select('.c3-chart-line.c3-target.c3-target-data3'), + legendItem = legend.select('.c3-legend-item.c3-legend-item-data3'); + expect(target.size()).toBe(1); + expect(legendItem.size()).toBe(1); + done(); + }, 500); + }); + + }); + + }); + + describe('category data', function () { + + it('should update arg to category data', function () { + args = { + data: { + x: 'x', + columns: [ + ['x', 'cat1', 'cat2', 'cat3', 'cat4', 'cat5', 'cat6'], + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 5000, 2000, 1000, 4000, 1500, 2500] + ] + }, + axis: { + x: { + type: 'category' + } + } + }; + expect(true).toBeTruthy(); + }); + + describe('as column', function () { + + it('should load additional data', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.load({ + columns: [ + ['data3', 800, 500, 900, 500, 1000, 700] + ] + }); + setTimeout(function () { + var target = main.select('.c3-chart-line.c3-target.c3-target-data3'), + legendItem = legend.select('.c3-legend-item.c3-legend-item-data3'), + tickTexts = main.selectAll('.c3-axis-x g.tick text'), + expected = ['cat1', 'cat2', 'cat3', 'cat4', 'cat5', 'cat6']; + expect(target.size()).toBe(1); + expect(legendItem.size()).toBe(1); + tickTexts.each(function (d, i) { + var text = d3.select(this).select('tspan').text(); + expect(text).toBe(expected[i]); + }); + done(); + }, 500); + }); + + it('should load additional data', function (done) { + var main = chart.internal.main, + legend = chart.internal.legend; + chart.load({ + columns: [ + ['x', 'new1', 'new2', 'new3', 'new4', 'new5', 'new6'], + ['data3', 800, 500, 900, 500, 1000, 700] + ] + }); + setTimeout(function () { + var target = main.select('.c3-chart-line.c3-target.c3-target-data3'), + legendItem = legend.select('.c3-legend-item.c3-legend-item-data3'), + tickTexts = main.selectAll('.c3-axis-x g.tick text'), + expected = ['new1', 'new2', 'new3', 'new4', 'new5', 'new6']; + expect(target.size()).toBe(1); + expect(legendItem.size()).toBe(1); + tickTexts.each(function (d, i) { + var text = d3.select(this).select('tspan').text(); + expect(text).toBe(expected[i]); + }); + done(); + }, 500); + }); + + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.zoom-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.zoom-spec.js new file mode 100644 index 0000000..4a65927 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/api.zoom-spec.js @@ -0,0 +1,115 @@ +describe('c3 api zoom', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('zoom', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ] + }, + zoom: { + enabled: true + } + }; + expect(true).toBeTruthy(); + }); + + it('should be zoomed properly', function () { + var target = [3, 5], domain; + chart.zoom(target); + domain = chart.internal.x.domain(); + expect(domain[0]).toBe(target[0]); + expect(domain[1]).toBe(target[1]); + }); + + it('should be zoomed properly again', function () { + var target = [1, 4], domain; + chart.zoom(target); + domain = chart.internal.x.domain(); + expect(domain[0]).toBe(target[0]); + expect(domain[1]).toBe(target[1]); + }); + + it('should load timeseries data', function () { + args = { + data: { + x: 'date', + columns: [ + ['date', '2014-01-01', '2014-01-02', '2014-08-01', '2014-10-19'], + ['data1', 30, 200, 100, 400] + ] + }, + axis: { + x: { + type: 'timeseries' + } + }, + zoom: { + enabled: true + } + }; + expect(true).toBeTruthy(); + }); + + it('should be zoomed properly', function () { + var target = [new Date(2014, 7, 1), new Date(2014, 8, 1)], domain; + chart.zoom(target); + domain = chart.internal.x.domain(); + expect(+domain[0]).toBe(+target[0]); + expect(+domain[1]).toBe(+target[1]); + }); + + it('should be zoomed properly', function () { + var target = ['2014-08-01', '2014-09-01'], domain; + chart.zoom(target); + domain = chart.internal.x.domain(); + expect(+domain[0]).toBe(+chart.internal.parseDate(target[0])); + expect(+domain[1]).toBe(+chart.internal.parseDate(target[1])); + }); + + }); + + describe('unzoom', function () { + + it('should load indexed data', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250] + ] + }, + zoom: { + enabled: true + } + }; + expect(true).toBeTruthy(); + }); + + it('should be unzoomed properly', function () { + var target = [1, 4], orginal = chart.internal.x.domain(), domain; + + chart.zoom(target); + domain = chart.internal.x.domain(); + expect(domain[0]).toBe(target[0]); + expect(domain[1]).toBe(target[1]); + + chart.unzoom(); + domain = chart.internal.x.domain(); + expect(domain[0]).toBe(orginal[0]); + expect(domain[1]).toBe(orginal[1]); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/arc-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/arc-spec.js new file mode 100644 index 0000000..517bf64 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/arc-spec.js @@ -0,0 +1,100 @@ +describe('c3 chart arc', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('show pie chart', function () { + + it('should update args to have pie chart', function () { + args = { + data: { + columns: [ + ['data1', 30], + ['data2', 150], + ['data3', 120] + ], + type: 'pie' + } + }; + expect(true).toBeTruthy(); + }); + + it('should have correct classes', function () { + var chartArc = d3.select('.c3-chart-arcs'), + arcs = { + data1: chartArc.select('.c3-chart-arc.c3-target.c3-target-data1') + .select('g.c3-shapes.c3-shapes-data1.c3-arcs.c3-arcs-data1') + .select('path.c3-shape.c3-shape.c3-arc.c3-arc-data1'), + data2: chartArc.select('.c3-chart-arc.c3-target.c3-target-data2') + .select('g.c3-shapes.c3-shapes-data2.c3-arcs.c3-arcs-data2') + .select('path.c3-shape.c3-shape.c3-arc.c3-arc-data2'), + data3: chartArc.select('.c3-chart-arc.c3-target.c3-target-data3') + .select('g.c3-shapes.c3-shapes-data3.c3-arcs.c3-arcs-data3') + .select('path.c3-shape.c3-shape.c3-arc.c3-arc-data3') + }; + expect(arcs.data1.size()).toBe(1); + expect(arcs.data2.size()).toBe(1); + expect(arcs.data3.size()).toBe(1); + }); + + it('should have correct d', function () { + expect(d3.select('.c3-arc-data1').attr('d')).toMatch(/M-124\..+,-171\..+A211\..+,211\..+ 0 0,1 -3\..+,-211\..+L0,0Z/); + expect(d3.select('.c3-arc-data2').attr('d')).toMatch(/M1\..+,-211\..+A211\..+,211\..+ 0 0,1 1\..+,211\..+L0,0Z/); + expect(d3.select('.c3-arc-data3').attr('d')).toMatch(/M1\..+,211\..+A211\..+,211\..+ 0 0,1 -124\..+,-171\..+L0,0Z/); + }); + + it('should set args with data id that can be converted to a color', function () { + args.data.columns = [ + ['black', 30], + ['data2', 150], + ['data3', 120] + ]; + expect(true).toBeTruthy(); + }); + + it('should have correct d even if data id can be converted to a color', function (done) { + setTimeout(function () { + expect(d3.select('.c3-arc-black').attr('d')).toMatch(/M-124\..+,-171\..+A211\..+,211\..+ 0 0,1 -3\..+,-211\..+L0,0Z/); + done(); + }, 500); + }); + + it('should update args to have empty pie chart', function () { + args = { + data: { + columns: [ + ['data1', null], + ['data2', null], + ['data3', null] + ], + type: 'pie' + } + }; + expect(true).toBeTruthy(); + }); + + it('should have correct d attribute', function () { + var chartArc = d3.select('.c3-chart-arcs'), + arcs = { + data1: chartArc.select('.c3-chart-arc.c3-target.c3-target-data1') + .select('g.c3-shapes.c3-shapes-data1.c3-arcs.c3-arcs-data1') + .select('path.c3-shape.c3-shape.c3-arc.c3-arc-data1'), + data2: chartArc.select('.c3-chart-arc.c3-target.c3-target-data2') + .select('g.c3-shapes.c3-shapes-data2.c3-arcs.c3-arcs-data2') + .select('path.c3-shape.c3-shape.c3-arc.c3-arc-data2'), + data3: chartArc.select('.c3-chart-arc.c3-target.c3-target-data3') + .select('g.c3-shapes.c3-shapes-data3.c3-arcs.c3-arcs-data3') + .select('path.c3-shape.c3-shape.c3-arc.c3-arc-data3') + }; + expect(arcs.data1.attr('d').indexOf('NaN')).toBe(-1); + expect(arcs.data2.attr('d').indexOf('NaN')).toBe(-1); + expect(arcs.data3.attr('d').indexOf('NaN')).toBe(-1); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/axis-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/axis-spec.js new file mode 100644 index 0000000..0f4aa2d --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/axis-spec.js @@ -0,0 +1,769 @@ +describe('c3 chart axis', function () { + 'use strict'; + + var chart; + + var args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ] + }, + axis: { + y: { + tick: { + values: null, + count: undefined + } + }, + y2: { + tick: { + values: null, + count: undefined + } + } + } + }; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('axis.y.tick.count', function () { + + it('should update args to have only 1 tick on y axis', function () { + args.axis.y.tick.count = 1; + expect(true).toBeTruthy(); + }); + + it('should have only 1 tick on y axis', function () { + var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); + expect(ticksSize).toBe(1); + }); + + it('should update args to have 2 ticks on y axis', function () { + args.axis.y.tick.count = 2; + expect(true).toBeTruthy(); + }); + + it('should have 2 ticks on y axis', function () { + var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); + expect(ticksSize).toBe(2); + }); + + it('should update args to have 3 ticks on y axis', function () { + args.axis.y.tick.count = 3; + expect(true).toBeTruthy(); + }); + + it('should have 3 ticks on y axis', function () { + var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); + expect(ticksSize).toBe(3); + }); + + }); + + describe('axis.y.tick.values', function () { + + var values = [100, 500]; + + it('should update args to have only 2 ticks on y axis', function () { + args.axis.y.tick.values = values; + expect(true).toBeTruthy(); + }); + + it('should have only 2 tick on y axis', function () { + var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); + expect(ticksSize).toBe(2); + }); + + it('should have specified tick texts', function () { + d3.select('.c3-axis-y').selectAll('g.tick').each(function (d, i) { + var text = d3.select(this).select('text').text(); + expect(+text).toBe(values[i]); + }); + }); + + }); + + describe('axis y timeseries', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ["times", 60000, 120000, 180000, 240000] + ] + }, + axis: { + y: { + type : 'timeseries', + tick: { + time: { + } + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have 7 ticks on y axis', function () { + var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); + expect(ticksSize).toBe(7); // the count starts at initial value and increments by the set interval + }); + + it('should have specified 30 second intervals', function () { + var prevValue; + d3.select('.c3-axis-y').selectAll('g.tick').each(function (d, i) { + if (i !== 0) { + var result = d - prevValue; + expect(result).toEqual(30000); // expressed in milliseconds + } + prevValue = d; + }); + }); + + it('should update args to set axis.y.time', function () { + args.axis.y.tick.time = { + value : 'seconds', + interval : 60 + }; + expect(true).toBeTruthy(); + }); + + it('should have 4 ticks on y axis', function () { + var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size(); + expect(ticksSize).toBe(4); // the count starts at initial value and increments by the set interval + }); + + it('should have specified 60 second intervals', function () { + var prevValue; + d3.select('.c3-axis-y').selectAll('g.tick').each(function (d, i) { + if (i !== 0) { + var result = d - prevValue; + expect(result).toEqual(60000); // expressed in milliseconds + } + prevValue = d; + }); + }); + }); + + describe('axis.x.tick.width', function () { + + describe('indexed x axis and y/y2 axis', function () { + + describe('not rotated', function () { + + it('should update args successfully', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ], + axes: { + data2: 'y2' + } + }, + axis: { + y2: { + show: true + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should construct indexed x axis properly', function () { + var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'), + expectedX = '0', + expectedDy = '.71em'; + expect(ticks.size()).toBe(6); + ticks.each(function (d, i) { + var tspans = d3.select(this).selectAll('tspan'); + expect(tspans.size()).toBe(1); + tspans.each(function () { + var tspan = d3.select(this); + expect(tspan.text()).toBe(i + ''); + expect(tspan.attr('x')).toBe(expectedX); + expect(tspan.attr('dy')).toBe(expectedDy); + }); + }); + }); + + it('should set axis.x.tick.format', function () { + args.axis.x = { + tick: { + format: function () { + return 'very long tick text on x axis'; + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should split x axis tick text to multiple lines', function () { + var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'), + expectedTexts = ['very long tick text', 'on x axis'], + expectedX = '0'; + expect(ticks.size()).toBe(6); + ticks.each(function () { + var tspans = d3.select(this).selectAll('tspan'); + expect(tspans.size()).toBe(2); + tspans.each(function (d, i) { + var tspan = d3.select(this); + expect(tspan.text()).toBe(expectedTexts[i]); + expect(tspan.attr('x')).toBe(expectedX); + if (i === 0) { + expect(tspan.attr('dy')).toBe('.71em'); + } else { + expect(tspan.attr('dy')).toBeGreaterThan(8); + } + }); + }); + }); + + it('should construct y axis properly', function () { + var ticks = chart.internal.main.select('.c3-axis-y').selectAll('g.tick'), + expectedX = '-9', + expectedDy = '3'; + expect(ticks.size()).toBe(9); + ticks.each(function (d) { + var tspans = d3.select(this).selectAll('tspan'); + expect(tspans.size()).toBe(1); + tspans.each(function () { + var tspan = d3.select(this); + expect(tspan.text()).toBe(d + ''); + expect(tspan.attr('x')).toBe(expectedX); + expect(tspan.attr('dy')).toBe(expectedDy); + }); + }); + }); + + it('should construct y2 axis properly', function () { + var ticks = chart.internal.main.select('.c3-axis-y2').selectAll('g.tick'), + expectedX = '9', + expectedDy = '3'; + expect(ticks.size()).toBe(9); + ticks.each(function (d) { + var tspans = d3.select(this).selectAll('tspan'); + expect(tspans.size()).toBe(1); + tspans.each(function () { + var tspan = d3.select(this); + expect(tspan.text()).toBe(d + ''); + expect(tspan.attr('x')).toBe(expectedX); + expect(tspan.attr('dy')).toBe(expectedDy); + }); + }); + }); + + it('should set big values in y', function () { + args.data.columns = [ + ['data1', 3000000000000000, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ]; + expect(true).toBeTruthy(); + }); + + it('should not split y axis tick text to multiple lines', function () { + var ticks = chart.internal.main.select('.c3-axis-y2').selectAll('g.tick'); + ticks.each(function () { + var tspans = d3.select(this).selectAll('tspan'); + expect(tspans.size()).toBe(1); + }); + }); + + }); + + describe('rotated', function () { + + it('should update args to rotate axis', function () { + args.axis.rotated = true; + expect(true).toBeTruthy(); + }); + + it('should split x axis tick text to multiple lines', function () { + var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'), + expectedTexts = ['very long tick', 'text on x axis'], + expectedX = '-9'; + expect(ticks.size()).toBe(6); + ticks.each(function () { + var tspans = d3.select(this).selectAll('tspan'); + expect(tspans.size()).toBe(2); + tspans.each(function (d, i) { + var tspan = d3.select(this); + expect(tspan.text()).toBe(expectedTexts[i]); + expect(tspan.attr('x')).toBe(expectedX); + if (i === 0) { + expect(tspan.attr('dy')).toBeLessThan(0); + } else { + expect(tspan.attr('dy')).toBeGreaterThan(9); + } + }); + }); + }); + + it('should not split y axis tick text to multiple lines', function () { + var ticks = chart.internal.main.select('.c3-axis-y').selectAll('g.tick'), + expectedTexts = [ + '0', + '500000000000000', + '1000000000000000', + '1500000000000000', + '2000000000000000', + '2500000000000000', + '3000000000000000' + ], + expectedX = '0', + expectedDy = '.71em'; + expect(ticks.size()).toBe(7); + ticks.each(function (d, i) { + var tspans = d3.select(this).selectAll('tspan'); + expect(tspans.size()).toBe(1); + tspans.each(function () { + var tspan = d3.select(this); + expect(tspan.text()).toBe(expectedTexts[i]); + expect(tspan.attr('x')).toBe(expectedX); + expect(tspan.attr('dy')).toBe(expectedDy); + }); + }); + }); + + }); + }); + + describe('category axis', function () { + + describe('not rotated', function () { + + it('should update args successfully', function () { + args = { + data: { + x: 'x', + columns: [ + ['x', 'this is a very long tick text on category axis', 'cat1', 'cat2', 'cat3', 'cat4', 'cat5'], + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + }, + axis: { + x: { + type: 'category' + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should locate ticks properly', function () { + var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'); + ticks.each(function (d, i) { + var tspans = d3.select(this).selectAll('tspan'), + expectedX = '0', + expectedDy = '.71em'; + if (i > 0) { // i === 0 should be checked in next test + expect(tspans.size()).toBe(1); + tspans.each(function () { + var tspan = d3.select(this); + expect(tspan.attr('x')).toBe(expectedX); + expect(tspan.attr('dy')).toBe(expectedDy); + }); + } + }); + }); + + it('should split tick text properly', function () { + var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), + tspans = tick.selectAll('tspan'), + expectedTickTexts = [ + 'this is a very', + 'long tick text', + 'on category axis' + ], + expectedX = '0'; + expect(tspans.size()).toBe(3); + tspans.each(function (d, i) { + var tspan = d3.select(this); + expect(tspan.text()).toBe(expectedTickTexts[i]); + expect(tspan.attr('x')).toBe(expectedX); + // unable to define pricise number because it differs depends on environment.. + if (i === 0) { + expect(tspan.attr('dy')).toBe('.71em'); + } else { + expect(tspan.attr('dy')).toBeGreaterThan(8); + } + }); + }); + }); + + describe('rotated', function () { + + it('should update args to rotate axis', function () { + args.axis.rotated = true; + expect(true).toBeTruthy(); + }); + + it('should locate ticks on rotated axis properly', function () { + var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'); + ticks.each(function (d, i) { + var tspans = d3.select(this).selectAll('tspan'), + expectedX = '-9', + expectedDy = '3'; + if (i > 0) { // i === 0 should be checked in next test + expect(tspans.size()).toBe(1); + tspans.each(function () { + var tspan = d3.select(this); + expect(tspan.attr('x')).toBe(expectedX); + expect(tspan.attr('dy')).toBe(expectedDy); + }); + } + }); + }); + + it('should split tick text on rotated axis properly', function () { + var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), + tspans = tick.selectAll('tspan'), + expectedTickTexts = [ + 'this is a very', + 'long tick text on', + 'category axis' + ], + expectedX = '-9'; + expect(tspans.size()).toBe(3); + tspans.each(function (d, i) { + var tspan = d3.select(this); + expect(tspan.text()).toBe(expectedTickTexts[i]); + expect(tspan.attr('x')).toBe(expectedX); + // unable to define pricise number because it differs depends on environment.. + if (i === 0) { + expect(tspan.attr('dy')).toBeLessThan(0); + } else { + expect(tspan.attr('dy')).toBeGreaterThan(8); + } + }); + }); + + }); + + describe('option used', function () { + + describe('as null', function () { + + it('should update args not to split ticks', function () { + args.axis.x.tick = { + multiline: false + }; + expect(true).toBeTruthy(); + }); + + it('should split x tick', function () { + var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), + tspans = tick.selectAll('tspan'); + expect(tspans.size()).toBe(1); + }); + + }); + + describe('as value', function () { + + it('should update args not to split ticks', function () { + args.axis.x.tick = { + width: 150 + }; + expect(true).toBeTruthy(); + }); + + it('should split x tick to 2 lines properly', function () { + var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), + tspans = tick.selectAll('tspan'), + expectedTickTexts = [ + 'this is a very long tick', + 'text on category axis' + ], + expectedX = '-9'; + expect(tspans.size()).toBe(2); + tspans.each(function (d, i) { + var tspan = d3.select(this); + expect(tspan.text()).toBe(expectedTickTexts[i]); + expect(tspan.attr('x')).toBe(expectedX); + // unable to define pricise number because it differs depends on environment.. + if (i === 0) { + expect(tspan.attr('dy')).toBeLessThan(0); + } else { + expect(tspan.attr('dy')).toBeGreaterThan(8); + } + }); + }); + }); + }); + }); + + describe('with axis.x.tick.format', function () { + + it('should update args to use axis.x.tick.format', function () { + args.axis.x.tick.format = function () { + return ['this is a very long tick text', 'on category axis']; + }; + expect(true).toBeTruthy(); + }); + + it('should have multiline tick text', function () { + var tick = chart.internal.main.select('.c3-axis-x').select('g.tick'), + tspans = tick.selectAll('tspan'), + expectedTickTexts = ['this is a very long tick text', 'on category axis']; + expect(tspans.size()).toBe(2); + tspans.each(function (d, i) { + var tspan = d3.select(this); + expect(tspan.text()).toBe(expectedTickTexts[i]); + }); + }); + + }); + }); + + describe('axis.x.tick.rotate', function () { + + describe('not rotated', function () { + + it('should update args successfully', function () { + args = { + data: { + x: 'x', + columns: [ + ['x', 'category 1', 'category 2', 'category 3', 'category 4', 'category 5', 'category 6'], + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + }, + axis: { + x: { + type: 'category', + tick: { + rotate: 60 + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should rotate tick texts', function () { + chart.internal.main.selectAll('.c3-axis-x g.tick').each(function () { + var tick = d3.select(this), + text = tick.select('text'), + tspan = text.select('tspan'); + expect(text.attr('transform')).toBe('rotate(60)'); + expect(text.attr('y')).toBe('1.5'); + expect(tspan.attr('dx')).toBe('6.928203230275509'); + }); + }); + + it('should have automatically calculated x axis height', function () { + var box = chart.internal.main.select('.c3-axis-x').node().getBoundingClientRect(), + height = chart.internal.getHorizontalAxisHeight('x'); + expect(box.height).toBeGreaterThan(50); + expect(height).toBeCloseTo(70, -1); + }); + + }); + }); + + describe('axis.x.tick.fit', function () { + + describe('axis.x.tick.fit = true', function () { + + it('should set args for indexed data', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should show fitted ticks on indexed data', function () { + var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); + expect(ticks.size()).toBe(6); + }); + + it('should set args for x-based data', function () { + args = { + data: { + x: 'x', + columns: [ + ['x', 10, 20, 100, 110, 200, 1000], + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should show fitted ticks on indexed data', function () { + var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); + expect(ticks.size()).toBe(6); + }); + + it('should show fitted ticks after hide and show', function () { + chart.hide(); + chart.show(); + var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); + expect(ticks.size()).toBe(6); + }); + + }); + + describe('axis.x.tick.fit = false', function () { + + it('should set args for indexed data', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ] + }, + axis: { + x: { + tick: { + fit: false + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should show fitted ticks on indexed data', function () { + var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); + expect(ticks.size()).toBe(11); + }); + + it('should set args for x-based data', function () { + args.data = { + x: 'x', + columns: [ + ['x', 10, 20, 100, 110, 200, 1000], + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ] + }; + expect(true).toBeTruthy(); + }); + + it('should show fitted ticks on indexed data', function () { + var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); + expect(ticks.size()).toBe(10); + }); + + it('should show fitted ticks after hide and show', function () { + chart.hide(); + chart.show(); + var ticks = chart.internal.main.selectAll('.c3-axis-x g.tick'); + expect(ticks.size()).toBe(10); + }); + + }); + }); + + describe('axis.y.inner', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + }, + axis: { + y: { + inner: false + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should not have inner y axis', function () { + var paddingLeft = chart.internal.getCurrentPaddingLeft(), + tickTexts = chart.internal.main.selectAll('.c3-axis-y g.tick text'); + expect(paddingLeft).toBeGreaterThan(19); + tickTexts.each(function () { + expect(+d3.select(this).attr('x')).toBeLessThan(0); + }); + }); + + it('should update args to have inner y axis', function () { + args.axis.y.inner = true; + expect(true).toBeTruthy(); + }); + + it('should have inner y axis', function () { + var paddingLeft = chart.internal.getCurrentPaddingLeft(), + tickTexts = chart.internal.main.selectAll('.c3-axis-y g.tick text'); + expect(paddingLeft).toBe(1); + tickTexts.each(function () { + expect(+d3.select(this).attr('x')).toBeGreaterThan(0); + }); + }); + + }); + + describe('axis.y2.inner', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + }, + axis: { + y2: { + show: true, + inner: false + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should not have inner y axis', function () { + var paddingRight = chart.internal.getCurrentPaddingRight(), + tickTexts = chart.internal.main.selectAll('.c3-axis-2y g.tick text'); + expect(paddingRight).toBeGreaterThan(19); + tickTexts.each(function () { + expect(+d3.select(this).attr('x')).toBeGreaterThan(0); + }); + }); + + it('should update args to have inner y axis', function () { + args.axis.y2.inner = true; + expect(true).toBeTruthy(); + }); + + it('should have inner y axis', function () { + var paddingRight = chart.internal.getCurrentPaddingRight(), + tickTexts = chart.internal.main.selectAll('.c3-axis-2y g.tick text'); + expect(paddingRight).toBe(2); + tickTexts.each(function () { + expect(+d3.select(this).attr('x')).toBeLessThan(0); + }); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/c3-helper.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/c3-helper.js new file mode 100644 index 0000000..970cd1b --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/c3-helper.js @@ -0,0 +1,47 @@ +function initDom() { + 'use strict'; + + var div = document.createElement('div'); + div.id = 'chart'; + div.style.width = '640px'; + div.style.height = '480px'; + document.body.appendChild(div); + document.body.style.margin = '0px'; +} +typeof initDom !== 'undefined'; + +function setMouseEvent(chart, name, x, y, element) { + 'use strict'; + + var paddingLeft = chart.internal.main.node().transform.baseVal.getItem(0).matrix.e, + event = document.createEvent("MouseEvents"); + event.initMouseEvent(name, true, true, window, + 0, 0, 0, x + paddingLeft, y + 5, + false, false, false, false, 0, null); + chart.internal.d3.event = event; + if (element) { element.dispatchEvent(event); } +} +typeof setMouseEvent !== 'undefined'; + +function initChart(chart, args, done) { + 'use strict'; + + if (typeof chart === 'undefined') { + window.initDom(); + } + if (args) { + chart = window.c3.generate(args); + window.d3 = chart.internal.d3; + window.d3.select('.jasmine_html-reporter') + .style('position', 'absolute') + .style('width', '640px') + .style('right', 0); + } + + window.setTimeout(function () { + done(); + }, 10); + + return chart; +} +typeof initChart !== 'undefined'; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/c3-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/c3-spec.js new file mode 100644 index 0000000..7be30b3 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/c3-spec.js @@ -0,0 +1,10 @@ +describe('c3', function () { + 'use strict'; + + var c3 = window.c3; + + it('exists', function () { + expect(c3).not.toBeNull(); + expect(typeof c3).toBe('object'); + }); +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/class-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/class-spec.js new file mode 100644 index 0000000..97d0e69 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/class-spec.js @@ -0,0 +1,61 @@ +describe('c3 chart class', function () { + 'use strict'; + + var chart; + + var args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2 prefix', 50, 20, 10, 40, 15, 25], + ['data3 мужчины', 150, 120, 110, 140, 115, 125] + ] + } + }; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('internal.getTargetSelectorSuffix', function () { + + it('should not replace any characters', function () { + var input = 'data1', + expected = '-' + input, + suffix = chart.internal.getTargetSelectorSuffix(input); + expect(suffix).toBe(expected); + }); + + it('should replace space to "-"', function () { + var input = 'data1 suffix', + expected = '-data1-suffix', + suffix = chart.internal.getTargetSelectorSuffix(input); + expect(suffix).toBe(expected); + }); + + it('should replace space to "-" with multibyte characters', function () { + var input = 'data1 suffix 日本語', + expected = '-data1-suffix-日本語', + suffix = chart.internal.getTargetSelectorSuffix(input); + expect(suffix).toBe(expected); + }); + + it('should replace special charactors to "-"', function () { + var input = 'data1 !@#$%^&*()_=+,.<>"\':;[]/|?~`{}\\', + expected = '-data1--------------------------------', + suffix = chart.internal.getTargetSelectorSuffix(input); + expect(suffix).toBe(expected); + }); + + }); + + describe('multibyte characters on chart', function () { + + it('should replace space to "-" with multibyte characters', function () { + var selector = '.c3-target-data3-мужчины'; + expect(chart.internal.main.select(selector).size()).toBe(1); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/core-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/core-spec.js new file mode 100644 index 0000000..048df38 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/core-spec.js @@ -0,0 +1,150 @@ +describe('c3 chart', function () { + 'use strict'; + + var chart; + + var args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ] + } + }; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('init', function () { + + it('should be created', function () { + var svg = d3.select('#chart svg'); + expect(svg).not.toBeNull(); + }); + + it('should set 3rd party property to Function', function () { + Function.prototype.$extIsFunction = true; + expect(true).toBeTruthy(); + }); + + it('should be created even if 3rd party property has been set', function () { + var svg = d3.select('#chart svg'); + expect(svg).not.toBeNull(); + }); + + }); + + describe('size', function () { + + it('should have same width', function () { + var svg = d3.select('#chart svg'); + expect(+svg.attr('width')).toBe(640); + }); + + it('should have same height', function () { + var svg = d3.select('#chart svg'); + expect(+svg.attr('height')).toBe(480); + }); + + }); + + describe('bindto', function () { + + describe('selector', function () { + it('update args', function () { + d3.select('#chart').html(''); + args.bindto = '#chart'; + expect(true).toBeTruthy(); + }); + it('should be created', function () { + var svg = d3.select('#chart svg'); + expect(svg.size()).toBe(1); + }); + }); + + describe('d3.selection object', function () { + it('update args', function () { + d3.select('#chart').html(''); + args.bindto = d3.select('#chart'); + expect(true).toBeTruthy(); + }); + it('should be created', function () { + var svg = d3.select('#chart svg'); + expect(svg.size()).toBe(1); + }); + }); + + describe('null', function () { + it('update args', function () { + d3.select('#chart').html(''); + args.bindto = null; + expect(true).toBeTruthy(); + }); + it('should not be created', function () { + var svg = d3.select('#chart svg'); + expect(svg.size()).toBe(0); + }); + }); + + describe('empty string', function () { + it('update args', function () { + d3.select('#chart').html(''); + args.bindto = ''; + expect(true).toBeTruthy(); + }); + it('should not be created', function () { + var svg = d3.select('#chart svg'); + expect(svg.size()).toBe(0); + }); + }); + + }); + + describe('empty data', function () { + + it('should upaate args for empty data', function () { + args = { + data: { + columns: [ + ['data1'], + ['data2'] + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should generate a chart', function () { + var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'); + expect(ticks.size()).toBe(0); + }); + + it('should upaate args for empty data', function () { + args = { + data: { + x: 'x', + columns: [ + ['x'], + ['data1'], + ['data2'] + ] + }, + axis: { + x: { + type: 'timeseries' + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should generate a chart', function () { + var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'); + expect(ticks.size()).toBe(0); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/data-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/data-spec.js new file mode 100644 index 0000000..db7e929 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/data-spec.js @@ -0,0 +1,1220 @@ +describe('c3 chart data', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('load json', function () { + + it('should update args', function () { + args = { + data: { + json: { + data1: [30, 20, 50], + data2: [200, 130, 90] + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should draw correctly', function () { + var expectedCx = [6, 299, 593], + expectedCy = [370, 390, 331]; + d3.selectAll('.c3-circles-data1 .c3-circle').each(function (d, i) { + var circle = d3.select(this); + expect(+circle.attr('cx')).toBeCloseTo(expectedCx[i], -2); + expect(+circle.attr('cy')).toBeCloseTo(expectedCy[i], -2); + }); + }); + + it('should update args', function () { + args = { + data: { + json: [{ + "date": "2014-06-03", + "443": "3000", + "995": "500" + }, { + "date": "2014-06-04", + "443": "1000" + }, { + "date": "2014-06-05", + "443": "5000", + "995": "1000" + }], + keys: { + x: 'date', + value: [ "443", "995" ] + } + }, + axis: { + x: { + type: "category" + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should draw correctly', function () { + var expectedCx = {443: [98, 294, 490], 995: [98, 294, 490]}, + expectedCy = {443: [193, 351, 36], 995: [390, 429, 351]}; + d3.selectAll('.c3-circles-443 .c3-circle').each(function (d, i) { + var circle = d3.select(this); + expect(+circle.attr('cx')).toBeCloseTo(expectedCx[443][i], -2); + expect(+circle.attr('cy')).toBeCloseTo(expectedCy[443][i], -2); + }); + d3.selectAll('.c3-circles-995 .c3-circle').each(function (d, i) { + var circle = d3.select(this); + expect(+circle.attr('cx')).toBeCloseTo(expectedCx[995][i], -2); + expect(+circle.attr('cy')).toBeCloseTo(expectedCy[995][i], -2); + }); + }); + + }); + + describe('function in data.order', function () { + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ], + order: function () { + return 0; + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should return false in isOrderAsc and isOrderDesc functions', function () { + expect(chart.internal.isOrderAsc() || chart.internal.isOrderDesc()).toBe(false); + }); + }); + + describe('data.xs', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ], + } + }; + expect(true).toBeTruthy(); + }); + + describe('normal x', function () { + + it('should have correct number of xs for each', function () { + expect(Object.keys(chart.internal.data.xs).length).toBe(3); + expect(chart.internal.data.xs.data1.length).toBe(6); + expect(chart.internal.data.xs.data2.length).toBe(6); + expect(chart.internal.data.xs.data3.length).toBe(6); + }); + + it('should have integer index as x', function () { + for (var i = 0; i < chart.internal.data.xs.data3.length; i++) { + expect(chart.internal.data.xs.data1[i]).toBe(i); + expect(chart.internal.data.xs.data2[i]).toBe(i); + expect(chart.internal.data.xs.data3[i]).toBe(i); + } + }); + + }); + + describe('timeseries x', function () { + describe('without xFormat', function () { + + it('should load timeseries data successfully', function () { + args = { + data: { + x : 'date', + columns: [ + ['date', '2013-01-01', '2013-01-02', '2013-01-03'], + ['data1', 30, 200, 100], + ['data2', 130, 300, 200] + ] + }, + axis : { + x : { + type : 'timeseries' + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have correct number of xs', function () { + expect(Object.keys(chart.internal.data.xs).length).toBe(2); + expect(chart.internal.data.xs.data1.length).toBe(3); + expect(chart.internal.data.xs.data2.length).toBe(3); + }); + + it('should have Date object as x', function () { + var xs = chart.internal.data.xs; + expect(+xs.data1[0]).toBe(+new Date(2013, 0, 1, 0, 0, 0)); + expect(+xs.data1[1]).toBe(+new Date(2013, 0, 2, 0, 0, 0)); + expect(+xs.data1[2]).toBe(+new Date(2013, 0, 3, 0, 0, 0)); + expect(+xs.data2[0]).toBe(+new Date(2013, 0, 1, 0, 0, 0)); + expect(+xs.data2[1]).toBe(+new Date(2013, 0, 2, 0, 0, 0)); + expect(+xs.data2[2]).toBe(+new Date(2013, 0, 3, 0, 0, 0)); + }); + }); + + describe('with xFormat', function () { + describe('timeseries x with xFormat', function () { + it('should load timeseries data successfully', function () { + args = { + data: { + x : 'date', + xFormat: '%Y%m%d', + columns: [ + ['date', '20130101', '20130102', '20130103'], + ['data1', 30, 200, 100], + ['data2', 130, 300, 200] + ] + }, + axis : { + x : { + type : 'timeseries' + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have correct number of xs', function () { + expect(Object.keys(chart.internal.data.xs).length).toBe(2); + expect(chart.internal.data.xs.data1.length).toBe(3); + expect(chart.internal.data.xs.data2.length).toBe(3); + }); + + it('should have Date object as x', function () { + var xs = chart.internal.data.xs; + expect(+xs.data1[0]).toBe(+new Date(2013, 0, 1, 0, 0, 0)); + expect(+xs.data1[1]).toBe(+new Date(2013, 0, 2, 0, 0, 0)); + expect(+xs.data1[2]).toBe(+new Date(2013, 0, 3, 0, 0, 0)); + expect(+xs.data2[0]).toBe(+new Date(2013, 0, 1, 0, 0, 0)); + expect(+xs.data2[1]).toBe(+new Date(2013, 0, 2, 0, 0, 0)); + expect(+xs.data2[2]).toBe(+new Date(2013, 0, 3, 0, 0, 0)); + }); + }); + }); + }); + + describe('milliseconds timeseries x', function () { + + describe('as date string', function () { + + it('should update args', function () { + args = { + data: { + x : 'date', + xFormat: '%Y-%m-%d %H:%M:%S.%L', + columns: [ + ['date', "2014-05-20 17:25:00.123", "2014-05-20 17:30:00.345"], + ['data1', 30, 200], + ['data2', 130, 300] + ] + }, + axis: { + x: { + type: 'timeseries', + tick: { + format: '%Y-%m-%d %H:%M:%S.%L', + multiline: false + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have correct number of xs', function () { + expect(Object.keys(chart.internal.data.xs).length).toBe(2); + expect(chart.internal.data.xs.data1.length).toBe(2); + expect(chart.internal.data.xs.data2.length).toBe(2); + }); + + it('should have Date object as x', function () { + var xs = chart.internal.data.xs; + expect(+xs.data1[0]).toBe(+new Date(2014, 4, 20, 17, 25, 0, 123)); + expect(+xs.data1[1]).toBe(+new Date(2014, 4, 20, 17, 30, 0, 345)); + expect(+xs.data2[0]).toBe(+new Date(2014, 4, 20, 17, 25, 0, 123)); + expect(+xs.data2[1]).toBe(+new Date(2014, 4, 20, 17, 30, 0, 345)); + }); + + it('should have milliseconds tick format', function () { + var expected = ["2014-05-20 17:25:00.123", "2014-05-20 17:30:00.345"]; + chart.internal.main.selectAll('.c3-axis-x g.tick text').each(function (d, i) { + expect(d3.select(this).text()).toBe(expected[i]); + }); + }); + + }); + + describe('as unixtime number', function () { + + it('should update args', function () { + args = { + data: { + x : 'date', + columns: [ + ['date', 1417622461123, 1417622522345], + ['data1', 30, 200], + ['data2', 130, 300] + ] + }, + axis: { + x: { + type: 'timeseries', + tick: { + format: '%Y-%m-%d %H:%M:%S.%L' + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have correct number of xs', function () { + expect(Object.keys(chart.internal.data.xs).length).toBe(2); + expect(chart.internal.data.xs.data1.length).toBe(2); + expect(chart.internal.data.xs.data2.length).toBe(2); + }); + + it('should have Date object as x', function () { + var xs = chart.internal.data.xs; + expect(+xs.data1[0]).toBe(1417622461123); + expect(+xs.data1[1]).toBe(1417622522345); + expect(+xs.data2[0]).toBe(1417622461123); + expect(+xs.data2[1]).toBe(1417622522345); + }); + }); + + }); + + }); + + describe('data.label', function () { + + describe('on line chart', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 1030, 2200, 2100], + ['data2', 1150, 2010, 1200], + ['data3', -1150, -2010, -1200], + ['data4', -1030, -2200, -2100], + ], + type: 'line', + labels: true, + } + }; + expect(true).toBeTruthy(); + }); + + it('should locate data labels in correct position', function () { + var expectedTextY = { + data1: [128, 38, 46], + data2: [119, 53, 115], + data3: [311, 377, 315], + data4: [302, 392, 384], + }; + var expectedTextX = { + data1: [6, 294, 583], + data2: [6, 294, 583], + data3: [6, 294, 583], + data4: [6, 294, 583], + }; + Object.keys(expectedTextY).forEach(function (key) { + d3.selectAll('.c3-texts-' + key + ' text.c3-text').each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedTextY[key][i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedTextX[key][i], -2); + }); + }); + }); + + it('should update args to be stacked', function () { + args.data.groups = [['data1', 'data2'], ['data3', 'data4']]; + expect(true).toBeTruthy(); + }); + + it('should locate data labels in correct position', function () { + var expectedTextY = { + data1: [120, 38, 75], + data2: [161, 127, 159], + data3: [269, 303, 271], + data4: [310, 392, 355], + }; + var expectedTextX = { + data1: [6, 294, 583], + data2: [6, 294, 583], + data3: [6, 294, 583], + data4: [6, 294, 583], + }; + Object.keys(expectedTextY).forEach(function (key) { + d3.selectAll('.c3-texts-' + key + ' text.c3-text').each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedTextY[key][i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedTextX[key][i], -2); + }); + }); + }); + + }); + + describe('on area chart', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 1030, 2200, 2100], + ['data2', 1150, 2010, 1200], + ['data3', -1150, -2010, -1200], + ['data4', -1030, -2200, -2100], + ], + type: 'area', + labels: true, + } + }; + expect(true).toBeTruthy(); + }); + + it('should locate data labels in correct position', function () { + var expectedTextY = { + data1: [128, 38, 46], + data2: [119, 53, 115], + data3: [311, 377, 315], + data4: [302, 392, 384], + }; + var expectedTextX = { + data1: [6, 294, 583], + data2: [6, 294, 583], + data3: [6, 294, 583], + data4: [6, 294, 583], + }; + Object.keys(expectedTextY).forEach(function (key) { + d3.selectAll('.c3-texts-' + key + ' text.c3-text').each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedTextY[key][i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedTextX[key][i], -2); + }); + }); + }); + + it('should update args to be stacked', function () { + args.data.groups = [['data1', 'data2'], ['data3', 'data4']]; + expect(true).toBeTruthy(); + }); + + it('should locate data labels in correct position', function () { + var expectedTextY = { + data1: [120, 38, 75], + data2: [161, 127, 159], + data3: [269, 303, 271], + data4: [310, 392, 355], + }; + var expectedTextX = { + data1: [6, 294, 583], + data2: [6, 294, 583], + data3: [6, 294, 583], + data4: [6, 294, 583], + }; + Object.keys(expectedTextY).forEach(function (key) { + d3.selectAll('.c3-texts-' + key + ' text.c3-text').each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedTextY[key][i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedTextX[key][i], -2); + }); + }); + }); + + }); + + describe('on bar chart', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 1030, 2200, 2100], + ['data2', 1150, 2010, 1200], + ['data3', -1150, -2010, -1200], + ['data4', -1030, -2200, -2100], + ], + type: 'bar', + labels: true, + } + }; + expect(true).toBeTruthy(); + }); + + it('should locate data labels in correct position', function () { + var expectedTextY = { + data1: [128, 38, 46], + data2: [119, 53, 115], + data3: [311, 377, 315], + data4: [302, 392, 384], + }; + var expectedTextX = { + data1: [53, 249, 445], + data2: [83, 279, 475], + data3: [112, 308, 504], + data4: [142, 338, 534], + }; + Object.keys(expectedTextY).forEach(function (key) { + d3.selectAll('.c3-texts-' + key + ' text.c3-text').each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedTextY[key][i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedTextX[key][i], -2); + }); + }); + }); + + it('should update args to be stacked', function () { + args.data.groups = [['data1', 'data2'], ['data3', 'data4']]; + expect(true).toBeTruthy(); + }); + + it('should locate data labels in correct position', function () { + var expectedTextY = { + data1: [120, 38, 75], + data2: [161, 127, 159], + data3: [269, 303, 271], + data4: [310, 392, 355], + }; + var expectedTextX = { + data1: [68.6, 264, 460], + data2: [68.6, 264, 460], + data3: [127, 323, 519], + data4: [127, 323, 519], + }; + Object.keys(expectedTextY).forEach(function (key) { + d3.selectAll('.c3-texts-' + key + ' text.c3-text').each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedTextY[key][i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedTextX[key][i], -2); + }); + }); + }); + + }); + + describe('for all targets', function () { + + it('should update args to show data label for all data', function () { + args = { + data: { + columns: [ + ['data1', 100, 200, 100, 400, 150, 250], + ['data2', 10, 20, 10, 40, 15, 25], + ['data3', 1000, 2000, 1000, 4000, 1500, 2500] + ], + labels: true + } + }; + expect(true).toBeTruthy(); + }); + + it('should have data labels on all data', function () { + d3.selectAll('.c3-texts-data1 text').each(function (d, i) { + expect(d3.select(this).text()).toBe(args.data.columns[0][i + 1] + ''); + }); + d3.selectAll('.c3-texts-data2 text').each(function (d, i) { + expect(d3.select(this).text()).toBe(args.data.columns[1][i + 1] + ''); + }); + d3.selectAll('.c3-texts-data3 text').each(function (d, i) { + expect(d3.select(this).text()).toBe(args.data.columns[2][i + 1] + ''); + }); + }); + + }); + + describe('for each target', function () { + + describe('as true', function () { + + it('should update args to show data label for only data1', function () { + args = { + data: { + columns: [ + ['data1', 100, 200, 100, 400, 150, 250], + ['data2', 10, 20, 10, 40, 15, 25], + ['data3', 1000, 2000, 1000, 4000, 1500, 2500] + ], + labels: { + format: { + data1: true + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have data labels on all data', function () { + d3.selectAll('.c3-texts-data1 text').each(function (d, i) { + expect(d3.select(this).text()).toBe(args.data.columns[0][i + 1] + ''); + }); + d3.selectAll('.c3-texts-data2 text').each(function () { + expect(d3.select(this).text()).toBe(''); + }); + d3.selectAll('.c3-texts-data3 text').each(function () { + expect(d3.select(this).text()).toBe(''); + }); + }); + }); + + describe('as function', function () { + + it('should update args to show data label for only data1', function () { + args = { + data: { + columns: [ + ['data1', 100, 200, 100, 400, 150, 250], + ['data2', 10, 20, 10, 40, 15, 25], + ['data3', 1000, 2000, 1000, 4000, 1500, 2500] + ], + labels: { + format: { + data1: d3.format('$') + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have data labels on all data', function () { + d3.selectAll('.c3-texts-data1 text').each(function (d, i) { + expect(d3.select(this).text()).toBe('$' + args.data.columns[0][i + 1]); + }); + d3.selectAll('.c3-texts-data2 text').each(function () { + expect(d3.select(this).text()).toBe(''); + }); + d3.selectAll('.c3-texts-data3 text').each(function () { + expect(d3.select(this).text()).toBe(''); + }); + }); + }); + + }); + + describe('with small values', function () { + + it('should update args to show data label', function () { + args = { + data: { + columns: [ + ['data1', 0.03, 0.2, 0.1, 0.4, 0.15, 0.250] + ], + labels: true + } + }; + expect(true).toBeTruthy(); + }); + + it('should have proper y domain', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-0.02); + expect(domain[1]).toBeCloseTo(0.45); + }); + }); + + describe('with positive values and null', function () { + + describe('on not rotated axis', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 190, 200, 190, null], + ], + type: 'bar', + labels: { + format: function (v) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(0, -1); + expect(domain[1]).toBeCloseTo(227, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [67, 49, 67, 423], + expectedXs = [74, 221, 368, 515]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(189, -1); + expect(domain[1]).toBeCloseTo(201, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [375, 40, 375, 422], + expectedXs = [6, 198, 391, 583]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + }); + + describe('on rotated axis', function () { + + it('should update args', function () { + args.data.type = 'bar'; + args.axis = { + rotated: true + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(0, -1); + expect(domain[1]).toBeCloseTo(231, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [57, 163, 269, 375], + expectedXs = [490, 516, 490, 4]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(188, -1); + expect(domain[1]).toBeCloseTo(202, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [9, 147, 286, 424], + expectedXs = [76, 526, 76, 4]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + }); + + }); + + describe('with positive values and null', function () { + + describe('on not rotated axis', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', -190, -200, -190, null], + ], + type: 'bar', + labels: { + format: function (v) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-227, -1); + expect(domain[1]).toBeCloseTo(0, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [368, 387, 368, 12], + expectedXs = [74, 221, 368, 515]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-201, -1); + expect(domain[1]).toBeCloseTo(-189, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [58, 392, 58, 12], + expectedXs = [6, 198, 391, 583]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + }); + + describe('on rotated axis', function () { + + it('should update args', function () { + args.data.type = 'bar'; + args.axis = { + rotated: true + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-232, -1); + expect(domain[1]).toBeCloseTo(0, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [57, 163, 269, 375], + expectedXs = [103, 78, 103, 526]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-202, -1); + expect(domain[1]).toBeCloseTo(-188, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [9, 147, 286, 424], + expectedXs = [511, 67, 511, 526]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + }); + + }); + + describe('with positive and negative values and null', function () { + + describe('on non rotated axis', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', -190, 200, 190, null], + ], + type: 'bar', + labels: { + format: function (v) { + if (v === null) { + return 'Not Applicable'; + } + return d3.format('$')(v); + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-243, -1); + expect(domain[1]).toBeCloseTo(253, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [392, 43, 52, 215], + expectedXs = [74, 221, 368, 515]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-243, -1); + expect(domain[1]).toBeCloseTo(253, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [392, 40, 49, 212], + expectedXs = [6, 198, 391, 583]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + }); + + describe('on rotated axis', function () { + + it('should update args', function () { + args.data.type = 'bar'; + args.axis = { + rotated: true + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-254, -1); + expect(domain[1]).toBeCloseTo(260, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [57, 163, 269, 375], + expectedXs = [69, 525, 513, 295]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-254, -1); + expect(domain[1]).toBeCloseTo(260, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [9, 147, 286, 424], + expectedXs = [67, 527, 515, 297]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + }); + + }); + + describe('with positive grouped values', function () { + + describe('on non rotated axis', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 500], + ['data2', 50, 20, 10, 40], + ['data3', 250, 220, 210, 240], + ], + groups: [['data1', 'data2', 'data3']], + labels: true, + type: 'bar', + } + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(0, -1); + expect(domain[1]).toBeCloseTo(885, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [385, 317, 370, 164], + expectedXs = [74, 221, 368, 515]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-94, -1); + expect(domain[1]).toBeCloseTo(884, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [344, 284, 331, 144], + expectedXs = [6, 198, 391, 583]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + }); + + describe('on rotated axis', function () { + + it('should update args', function () { + args.data.type = 'bar'; + args.axis = { + rotated: true + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(0, -1); + expect(domain[1]).toBeCloseTo(888, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [57, 163, 269, 375], + expectedXs = [57, 150, 77, 363]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-87, -1); + expect(domain[1]).toBeCloseTo(887, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [9, 147, 286, 424], + expectedXs = [107, 192, 125, 386]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + }); + + }); + + describe('with negative grouped values', function () { + + describe('on non rotated axis', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', -30, -200, -100, -500], + ['data2', -50, -20, -10, -40], + ['data3', -250, -220, -210, -240] + ], + groups: [['data1', 'data2', 'data3']], + labels: true, + type: 'bar', + } + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-885, -1); + expect(domain[1]).toBeCloseTo(0, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [51, 118, 65, 272], + expectedXs = [74, 221, 368, 515]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-884, -1); + expect(domain[1]).toBeCloseTo(94, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [88, 149, 101, 288], + expectedXs = [6, 198, 391, 583]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + }); + + describe('on rotated axis', function () { + + it('should update args', function () { + args.data.type = 'bar'; + args.axis = { + rotated: true + }; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-894, -1); + expect(domain[1]).toBeCloseTo(0, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [57, 163, 269, 375], + expectedXs = [533, 440, 513, 230]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + + it('should update args', function () { + args.data.type = 'line'; + expect(true).toBeTruthy(); + }); + + it('should have y domain with proper padding', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-894, -1); + expect(domain[1]).toBeCloseTo(94, -1); + }); + + it('should locate labels above each data point', function () { + var texts = chart.internal.main.selectAll('.c3-texts-data1 text'), + expectedYs = [9, 147, 286, 424], + expectedXs = [480, 397, 462, 205]; + texts.each(function (d, i) { + var text = d3.select(this); + expect(+text.attr('y')).toBeCloseTo(expectedYs[i], -2); + expect(+text.attr('x')).toBeCloseTo(expectedXs[i], -2); + }); + }); + }); + + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/domain-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/domain-spec.js new file mode 100644 index 0000000..69f7995 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/domain-spec.js @@ -0,0 +1,110 @@ +describe('c3 chart domain', function () { + 'use strict'; + + var chart; + + var args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + }, + axis: { + y: {}, + y2: {} + } + }; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('axis.y.min', function () { + + it('should change axis.y.min to -100', function () { + args.axis.y.min = -100; + expect(true).toBeTruthy(); + }); + + it('should be set properly when smaller than max of data', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBe(-150); + expect(domain[1]).toBe(450); + }); + + it('should change axis.y.min to 500', function () { + args.axis.y.min = 500; + expect(true).toBeTruthy(); + }); + + it('should be set properly when bigger than max of data', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBe(499); + expect(domain[1]).toBe(511); + }); + + it('should change axis.y.min to undefined', function () { + args.axis.y.min = undefined; + expect(true).toBeTruthy(); + }); + + }); + + describe('axis.y.max', function () { + + it('should change axis.y.max to 1000', function () { + args.axis.y.max = 1000; + expect(true).toBeTruthy(); + }); + + it('should be set properly when bigger than min of data', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBe(-89); + expect(domain[1]).toBe(1099); + }); + + it('should change axis.y.max to 0', function () { + args.axis.y.max = 0; + expect(true).toBeTruthy(); + }); + + it('should be set properly when smaller than min of data', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBe(-11); + expect(domain[1]).toBe(1); + }); + + }); + + describe('axis.y.padding', function () { + + it('should change axis.y.max to 1000', function () { + args = { + data: { + columns: [ + ['data1', 10, 20, 10, 40, 15, 25], + ['data2', 50, 40, 30, 45, 25, 45] + ] + }, + axis: { + y: { + padding: { + top: 200, + bottom: 200 + } + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should be set properly when bigger than min of data', function () { + var domain = chart.internal.y.domain(); + expect(domain[0]).toBeCloseTo(-9, -1); + expect(domain[1]).toBeCloseTo(69, -1); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/grid-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/grid-spec.js new file mode 100644 index 0000000..0443ec1 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/grid-spec.js @@ -0,0 +1,365 @@ +describe('c3 chart grid', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('y grid show', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250] + ] + }, + axis: { + y: { + tick: { + } + } + }, + grid: { + y: { + show: false + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should not show y grids', function () { + expect(chart.internal.main.select('.c3-ygrids').size()).toBe(0); + }); + + it('should update args to show y grids', function () { + args.grid.y.show = true; + expect(true).toBeTruthy(); + }); + + it('should show y grids', function () { + var ygrids = chart.internal.main.select('.c3-ygrids'); + expect(ygrids.size()).toBe(1); + expect(ygrids.selectAll('.c3-ygrid').size()).toBe(9); + }); + + it('should update args to show only 3 y grids', function () { + args.grid.y.ticks = 3; + expect(true).toBeTruthy(); + }); + + it('should show only 3 y grids', function () { + var ygrids = chart.internal.main.select('.c3-ygrids'); + expect(ygrids.size()).toBe(1); + expect(ygrids.selectAll('.c3-ygrid').size()).toBe(3); + }); + + it('should update args to show y grids depending on y axis ticks', function () { + args.axis.y.tick.count = 5; + expect(true).toBeTruthy(); + }); + + it('should show grids depending on y axis ticks', function () { + var ygrids = chart.internal.main.select('.c3-ygrids'), + expectedYs = []; + ygrids.selectAll('.c3-ygrid').each(function (d, i) { + expectedYs[i] = +d3.select(this).attr('y1'); + }); + expect(ygrids.size()).toBe(1); + expect(ygrids.selectAll('.c3-ygrid').size()).toBe(5); + chart.internal.main.select('.c3-axis-y').selectAll('.tick').each(function (d, i) { + var t = d3.transform(d3.select(this).attr('transform')); + expect(t.translate[1]).toBe(expectedYs[i]); + }); + }); + }); + + describe('y grid lines', function () { + + describe('position', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 10, 200, 100, 400, 150, 250] + ] + }, + grid: { + y: { + lines: [ + {value: 30, text: 'Lable 30', position: 'start'}, + {value: 145, text: 'Lable 145', position: 'middle'}, + {value: 225, text: 'Lable 225'} + ] + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should show 3 grid lines', function () { + expect(chart.internal.main.selectAll('.c3-ygrid-lines .c3-ygrid-line').size()).toBe(3); + }); + + it('should locate grid lines properly', function () { + var lines = chart.internal.main.selectAll('.c3-ygrid-lines .c3-ygrid-line'), + expectedY1s = [373, 268, 196]; + lines.each(function (d, i) { + var y1 = d3.select(this).select('line').attr('y1'); + expect(y1).toBeCloseTo(expectedY1s[i], -2); + }); + }); + + it('should locate grid texts properly', function () { + var lines = chart.internal.main.selectAll('.c3-ygrid-lines .c3-ygrid-line'), + expectedPositions = ['start', 'middle', 'end'], + expectedDxs = [4, 0, -4]; + lines.each(function (d, i) { + var text = d3.select(this).select('text'), + textAnchor = text.attr('text-anchor'), + dx = text.attr('dx'); + expect(textAnchor).toBe(expectedPositions[i]); + expect(+dx).toBe(expectedDxs[i]); + }); + }); + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 10, 200, 100, 400, 150, 250] + ] + }, + axis: { + rotated: true + }, + grid: { + y: { + lines: [ + {value: 30, text: 'Lable 30', position: 'start'}, + {value: 145, text: 'Lable 145', position: 'middle'}, + {value: 225, text: 'Lable 225'} + ] + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should show 3 grid lines', function () { + expect(chart.internal.main.selectAll('.c3-ygrid-lines .c3-ygrid-line').size()).toBe(3); + }); + + it('should locate grid lines properly', function () { + var lines = chart.internal.main.selectAll('.c3-ygrid-lines .c3-ygrid-line'), + expectedX1s = [75, 220, 321]; + lines.each(function (d, i) { + var x1 = d3.select(this).select('line').attr('x1'); + expect(x1).toBeCloseTo(expectedX1s[i], -2); + }); + }); + + it('should locate grid texts properly', function () { + var lines = chart.internal.main.selectAll('.c3-ygrid-lines .c3-ygrid-line'), + expectedPositions = ['start', 'middle', 'end'], + expectedDxs = [4, 0, -4]; + lines.each(function (d, i) { + var text = d3.select(this).select('text'), + textAnchor = text.attr('text-anchor'), + dx = text.attr('dx'); + expect(textAnchor).toBe(expectedPositions[i]); + expect(+dx).toBe(expectedDxs[i]); + }); + }); + + }); + }); + + describe('x grid lines', function () { + + describe('position', function () { + + it('should have correct height', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400], + ] + }, + grid: { + x: { + lines: [ + {value: 1, text: 'Label 1', position: 'start'}, + {value: 2, text: 'Label 2', position: 'middle'}, + {value: 3, text: 'Label 3'}, + ] + } + }, + }; + expect(true).toBeTruthy(); + }); + + it('should show 3 grid lines', function () { + expect(chart.internal.main.selectAll('.c3-xgrid-lines .c3-xgrid-line').size()).toBe(3); + }); + + it('should locate grid lines properly', function () { + var lines = chart.internal.main.selectAll('.c3-xgrid-lines .c3-xgrid-line'), + expectedX1s = [202, 397, 593]; + lines.each(function (d, i) { + var x1 = d3.select(this).select('line').attr('x1'); + expect(x1).toBeCloseTo(expectedX1s[i], -2); + }); + }); + + it('should locate grid texts properly', function () { + var lines = chart.internal.main.selectAll('.c3-xgrid-lines .c3-xgrid-line'), + expectedPositions = ['start', 'middle', 'end'], + expectedDxs = [4, 0, -4]; + lines.each(function (d, i) { + var text = d3.select(this).select('text'), + textAnchor = text.attr('text-anchor'), + dx = text.attr('dx'); + expect(textAnchor).toBe(expectedPositions[i]); + expect(+dx).toBe(expectedDxs[i]); + }); + }); + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400], + ] + }, + axis: { + rotated: true + }, + grid: { + x: { + lines: [ + {value: 1, text: 'Label 1', position: 'start'}, + {value: 2, text: 'Label 2', position: 'middle'}, + {value: 3, text: 'Label 3'}, + ] + } + }, + }; + expect(true).toBeTruthy(); + }); + + it('should show 3 grid lines', function () { + expect(chart.internal.main.selectAll('.c3-xgrid-lines .c3-xgrid-line').size()).toBe(3); + }); + + it('should locate grid lines properly', function () { + var lines = chart.internal.main.selectAll('.c3-xgrid-lines .c3-xgrid-line'), + expectedY1s = [144, 283, 421]; + lines.each(function (d, i) { + var y1 = d3.select(this).select('line').attr('y1'); + expect(y1).toBeCloseTo(expectedY1s[i], -2); + }); + }); + + it('should locate grid texts properly', function () { + var lines = chart.internal.main.selectAll('.c3-xgrid-lines .c3-xgrid-line'), + expectedPositions = ['start', 'middle', 'end'], + expectedDxs = [4, 0, -4]; + lines.each(function (d, i) { + var text = d3.select(this).select('text'), + textAnchor = text.attr('text-anchor'), + dx = text.attr('dx'); + expect(textAnchor).toBe(expectedPositions[i]); + expect(+dx).toBe(expectedDxs[i]); + }); + }); + + }); + + describe('with padding.top', function () { + + it('should have correct height', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400], + ] + }, + grid: { + x: { + lines: [ + {value: 3, text: 'Label 3'} + ] + } + }, + padding: { + top: 50 + } + }; + expect(true).toBeTruthy(); + }); + + it('should show x grid lines', function () { + var lines = chart.internal.main.select('.c3-xgrid-lines .c3-xgrid-line'), + expectedX1 = 593, + expectedText = ['Label 3']; + lines.each(function (id, i) { + var line = d3.select(this), + l = line.select('line'), + t = line.select('text'); + expect(+l.attr('x1')).toBeCloseTo(expectedX1, -2); + expect(t.text()).toBe(expectedText[i]); + }); + }); + + }); + + describe('on category axis', function () { + + it('should update args', function () { + args = { + data: { + x: 'x', + columns: [ + ['x', 'a', 'b', 'c', 'd'], + ['data1', 30, 200, 100, 400], + ] + }, + axis: { + x: { + type: 'category' + } + }, + grid: { + x: { + lines: [ + {value: 3, text: 'Label 3'}, + {value: 'a', text: 'Label a'} + ] + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should show x grid lines', function () { + var lines = chart.internal.main.selectAll('.c3-xgrid-lines .c3-xgrid-line'), + expectedX1 = [515, 74], + expectedText = ['Label 3', 'Label a']; + lines.each(function (id, i) { + var line = d3.select(this), + l = line.select('line'), + t = line.select('text'); + expect(+l.attr('x1')).toBeCloseTo(expectedX1[i], -2); + expect(t.text()).toBe(expectedText[i]); + }); + }); + + }); + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/interaction-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/interaction-spec.js new file mode 100644 index 0000000..4e62070 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/interaction-spec.js @@ -0,0 +1,116 @@ +describe('c3 chart interaction', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('generate event rects', function () { + + describe('custom x', function () { + + it('should generate bar chart', function () { + args = { + data: { + x: 'x', + columns: [ + ['x', 0, 1000, 3000, 10000], + ['data', 10, 10, 10, 10] + ], + type: 'bar' + } + }; + expect(true).toBeTruthy(); + }); + + it('should have 4 event rects properly', function () { + var lefts = [78, 138, 205.5, 407.5], + widths = [60, 67.5, 202, 194]; + d3.selectAll('.c3-event-rect').each(function (d, i) { + var box = d3.select(this).node().getBoundingClientRect(); + expect(box.left).toBeCloseTo(lefts[i], -2); + expect(box.width).toBeCloseTo(widths[i], -2); + }); + }); + + it('should generate bar chart with only one data', function () { + args = { + data: { + x: 'x', + columns: [ + ['x', 0], + ['data', 10] + ], + type: 'bar' + } + }; + expect(true).toBeTruthy(); + }); + + it('should have 1 event rects properly', function () { + var eventRects = d3.selectAll('.c3-event-rect'); + expect(eventRects.size()).toBe(1); + eventRects.each(function () { + var box = d3.select(this).node().getBoundingClientRect(); + expect(box.left).toBeCloseTo(40.5, -2); + expect(box.width).toBeCloseTo(598, -2); + }); + }); + }); + + describe('timeseries', function () { + + it('should generate line chart with timeseries', function () { + args = { + data: { + x: 'x', + columns: [ + ['x', '20140101', '20140201', '20140210', '20140301'], + ['data', 10, 10, 10, 10] + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should have 4 event rects properly', function () { + var lefts = [43.5, 193, 353, 500], + widths = [149.5, 160, 147, 136]; + d3.selectAll('.c3-event-rect').each(function (d, i) { + var box = d3.select(this).node().getBoundingClientRect(); + expect(box.left).toBeCloseTo(lefts[i], -2); + expect(box.width).toBeCloseTo(widths[i], -2); + }); + + }); + + it('should generate line chart with only 1 data timeseries', function () { + args = { + data: { + x: 'x', + columns: [ + ['x', '20140101'], + ['data', 10] + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should have 1 event rects properly', function () { + var eventRects = d3.selectAll('.c3-event-rect'); + expect(eventRects.size()).toBe(1); + eventRects.each(function () { + var box = d3.select(this).node().getBoundingClientRect(); + expect(box.left).toBeCloseTo(40.5, -2); + expect(box.width).toBeCloseTo(598, -2); + }); + }); + + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/legend-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/legend-spec.js new file mode 100644 index 0000000..5773b1a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/legend-spec.js @@ -0,0 +1,220 @@ +describe('c3 chart legend', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('legend when multiple charts rendered', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30], + ['data2', 50], + ['data3', 100] + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should update args with long data names', function () { + args = { + data: { + columns: [ + ['long data name 1', 30], + ['long data name 2', 50], + ['long data name 3', 50], + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should have properly computed legend width', function () { + var expectedLeft = [148, 226, 384], + expectedWidth = [118, 118, 108]; + d3.selectAll('.c3-legend-item').each(function (d, i) { + var rect = d3.select(this).node().getBoundingClientRect(); + expect(rect.left).toBeCloseTo(expectedLeft[i], -2); + expect(rect.width).toBeCloseTo(expectedWidth[i], -2); + }); + }); + }); + + describe('legend position', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + } + }; + expect(true).toBeTruthy(); + }); + + it('should be located on the center of chart', function () { + var box = chart.internal.legend.node().getBoundingClientRect(); + expect(box.left + box.right).toBe(640); + }); + + }); + + describe('legend as inset', function () { + + it('should change the legend to "inset" successfully', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25] + ] + }, + legend: { + position: 'inset', + inset: { + step: null + } + } + }; + expect(true).toBeTruthy(); + }); + + it('should be positioned properly', function () { + var box = d3.select('.c3-legend-background').node().getBoundingClientRect(); + expect(box.top).toBe(5.5); + expect(box.left).toBeGreaterThan(30); + }); + + it('should have automatically calculated height', function () { + var box = d3.select('.c3-legend-background').node().getBoundingClientRect(); + expect(box.height).toBe(48); + }); + + it('should change the legend step to 1 successfully', function () { + args.legend.inset.step = 1; + expect(true).toBeTruthy(); + }); + + it('should have automatically calculated height', function () { + var box = d3.select('.c3-legend-background').node().getBoundingClientRect(); + expect(box.height).toBe(28); + }); + + it('should change the legend step to 2 successfully', function () { + args.legend.inset.step = 2; + expect(true).toBeTruthy(); + }); + + it('should have automatically calculated height', function () { + var box = d3.select('.c3-legend-background').node().getBoundingClientRect(); + expect(box.height).toBe(48); + }); + + it('should update args to have only one series', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ] + }, + legend: { + position: 'inset' + } + }; + expect(true).toBeTruthy(); + }); + + it('should locate legend properly', function () { + var box = d3.select('.c3-legend-background').node().getBoundingClientRect(); + expect(box.height).toBe(28); + expect(box.width).toBeGreaterThan(64); + }); + + }); + + describe('legend.hide', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 200, 100, 250, 150] + ] + }, + legend: { + hide: true + } + }; + expect(true).toBeTruthy(); + }); + + it('should not show legends', function () { + d3.selectAll('.c3-legend-item').each(function () { + expect(d3.select(this).style('visibility')).toBe('hidden'); + }); + }); + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 200, 100, 250, 150] + ] + }, + legend: { + hide: 'data2' + } + }; + expect(true).toBeTruthy(); + }); + + it('should not show legends', function () { + expect(d3.select('.c3-legend-item-data1').style('visibility')).toBe('visible'); + expect(d3.select('.c3-legend-item-data2').style('visibility')).toBe('hidden'); + }); + + }); + + describe('legend.show', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 130, 100, 200, 100, 250, 150] + ] + }, + legend: { + show: false + } + }; + expect(true).toBeTruthy(); + }); + + it('should not initially have rendered any legend items', function () { + expect(d3.selectAll('.c3-legend-item').empty()).toBe(true); + }); + + it('allows us to show the legend on showLegend call', function () { + chart.legend.show(); + d3.selectAll('.c3-legend-item').each(function () { + expect(d3.select(this).style('visibility')).toBe('visible'); + // This selects all the children, but we expect it to be empty + expect(d3.select(this).selectAll("*").length).not.toEqual(0); + }); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/shape.bar-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/shape.bar-spec.js new file mode 100644 index 0000000..78f2971 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/shape.bar-spec.js @@ -0,0 +1,88 @@ +var setMouseEvent = window.setMouseEvent; + +describe('c3 chart shape bar', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('internal.isWithinBar', function () { + + describe('with normal axis', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, -150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', -150, 120, 110, 140, 115, 125] + ], + type: 'bar' + }, + axis: { + rotated: false + } + }; + expect(true).toBeTruthy(); + }); + + it('should not be within bar', function () { + var bar = d3.select('.c3-target-data1 .c3-bar-0').node(); + setMouseEvent(chart, 'click', 0, 0); + expect(chart.internal.isWithinBar(bar)).toBeFalsy(); + }); + + it('should be within bar', function () { + var bar = d3.select('.c3-target-data1 .c3-bar-0').node(); + setMouseEvent(chart, 'click', 31, 280); + expect(chart.internal.isWithinBar(bar)).toBeTruthy(); + }); + + it('should not be within bar of negative value', function () { + var bar = d3.select('.c3-target-data3 .c3-bar-0').node(); + setMouseEvent(chart, 'click', 68, 280); + expect(chart.internal.isWithinBar(bar)).toBeFalsy(); + }); + + it('should be within bar of negative value', function () { + var bar = d3.select('.c3-target-data3 .c3-bar-0').node(); + setMouseEvent(chart, 'click', 68, 350); + expect(chart.internal.isWithinBar(bar)).toBeTruthy(); + }); + + }); + + describe('with rotated axis', function () { + + it('should change the chart as axis rotated', function () { + args.axis.rotated = true; + expect(true).toBeTruthy(); + }); + + it('should not be within bar', function () { + var bar = d3.select('.c3-target-data1 .c3-bar-0').node(); + setMouseEvent(chart, 'click', 0, 0); + expect(chart.internal.isWithinBar(bar)).toBeFalsy(); + }); + + it('should be within bar', function () { + var bar = d3.select('.c3-target-data1 .c3-bar-0').node(); + setMouseEvent(chart, 'click', 190, 20); + expect(chart.internal.isWithinBar(bar)).toBeTruthy(); + }); + + it('should be within bar of negative value', function () { + var bar = d3.select('.c3-target-data3 .c3-bar-0').node(); + setMouseEvent(chart, 'click', 68, 50); + expect(chart.internal.isWithinBar(bar)).toBeTruthy(); + }); + + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/shape.line-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/shape.line-spec.js new file mode 100644 index 0000000..b4f5dc8 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/shape.line-spec.js @@ -0,0 +1,99 @@ +describe('c3 chart shape line', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('shape-rendering for line chart', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, -150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', -150, 120, 110, 140, 115, 125] + ], + type: 'line' + } + }; + expect(true).toBeTruthy(); + }); + + it("should not have shape-rendering when it's line chart", function () { + d3.selectAll('.c3-line').each(function () { + var style = d3.select(this).style('shape-rendering'); + expect(style).toBe('auto'); + }); + }); + + it('should chnage to step chart', function () { + args.data.type = 'step'; + expect(true).toBeTruthy(); + }); + + it("should have shape-rendering = crispedges when it's step chart", function () { + d3.selectAll('.c3-line').each(function () { + var style = d3.select(this).style('shape-rendering'); + expect(style).toBe('crispedges'); + }); + }); + + }); + + describe('point.show option', function () { + + it('should change args to include null data', function () { + args = { + data: { + columns: [ + ['data1', 30, null, 100, 400, -150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', -150, 120, 110, 140, 115, 125] + ], + type: 'line' + } + }; + expect(true).toBeTruthy(); + }); + + it('should not show the circle for null', function (done) { + setTimeout(function () { + var target = chart.internal.main.select('.c3-chart-line.c3-target-data1'); + expect(+target.select('.c3-circle-0').style('opacity')).toBe(1); + expect(+target.select('.c3-circle-1').style('opacity')).toBe(0); + expect(+target.select('.c3-circle-2').style('opacity')).toBe(1); + done(); + }, 500); + }); + + it('should change args to include null data on scatter plot', function () { + args = { + data: { + columns: [ + ['data1', 30, null, 100, 400, -150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', -150, 120, 110, 140, 115, 125] + ], + type: 'scatter' + } + }; + expect(true).toBeTruthy(); + }); + + it('should not show the circle for null', function (done) { + setTimeout(function () { + var target = chart.internal.main.select('.c3-chart-line.c3-target-data1'); + expect(+target.select('.c3-circle-0').style('opacity')).toBe(0.5); + expect(+target.select('.c3-circle-1').style('opacity')).toBe(0); + expect(+target.select('.c3-circle-2').style('opacity')).toBe(0.5); + done(); + }, 500); + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/tooltip-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/tooltip-spec.js new file mode 100644 index 0000000..de3983f --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/tooltip-spec.js @@ -0,0 +1,101 @@ +describe('c3 chart tooltip', function () { + 'use strict'; + + var chart; + var tooltipConfiguration; + + var args = function () { + return { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ], + }, + tooltip: tooltipConfiguration + }; + }; + + beforeEach(function (done) { + chart = window.initChart(chart, args(), done); + }); + + describe('tooltip position', function () { + beforeAll(function () { + tooltipConfiguration = {}; + }); + + describe('without left margin', function () { + + it('should show tooltip on proper position', function () { + var eventRect = d3.select('.c3-event-rect-2').node(); + window.setMouseEvent(chart, 'mousemove', 100, 100, eventRect); + + var tooltipContainer = d3.select('.c3-tooltip-container'), + top = Math.floor(+tooltipContainer.style('top').replace(/px/, '')), + left = Math.floor(+tooltipContainer.style('left').replace(/px/, '')), + topExpected = 115, + leftExpected = 280; + expect(top).toBe(topExpected); + expect(left).toBeGreaterThan(leftExpected); + }); + + }); + + describe('with left margin', function () { + + it('should set left margin', function () { + d3.select('#chart').style('margin-left', '300px'); + expect(true).toBeTruthy(); + }); + + it('should show tooltip on proper position', function () { + var eventRect = d3.select('.c3-event-rect-2').node(); + window.setMouseEvent(chart, 'mousemove', 100, 100, eventRect); + + var tooltipContainer = d3.select('.c3-tooltip-container'), + top = Math.floor(+tooltipContainer.style('top').replace(/px/, '')), + left = Math.floor(+tooltipContainer.style('left').replace(/px/, '')), + topExpected = 115, + leftExpected = 280; + expect(top).toBe(topExpected); + expect(left).toBeGreaterThan(leftExpected); + }); + + }); + + }); + + describe('tooltip positionFunction', function () { + var topExpected = 37, leftExpected = 79; + + beforeAll(function () { + tooltipConfiguration = { + position: function (data, width, height, element) { + expect(data.length).toBe(args().data.columns.length); + expect(data[0]).toEqual(jasmine.objectContaining({ + index: 2, + value: 100, + id: 'data1' + })); + expect(width).toBeGreaterThan(0); + expect(height).toBeGreaterThan(0); + expect(element).toBe(d3.select('.c3-event-rect-2').node()); + return {top: topExpected, left: leftExpected}; + } + }; + }); + + it('should be set to the coordinate where the function returned', function () { + var eventRect = d3.select('.c3-event-rect-2').node(); + window.setMouseEvent(chart, 'mousemove', 100, 100, eventRect); + + var tooltipContainer = d3.select('.c3-tooltip-container'), + top = Math.floor(+tooltipContainer.style('top').replace(/px/, '')), + left = Math.floor(+tooltipContainer.style('left').replace(/px/, '')); + expect(top).toBe(topExpected); + expect(left).toBe(leftExpected); + }); + }); +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/type-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/type-spec.js new file mode 100644 index 0000000..9210d50 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/type-spec.js @@ -0,0 +1,137 @@ +describe('c3 chart types', function () { + 'use strict'; + + var chart, args; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('internal.hasArcType', function () { + + describe('with data', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ], + type: 'pie' + } + }; + expect(true).toBeTruthy(); + }); + + it('should return true', function () { + expect(chart.internal.hasArcType()).toBeTruthy(); + }); + + it('should change chart type to "bar"', function () { + args.data.type = 'bar'; + expect(true).toBeTruthy(); + }); + + it('should return false', function () { + expect(chart.internal.hasArcType()).toBeFalsy(); + }); + + }); + + describe('with empty data', function () { + + it('should update args to have empty data', function () { + args = { + data: { + columns: [], + type: 'pie' + } + }; + expect(true).toBeTruthy(); + }); + + it('should return true', function () { + expect(chart.internal.hasArcType()).toBeTruthy(); + }); + + it('should change chart type to "bar"', function () { + args.data.type = 'bar'; + expect(true).toBeTruthy(); + }); + + it('should return false', function () { + expect(chart.internal.hasArcType()).toBeFalsy(); + }); + + }); + + }); + + describe('internal.hasType', function () { + + it('should update args', function () { + args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 150, 250], + ['data2', 50, 20, 10, 40, 15, 25], + ['data3', 150, 120, 110, 140, 115, 125] + ], + type: 'pie' + } + }; + expect(true).toBeTruthy(); + }); + + it('should return true for "pie" type', function () { + expect(chart.internal.hasType('pie')).toBeTruthy(); + }); + + it('should return false for "line" type', function () { + expect(chart.internal.hasType('line')).toBeFalsy(); + }); + + it('should return false for "bar" type', function () { + expect(chart.internal.hasType('bar')).toBeFalsy(); + }); + + it('should unload successfully', function () { + chart.unload([]); + expect(true).toBeTruthy(); + }); + + it('should return true for "pie" type even if no data', function () { + expect(chart.internal.hasType('pie')).toBeTruthy(); + }); + + it('should return false for "line" type even if no data', function () { + expect(chart.internal.hasType('line')).toBeFalsy(); + }); + + it('should return false for "bar" type even if no data', function () { + expect(chart.internal.hasType('bar')).toBeFalsy(); + }); + + it('should change chart type to "bar" successfully', function () { + args.data.type = 'bar'; + expect(true).toBeTruthy(); + }); + + it('should return false for "pie" type even if no data', function () { + expect(chart.internal.hasType('pie')).toBeFalsy(); + }); + + it('should return false for "line" type even if no data', function () { + expect(chart.internal.hasType('line')).toBeFalsy(); + }); + + it('should return true for "bar" type even if no data', function () { + expect(chart.internal.hasType('bar')).toBeTruthy(); + }); + + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/spec/zoom-spec.js b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/zoom-spec.js new file mode 100644 index 0000000..7f1490b --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/spec/zoom-spec.js @@ -0,0 +1,67 @@ +describe('c3 chart zoom', function () { + 'use strict'; + + var chart; + + var args = { + data: { + columns: [ + ['data1', 30, 200, 100, 400, 3150, 250], + ['data2', 50, 20, 10, 40, 15, 6025] + ] + }, + axis: { + x: { + extent: [1, 2] + } + }, + zoom: { + enable: true + }, + subchart: { + show: true + } + }; + + beforeEach(function (done) { + chart = window.initChart(chart, args, done); + }); + + describe('default extent', function () { + + describe('main chart domain', function () { + + it('should have original y domain', function () { + var yDomain = chart.internal.y.domain(), + expectedYDomain = [-591.5, 6626.5]; + expect(yDomain[0]).toBe(expectedYDomain[0]); + expect(yDomain[1]).toBe(expectedYDomain[1]); + }); + + }); + + describe('main chart domain', function () { + + it('should have original y domain in subchart', function () { + var yDomain = chart.internal.y.domain(), + subYDomain = chart.internal.subY.domain(); + expect(subYDomain[0]).toBe(yDomain[0]); + expect(subYDomain[1]).toBe(yDomain[1]); + }); + + }); + + describe('main chart domain', function () { + + it('should have specified brush extent', function () { + var brushExtent = chart.internal.brush.extent(), + expectedBrushExtent = [1, 2]; + expect(brushExtent[0]).toBe(expectedBrushExtent[0]); + expect(brushExtent[1]).toBe(expectedBrushExtent[1]); + }); + + }); + + }); + +}); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.axis.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.axis.js new file mode 100644 index 0000000..281a7bb --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.axis.js @@ -0,0 +1,60 @@ +c3_chart_fn.axis = function () {}; +c3_chart_fn.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? +}; +c3_chart_fn.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 + }; + } +}; +c3_chart_fn.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 + }; + } +}; +c3_chart_fn.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() + }; + } +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.category.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.category.js new file mode 100644 index 0000000..1616c4a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.category.js @@ -0,0 +1,15 @@ +c3_chart_fn.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]; +}; +c3_chart_fn.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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.chart.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.chart.js new file mode 100644 index 0000000..a13b0da --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.chart.js @@ -0,0 +1,27 @@ +c3_chart_fn.resize = function (size) { + var $$ = this.internal, config = $$.config; + config.size_width = size ? size.width : null; + config.size_height = size ? size.height : null; + this.flush(); +}; + +c3_chart_fn.flush = function () { + var $$ = this.internal; + $$.updateAndRedraw({withLegend: true, withTransition: false, withTransitionForTransform: false}); +}; + +c3_chart_fn.destroy = function () { + var $$ = this.internal; + + window.clearInterval($$.intervalForObserveInserted); + window.onresize = null; + + $$.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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.color.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.color.js new file mode 100644 index 0000000..15aaa3e --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.color.js @@ -0,0 +1,5 @@ +// TODO: fix +c3_chart_fn.color = function (id) { + var $$ = this.internal; + return $$.color(id); // more patterns +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.data.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.data.js new file mode 100644 index 0000000..be5b8f7 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.data.js @@ -0,0 +1,27 @@ +c3_chart_fn.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; + }); +}; +c3_chart_fn.data.shown = function (targetIds) { + return this.internal.filterTargetsToShow(this.data(targetIds)); +}; +c3_chart_fn.data.values = function (targetId) { + var targets, values = null; + if (targetId) { + targets = this.data(targetId); + values = targets[0] ? targets[0].values.map(function (d) { return d.value; }) : null; + } + return values; +}; +c3_chart_fn.data.names = function (names) { + this.internal.clearLegendItemTextBoxCache(); + return this.internal.updateDataAttributes('names', names); +}; +c3_chart_fn.data.colors = function (colors) { + return this.internal.updateDataAttributes('colors', colors); +}; +c3_chart_fn.data.axes = function (axes) { + return this.internal.updateDataAttributes('axes', axes); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.flow.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.flow.js new file mode 100644 index 0000000..d8afc19 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.flow.js @@ -0,0 +1,294 @@ +c3_chart_fn.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, + }); +}; + +c3_chart_internal_fn.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 = $$.xgrid || d3.selectAll([]), + 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([]); + + // 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); } + + // 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.x === 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)'; + + // hide tooltip + $$.hideXGridFocus(); + $$.hideTooltip(); + + d3.transition().ease('linear').duration(durationForFlow).each(function () { + wait.add($$.axes.x.transition().call($$.xAxis)); + wait.add(mainBar.transition().attr('transform', transform)); + wait.add(mainLine.transition().attr('transform', transform)); + wait.add(mainArea.transition().attr('transform', transform)); + wait.add(mainCircle.transition().attr('transform', transform)); + wait.add(mainText.transition().attr('transform', transform)); + wait.add(mainRegion.filter($$.isRegionOnX).transition().attr('transform', transform)); + wait.add(xgrid.transition().attr('transform', transform)); + wait.add(xgridLines.transition().attr('transform', transform)); + }) + .call(wait, function () { + var i, shapes = [], texts = [], eventRects = []; + + // remove flowed elements + if (flowLength) { + for (i = 0; i < flowLength; i++) { + shapes.push('.' + CLASS.shape + '-' + (flowIndex + i)); + texts.push('.' + CLASS.text + '-' + (flowIndex + i)); + eventRects.push('.' + CLASS.eventRect + '-' + (flowIndex + i)); + } + $$.svg.selectAll('.' + CLASS.shapes).selectAll(shapes).remove(); + $$.svg.selectAll('.' + CLASS.texts).selectAll(texts).remove(); + $$.svg.selectAll('.' + CLASS.eventRects).selectAll(eventRects).remove(); + $$.svg.select('.' + CLASS.xgrid).remove(); + } + + // draw again for removing flowed elements and reverting attr + xgrid + .attr('transform', null) + .attr($$.xgridAttr); + 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.select('rect').filter($$.isRegionOnX) + .attr("x", $$.regionX.bind($$)) + .attr("width", $$.regionWidth.bind($$)); + + if (config.interaction_enabled) { + $$.redrawEventRect(); + } + + // callback for end of flow + done(); + + $$.flowing = false; + }); + }; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.focus.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.focus.js new file mode 100644 index 0000000..1a65bcc --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.focus.js @@ -0,0 +1,60 @@ +c3_chart_fn.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; + }); +}; + +c3_chart_fn.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; +}; + +c3_chart_fn.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 = []; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.grid.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.grid.js new file mode 100644 index 0000000..038aa6b --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.grid.js @@ -0,0 +1,31 @@ +c3_chart_fn.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; +}; +c3_chart_fn.xgrids.add = function (grids) { + var $$ = this.internal; + return this.xgrids($$.config.grid_x_lines.concat(grids ? grids : [])); +}; +c3_chart_fn.xgrids.remove = function (params) { // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, true); +}; + +c3_chart_fn.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; +}; +c3_chart_fn.ygrids.add = function (grids) { + var $$ = this.internal; + return this.ygrids($$.config.grid_y_lines.concat(grids ? grids : [])); +}; +c3_chart_fn.ygrids.remove = function (params) { // TODO: multiple + var $$ = this.internal; + $$.removeGridLines(params, false); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.group.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.group.js new file mode 100644 index 0000000..47fedb4 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.group.js @@ -0,0 +1,7 @@ +c3_chart_fn.groups = function (groups) { + var $$ = this.internal, config = $$.config; + if (isUndefined(groups)) { return config.data_groups; } + config.data_groups = groups; + $$.redraw(); + return config.data_groups; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.legend.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.legend.js new file mode 100644 index 0000000..182caa1 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.legend.js @@ -0,0 +1,11 @@ +c3_chart_fn.legend = function () {}; +c3_chart_fn.legend.show = function (targetIds) { + var $$ = this.internal; + $$.showLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({withLegend: true}); +}; +c3_chart_fn.legend.hide = function (targetIds) { + var $$ = this.internal; + $$.hideLegend($$.mapToTargetIds(targetIds)); + $$.updateAndRedraw({withLegend: true}); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.load.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.load.js new file mode 100644 index 0000000..6bb4c9a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.load.js @@ -0,0 +1,57 @@ +c3_chart_fn.load = function (args) { + var $$ = this.internal, config = $$.config; + // update xs if specified + if (args.xs) { + $$.addXs(args.xs); + } + // 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 ('unload' in args) { + // TODO: do not unload if target will load (included in url/rows/columns) + $$.unload($$.mapToTargetIds((typeof args.unload === 'boolean' && args.unload) ? null : args.unload), function () { + $$.loadFromArgs(args); + }); + } else { + $$.loadFromArgs(args); + } +}; + +c3_chart_fn.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(); } + }); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.region.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.region.js new file mode 100644 index 0000000..b587b4f --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.region.js @@ -0,0 +1,40 @@ +c3_chart_fn.regions = function (regions) { + var $$ = this.internal, config = $$.config; + if (!regions) { return config.regions; } + config.regions = regions; + $$.redrawWithoutRescale(); + return config.regions; +}; +c3_chart_fn.regions.add = function (regions) { + var $$ = this.internal, config = $$.config; + if (!regions) { return config.regions; } + config.regions = config.regions.concat(regions); + $$.redrawWithoutRescale(); + return config.regions; +}; +c3_chart_fn.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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.selection.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.selection.js new file mode 100644 index 0000000..02ad601 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.selection.js @@ -0,0 +1,54 @@ +c3_chart_fn.selected = function (targetId) { + var $$ = this.internal, d3 = $$.d3; + return d3.merge( + $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(targetId)).selectAll('.' + CLASS.shape) + .filter(function () { return d3.select(this).classed(CLASS.SELECTED); }) + .map(function (d) { return d.map(function (d) { var data = d.__data__; return data.data ? data.data : data; }); }) + ); +}; +c3_chart_fn.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); + } + } + }); +}; +c3_chart_fn.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); + } + } + } + }); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.show.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.show.js new file mode 100644 index 0000000..08e99e1 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.show.js @@ -0,0 +1,50 @@ +c3_chart_fn.show = function (targetIds, options) { + var $$ = this.internal, targets; + + targetIds = $$.mapToTargetIds(targetIds); + options = options || {}; + + $$.removeHiddenTargetIds(targetIds); + targets = $$.svg.selectAll($$.selectorTargets(targetIds)); + + targets.transition() + .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}); +}; + +c3_chart_fn.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); + }); + + if (options.withLegend) { + $$.hideLegend(targetIds); + } + + $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); +}; + +c3_chart_fn.toggle = function (targetIds, options) { + var that = this, $$ = this.internal; + $$.mapToTargetIds(targetIds).forEach(function (targetId) { + $$.isTargetToShow(targetId) ? that.hide(targetId, options) : that.show(targetId, options); + }); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.tooltip.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.tooltip.js new file mode 100644 index 0000000..045a52e --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.tooltip.js @@ -0,0 +1,35 @@ +c3_chart_fn.tooltip = function () {}; +c3_chart_fn.tooltip.show = function (args) { + var $$ = this.internal, index, mouse; + + // determine mouse position on the chart + if (args.mouse) { + mouse = args.mouse; + } + + // determine focus data + if (args.data) { + if ($$.isMultipleX()) { + // if multiple xs, target point will be determined by mouse + mouse = [$$.x(args.data.x), $$.getYScale(args.data.id)(args.data.value)]; + index = null; + } else { + // TODO: when tooltip_grouped = false + index = isValue(args.data.index) ? args.data.index : $$.getIndexByX(args.data.x); + } + } + else if (typeof args.x !== 'undefined') { + index = $$.getIndexByX(args.x); + } + else if (typeof args.index !== 'undefined') { + index = args.index; + } + + // emulate mouse events to show + $$.dispatchEvent('mouseover', index, mouse); + $$.dispatchEvent('mousemove', index, mouse); +}; +c3_chart_fn.tooltip.hide = function () { + // TODO: get target data by checking the state of focus + this.internal.dispatchEvent('mouseout', 0); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.transform.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.transform.js new file mode 100644 index 0000000..f04b505 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.transform.js @@ -0,0 +1,16 @@ +c3_chart_fn.transform = function (type, targetIds) { + var $$ = this.internal, + options = ['pie', 'donut'].indexOf(type) >= 0 ? {withTransform: true} : null; + $$.transformTo(targetIds, type, options); +}; + +c3_chart_internal_fn.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); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.x.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.x.js new file mode 100644 index 0000000..93d25d4 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.x.js @@ -0,0 +1,16 @@ +c3_chart_fn.x = function (x) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetX($$.data.targets, x); + $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); + } + return $$.data.xs; +}; +c3_chart_fn.xs = function (xs) { + var $$ = this.internal; + if (arguments.length) { + $$.updateTargetXs($$.data.targets, xs); + $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); + } + return $$.data.xs; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.zoom.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.zoom.js new file mode 100644 index 0000000..07e7a58 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/api.zoom.js @@ -0,0 +1,22 @@ +c3_chart_fn.zoom = function (domain) { + var $$ = this.internal; + if (domain) { + if ($$.isTimeSeries()) { + domain = domain.map(function (x) { return $$.parseDate(x); }); + } + $$.brush.extent(domain); + $$.redraw({withUpdateXDomain: true, withY: $$.config.zoom_rescale}); + $$.config.zoom_onzoom.call(this, $$.x.orgDomain()); + } + return $$.brush.extent(); +}; +c3_chart_fn.zoom.enable = function (enabled) { + var $$ = this.internal; + $$.config.zoom_enabled = enabled; + $$.updateAndRedraw(); +}; +c3_chart_fn.unzoom = function () { + var $$ = this.internal; + $$.brush.clear().update(); + $$.redraw({withUpdateXDomain: true}); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/arc.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/arc.js new file mode 100644 index 0000000..40861eb --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/arc.js @@ -0,0 +1,394 @@ +c3_chart_internal_fn.initPie = function () { + var $$ = this, d3 = $$.d3, config = $$.config; + $$.pie = d3.layout.pie().value(function (d) { + return d.values.reduce(function (a, b) { return a + b.value; }, 0); + }); + if (!config.data_order) { + $$.pie.sort(null); + } +}; + +c3_chart_internal_fn.updateRadius = function () { + var $$ = this, config = $$.config, + w = config.gauge_width || config.donut_width; + $$.radiusExpanded = Math.min($$.arcWidth, $$.arcHeight) / 2; + $$.radius = $$.radiusExpanded * 0.95; + $$.innerRadiusRatio = w ? ($$.radius - w) / $$.radius : 0.6; + $$.innerRadius = $$.hasType('donut') || $$.hasType('gauge') ? $$.radius * $$.innerRadiusRatio : 0; +}; + +c3_chart_internal_fn.updateArc = function () { + var $$ = this; + $$.svgArc = $$.getSvgArc(); + $$.svgArcExpanded = $$.getSvgArcExpanded(); + $$.svgArcExpandedSub = $$.getSvgArcExpanded(0.98); +}; + +c3_chart_internal_fn.updateAngle = function (d) { + var $$ = this, config = $$.config, + found = false, index = 0, + gMin = config.gauge_min, gMax = config.gauge_max, gTic, gValue; + $$.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)) { + gTic = (Math.PI) / (gMax - gMin); + gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : (gMax - gMin); + d.startAngle = -1 * (Math.PI / 2); + d.endAngle = d.startAngle + gTic * gValue; + } + return found ? d : null; +}; + +c3_chart_internal_fn.getSvgArc = function () { + var $$ = this, + arc = $$.d3.svg.arc().outerRadius($$.radius).innerRadius($$.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; +}; + +c3_chart_internal_fn.getSvgArcExpanded = function (rate) { + var $$ = this, + arc = $$.d3.svg.arc().outerRadius($$.radiusExpanded * (rate ? rate : 1)).innerRadius($$.innerRadius); + return function (d) { + var updated = $$.updateAngle(d); + return updated ? arc(updated) : "M 0 0"; + }; +}; + +c3_chart_internal_fn.getArc = function (d, withoutUpdate, force) { + return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0"; +}; + + +c3_chart_internal_fn.transformForArcLabel = function (d) { + var $$ = this, + updated = $$.updateAngle(d), c, x, y, h, ratio, translate = ""; + if (updated && !$$.hasType('gauge')) { + 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); + // TODO: ratio should be an option? + ratio = $$.radius && h ? (36 / $$.radius > 0.375 ? 1.175 - 36 / $$.radius : 0.8) * $$.radius / h : 0; + translate = "translate(" + (x * ratio) + ',' + (y * ratio) + ")"; + } + return translate; +}; + +c3_chart_internal_fn.getArcRatio = function (d) { + var $$ = this, + whole = $$.hasType('gauge') ? Math.PI : (Math.PI * 2); + return d ? (d.endAngle - d.startAngle) / whole : null; +}; + +c3_chart_internal_fn.convertToArcData = function (d) { + return this.addName({ + id: d.data.id, + value: d.value, + ratio: this.getArcRatio(d), + index: d.index + }); +}; + +c3_chart_internal_fn.textForArcLabel = function (d) { + var $$ = this, + updated, value, ratio, id, format; + if (! $$.shouldShowArcLabel()) { return ""; } + updated = $$.updateAngle(d); + value = updated ? updated.value : null; + ratio = $$.getArcRatio(updated); + id = d.data.id; + if (! $$.hasType('gauge') && ! $$.meetsArcLabelThreshold(ratio)) { return ""; } + format = $$.getArcLabelFormat(); + return format ? format(value, ratio, id) : $$.defaultArcValueFormat(value, ratio); +}; + +c3_chart_internal_fn.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(50) + .attr("d", $$.svgArcExpanded) + .transition().duration(100) + .attr("d", $$.svgArcExpandedSub) + .each(function (d) { + if ($$.isDonutType(d.data)) { + // callback here + } + }); + }); +}; + +c3_chart_internal_fn.unexpandArc = function (targetIds) { + var $$ = this; + + if ($$.transiting) { return; } + + targetIds = $$.mapToTargetIds(targetIds); + + $$.svg.selectAll($$.selectorTargets(targetIds, '.' + CLASS.chartArc)).selectAll('path') + .transition().duration(50) + .attr("d", $$.svgArc); + $$.svg.selectAll('.' + CLASS.arc) + .style("opacity", 1); +}; + +c3_chart_internal_fn.shouldExpand = function (id) { + var $$ = this, config = $$.config; + return ($$.isDonutType(id) && config.donut_expand) || ($$.isGaugeType(id) && config.gauge_expand) || ($$.isPieType(id) && config.pie_expand); +}; + +c3_chart_internal_fn.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; +}; + +c3_chart_internal_fn.meetsArcLabelThreshold = function (ratio) { + var $$ = this, config = $$.config, + threshold = $$.hasType('donut') ? config.donut_label_threshold : config.pie_label_threshold; + return ratio >= threshold; +}; + +c3_chart_internal_fn.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; +}; + +c3_chart_internal_fn.getArcTitle = function () { + var $$ = this; + return $$.hasType('donut') ? $$.config.donut_title : ""; +}; + +c3_chart_internal_fn.updateTargetsForArc = function (targets) { + var $$ = this, main = $$.main, + mainPieUpdate, mainPieEnter, + classChartArc = $$.classChartArc.bind($$), + classArcs = $$.classArcs.bind($$), + classFocus = $$.classFocus.bind($$); + mainPieUpdate = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc) + .data($$.pie(targets)) + .attr("class", function (d) { return classChartArc(d) + classFocus(d.data); }); + mainPieEnter = mainPieUpdate.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(); +}; + +c3_chart_internal_fn.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()); +}; + +c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransform) { + var $$ = this, d3 = $$.d3, config = $$.config, main = $$.main, + mainArc; + mainArc = main.selectAll('.' + CLASS.arcs).selectAll('.' + CLASS.arc) + .data($$.arcData.bind($$)); + mainArc.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; }) + .style("opacity", 0) + .each(function (d) { + if ($$.isGaugeType(d.data)) { + d.startAngle = d.endAngle = -1 * (Math.PI / 2); + } + this._current = d; + }); + mainArc + .attr("transform", function (d) { return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : ""; }) + .style("opacity", function (d) { return d === this._current ? 0 : 1; }) + .on('mouseover', config.interaction_enabled ? function (d) { + var updated, arcData; + if ($$.transiting) { // skip while transiting + return; + } + updated = $$.updateAngle(d); + 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 = $$.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); + 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 = $$.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) { + 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[0].value) : $$.color(d.data.id); + }) // Where gauge reading color would receive customization. + .style("opacity", 1) + .call($$.endall, function () { + $$.transiting = false; + }); + mainArc.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) ? 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') || $$.hasType('gauge') ? 1 : 0); + + if ($$.hasType('gauge')) { + $$.arcs.select('.' + CLASS.chartArcsBackground) + .attr("d", function () { + var d = { + data: [{value: config.gauge_max}], + startAngle: -1 * (Math.PI / 2), + endAngle: Math.PI / 2 + }; + return $$.getArc(d, true, true); + }); + $$.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) / 2)) + "px") + .attr("dy", "1.2em") + .text(config.gauge_label_show ? config.gauge_min : ''); + $$.arcs.select('.' + CLASS.chartArcsGaugeMax) + .attr("dx", $$.innerRadius + (($$.radius - $$.innerRadius) / 2) + "px") + .attr("dy", "1.2em") + .text(config.gauge_label_show ? config.gauge_max : ''); + } +}; +c3_chart_internal_fn.initGauge = function () { + var arcs = this.arcs; + if (this.hasType('gauge')) { + arcs.append('path') + .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"); + } +}; +c3_chart_internal_fn.getGaugeLabelHeight = function () { + return this.config.gauge_label_show ? 20 : 0; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/axis.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/axis.js new file mode 100644 index 0000000..cd14bd6 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/axis.js @@ -0,0 +1,383 @@ +function Axis(owner) { + API.call(this, owner); +} + +inherit(API, Axis); + +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", $$.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, + tickWidth: config.axis_x_tick_width, + tickTextRotate: withoutRotateTickText ? 0 : config.axis_x_tick_rotate, + withoutTransition: withoutTransition, + }, + axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient); + + if ($$.isTimeSeries() && tickValues) { + 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(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition) { + var axisParams = { + withOuterTick: withOuterTick, + withoutTransition: withoutTransition, + }, + $$ = this.owner, + d3 = $$.d3, + config = $$.config, + axis = c3_axis(d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat); + if ($$.isTimeSeriesY()) { + axis.ticks(d3.time[config.axis_y_tick_time_value], 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() { + var $$ = this.owner, config = $$.config, + format = $$.isTimeSeries() ? $$.defaultAxisTimeFormat : $$.isCategorized() ? $$.categoryName : function (v) { return v < 0 ? v.toFixed(0) : 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 - this.getMaxTickWidth('x'); + } else { + return position.isInner ? "-0.5em" : config.axis_x_height ? config.axis_x_height - 10 : "3em"; + } +}; +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, config = $$.config, + 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(scale, $$.yOrient, config.axis_y_tick_format, $$.yAxisTickValues, false, true); + } else if (id === 'y2') { + scale = $$.y2.copy().domain($$.getYDomain(targetsToShow, 'y2')); + axis = this.getYAxis(scale, $$.y2Orient, config.axis_y2_tick_format, $$.y2AxisTickValues, false, 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 = this.getBoundingClientRect(); + 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) { + if (!isValue(padding[key])) { + return defaultValue; + } + if (padding.unit === 'ratio') { + return padding[key] * domainLength; + } + // assume padding is pixels if unit is not specified + return this.convertPixelsToAxisPadding(padding[key], 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(transitions, isHidden) { + var $$ = this.owner; + $$.axes.x.style("opacity", isHidden ? 0 : 1); + $$.axes.y.style("opacity", isHidden ? 0 : 1); + $$.axes.y2.style("opacity", isHidden ? 0 : 1); + $$.axes.subx.style("opacity", isHidden ? 0 : 1); + transitions.axisX.call($$.xAxis); + transitions.axisY.call($$.yAxis); + transitions.axisY2.call($$.y2Axis); + transitions.axisSubX.call($$.subXAxis); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/c3.axis.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/c3.axis.js new file mode 100644 index 0000000..6d4f7a3 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/c3.axis.js @@ -0,0 +1,330 @@ +// Features: +// 1. category axis +// 2. ceil values of translate/x/y to int for half pixel antialiasing +// 3. multiline tick text +var tickTextCharSize; +function c3_axis(d3, params) { + var scale = d3.scale.linear(), orient = "bottom", innerTickSize = 6, outerTickSize, tickPadding = 3, tickValues = null, tickFormat, tickArguments; + + var tickOffset = 0, tickCulling = true, tickCentered; + + params = params || {}; + outerTickSize = params.withOuterTick ? 6 : 0; + + function axisX(selection, x) { + selection.attr("transform", function (d) { + return "translate(" + Math.ceil(x(d) + tickOffset) + ", 0)"; + }); + } + function axisY(selection, y) { + selection.attr("transform", function (d) { + return "translate(0," + Math.ceil(y(d)) + ")"; + }); + } + function scaleExtent(domain) { + var start = domain[0], stop = domain[domain.length - 1]; + return start < stop ? [ start, stop ] : [ stop, start ]; + } + function generateTicks(scale) { + var i, domain, ticks = []; + if (scale.ticks) { + return scale.ticks.apply(scale, 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; + } + function copyScale() { + var newScale = scale.copy(), domain; + if (params.isCategory) { + domain = scale.domain(); + newScale.domain([domain[0], domain[1] - 1]); + } + return newScale; + } + function textFormatted(v) { + var formatted = tickFormat ? tickFormat(v) : v; + return typeof formatted !== 'undefined' ? formatted : ''; + } + function getSizeFor1Char(tick) { + if (tickTextCharSize) { + return tickTextCharSize; + } + var size = { + h: 11.5, + w: 5.5 + }; + tick.select('text').text(textFormatted).each(function (d) { + var box = this.getBoundingClientRect(), + text = textFormatted(d), + h = box.height, + w = text ? (box.width / text.length) : undefined; + if (h && w) { + size.h = h; + size.w = w; + } + }).text(''); + tickTextCharSize = size; + return size; + } + function transitionise(selection) { + return params.withoutTransition ? selection : d3.transition(selection); + } + function axis(g) { + g.each(function () { + var g = axis.g = d3.select(this); + + var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = copyScale(); + + var ticks = tickValues ? tickValues : generateTicks(scale1), + tick = g.selectAll(".tick").data(ticks, scale1), + tickEnter = tick.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 = tick.exit().remove(), + tickUpdate = transitionise(tick).style("opacity", 1), + tickTransform, tickX, tickY; + + var range = scale.rangeExtent ? scale.rangeExtent() : scaleExtent(scale.range()), + path = g.selectAll(".domain").data([ 0 ]), + pathUpdate = (path.enter().append("path").attr("class", "domain"), transitionise(path)); + tickEnter.append("line"); + tickEnter.append("text"); + + var lineEnter = tickEnter.select("line"), + lineUpdate = tickUpdate.select("line"), + textEnter = tickEnter.select("text"), + textUpdate = tickUpdate.select("text"); + + if (params.isCategory) { + tickOffset = Math.ceil((scale1(1) - scale1(0)) / 2); + tickX = tickCentered ? 0 : tickOffset; + tickY = tickCentered ? tickOffset : 0; + } else { + tickOffset = tickX = 0; + } + + var text, tspan, sizeFor1Char = getSizeFor1Char(g.select('.tick')), counts = []; + var tickLength = Math.max(innerTickSize, 0) + tickPadding, + isVertical = orient === 'left' || orient === 'right'; + + // this should be called only when category axis + function splitTickText(d, maxWidth) { + var tickText = textFormatted(d), + subtext, spaceIndex, textWidth, splitted = []; + + if (Object.prototype.toString.call(tickText) === "[object Array]") { + return tickText; + } + + if (!maxWidth || maxWidth <= 0) { + maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[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 = sizeFor1Char.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 + ""); + } + + function tspanDy(d, i) { + var dy = sizeFor1Char.h; + if (i === 0) { + if (orient === 'left' || orient === 'right') { + dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3); + } else { + dy = ".71em"; + } + } + return dy; + } + + function tickSize(d) { + var tickPosition = scale(d) + (tickCentered ? 0 : tickOffset); + return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0; + } + + text = tick.select("text"); + tspan = text.selectAll('tspan') + .data(function (d, i) { + var splitted = params.tickMultiline ? splitTickText(d, params.tickWidth) : [].concat(textFormatted(d)); + counts[i] = splitted.length; + return splitted.map(function (s) { + return { index: i, splitted: s }; + }); + }); + tspan.enter().append('tspan'); + tspan.exit().remove(); + tspan.text(function (d) { return d.splitted; }); + + var rotate = params.tickTextRotate; + + function textAnchorForText(rotate) { + if (!rotate) { + return 'middle'; + } + return rotate > 0 ? "start" : "end"; + } + function textTransform(rotate) { + if (!rotate) { + return ''; + } + return "rotate(" + rotate + ")"; + } + function dxForText(rotate) { + if (!rotate) { + return 0; + } + return 8 * Math.sin(Math.PI * (rotate / 180)); + } + function yForText(rotate) { + if (!rotate) { + return tickLength; + } + return 11.5 - 2.5 * (rotate / 15) * (rotate > 0 ? 1 : -1); + } + + switch (orient) { + case "bottom": + { + tickTransform = axisX; + lineEnter.attr("y2", innerTickSize); + textEnter.attr("y", tickLength); + lineUpdate.attr("x1", tickX).attr("x2", tickX).attr("y2", tickSize); + textUpdate.attr("x", 0).attr("y", yForText(rotate)) + .style("text-anchor", textAnchorForText(rotate)) + .attr("transform", textTransform(rotate)); + tspan.attr('x', 0).attr("dy", tspanDy).attr('dx', dxForText(rotate)); + pathUpdate.attr("d", "M" + range[0] + "," + outerTickSize + "V0H" + range[1] + "V" + outerTickSize); + break; + } + case "top": + { + // TODO: rotated tick text + tickTransform = axisX; + lineEnter.attr("y2", -innerTickSize); + textEnter.attr("y", -tickLength); + lineUpdate.attr("x2", 0).attr("y2", -innerTickSize); + textUpdate.attr("x", 0).attr("y", -tickLength); + text.style("text-anchor", "middle"); + tspan.attr('x', 0).attr("dy", "0em"); + pathUpdate.attr("d", "M" + range[0] + "," + -outerTickSize + "V0H" + range[1] + "V" + -outerTickSize); + break; + } + case "left": + { + tickTransform = axisY; + lineEnter.attr("x2", -innerTickSize); + textEnter.attr("x", -tickLength); + lineUpdate.attr("x2", -innerTickSize).attr("y1", tickY).attr("y2", tickY); + textUpdate.attr("x", -tickLength).attr("y", tickOffset); + text.style("text-anchor", "end"); + tspan.attr('x', -tickLength).attr("dy", tspanDy); + pathUpdate.attr("d", "M" + -outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + -outerTickSize); + break; + } + case "right": + { + tickTransform = axisY; + lineEnter.attr("x2", innerTickSize); + textEnter.attr("x", tickLength); + lineUpdate.attr("x2", innerTickSize).attr("y2", 0); + textUpdate.attr("x", tickLength).attr("y", 0); + text.style("text-anchor", "start"); + tspan.attr('x', tickLength).attr("dy", tspanDy); + pathUpdate.attr("d", "M" + outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + 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); + } + tickEnter.call(tickTransform, scale0); + tickUpdate.call(tickTransform, scale1); + }); + } + axis.scale = function (x) { + if (!arguments.length) { return scale; } + scale = x; + return axis; + }; + axis.orient = function (x) { + if (!arguments.length) { return orient; } + orient = x in {top: 1, right: 1, bottom: 1, left: 1} ? x + "" : "bottom"; + return axis; + }; + axis.tickFormat = function (format) { + if (!arguments.length) { return tickFormat; } + tickFormat = format; + return axis; + }; + axis.tickCentered = function (isCentered) { + if (!arguments.length) { return tickCentered; } + tickCentered = isCentered; + return axis; + }; + axis.tickOffset = function () { + return tickOffset; + }; + axis.tickInterval = function () { + var interval, length; + if (params.isCategory) { + interval = tickOffset * 2; + } + else { + length = axis.g.select('path.domain').node().getTotalLength() - outerTickSize * 2; + interval = length / axis.g.selectAll('line').size(); + } + return interval === Infinity ? 0 : interval; + }; + axis.ticks = function () { + if (!arguments.length) { return tickArguments; } + tickArguments = arguments; + return axis; + }; + axis.tickCulling = function (culling) { + if (!arguments.length) { return tickCulling; } + tickCulling = culling; + return axis; + }; + axis.tickValues = function (x) { + if (typeof x === 'function') { + tickValues = function () { + return x(scale.domain()); + }; + } + else { + if (!arguments.length) { return tickValues; } + tickValues = x; + } + return axis; + }; + return axis; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/cache.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/cache.js new file mode 100644 index 0000000..6566616 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/cache.js @@ -0,0 +1,16 @@ +c3_chart_internal_fn.hasCaches = function (ids) { + for (var i = 0; i < ids.length; i++) { + if (! (ids[i] in this.cache)) { return false; } + } + return true; +}; +c3_chart_internal_fn.addCache = function (id, target) { + this.cache[id] = this.cloneTarget(target); +}; +c3_chart_internal_fn.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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/category.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/category.js new file mode 100644 index 0000000..5143c6c --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/category.js @@ -0,0 +1,4 @@ +c3_chart_internal_fn.categoryName = function (i) { + var config = this.config; + return i < config.axis_x_categories.length ? config.axis_x_categories[i] : i; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/class.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/class.js new file mode 100644 index 0000000..335f17c --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/class.js @@ -0,0 +1,174 @@ +var CLASS = c3_chart_internal_fn.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', + focused: 'c3-focused', + defocused: 'c3-defocused', + region: 'c3-region', + regions: 'c3-regions', + 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', + 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', + 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_' +}; +c3_chart_internal_fn.generateClass = function (prefix, targetId) { + return " " + prefix + " " + prefix + this.getTargetSelectorSuffix(targetId); +}; +c3_chart_internal_fn.classText = function (d) { + return this.generateClass(CLASS.text, d.index); +}; +c3_chart_internal_fn.classTexts = function (d) { + return this.generateClass(CLASS.texts, d.id); +}; +c3_chart_internal_fn.classShape = function (d) { + return this.generateClass(CLASS.shape, d.index); +}; +c3_chart_internal_fn.classShapes = function (d) { + return this.generateClass(CLASS.shapes, d.id); +}; +c3_chart_internal_fn.classLine = function (d) { + return this.classShape(d) + this.generateClass(CLASS.line, d.id); +}; +c3_chart_internal_fn.classLines = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.lines, d.id); +}; +c3_chart_internal_fn.classCircle = function (d) { + return this.classShape(d) + this.generateClass(CLASS.circle, d.index); +}; +c3_chart_internal_fn.classCircles = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.circles, d.id); +}; +c3_chart_internal_fn.classBar = function (d) { + return this.classShape(d) + this.generateClass(CLASS.bar, d.index); +}; +c3_chart_internal_fn.classBars = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.bars, d.id); +}; +c3_chart_internal_fn.classArc = function (d) { + return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id); +}; +c3_chart_internal_fn.classArcs = function (d) { + return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id); +}; +c3_chart_internal_fn.classArea = function (d) { + return this.classShape(d) + this.generateClass(CLASS.area, d.id); +}; +c3_chart_internal_fn.classAreas = function (d) { + return this.classShapes(d) + this.generateClass(CLASS.areas, d.id); +}; +c3_chart_internal_fn.classRegion = function (d, i) { + return this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d['class'] : ''); +}; +c3_chart_internal_fn.classEvent = function (d) { + return this.generateClass(CLASS.eventRect, d.index); +}; +c3_chart_internal_fn.classTarget = function (id) { + var $$ = this; + var additionalClassSuffix = $$.config.data_classes[id], additionalClass = ''; + if (additionalClassSuffix) { + additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix; + } + return $$.generateClass(CLASS.target, id) + additionalClass; +}; +c3_chart_internal_fn.classFocus = function (d) { + return this.classFocused(d) + this.classDefocused(d); +}; +c3_chart_internal_fn.classFocused = function (d) { + return ' ' + (this.focusedTargetIds.indexOf(d.id) >= 0 ? CLASS.focused : ''); +}; +c3_chart_internal_fn.classDefocused = function (d) { + return ' ' + (this.defocusedTargetIds.indexOf(d.id) >= 0 ? CLASS.defocused : ''); +}; +c3_chart_internal_fn.classChartText = function (d) { + return CLASS.chartText + this.classTarget(d.id); +}; +c3_chart_internal_fn.classChartLine = function (d) { + return CLASS.chartLine + this.classTarget(d.id); +}; +c3_chart_internal_fn.classChartBar = function (d) { + return CLASS.chartBar + this.classTarget(d.id); +}; +c3_chart_internal_fn.classChartArc = function (d) { + return CLASS.chartArc + this.classTarget(d.data.id); +}; +c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) { + return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g, '-') : ''; +}; +c3_chart_internal_fn.selectorTarget = function (id, prefix) { + return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id); +}; +c3_chart_internal_fn.selectorTargets = function (ids, prefix) { + var $$ = this; + ids = ids || []; + return ids.length ? ids.map(function (id) { return $$.selectorTarget(id, prefix); }) : null; +}; +c3_chart_internal_fn.selectorLegend = function (id) { + return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id); +}; +c3_chart_internal_fn.selectorLegends = function (ids) { + var $$ = this; + return ids && ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/clip.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/clip.js new file mode 100644 index 0000000..322dbb5 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/clip.js @@ -0,0 +1,58 @@ +c3_chart_internal_fn.getClipPath = function (id) { + var isIE9 = window.navigator.appVersion.toLowerCase().indexOf("msie 9.") >= 0; + return "url(" + (isIE9 ? "" : document.URL.split('#')[0]) + "#" + id + ")"; +}; +c3_chart_internal_fn.appendClip = function (parent, id) { + return parent.append("clipPath").attr("id", id).append("rect"); +}; +c3_chart_internal_fn.getAxisClipX = function (forHorizontal) { + // axis line width + padding for left + var left = Math.max(30, this.margin.left); + return forHorizontal ? -(1 + left) : -(left - 1); +}; +c3_chart_internal_fn.getAxisClipY = function (forHorizontal) { + return forHorizontal ? -20 : -this.margin.top; +}; +c3_chart_internal_fn.getXAxisClipX = function () { + var $$ = this; + return $$.getAxisClipX(!$$.config.axis_rotated); +}; +c3_chart_internal_fn.getXAxisClipY = function () { + var $$ = this; + return $$.getAxisClipY(!$$.config.axis_rotated); +}; +c3_chart_internal_fn.getYAxisClipX = function () { + var $$ = this; + return $$.config.axis_y_inner ? -1 : $$.getAxisClipX($$.config.axis_rotated); +}; +c3_chart_internal_fn.getYAxisClipY = function () { + var $$ = this; + return $$.getAxisClipY($$.config.axis_rotated); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.getXAxisClipWidth = function () { + var $$ = this; + return $$.getAxisClipWidth(!$$.config.axis_rotated); +}; +c3_chart_internal_fn.getXAxisClipHeight = function () { + var $$ = this; + return $$.getAxisClipHeight(!$$.config.axis_rotated); +}; +c3_chart_internal_fn.getYAxisClipWidth = function () { + var $$ = this; + return $$.getAxisClipWidth($$.config.axis_rotated) + ($$.config.axis_y_inner ? 20 : 0); +}; +c3_chart_internal_fn.getYAxisClipHeight = function () { + var $$ = this; + return $$.getAxisClipHeight($$.config.axis_rotated); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/color.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/color.js new file mode 100644 index 0000000..da1888e --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/color.js @@ -0,0 +1,46 @@ +c3_chart_internal_fn.generateColor = function () { + var $$ = this, config = $$.config, d3 = $$.d3, + colors = config.data_colors, + pattern = notEmpty(config.color_pattern) ? config.color_pattern : d3.scale.category10().range(), + 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; + }; +}; +c3_chart_internal_fn.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(config.color_threshold) ? 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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/config.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/config.js new file mode 100644 index 0000000..737ce1b --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/config.js @@ -0,0 +1,230 @@ +c3_chart_internal_fn.getDefaultConfig = function () { + var config = { + bindto: '#chart', + size_width: undefined, + size_height: undefined, + padding_left: undefined, + padding_right: undefined, + padding_top: undefined, + padding_bottom: undefined, + zoom_enabled: false, + zoom_extent: undefined, + zoom_privileged: false, + zoom_rescale: false, + zoom_onzoom: function () {}, + zoom_onzoomstart: function () {}, + zoom_onzoomend: function () {}, + interaction_enabled: true, + onmouseover: function () {}, + onmouseout: function () {}, + onresize: function () {}, + onresized: function () {}, + oninit: function () {}, + onrendered: function () {}, + transition_duration: 350, + 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_onclick: function () {}, + data_onmouseover: function () {}, + data_onmouseout: function () {}, + data_onselected: function () {}, + data_onunselected: function () {}, + data_url: 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_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, + // 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_width: null, + axis_x_max: undefined, + axis_x_min: undefined, + axis_x_padding: {}, + axis_x_height: undefined, + axis_x_extent: undefined, + axis_x_label: {}, + axis_y_show: true, + axis_y_type: undefined, + 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_count: undefined, + axis_y_tick_time_value: undefined, + axis_y_tick_time_interval: undefined, + axis_y_padding: {}, + axis_y_default: undefined, + axis_y2_show: false, + 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_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, + // area + area_zerobased: true, + // pie + pie_label_show: true, + pie_label_format: undefined, + pie_label_threshold: 0.05, + pie_expand: true, + // gauge + gauge_label_show: true, + gauge_label_format: undefined, + gauge_expand: true, + gauge_min: 0, + gauge_max: 100, + gauge_units: undefined, + gauge_width: undefined, + // donut + donut_label_show: true, + donut_label_format: undefined, + donut_label_threshold: 0.05, + donut_width: undefined, + donut_expand: true, + donut_title: "", + // region - region to change style + regions: [], + // tooltip - show when mouseover on each data + tooltip_show: true, + tooltip_grouped: true, + tooltip_format_title: undefined, + tooltip_format_name: undefined, + tooltip_format_value: 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'} + }; + + Object.keys(this.additionalConfig).forEach(function (key) { + config[key] = this.additionalConfig[key]; + }, this); + + return config; +}; +c3_chart_internal_fn.additionalConfig = {}; + +c3_chart_internal_fn.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; + } + }); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/core.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/core.js new file mode 100644 index 0000000..5b19c7c --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/core.js @@ -0,0 +1,1008 @@ +var c3 = { version: "0.4.10" }; + +var c3_chart_fn, + c3_chart_internal_fn, + c3_chart_internal_axis_fn; + +function API(owner) { + this.owner = owner; +} + +function inherit(base, derived) { + + if (Object.create) { + derived.prototype = Object.create(base.prototype); + } else { + var f = function f() {}; + f.prototype = base.prototype; + derived.prototype = new f(); + } + + derived.prototype.constructor = derived; + + return derived; +} + +function Chart(config) { + var $$ = this.internal = new ChartInternal(this); + $$.loadConfig(config); + $$.init(); + + // 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); + } + }); + })(c3_chart_fn, this, this); +} + +function ChartInternal(api) { + var $$ = this; + $$.d3 = window.d3 ? window.d3 : typeof require !== 'undefined' ? require("d3") : undefined; + $$.api = api; + $$.config = $$.getDefaultConfig(); + $$.data = {}; + $$.cache = {}; + $$.axes = {}; +} + +c3.generate = function (config) { + return new Chart(config); +}; + +c3.chart = { + fn: Chart.prototype, + internal: { + fn: ChartInternal.prototype, + axis: { + fn: Axis.prototype + } + } +}; +c3_chart_fn = c3.chart.fn; +c3_chart_internal_fn = c3.chart.internal.fn; +c3_chart_internal_axis_fn = c3.chart.internal.axis.fn; + +c3_chart_internal_fn.init = function () { + var $$ = this, config = $$.config; + + $$.initParams(); + + if (config.data_url) { + $$.convertUrlToData(config.data_url, config.data_mimeType, 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.'); + } +}; + +c3_chart_internal_fn.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()) + '-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 = false; + $$.transiting = false; + + $$.color = $$.generateColor(); + $$.levelColor = $$.generateLevelColor(); + + $$.dataTimeFormat = config.data_xLocaltime ? d3.time.format : d3.time.format.utc; + $$.axisTimeFormat = config.axis_x_localtime ? d3.time.format : d3.time.format.utc; + $$.defaultAxisTimeFormat = $$.axisTimeFormat.multi([ + [".%L", function (d) { return d.getMilliseconds(); }], + [":%S", function (d) { return d.getSeconds(); }], + ["%I:%M", function (d) { return d.getMinutes(); }], + ["%I %p", function (d) { return d.getHours(); }], + ["%-m/%-d", function (d) { return d.getDay() && d.getDate() !== 1; }], + ["%-m/%-d", function (d) { return d.getDate() !== 1; }], + ["%-m/%-d", function (d) { return d.getMonth(); }], + ["%Y/%-m/%-d", function () { return true; }] + ]); + + $$.hiddenTargetIds = []; + $$.hiddenLegendIds = []; + $$.focusedTargetIds = []; + $$.defocusedTargetIds = []; + + $$.xOrient = config.axis_rotated ? "left" : "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 +}; + +c3_chart_internal_fn.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(); } +}; + +c3_chart_internal_fn.initWithData = function (data) { + var $$ = this, d3 = $$.d3, config = $$.config; + var defs, main, binding = true; + + $$.axis = new Axis($$); + + if ($$.initPie) { $$.initPie(); } + if ($$.initBrush) { $$.initBrush(); } + if ($$.initZoom) { $$.initZoom(); } + + 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); + } + + // when gauge, hide legend // TODO: fix + if ($$.hasType('gauge')) { + config.legend_show = false; + } + + // 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(); + + // Set initialized scales to brush and zoom + if ($$.brush) { $$.brush.scale($$.subX); } + if (config.zoom_enabled) { $$.zoom.scale($$.x); } + + /*-- 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($$); }); + + // 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 ($$.initSubchart) { $$.initSubchart(); } + if ($$.initTooltip) { $$.initTooltip(); } + if ($$.initLegend) { $$.initLegend(); } + + /*-- 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(); } + + // Cover whole with rects for events + $$.initEventRect(); + + // Define g for chart + $$.initChartElements(); + + // if zoom privileged, insert rect to forefront + // TODO: is this needed? + main.insert('rect', config.zoom_privileged ? null : 'g.' + CLASS.regions) + .attr('class', CLASS.zoomRect) + .attr('width', $$.width) + .attr('height', $$.height) + .style('opacity', 0) + .on("dblclick.zoom", null); + + // Set default extent if defined + if (config.axis_x_extent) { $$.brush.extent($$.getDefaultExtent()); } + + // Add Axis + $$.axis.init(); + + // Set targets + $$.updateTargets($$.data.targets); + + // Draw with targets + if (binding) { + $$.updateDimension(); + $$.config.oninit.call($$); + $$.redraw({ + withTransition: false, + withTransform: true, + withUpdateXDomain: true, + withUpdateOrgXDomain: true, + withTransitionForAxis: false + }); + } + + // Bind resize event + if (window.onresize == null) { + window.onresize = $$.generateResize(); + } + if (window.onresize.add) { + window.onresize.add(function () { + config.onresize.call($$); + }); + window.onresize.add(function () { + $$.api.flush(); + }); + window.onresize.add(function () { + config.onresized.call($$); + }); + } + + // export element of the chart + $$.api.element = $$.selectChart.node(); +}; + +c3_chart_internal_fn.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) + }); + }); + } +}; + + +c3_chart_internal_fn.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')) { + $$.arcHeight += $$.height - $$.getGaugeLabelHeight(); + } + if ($$.updateRadius) { $$.updateRadius(); } + + if ($$.isLegendRight && hasArc) { + $$.margin3.left = $$.arcWidth / 2 + $$.radiusExpanded * 1.1; + } +}; + +c3_chart_internal_fn.updateTargets = function (targets) { + var $$ = this; + + /*-- Main --*/ + + //-- Text --// + $$.updateTargetsForText(targets); + + //-- Bar --// + $$.updateTargetsForBar(targets); + + //-- Line --// + $$.updateTargetsForLine(targets); + + //-- Arc --// + if ($$.hasArcType() && $$.updateTargetsForArc) { $$.updateTargetsForArc(targets); } + + /*-- Sub --*/ + + if ($$.updateTargetsForSubchart) { $$.updateTargetsForSubchart(targets); } + + // Fade-in each chart + $$.showTargets(); +}; +c3_chart_internal_fn.showTargets = function () { + var $$ = this; + $$.svg.selectAll('.' + CLASS.target).filter(function (d) { return $$.isTargetToShow(d.id); }) + .transition().duration($$.config.transition_duration) + .style("opacity", 1); +}; + +c3_chart_internal_fn.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 waitForDraw, flow; + 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(transitions, 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 sub domain + if (withY) { + $$.subY.domain($$.getYDomain(targetsToShow, 'y')); + $$.subY2.domain($$.getYDomain(targetsToShow, 'y2')); + } + + // tooltip + $$.tooltip.style("display", "none"); + + // 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); + + // grid + $$.updateGrid(duration); + + // rect for regions + $$.updateRegion(duration); + + // bars + $$.updateBar(durationForExit); + + // lines, areas and cricles + $$.updateLine(durationForExit); + $$.updateArea(durationForExit); + $$.updateCircle(); + + // text + if ($$.hasDataLabel()) { + $$.updateText(durationForExit); + } + + // arc + if ($$.redrawArc) { $$.redrawArc(duration, durationForExit, withTransform); } + + // subchart + if ($$.redrawSubchart) { + $$.redrawSubchart(withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices); + } + + // circles for select + main.selectAll('.' + CLASS.selectedCircles) + .filter($$.isBarType.bind($$)) + .selectAll('circle') + .remove(); + + // event rects will redrawn when flow called + if (config.interaction_enabled && !options.flow && withEventRect) { + $$.redrawEventRect(); + if ($$.updateZoom) { $$.updateZoom(); } + } + + // 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($$); + + 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 || flow) && $$.isTabVisible()) { // Only use transition if tab visible. See #938. + // transition should be derived from one transition + d3.transition().duration(duration).each(function () { + var transitionsToWait = []; + + // redraw and gather transitions + [ + $$.redrawBar(drawBar, true), + $$.redrawLine(drawLine, true), + $$.redrawArea(drawArea, true), + $$.redrawCircle(cx, cy, true), + $$.redrawText(xForText, yForText, options.flow, true), + $$.redrawRegion(true), + $$.redrawGrid(true), + ].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); + }); + }) + .call(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 (config.onrendered) { + config.onrendered.call($$); + } + } + + // update fadein condition + $$.mapToIds($$.data.targets).forEach(function (id) { + $$.withoutFadeIn[id] = true; + }); +}; + +c3_chart_internal_fn.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 = true; + 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); +}; +c3_chart_internal_fn.redrawWithoutRescale = function () { + this.redraw({ + withY: false, + withSubchart: false, + withEventRect: false, + withTransitionForAxis: false + }); +}; + +c3_chart_internal_fn.isTimeSeries = function () { + return this.config.axis_x_type === 'timeseries'; +}; +c3_chart_internal_fn.isCategorized = function () { + return this.config.axis_x_type.indexOf('categor') >= 0; +}; +c3_chart_internal_fn.isCustomX = function () { + var $$ = this, config = $$.config; + return !$$.isTimeSeries() && (config.data_x || notEmpty(config.data_xs)); +}; + +c3_chart_internal_fn.isTimeSeriesY = function () { + return this.config.axis_y_type === 'timeseries'; +}; + +c3_chart_internal_fn.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; + } + return "translate(" + x + "," + y + ")"; +}; +c3_chart_internal_fn.initialOpacity = function (d) { + return d.value !== null && this.withoutFadeIn[d.id] ? 1 : 0; +}; +c3_chart_internal_fn.initialOpacityForCircle = function (d) { + return d.value !== null && this.withoutFadeIn[d.id] ? this.opacityForCircle(d) : 0; +}; +c3_chart_internal_fn.opacityForCircle = function (d) { + var opacity = this.config.point_show ? 1 : 0; + return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0; +}; +c3_chart_internal_fn.opacityForText = function () { + return this.hasDataLabel() ? 1 : 0; +}; +c3_chart_internal_fn.xx = function (d) { + return d ? this.x(d.x) : null; +}; +c3_chart_internal_fn.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)); +}; +c3_chart_internal_fn.yv = function (d) { + var $$ = this, + yScale = d.axis && d.axis === 'y2' ? $$.y2 : $$.y; + return Math.ceil(yScale(d.value)); +}; +c3_chart_internal_fn.subxx = function (d) { + return d ? this.subX(d.x) : null; +}; + +c3_chart_internal_fn.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')); +}; +c3_chart_internal_fn.transformAll = function (withTransition, transitions) { + var $$ = this; + $$.transformMain(withTransition, transitions); + if ($$.config.subchart_show) { $$.transformContext(withTransition, transitions); } + if ($$.legend) { $$.transformLegend(withTransition); } +}; + +c3_chart_internal_fn.updateSvgSize = function () { + var $$ = this, + brush = $$.svg.select(".c3-brush .background"); + $$.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); + $$.svg.select('.' + CLASS.zoomRect) + .attr('width', $$.width) + .attr('height', $$.height); + // MEMO: parent div's height will be bigger than svg when <!DOCTYPE html> + $$.selectChart.style('max-height', $$.currentHeight + "px"); +}; + + +c3_chart_internal_fn.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); +}; + +c3_chart_internal_fn.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(); + $$.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}); +}; + + +c3_chart_internal_fn.generateResize = function () { + var resizeFunctions = []; + function callResizeFunctions() { + resizeFunctions.forEach(function (f) { + f(); + }); + } + callResizeFunctions.add = function (f) { + resizeFunctions.push(f); + }; + return callResizeFunctions; +}; + +c3_chart_internal_fn.endall = function (transition, callback) { + var n = 0; + transition + .each(function () { ++n; }) + .each("end", function () { + if (!--n) { callback.apply(this, arguments); } + }); +}; +c3_chart_internal_fn.generateWait = function () { + var transitionsToWait = [], + f = function (transition, callback) { + var timer = setInterval(function () { + 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(); } + } + }, 10); + }; + f.add = function (transition) { + transitionsToWait.push(transition); + }; + return f; +}; + +c3_chart_internal_fn.parseDate = function (date) { + var $$ = this, parsedDate; + if (date instanceof Date) { + parsedDate = date; + } else if (typeof date === 'string') { + parsedDate = $$.dataTimeFormat($$.config.data_xFormat).parse(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; +}; + +c3_chart_internal_fn.isTabVisible = function () { + var hidden; + if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support + hidden = "hidden"; + } else if (typeof document.mozHidden !== "undefined") { + hidden = "mozHidden"; + } else if (typeof document.msHidden !== "undefined") { + hidden = "msHidden"; + } else if (typeof document.webkitHidden !== "undefined") { + hidden = "webkitHidden"; + } + + return document[hidden] ? false : true; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/data.convert.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/data.convert.js new file mode 100644 index 0000000..4384e7a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/data.convert.js @@ -0,0 +1,191 @@ +c3_chart_internal_fn.convertUrlToData = function (url, mimeType, keys, done) { + var $$ = this, type = mimeType ? mimeType : 'csv'; + $$.d3.xhr(url, function (error, data) { + var d; + if (!data) { + throw new Error(error.responseURL + ' ' + error.status + ' (' + error.statusText + ')'); + } + if (type === 'json') { + d = $$.convertJsonToData(JSON.parse(data.response), keys); + } else if (type === 'tsv') { + d = $$.convertTsvToData(data.response); + } else { + d = $$.convertCsvToData(data.response); + } + done.call($$, d); + }); +}; +c3_chart_internal_fn.convertXsvToData = function (xsv, parser) { + var rows = parser.parseRows(xsv), d; + if (rows.length === 1) { + d = [{}]; + rows[0].forEach(function (id) { + d[0][id] = null; + }); + } else { + d = parser.parse(xsv); + } + return d; +}; +c3_chart_internal_fn.convertCsvToData = function (csv) { + return this.convertXsvToData(csv, this.d3.csv); +}; +c3_chart_internal_fn.convertTsvToData = function (tsv) { + return this.convertXsvToData(tsv, this.d3.tsv); +}; +c3_chart_internal_fn.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 = isUndefined(o[key]) ? null : o[key]; + 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; +}; +c3_chart_internal_fn.convertRowsToData = function (rows) { + var keys = rows[0], new_row = {}, new_rows = [], i, j; + for (i = 1; i < rows.length; i++) { + new_row = {}; + for (j = 0; j < rows[i].length; j++) { + if (isUndefined(rows[i][j])) { + throw new Error("Source data is missing a component at (" + i + "," + j + ")!"); + } + new_row[keys[j]] = rows[i][j]; + } + new_rows.push(new_row); + } + return new_rows; +}; +c3_chart_internal_fn.convertColumnsToData = function (columns) { + var new_rows = [], i, j, key; + for (i = 0; i < columns.length; i++) { + key = columns[i][0]; + for (j = 1; j < columns[i].length; j++) { + if (isUndefined(new_rows[j - 1])) { + new_rows[j - 1] = {}; + } + if (isUndefined(columns[i][j])) { + throw new Error("Source data is missing a component at (" + i + "," + j + ")!"); + } + new_rows[j - 1][key] = columns[i][j]; + } + } + return new_rows; +}; +c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) { + var $$ = this, config = $$.config, + ids = $$.d3.keys(data[0]).filter($$.isNotX, $$), + xs = $$.d3.keys(data[0]).filter($$.isX, $$), + targets; + + // 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], x = $$.generateTargetX(rawX, id, i); + // use x as categories if custom x and categorized + if ($$.isCustomX() && $$.isCategorized() && index === 0 && rawX) { + if (i === 0) { config.axis_x_categories = []; } + config.axis_x_categories.push(rawX); + } + // 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; + } + return {x: x, value: d[id] !== null && !isNaN(d[id]) ? +d[id] : null, id: convertedId}; + }).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; + }); + }); + + // 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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/data.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/data.js new file mode 100644 index 0000000..b29bd63 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/data.js @@ -0,0 +1,369 @@ +c3_chart_internal_fn.isX = function (key) { + var $$ = this, config = $$.config; + return (config.data_x && key === config.data_x) || (notEmpty(config.data_xs) && hasValue(config.data_xs, key)); +}; +c3_chart_internal_fn.isNotX = function (key) { + return !this.isX(key); +}; +c3_chart_internal_fn.getXKey = function (id) { + var $$ = this, config = $$.config; + return config.data_x ? config.data_x : notEmpty(config.data_xs) ? config.data_xs[id] : null; +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.getIndexByX = function (x) { + var $$ = this, + data = $$.filterByX($$.data.targets, x); + return data.length ? data[0].index : null; +}; +c3_chart_internal_fn.getXValue = function (id, i) { + var $$ = this; + return id in $$.data.xs && $$.data.xs[id] && isValue($$.data.xs[id][i]) ? $$.data.xs[id][i] : i; +}; +c3_chart_internal_fn.getOtherTargetXs = function () { + var $$ = this, + idsForX = Object.keys($$.data.xs); + return idsForX.length ? $$.data.xs[idsForX[0]] : null; +}; +c3_chart_internal_fn.getOtherTargetX = function (index) { + var xs = this.getOtherTargetXs(); + return xs && index < xs.length ? xs[index] : null; +}; +c3_chart_internal_fn.addXs = function (xs) { + var $$ = this; + Object.keys(xs).forEach(function (id) { + $$.config.data_xs[id] = xs[id]; + }); +}; +c3_chart_internal_fn.hasMultipleX = function (xs) { + return this.d3.set(Object.keys(xs).map(function (id) { return xs[id]; })).size() > 1; +}; +c3_chart_internal_fn.isMultipleX = function () { + return notEmpty(this.config.data_xs) || !this.config.data_xSort || this.hasType('scatter'); +}; +c3_chart_internal_fn.addName = function (data) { + var $$ = this, name; + if (data) { + name = $$.config.data_names[data.id]; + data.name = name ? name : data.id; + } + return data; +}; +c3_chart_internal_fn.getValueOnIndex = function (values, index) { + var valueOnIndex = values.filter(function (v) { return v.index === index; }); + return valueOnIndex.length ? valueOnIndex[0] : null; +}; +c3_chart_internal_fn.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; + }); +}; +c3_chart_internal_fn.updateTargetXs = function (targets, xs) { + var $$ = this; + targets.forEach(function (t) { + if (xs[t.id]) { + $$.updateTargetX([t], xs[t.id]); + } + }); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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}; + }) + }; +}; +c3_chart_internal_fn.updateXs = function () { + var $$ = this; + if ($$.data.targets.length) { + $$.xs = []; + $$.data.targets[0].values.forEach(function (v) { + $$.xs[v.index] = v.x; + }); + } +}; +c3_chart_internal_fn.getPrevX = function (i) { + var x = this.xs[i - 1]; + return typeof x !== 'undefined' ? x : null; +}; +c3_chart_internal_fn.getNextX = function (i) { + var x = this.xs[i + 1]; + return typeof x !== 'undefined' ? x : null; +}; +c3_chart_internal_fn.getMaxDataCount = function () { + var $$ = this; + return $$.d3.max($$.data.targets, function (t) { return t.values.length; }); +}; +c3_chart_internal_fn.getMaxDataCountTarget = function (targets) { + var length = targets.length, max = 0, maxTarget; + if (length > 1) { + targets.forEach(function (t) { + if (t.values.length > max) { + maxTarget = t; + max = t.values.length; + } + }); + } else { + maxTarget = length ? targets[0] : null; + } + return maxTarget; +}; +c3_chart_internal_fn.getEdgeX = function (targets) { + var $$ = this; + return !targets.length ? [0, 0] : [ + $$.d3.min(targets, function (t) { return t.values[0].x; }), + $$.d3.max(targets, function (t) { return t.values[t.values.length - 1].x; }) + ]; +}; +c3_chart_internal_fn.mapToIds = function (targets) { + return targets.map(function (d) { return d.id; }); +}; +c3_chart_internal_fn.mapToTargetIds = function (ids) { + var $$ = this; + return ids ? (isString(ids) ? [ids] : ids) : $$.mapToIds($$.data.targets); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.isTargetToShow = function (targetId) { + return this.hiddenTargetIds.indexOf(targetId) < 0; +}; +c3_chart_internal_fn.isLegendToShow = function (targetId) { + return this.hiddenLegendIds.indexOf(targetId) < 0; +}; +c3_chart_internal_fn.filterTargetsToShow = function (targets) { + var $$ = this; + return targets.filter(function (t) { return $$.isTargetToShow(t.id); }); +}; +c3_chart_internal_fn.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(); + return $$.isTimeSeries() ? xs.map(function (x) { return new Date(+x); }) : xs.map(function (x) { return +x; }); +}; +c3_chart_internal_fn.addHiddenTargetIds = function (targetIds) { + this.hiddenTargetIds = this.hiddenTargetIds.concat(targetIds); +}; +c3_chart_internal_fn.removeHiddenTargetIds = function (targetIds) { + this.hiddenTargetIds = this.hiddenTargetIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); +}; +c3_chart_internal_fn.addHiddenLegendIds = function (targetIds) { + this.hiddenLegendIds = this.hiddenLegendIds.concat(targetIds); +}; +c3_chart_internal_fn.removeHiddenLegendIds = function (targetIds) { + this.hiddenLegendIds = this.hiddenLegendIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.hasNegativeValueInTargets = function (targets) { + return this.checkValueInTargets(targets, function (v) { return v < 0; }); +}; +c3_chart_internal_fn.hasPositiveValueInTargets = function (targets) { + return this.checkValueInTargets(targets, function (v) { return v > 0; }); +}; +c3_chart_internal_fn.isOrderDesc = function () { + var config = this.config; + return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'desc'; +}; +c3_chart_internal_fn.isOrderAsc = function () { + var config = this.config; + return typeof(config.data_order) === 'string' && config.data_order.toLowerCase() === 'asc'; +}; +c3_chart_internal_fn.orderTargets = function (targets) { + var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc(); + if (orderAsc || orderDesc) { + targets.sort(function (t1, t2) { + var reducer = function (p, c) { return p + Math.abs(c.value); }; + 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)) { + targets.sort(config.data_order); + } // TODO: accept name array for order + return targets; +}; +c3_chart_internal_fn.filterByX = function (targets, x) { + return this.d3.merge(targets.map(function (t) { return t.values; })).filter(function (v) { return v.x - x === 0; }); +}; +c3_chart_internal_fn.filterRemoveNull = function (data) { + return data.filter(function (d) { return isValue(d.value); }); +}; +c3_chart_internal_fn.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]; + }) + }; + }); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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] = this.getBoundingClientRect()[key] * paddingCoef; + }) + .remove(); + return lengths; +}; +c3_chart_internal_fn.isNoneArc = function (d) { + return this.hasTarget(this.data.targets, d.id); +}, +c3_chart_internal_fn.isArc = function (d) { + return 'data' in d && this.hasTarget(this.data.targets, d.data.id); +}; +c3_chart_internal_fn.findSameXOfValues = function (values, index) { + var i, targetX = values[index].x, sames = []; + for (i = index - 1; i >= 0; i--) { + if (targetX !== values[i].x) { break; } + sames.push(values[i]); + } + for (i = index; i < values.length; i++) { + if (targetX !== values[i].x) { break; } + sames.push(values[i]); + } + return sames; +}; + +c3_chart_internal_fn.findClosestFromTargets = function (targets, pos) { + var $$ = this, candidates; + + // map to array of closest points of each target + candidates = targets.map(function (target) { + return $$.findClosest(target.values, pos); + }); + + // decide closest point and return + return $$.findClosest(candidates, pos); +}; +c3_chart_internal_fn.findClosest = function (values, pos) { + var $$ = this, minDist = 100, closest; + + // find mouseovering bar + values.filter(function (v) { return v && $$.isBarType(v.id); }).forEach(function (v) { + var shape = $$.main.select('.' + CLASS.bars + $$.getTargetSelectorSuffix(v.id) + ' .' + CLASS.bar + '-' + v.index).node(); + if (!closest && $$.isWithinBar(shape)) { + closest = v; + } + }); + + // find closest point from non-bar + values.filter(function (v) { return v && !$$.isBarType(v.id); }).forEach(function (v) { + var d = $$.dist(v, pos); + if (d < minDist) { + minDist = d; + closest = v; + } + }); + + return closest; +}; +c3_chart_internal_fn.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.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/data.load.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/data.load.js new file mode 100644 index 0000000..49eee28 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/data.load.js @@ -0,0 +1,88 @@ +c3_chart_internal_fn.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(); } +}; +c3_chart_internal_fn.loadFromArgs = function (args) { + var $$ = this; + if (args.data) { + $$.load($$.convertDataToTargets(args.data), args); + } + else if (args.url) { + $$.convertUrlToData(args.url, args.mimeType, 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); + } +}; +c3_chart_internal_fn.unload = function (targetIds, done) { + var $$ = this; + 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; + }); + }); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/domain.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/domain.js new file mode 100644 index 0000000..5f03c5f --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/domain.js @@ -0,0 +1,234 @@ +c3_chart_internal_fn.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]); })); +}; +c3_chart_internal_fn.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]); })); +}; +c3_chart_internal_fn.getYDomain = function (targets, axisId, xDomain) { + var $$ = this, config = $$.config, + 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, 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 = 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'); + padding_top += $$.axis.convertPixelsToAxisPadding(lengths[1], domainLength); + padding_bottom += $$.axis.convertPixelsToAxisPadding(lengths[0], domainLength); + } + 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; +}; +c3_chart_internal_fn.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; }); }); +}; +c3_chart_internal_fn.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; }); }); +}; +c3_chart_internal_fn.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}; +}; +c3_chart_internal_fn.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]; +}; +c3_chart_internal_fn.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.scale($$.x).updateScaleExtent(); } + $$.subX.domain($$.x.domain()); + if ($$.brush) { $$.brush.scale($$.subX); } + } + if (withUpdateXDomain) { + $$.x.domain(domain ? domain : (!$$.brush || $$.brush.empty()) ? $$.orgXDomain : $$.brush.extent()); + if (config.zoom_enabled) { $$.zoom.scale($$.x).updateScaleExtent(); } + } + + // Trim domain when too big by zoom mousemove event + if (withTrim) { $$.x.domain($$.trimXDomain($$.x.orgDomain())); } + + return $$.x.domain(); +}; +c3_chart_internal_fn.trimXDomain = function (domain) { + var $$ = this; + if (domain[0] <= $$.orgXDomain[0]) { + domain[1] = +domain[1] + ($$.orgXDomain[0] - domain[0]); + domain[0] = $$.orgXDomain[0]; + } + if ($$.orgXDomain[1] <= domain[1]) { + domain[0] = +domain[0] - (domain[1] - $$.orgXDomain[1]); + domain[1] = $$.orgXDomain[1]; + } + return domain; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/drag.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/drag.js new file mode 100644 index 0000000..56ab070 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/drag.js @@ -0,0 +1,81 @@ +c3_chart_internal_fn.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.zoom_enabled && ! $$.zoom.altDomain) { return; } // skip if zoomable because of conflict drag dehavior + 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) + .filter(function (d) { return config.data_selection_isselectable(d); }) + .each(function (d, i) { + 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); + } + }); +}; + +c3_chart_internal_fn.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; +}; + +c3_chart_internal_fn.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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/format.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/format.js new file mode 100644 index 0000000..aa72780 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/format.js @@ -0,0 +1,42 @@ +c3_chart_internal_fn.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); + }; +}; +c3_chart_internal_fn.yFormat = function (v) { + var $$ = this, config = $$.config, + format = config.axis_y_tick_format ? config.axis_y_tick_format : $$.defaultValueFormat; + return format(v); +}; +c3_chart_internal_fn.y2Format = function (v) { + var $$ = this, config = $$.config, + format = config.axis_y2_tick_format ? config.axis_y2_tick_format : $$.defaultValueFormat; + return format(v); +}; +c3_chart_internal_fn.defaultValueFormat = function (v) { + return isValue(v) ? +v : ""; +}; +c3_chart_internal_fn.defaultArcValueFormat = function (v, ratio) { + return (ratio * 100).toFixed(1) + '%'; +}; +c3_chart_internal_fn.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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/grid.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/grid.js new file mode 100644 index 0000000..9a06432 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/grid.js @@ -0,0 +1,240 @@ +c3_chart_internal_fn.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(); } +}; +c3_chart_internal_fn.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([]); +}; +c3_chart_internal_fn.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 + }; + + $$.xgrid = $$.main.select('.' + CLASS.xgrids).selectAll('.' + CLASS.xgrid) + .data(xgridData); + $$.xgrid.enter().append('line').attr("class", CLASS.xgrid); + if (!withoutUpdate) { + $$.xgrid.attr($$.xgridAttr) + .style("opacity", function () { return +d3.select(this).attr(config.axis_rotated ? 'y1' : 'x1') === (config.axis_rotated ? $$.height : 0) ? 0 : 1; }); + } + $$.xgrid.exit().remove(); +}; + +c3_chart_internal_fn.updateYGrid = function () { + var $$ = this, config = $$.config, + gridValues = $$.yAxis.tickValues() || $$.y.ticks(config.grid_y_ticks); + $$.ygrid = $$.main.select('.' + CLASS.ygrids).selectAll('.' + CLASS.ygrid) + .data(gridValues); + $$.ygrid.enter().append('line') + .attr('class', CLASS.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'); +}; + +c3_chart_internal_fn.gridTextAnchor = function (d) { + return d.position ? d.position : "end"; +}; +c3_chart_internal_fn.gridTextDx = function (d) { + return d.position === 'start' ? 4 : d.position === 'middle' ? 0 : -4; +}; +c3_chart_internal_fn.xGridTextX = function (d) { + return d.position === 'start' ? -this.height : d.position === 'middle' ? -this.height / 2 : 0; +}; +c3_chart_internal_fn.yGridTextX = function (d) { + return d.position === 'start' ? 0 : d.position === 'middle' ? this.width / 2 : this.width; +}; +c3_chart_internal_fn.updateGrid = function (duration) { + var $$ = this, main = $$.main, config = $$.config, + xgridLine, ygridLine, yv; + + // hide if arc type + $$.grid.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + + main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); + if (config.grid_x_show) { + $$.updateXGrid(); + } + $$.xgridLines = main.select('.' + CLASS.xgridLines).selectAll('.' + CLASS.xgridLine) + .data(config.grid_x_lines); + // enter + xgridLine = $$.xgridLines.enter().append('g') + .attr("class", function (d) { return CLASS.xgridLine + (d['class'] ? ' ' + d['class'] : ''); }); + xgridLine.append('line') + .style("opacity", 0); + xgridLine.append('text') + .attr("text-anchor", $$.gridTextAnchor) + .attr("transform", config.axis_rotated ? "" : "rotate(-90)") + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style("opacity", 0); + // udpate + // done in d3.transition() of the end of this function + // exit + $$.xgridLines.exit().transition().duration(duration) + .style("opacity", 0) + .remove(); + + // Y-Grid + if (config.grid_y_show) { + $$.updateYGrid(); + } + $$.ygridLines = main.select('.' + CLASS.ygridLines).selectAll('.' + CLASS.ygridLine) + .data(config.grid_y_lines); + // enter + ygridLine = $$.ygridLines.enter().append('g') + .attr("class", function (d) { return CLASS.ygridLine + (d['class'] ? ' ' + d['class'] : ''); }); + ygridLine.append('line') + .style("opacity", 0); + ygridLine.append('text') + .attr("text-anchor", $$.gridTextAnchor) + .attr("transform", config.axis_rotated ? "rotate(-90)" : "") + .attr('dx', $$.gridTextDx) + .attr('dy', -5) + .style("opacity", 0); + // update + yv = $$.yv.bind($$); + $$.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 + $$.ygridLines.exit().transition().duration(duration) + .style("opacity", 0) + .remove(); +}; +c3_chart_internal_fn.redrawGrid = function (withTransition) { + var $$ = this, config = $$.config, xv = $$.xv.bind($$), + lines = $$.xgridLines.select('line'), + texts = $$.xgridLines.select('text'); + return [ + (withTransition ? lines.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() : texts) + .attr("x", config.axis_rotated ? $$.yGridTextX.bind($$) : $$.xGridTextX.bind($$)) + .attr("y", xv) + .text(function (d) { return d.text; }) + .style("opacity", 1) + ]; +}; +c3_chart_internal_fn.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 scatter plot exists + if ($$.hasType('scatter') || $$.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'); +}; +c3_chart_internal_fn.hideXGridFocus = function () { + this.main.select('line.' + CLASS.xgridFocus).style("visibility", "hidden"); +}; +c3_chart_internal_fn.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); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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; }; +}; +c3_chart_internal_fn.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); + } +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/head.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/head.js new file mode 100644 index 0000000..d77cbd0 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/head.js @@ -0,0 +1,4 @@ +(function (window) { + 'use strict'; + + /*global define, module, exports, require */ diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/interaction.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/interaction.js new file mode 100644 index 0000000..d7d4c41 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/interaction.js @@ -0,0 +1,341 @@ +c3_chart_internal_fn.initEventRect = function () { + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.eventRects) + .style('fill-opacity', 0); +}; +c3_chart_internal_fn.redrawEventRect = function () { + var $$ = this, config = $$.config, + eventRectUpdate, maxDataCountTarget, + isMultipleX = $$.isMultipleX(); + + // rects for mouseover + var eventRects = $$.main.select('.' + CLASS.eventRects) + .style('cursor', config.zoom_enabled ? config.axis_rotated ? 'ns-resize' : 'ew-resize' : null) + .classed(CLASS.eventRectsMultiple, isMultipleX) + .classed(CLASS.eventRectsSingle, !isMultipleX); + + // clear old rects + eventRects.selectAll('.' + CLASS.eventRect).remove(); + + // open as public variable + $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); + + if (isMultipleX) { + eventRectUpdate = $$.eventRect.data([0]); + // enter : only one rect will be added + $$.generateEventRectsForMultipleXs(eventRectUpdate.enter()); + // update + $$.updateEventRect(eventRectUpdate); + // exit : not needed because always only one rect exists + } + else { + // Set data and update $$.eventRect + maxDataCountTarget = $$.getMaxDataCountTarget($$.data.targets); + eventRects.datum(maxDataCountTarget ? maxDataCountTarget.values : []); + $$.eventRect = eventRects.selectAll('.' + CLASS.eventRect); + eventRectUpdate = $$.eventRect.data(function (d) { return d; }); + // enter + $$.generateEventRectsForSingleX(eventRectUpdate.enter()); + // update + $$.updateEventRect(eventRectUpdate); + // exit + eventRectUpdate.exit().remove(); + } +}; +c3_chart_internal_fn.updateEventRect = function (eventRectUpdate) { + var $$ = this, config = $$.config, + x, y, w, h, rectW, rectX; + + // set update selection if null + eventRectUpdate = eventRectUpdate || $$.eventRect.data(function (d) { return d; }); + + if ($$.isMultipleX()) { + // TODO: rotated not supported yet + x = 0; + y = 0; + w = $$.width; + h = $$.height; + } + else { + if (($$.isCustomX() || $$.isTimeSeries()) && !$$.isCategorized()) { + + // update index for x that is used by prevX and nextX + $$.updateXs(); + + rectW = function (d) { + var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index); + + // if there this is a single data point make the eventRect full width (or height) + if (prevX === null && nextX === null) { + return config.axis_rotated ? $$.height : $$.width; + } + + if (prevX === null) { prevX = $$.x.domain()[0]; } + if (nextX === null) { nextX = $$.x.domain()[1]; } + + return Math.max(0, ($$.x(nextX) - $$.x(prevX)) / 2); + }; + rectX = function (d) { + var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index), + thisX = $$.data.xs[d.id][d.index]; + + // if there this is a single data point position the eventRect at 0 + if (prevX === null && nextX === null) { + return 0; + } + + if (prevX === null) { prevX = $$.x.domain()[0]; } + + return ($$.x(thisX) + $$.x(prevX)) / 2; + }; + } else { + rectW = $$.getEventRectWidth(); + rectX = function (d) { + return $$.x(d.x) - (rectW / 2); + }; + } + x = config.axis_rotated ? 0 : rectX; + y = config.axis_rotated ? rectX : 0; + w = config.axis_rotated ? $$.width : rectW; + h = config.axis_rotated ? rectW : $$.height; + } + + eventRectUpdate + .attr('class', $$.classEvent.bind($$)) + .attr("x", x) + .attr("y", y) + .attr("width", w) + .attr("height", h); +}; +c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { + var $$ = this, d3 = $$.d3, config = $$.config; + eventRectEnter.append("rect") + .attr("class", $$.classEvent.bind($$)) + .style("cursor", config.data_selection_enabled && config.data_selection_grouped ? "pointer" : null) + .on('mouseover', function (d) { + var index = d.index; + + if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing + if ($$.hasArcType()) { return; } + + // Expand shapes for selection + if (config.point_focus_expand_enabled) { $$.expandCircles(index, null, true); } + $$.expandBars(index, null, true); + + // Call event handler + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { + config.data_onmouseover.call($$.api, d); + }); + }) + .on('mouseout', function (d) { + var index = d.index; + if (!$$.config) { return; } // chart is destroyed + if ($$.hasArcType()) { return; } + $$.hideXGridFocus(); + $$.hideTooltip(); + // Undo expanded shapes + $$.unexpandCircles(); + $$.unexpandBars(); + // Call event handler + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { + config.data_onmouseout.call($$.api, d); + }); + }) + .on('mousemove', function (d) { + var selectedData, index = d.index, + eventRect = $$.svg.select('.' + CLASS.eventRect + '-' + index); + + if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing + if ($$.hasArcType()) { return; } + + if ($$.isStepType(d) && $$.config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { + index -= 1; + } + + // Show tooltip + selectedData = $$.filterTargetsToShow($$.data.targets).map(function (t) { + return $$.addName($$.getValueOnIndex(t.values, index)); + }); + + if (config.tooltip_grouped) { + $$.showTooltip(selectedData, this); + $$.showXGridFocus(selectedData); + } + + if (config.tooltip_grouped && (!config.data_selection_enabled || config.data_selection_grouped)) { + return; + } + + $$.main.selectAll('.' + CLASS.shape + '-' + index) + .each(function () { + d3.select(this).classed(CLASS.EXPANDED, true); + if (config.data_selection_enabled) { + eventRect.style('cursor', config.data_selection_grouped ? 'pointer' : null); + } + if (!config.tooltip_grouped) { + $$.hideXGridFocus(); + $$.hideTooltip(); + if (!config.data_selection_grouped) { + $$.unexpandCircles(index); + $$.unexpandBars(index); + } + } + }) + .filter(function (d) { + return $$.isWithinShape(this, d); + }) + .each(function (d) { + if (config.data_selection_enabled && (config.data_selection_grouped || config.data_selection_isselectable(d))) { + eventRect.style('cursor', 'pointer'); + } + if (!config.tooltip_grouped) { + $$.showTooltip([d], this); + $$.showXGridFocus([d]); + if (config.point_focus_expand_enabled) { $$.expandCircles(index, d.id, true); } + $$.expandBars(index, d.id, true); + } + }); + }) + .on('click', function (d) { + var index = d.index; + if ($$.hasArcType() || !$$.toggleShape) { return; } + if ($$.cancelClick) { + $$.cancelClick = false; + return; + } + if ($$.isStepType(d) && config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { + index -= 1; + } + $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { + if (config.data_selection_grouped || $$.isWithinShape(this, d)) { + $$.toggleShape(this, d, index); + $$.config.data_onclick.call($$.api, d, this); + } + }); + }) + .call( + config.data_selection_draggable && $$.drag ? ( + d3.behavior.drag().origin(Object) + .on('drag', function () { $$.drag(d3.mouse(this)); }) + .on('dragstart', function () { $$.dragstart(d3.mouse(this)); }) + .on('dragend', function () { $$.dragend(); }) + ) : function () {} + ); +}; + +c3_chart_internal_fn.generateEventRectsForMultipleXs = function (eventRectEnter) { + var $$ = this, d3 = $$.d3, config = $$.config; + + function mouseout() { + $$.svg.select('.' + CLASS.eventRect).style('cursor', null); + $$.hideXGridFocus(); + $$.hideTooltip(); + $$.unexpandCircles(); + $$.unexpandBars(); + } + + eventRectEnter.append('rect') + .attr('x', 0) + .attr('y', 0) + .attr('width', $$.width) + .attr('height', $$.height) + .attr('class', CLASS.eventRect) + .on('mouseout', function () { + if (!$$.config) { return; } // chart is destroyed + if ($$.hasArcType()) { return; } + mouseout(); + }) + .on('mousemove', function () { + var targetsToShow = $$.filterTargetsToShow($$.data.targets); + var mouse, closest, sameXData, selectedData; + + if ($$.dragging) { return; } // do nothing when dragging + if ($$.hasArcType(targetsToShow)) { return; } + + mouse = d3.mouse(this); + closest = $$.findClosestFromTargets(targetsToShow, mouse); + + if ($$.mouseover && (!closest || closest.id !== $$.mouseover.id)) { + config.data_onmouseout.call($$.api, $$.mouseover); + $$.mouseover = undefined; + } + + if (! closest) { + mouseout(); + return; + } + + if ($$.isScatterType(closest) || !config.tooltip_grouped) { + sameXData = [closest]; + } else { + sameXData = $$.filterByX(targetsToShow, closest.x); + } + + // show tooltip when cursor is close to some point + selectedData = sameXData.map(function (d) { + return $$.addName(d); + }); + $$.showTooltip(selectedData, this); + + // expand points + if (config.point_focus_expand_enabled) { + $$.expandCircles(closest.index, closest.id, true); + } + $$.expandBars(closest.index, closest.id, true); + + // Show xgrid focus line + $$.showXGridFocus(selectedData); + + // Show cursor as pointer if point is close to mouse position + if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < 100) { + $$.svg.select('.' + CLASS.eventRect).style('cursor', 'pointer'); + if (!$$.mouseover) { + config.data_onmouseover.call($$.api, closest); + $$.mouseover = closest; + } + } + }) + .on('click', function () { + var targetsToShow = $$.filterTargetsToShow($$.data.targets); + var mouse, closest; + + if ($$.hasArcType(targetsToShow)) { return; } + + mouse = d3.mouse(this); + closest = $$.findClosestFromTargets(targetsToShow, mouse); + + if (! closest) { return; } + + // select if selection enabled + if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < 100) { + $$.main.selectAll('.' + CLASS.shapes + $$.getTargetSelectorSuffix(closest.id)).selectAll('.' + CLASS.shape + '-' + closest.index).each(function () { + if (config.data_selection_grouped || $$.isWithinShape(this, closest)) { + $$.toggleShape(this, closest, closest.index); + $$.config.data_onclick.call($$.api, closest, this); + } + }); + } + }) + .call( + config.data_selection_draggable && $$.drag ? ( + d3.behavior.drag().origin(Object) + .on('drag', function () { $$.drag(d3.mouse(this)); }) + .on('dragstart', function () { $$.dragstart(d3.mouse(this)); }) + .on('dragend', function () { $$.dragend(); }) + ) : function () {} + ); +}; +c3_chart_internal_fn.dispatchEvent = function (type, index, mouse) { + var $$ = this, + selector = '.' + CLASS.eventRect + (!$$.isMultipleX() ? '-' + index : ''), + 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); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/legend.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/legend.js new file mode 100644 index 0000000..7353a98 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/legend.js @@ -0,0 +1,322 @@ +c3_chart_internal_fn.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 upated by this, so transform not needed in updateLegend() + $$.updateLegendWithDefaults(); +}; +c3_chart_internal_fn.updateLegendWithDefaults = function () { + var $$ = this; + $$.updateLegend($$.mapToIds($$.data.targets), {withTransform: false, withTransitionForTransform: false, withTransition: false}); +}; +c3_chart_internal_fn.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 + }; +}; +c3_chart_internal_fn.transformLegend = function (withTransition) { + var $$ = this; + (withTransition ? $$.legend.transition() : $$.legend).attr("transform", $$.getTranslate('legend')); +}; +c3_chart_internal_fn.updateLegendStep = function (step) { + this.legendStep = step; +}; +c3_chart_internal_fn.updateLegendItemWidth = function (w) { + this.legendItemWidth = w; +}; +c3_chart_internal_fn.updateLegendItemHeight = function (h) { + this.legendItemHeight = h; +}; +c3_chart_internal_fn.getLegendWidth = function () { + var $$ = this; + return $$.config.legend_show ? $$.isLegendRight || $$.isLegendInset ? $$.legendItemWidth * ($$.legendStep + 1) : $$.currentWidth : 0; +}; +c3_chart_internal_fn.getLegendHeight = function () { + var $$ = this, h = 0; + if ($$.config.legend_show) { + if ($$.isLegendRight) { + h = $$.currentHeight; + } else { + h = Math.max(20, $$.legendItemHeight) * ($$.legendStep + 1); + } + } + return h; +}; +c3_chart_internal_fn.opacityForLegend = function (legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 1; +}; +c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) { + return legendItem.classed(CLASS.legendItemHidden) ? null : 0.3; +}; +c3_chart_internal_fn.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)); + }); +}; +c3_chart_internal_fn.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)); }); +}; +c3_chart_internal_fn.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)); }); +}; +c3_chart_internal_fn.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'); +}; +c3_chart_internal_fn.clearLegendItemTextBoxCache = function () { + this.legendItemTextBox = {}; +}; +c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { + var $$ = this, config = $$.config; + var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect; + var paddingTop = 4, paddingRight = 10, maxWidth = 0, maxHeight = 0, posMin = 10, tileWidth = 15; + var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; + var withTransition, withTransitionForTransform; + var texts, rects, tiles, background; + + 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); + } + 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), + 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) + 14; }; + 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; }; + + // 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', 'pointer') + .on('click', 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(); + } + } + }) + .on('mouseover', function (id) { + $$.d3.select(this).classed(CLASS.legendItemFocused, true); + if (!$$.transiting && $$.isTargetToShow(id)) { + $$.api.focus(id); + } + if (config.legend_item_onmouseover) { + config.legend_item_onmouseover.call($$, id); + } + }) + .on('mouseout', function (id) { + $$.d3.select(this).classed(CLASS.legendItemFocused, false); + $$.api.revert(); + if (config.legend_item_onmouseout) { + config.legend_item_onmouseout.call($$, id); + } + }); + 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('rect') + .attr("class", CLASS.legendItemTile) + .style("pointer-events", "none") + .style('fill', $$.color) + .attr('x', $$.isLegendRight || $$.isLegendInset ? xForLegendText : -200) + .attr('y', $$.isLegendRight || $$.isLegendInset ? -200 : yForLegend) + .attr('width', 10) + .attr('height', 10); + + // 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('rect.' + CLASS.legendItemTile) + .data(targetIds); + (withTransition ? tiles.transition() : tiles) + .style('fill', $$.color) + .attr('x', xForLegend) + .attr('y', yForLegend); + + 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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/polyfill.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/polyfill.js new file mode 100644 index 0000000..95d7812 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/polyfill.js @@ -0,0 +1,25 @@ +// PhantomJS doesn't have support for Function.prototype.bind, which has caused confusion. Use +// this polyfill to avoid the confusion. +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill + +if (!Function.prototype.bind) { + Function.prototype.bind = function(oThis) { + if (typeof this !== 'function') { + // closest thing possible to the ECMAScript 5 + // internal IsCallable function + throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function() {}, + fBound = function() { + return fToBind.apply(this instanceof fNOP ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/region.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/region.js new file mode 100644 index 0000000..20c70d5 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/region.js @@ -0,0 +1,81 @@ +c3_chart_internal_fn.initRegion = function () { + var $$ = this; + $$.region = $$.main.append('g') + .attr("clip-path", $$.clipPath) + .attr("class", CLASS.regions); +}; +c3_chart_internal_fn.updateRegion = function (duration) { + var $$ = this, config = $$.config; + + // hide if arc type + $$.region.style('visibility', $$.hasArcType() ? 'hidden' : 'visible'); + + $$.mainRegion = $$.main.select('.' + CLASS.regions).selectAll('.' + CLASS.region) + .data(config.regions); + $$.mainRegion.enter().append('g') + .attr('class', $$.classRegion.bind($$)) + .append('rect') + .style("fill-opacity", 0); + $$.mainRegion.exit().transition().duration(duration) + .style("opacity", 0) + .remove(); +}; +c3_chart_internal_fn.redrawRegion = function (withTransition) { + var $$ = this, + regions = $$.mainRegion.selectAll('rect'), + x = $$.regionX.bind($$), + y = $$.regionY.bind($$), + w = $$.regionWidth.bind($$), + h = $$.regionHeight.bind($$); + return [ + (withTransition ? regions.transition() : regions) + .attr("x", x) + .attr("y", y) + .attr("width", w) + .attr("height", h) + .style("fill-opacity", function (d) { return isValue(d.opacity) ? d.opacity : 0.1; }) + ]; +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.isRegionOnX = function (d) { + return !d.axis || d.axis === 'x'; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scale.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scale.js new file mode 100644 index 0000000..6c4c045 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scale.js @@ -0,0 +1,89 @@ +c3_chart_internal_fn.getScale = function (min, max, forTimeseries) { + return (forTimeseries ? this.d3.time.scale() : this.d3.scale.linear()).range([min, max]); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.getY = function (min, max, domain) { + var scale = this.getScale(min, max, this.isTimeSeriesY()); + if (domain) { scale.domain(domain); } + return scale; +}; +c3_chart_internal_fn.getYScale = function (id) { + return this.axis.getId(id) === 'y2' ? this.y2 : this.y; +}; +c3_chart_internal_fn.getSubYScale = function (id) { + return this.axis.getId(id) === 'y2' ? this.subY2 : this.subY; +}; +c3_chart_internal_fn.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($$.yMin, $$.yMax, forInit ? config.axis_y_default : $$.y.domain()); + $$.y2 = $$.getY($$.yMin, $$.yMax, forInit ? config.axis_y2_default : $$.y2.domain()); + $$.subX = $$.getX($$.xMin, $$.xMax, $$.orgXDomain, function (d) { return d % 1 ? 0 : $$.subXAxis.tickOffset(); }); + $$.subY = $$.getY($$.subYMin, $$.subYMax, forInit ? config.axis_y_default : $$.subY.domain()); + $$.subY2 = $$.getY($$.subYMin, $$.subYMax, forInit ? config.axis_y2_default : $$.subY2.domain()); + // 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, $$.yOrient, config.axis_y_tick_format, $$.yAxisTickValues, config.axis_y_tick_outer); + $$.y2Axis = $$.axis.getYAxis($$.y2, $$.y2Orient, config.axis_y2_tick_format, $$.y2AxisTickValues, config.axis_y2_tick_outer); + + // Set initialized scales to brush and zoom + if (!forInit) { + if ($$.brush) { $$.brush.scale($$.subX); } + if (config.zoom_enabled) { $$.zoom.scale($$.x); } + } + // update for arc + if ($$.updateArc) { $$.updateArc(); } +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/arc.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/arc.scss new file mode 100644 index 0000000..ddea0d7 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/arc.scss @@ -0,0 +1,24 @@ +.c3-chart-arcs-title { + dominant-baseline: middle; + font-size: 1.3em; +} + +.c3-chart-arcs .c3-chart-arcs-background { + fill: #e0e0e0; + stroke: none; +} +.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;*/ +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/area.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/area.scss new file mode 100644 index 0000000..5f3e2c4 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/area.scss @@ -0,0 +1,4 @@ +.c3-area { + stroke-width: 0; + opacity: 0.2; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/axis.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/axis.scss new file mode 100644 index 0000000..140ee4e --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/axis.scss @@ -0,0 +1,14 @@ +.c3-axis-x .tick { +} +.c3-axis-x-label { +} + +.c3-axis-y .tick { +} +.c3-axis-y-label { +} + +.c3-axis-y2 .tick { +} +.c3-axis-y2-label { +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/bar.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/bar.scss new file mode 100644 index 0000000..08ae998 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/bar.scss @@ -0,0 +1,6 @@ +.c3-bar { + stroke-width: 0; +} +.c3-bar._expanded_ { + fill-opacity: 0.75; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/brush.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/brush.scss new file mode 100644 index 0000000..0f547c4 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/brush.scss @@ -0,0 +1,3 @@ +.c3-brush .extent { + fill-opacity: .1; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/chart.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/chart.scss new file mode 100644 index 0000000..969e8da --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/chart.scss @@ -0,0 +1,29 @@ +.c3 svg { + font: 10px sans-serif; +} +.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 text { + fill: #fff; + font-size: 13px; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/focus.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/focus.scss new file mode 100644 index 0000000..02db8df --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/focus.scss @@ -0,0 +1,9 @@ +.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; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/grid.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/grid.scss new file mode 100644 index 0000000..fd9ce13 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/grid.scss @@ -0,0 +1,11 @@ +.c3-grid line { + stroke: #aaa; +} +.c3-grid text { + fill: #aaa; +} +.c3-xgrid, .c3-ygrid { + stroke-dasharray: 3 3; +} +.c3-xgrid-focus { +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/legend.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/legend.scss new file mode 100644 index 0000000..8d6d971 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/legend.scss @@ -0,0 +1,13 @@ +.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 +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/line.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/line.scss new file mode 100644 index 0000000..7690afa --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/line.scss @@ -0,0 +1,3 @@ +.c3-line { + stroke-width: 1px; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/main.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/main.scss new file mode 100644 index 0000000..20777b4 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/main.scss @@ -0,0 +1,59 @@ +/*-- Chart --*/ + +@import 'chart'; + +/*-- Axis --*/ + +@import 'axis'; + +/*-- Grid --*/ + +@import 'grid'; + +/*-- Text on Chart --*/ + +@import 'text'; + +/*-- Line --*/ + +@import 'line'; + +/*-- Point --*/ + +@import 'point'; + +/*-- Bar --*/ + +@import 'bar'; + +/*-- Focus --*/ + +@import 'focus'; + +/*-- Region --*/ + +@import 'region'; + +/*-- Brush --*/ + +@import 'brush'; + +/*-- Select - Drag --*/ + +@import 'select_drag'; + +/*-- Legend --*/ + +@import 'legend'; + +/*-- Tooltip --*/ + +@import 'tooltip'; + +/*-- Area --*/ + +@import 'area'; + +/*-- Arc --*/ + +@import 'arc'; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/point.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/point.scss new file mode 100644 index 0000000..532a644 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/point.scss @@ -0,0 +1,8 @@ +.c3-circle._expanded_ { + stroke-width: 1px; + stroke: white; +} +.c3-selected-circle { + fill: white; + stroke-width: 2px; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/region.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/region.scss new file mode 100644 index 0000000..d77f7c3 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/region.scss @@ -0,0 +1,4 @@ +.c3-region { + fill: steelblue; + fill-opacity: .1; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/select_drag.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/select_drag.scss new file mode 100644 index 0000000..ef5cb1a --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/select_drag.scss @@ -0,0 +1,2 @@ +.c3-dragarea { +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/text.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/text.scss new file mode 100644 index 0000000..d4453ce --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/text.scss @@ -0,0 +1,7 @@ +.c3-text { +} + +.c3-text.c3-empty { + fill: #808080; + font-size: 2em; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/tooltip.scss b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/tooltip.scss new file mode 100644 index 0000000..99f36f9 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/scss/tooltip.scss @@ -0,0 +1,38 @@ +.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 rgb(119,119,119); + -moz-box-shadow: 7px 7px 12px -9px rgb(119,119,119); + box-shadow: 7px 7px 12px -9px rgb(119,119,119); + 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 td.value{ + text-align: right; +} diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/selection.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/selection.js new file mode 100644 index 0000000..e9b4ada --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/selection.js @@ -0,0 +1,75 @@ +c3_chart_internal_fn.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); +}; +c3_chart_internal_fn.unselectPoint = function (target, d, i) { + var $$ = this; + $$.config.data_onunselected(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(); +}; +c3_chart_internal_fn.togglePoint = function (selected, target, d, i) { + selected ? this.selectPoint(target, d, i) : this.unselectPoint(target, d, i); +}; +c3_chart_internal_fn.selectPath = function (target, d) { + var $$ = this; + $$.config.data_onselected.call($$, d, target.node()); + target.transition().duration(100) + .style("fill", function () { return $$.d3.rgb($$.color(d)).brighter(0.75); }); +}; +c3_chart_internal_fn.unselectPath = function (target, d) { + var $$ = this; + $$.config.data_onunselected.call($$, d, target.node()); + target.transition().duration(100) + .style("fill", function () { return $$.color(d); }); +}; +c3_chart_internal_fn.togglePath = function (selected, target, d, i) { + selected ? this.selectPath(target, d, i) : this.unselectPath(target, d, i); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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); + } +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/shape.bar.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/shape.bar.js new file mode 100644 index 0000000..bd8403e --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/shape.bar.js @@ -0,0 +1,122 @@ +c3_chart_internal_fn.initBar = function () { + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartBars); +}; +c3_chart_internal_fn.updateTargetsForBar = function (targets) { + var $$ = this, config = $$.config, + mainBarUpdate, mainBarEnter, + classChartBar = $$.classChartBar.bind($$), + classBars = $$.classBars.bind($$), + classFocus = $$.classFocus.bind($$); + mainBarUpdate = $$.main.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) + .data(targets) + .attr('class', function (d) { return classChartBar(d) + classFocus(d); }); + mainBarEnter = mainBarUpdate.enter().append('g') + .attr('class', classChartBar) + .style('opacity', 0) + .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; }); + +}; +c3_chart_internal_fn.updateBar = function (durationForExit) { + var $$ = this, + barData = $$.barData.bind($$), + classBar = $$.classBar.bind($$), + initialOpacity = $$.initialOpacity.bind($$), + color = function (d) { return $$.color(d.id); }; + $$.mainBar = $$.main.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) + .data(barData); + $$.mainBar.enter().append('path') + .attr("class", classBar) + .style("stroke", color) + .style("fill", color); + $$.mainBar + .style("opacity", initialOpacity); + $$.mainBar.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); +}; +c3_chart_internal_fn.redrawBar = function (drawBar, withTransition) { + return [ + (withTransition ? this.mainBar.transition() : this.mainBar) + .attr('d', drawBar) + .style("fill", this.color) + .style("opacity", 1) + ]; +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.getBars = function (i, id) { + var $$ = this; + return (id ? $$.main.selectAll('.' + CLASS.bars + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS.bar + (isValue(i) ? '-' + i : '')); +}; +c3_chart_internal_fn.expandBars = function (i, id, reset) { + var $$ = this; + if (reset) { $$.unexpandBars(); } + $$.getBars(i, id).classed(CLASS.EXPANDED, true); +}; +c3_chart_internal_fn.unexpandBars = function (i) { + var $$ = this; + $$.getBars(i).classed(CLASS.EXPANDED, false); +}; +c3_chart_internal_fn.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; + }; +}; +c3_chart_internal_fn.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), + 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; } + } + // 4 points that make a bar + return [ + [posX, offset], + [posX, posY - (y0 - offset)], + [posX + barW, posY - (y0 - offset)], + [posX + barW, offset] + ]; + }; +}; +c3_chart_internal_fn.isWithinBar = function (that) { + var mouse = this.d3.mouse(that), box = that.getBoundingClientRect(), + seg0 = that.pathSegList.getItem(0), seg1 = that.pathSegList.getItem(1), + x = Math.min(seg0.x, seg1.x), y = Math.min(seg0.y, seg1.y), + w = box.width, h = box.height, offset = 2, + sx = x - offset, ex = x + w + offset, sy = y + h + offset, ey = y - offset; + return sx < mouse[0] && mouse[0] < ex && ey < mouse[1] && mouse[1] < sy; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/shape.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/shape.js new file mode 100644 index 0000000..fd40598 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/shape.js @@ -0,0 +1,71 @@ +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.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; + }; +}; +c3_chart_internal_fn.getShapeY = function (isSub) { + var $$ = this; + return function (d) { + var scale = isSub ? $$.getSubYScale(d.id) : $$.getYScale(d.id); + return scale(d.value); + }; +}; +c3_chart_internal_fn.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 values = $$.isStepType(d) ? $$.convertValuesToStep(t.values) : t.values; + if (t.id === d.id || indices[t.id] !== indices[d.id]) { return; } + if (targetIds.indexOf(t.id) < targetIds.indexOf(d.id)) { + if (values[i].value * d.value >= 0) { + offset += scale(values[i].value) - y0; + } + } + }); + return offset; + }; +}; +c3_chart_internal_fn.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(that) : true; + } + return isWithin; +}; + + +c3_chart_internal_fn.getInterpolate = function (d) { + var $$ = this; + return $$.isSplineType(d) ? "cardinal" : $$.isStepType(d) ? $$.config.line_step_type : "linear"; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/shape.line.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/shape.line.js new file mode 100644 index 0000000..057e35d --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/shape.line.js @@ -0,0 +1,385 @@ +c3_chart_internal_fn.initLine = function () { + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartLines); +}; +c3_chart_internal_fn.updateTargetsForLine = function (targets) { + var $$ = this, config = $$.config, + mainLineUpdate, mainLineEnter, + classChartLine = $$.classChartLine.bind($$), + classLines = $$.classLines.bind($$), + classAreas = $$.classAreas.bind($$), + classCircles = $$.classCircles.bind($$), + classFocus = $$.classFocus.bind($$); + mainLineUpdate = $$.main.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) + .data(targets) + .attr('class', function (d) { return classChartLine(d) + classFocus(d); }); + mainLineEnter = mainLineUpdate.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(); +}; +c3_chart_internal_fn.updateLine = function (durationForExit) { + var $$ = this; + $$.mainLine = $$.main.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + $$.mainLine.enter().append('path') + .attr('class', $$.classLine.bind($$)) + .style("stroke", $$.color); + $$.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) + .remove(); +}; +c3_chart_internal_fn.redrawLine = function (drawLine, withTransition) { + return [ + (withTransition ? this.mainLine.transition() : this.mainLine) + .attr("d", drawLine) + .style("stroke", this.color) + .style("opacity", 1) + ]; +}; +c3_chart_internal_fn.generateDrawLine = function (lineIndices, isSub) { + var $$ = this, config = $$.config, + line = $$.d3.svg.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 ? $$.x : $$.subX, 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.interpolate($$.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"; + }; +}; +c3_chart_internal_fn.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 + ]; + }; +}; + + +c3_chart_internal_fn.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; +}; + + +c3_chart_internal_fn.updateArea = function (durationForExit) { + var $$ = this, d3 = $$.d3; + $$.mainArea = $$.main.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + $$.mainArea.enter().append('path') + .attr("class", $$.classArea.bind($$)) + .style("fill", $$.color) + .style("opacity", function () { $$.orgAreaOpacity = +d3.select(this).style('opacity'); return 0; }); + $$.mainArea + .style("opacity", $$.orgAreaOpacity); + $$.mainArea.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); +}; +c3_chart_internal_fn.redrawArea = function (drawArea, withTransition) { + return [ + (withTransition ? this.mainArea.transition() : this.mainArea) + .attr("d", drawArea) + .style("fill", this.color) + .style("opacity", this.orgAreaOpacity) + ]; +}; +c3_chart_internal_fn.generateDrawArea = function (areaIndices, isSub) { + var $$ = this, config = $$.config, area = $$.d3.svg.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(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.interpolate($$.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"; + }; +}; +c3_chart_internal_fn.getAreaBaseValue = function () { + return 0; +}; +c3_chart_internal_fn.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 + ]; + }; +}; + + +c3_chart_internal_fn.updateCircle = function () { + var $$ = this; + $$.mainCircle = $$.main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle) + .data($$.lineOrScatterData.bind($$)); + $$.mainCircle.enter().append("circle") + .attr("class", $$.classCircle.bind($$)) + .attr("r", $$.pointR.bind($$)) + .style("fill", $$.color); + $$.mainCircle + .style("opacity", $$.initialOpacityForCircle.bind($$)); + $$.mainCircle.exit().remove(); +}; +c3_chart_internal_fn.redrawCircle = function (cx, cy, withTransition) { + var selectedCircles = this.main.selectAll('.' + CLASS.selectedCircle); + return [ + (withTransition ? this.mainCircle.transition() : this.mainCircle) + .style('opacity', this.opacityForCircle.bind(this)) + .style("fill", this.color) + .attr("cx", cx) + .attr("cy", cy), + (withTransition ? selectedCircles.transition() : selectedCircles) + .attr("cx", cx) + .attr("cy", cy) + ]; +}; +c3_chart_internal_fn.circleX = function (d) { + return d.x || d.x === 0 ? this.x(d.x) : null; +}; +c3_chart_internal_fn.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); + }; + } +}; +c3_chart_internal_fn.getCircles = function (i, id) { + var $$ = this; + return (id ? $$.main.selectAll('.' + CLASS.circles + $$.getTargetSelectorSuffix(id)) : $$.main).selectAll('.' + CLASS.circle + (isValue(i) ? '-' + i : '')); +}; +c3_chart_internal_fn.expandCircles = function (i, id, reset) { + var $$ = this, + r = $$.pointExpandedR.bind($$); + if (reset) { $$.unexpandCircles(); } + $$.getCircles(i, id) + .classed(CLASS.EXPANDED, true) + .attr('r', r); +}; +c3_chart_internal_fn.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); +}; +c3_chart_internal_fn.pointR = function (d) { + var $$ = this, config = $$.config; + return $$.isStepType(d) ? 0 : (isFunction(config.point_r) ? config.point_r(d) : config.point_r); +}; +c3_chart_internal_fn.pointExpandedR = function (d) { + var $$ = this, config = $$.config; + return config.point_focus_expand_enabled ? (config.point_focus_expand_r ? config.point_focus_expand_r : $$.pointR(d) * 1.75) : $$.pointR(d); +}; +c3_chart_internal_fn.pointSelectR = function (d) { + var $$ = this, config = $$.config; + return config.point_select_r ? config.point_select_r : $$.pointR(d) * 4; +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.isWithinStep = function (that, y) { + return Math.abs(y - this.d3.mouse(that)[1]) < 30; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/size.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/size.js new file mode 100644 index 0000000..4bfb619 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/size.js @@ -0,0 +1,104 @@ +c3_chart_internal_fn.getCurrentWidth = function () { + var $$ = this, config = $$.config; + return config.size_width ? config.size_width : $$.getParentWidth(); +}; +c3_chart_internal_fn.getCurrentHeight = function () { + var $$ = this, config = $$.config, + h = config.size_height ? config.size_height : $$.getParentHeight(); + return h > 0 ? h : 320 / ($$.hasType('gauge') ? 2 : 1); +}; +c3_chart_internal_fn.getCurrentPaddingTop = function () { + var config = this.config; + return isValue(config.padding_top) ? config.padding_top : 0; +}; +c3_chart_internal_fn.getCurrentPaddingBottom = function () { + var config = this.config; + return isValue(config.padding_bottom) ? config.padding_bottom : 0; +}; +c3_chart_internal_fn.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 ? 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)); + } +}; +c3_chart_internal_fn.getCurrentPaddingRight = function () { + var $$ = this, config = $$.config, + defaultPadding = 10, legendWidthOnRight = $$.isLegendRight ? $$.getLegendWidth() + 20 : 0; + if (isValue(config.padding_right)) { + return config.padding_right + 1; // 1 is needed not to hide tick line + } else if (config.axis_rotated) { + return defaultPadding + legendWidthOnRight; + } else if (!config.axis_y2_show || config.axis_y2_inner) { // && !config.axis_rotated + return 2 + legendWidthOnRight + ($$.axis.getY2AxisLabelPosition().isOuter ? 20 : 0); + } else { + return ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight; + } +}; + +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.getParentWidth = function () { + return this.getParentRectValue('width'); +}; +c3_chart_internal_fn.getParentHeight = function () { + var h = this.selectChart.style('height'); + return h.indexOf('px') > 0 ? +h.replace('px', '') : 0; +}; + + +c3_chart_internal_fn.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; +}; + + +c3_chart_internal_fn.getAxisWidthByAxisId = function (id, withoutRecompute) { + var $$ = this, position = $$.axis.getLabelPositionById(id); + return $$.axis.getMaxTickWidth(id, withoutRecompute) + (position.isInner ? 20 : 40); +}; +c3_chart_internal_fn.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 - config.axis_x_tick_rotate) / 180); + } + return h + ($$.axis.getLabelPositionById(axisId).isInner ? 0 : 10) + (axisId === 'y2' ? -10 : 0); +}; + +c3_chart_internal_fn.getEventRectWidth = function () { + return Math.max(0, this.xAxis.tickInterval()); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/subchart.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/subchart.js new file mode 100644 index 0000000..ba41035 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/subchart.js @@ -0,0 +1,204 @@ +c3_chart_internal_fn.initBrush = function () { + var $$ = this, d3 = $$.d3; + $$.brush = d3.svg.brush().on("brush", function () { $$.redrawForBrush(); }); + $$.brush.update = function () { + if ($$.context) { $$.context.select('.' + CLASS.brush).call(this); } + return this; + }; + $$.brush.scale = function (scale) { + return $$.config.axis_rotated ? this.y(scale) : this.x(scale); + }; +}; +c3_chart_internal_fn.initSubchart = function () { + var $$ = this, config = $$.config, + context = $$.context = $$.svg.append("g").attr("transform", $$.getTranslate('context')); + + context.style('visibility', config.subchart_show ? 'visible' : 'hidden'); + + // 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) + .call($$.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); +}; +c3_chart_internal_fn.updateTargetsForSubchart = function (targets) { + var $$ = this, context = $$.context, config = $$.config, + contextLineEnter, contextLineUpdate, contextBarEnter, contextBarUpdate, + classChartBar = $$.classChartBar.bind($$), + classBars = $$.classBars.bind($$), + classChartLine = $$.classChartLine.bind($$), + classLines = $$.classLines.bind($$), + classAreas = $$.classAreas.bind($$); + + if (config.subchart_show) { + //-- Bar --// + contextBarUpdate = context.select('.' + CLASS.chartBars).selectAll('.' + CLASS.chartBar) + .data(targets) + .attr('class', classChartBar); + contextBarEnter = contextBarUpdate.enter().append('g') + .style('opacity', 0) + .attr('class', classChartBar); + // Bars for each data + contextBarEnter.append('g') + .attr("class", classBars); + + //-- Line --// + contextLineUpdate = context.select('.' + CLASS.chartLines).selectAll('.' + CLASS.chartLine) + .data(targets) + .attr('class', classChartLine); + contextLineEnter = contextLineUpdate.enter().append('g') + .style('opacity', 0) + .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); + } +}; +c3_chart_internal_fn.updateBarForSubchart = function (durationForExit) { + var $$ = this; + $$.contextBar = $$.context.selectAll('.' + CLASS.bars).selectAll('.' + CLASS.bar) + .data($$.barData.bind($$)); + $$.contextBar.enter().append('path') + .attr("class", $$.classBar.bind($$)) + .style("stroke", 'none') + .style("fill", $$.color); + $$.contextBar + .style("opacity", $$.initialOpacity.bind($$)); + $$.contextBar.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); +}; +c3_chart_internal_fn.redrawBarForSubchart = function (drawBarOnSub, withTransition, duration) { + (withTransition ? this.contextBar.transition().duration(duration) : this.contextBar) + .attr('d', drawBarOnSub) + .style('opacity', 1); +}; +c3_chart_internal_fn.updateLineForSubchart = function (durationForExit) { + var $$ = this; + $$.contextLine = $$.context.selectAll('.' + CLASS.lines).selectAll('.' + CLASS.line) + .data($$.lineData.bind($$)); + $$.contextLine.enter().append('path') + .attr('class', $$.classLine.bind($$)) + .style('stroke', $$.color); + $$.contextLine + .style("opacity", $$.initialOpacity.bind($$)); + $$.contextLine.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); +}; +c3_chart_internal_fn.redrawLineForSubchart = function (drawLineOnSub, withTransition, duration) { + (withTransition ? this.contextLine.transition().duration(duration) : this.contextLine) + .attr("d", drawLineOnSub) + .style('opacity', 1); +}; +c3_chart_internal_fn.updateAreaForSubchart = function (durationForExit) { + var $$ = this, d3 = $$.d3; + $$.contextArea = $$.context.selectAll('.' + CLASS.areas).selectAll('.' + CLASS.area) + .data($$.lineData.bind($$)); + $$.contextArea.enter().append('path') + .attr("class", $$.classArea.bind($$)) + .style("fill", $$.color) + .style("opacity", function () { $$.orgAreaOpacity = +d3.select(this).style('opacity'); return 0; }); + $$.contextArea + .style("opacity", 0); + $$.contextArea.exit().transition().duration(durationForExit) + .style('opacity', 0) + .remove(); +}; +c3_chart_internal_fn.redrawAreaForSubchart = function (drawAreaOnSub, withTransition, duration) { + (withTransition ? this.contextArea.transition().duration(duration) : this.contextArea) + .attr("d", drawAreaOnSub) + .style("fill", this.color) + .style("opacity", this.orgAreaOpacity); +}; +c3_chart_internal_fn.redrawSubchart = function (withSubchart, transitions, duration, durationForExit, areaIndices, barIndices, lineIndices) { + var $$ = this, d3 = $$.d3, config = $$.config, + drawAreaOnSub, drawBarOnSub, drawLineOnSub; + + $$.context.style('visibility', config.subchart_show ? 'visible' : 'hidden'); + + // subchart + if (config.subchart_show) { + // reflect main chart to extent on subchart if zoomed + if (d3.event && d3.event.type === 'zoom') { + $$.brush.extent($$.x.orgDomain()).update(); + } + // update subchart elements if needed + if (withSubchart) { + + // extent rect + if (!$$.brush.empty()) { + $$.brush.extent($$.x.orgDomain()).update(); + } + // 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); + } + } +}; +c3_chart_internal_fn.redrawForBrush = function () { + var $$ = this, x = $$.x; + $$.redraw({ + withTransition: false, + withY: $$.config.zoom_rescale, + withSubchart: false, + withUpdateXDomain: true, + withDimension: false + }); + $$.config.subchart_onbrush.call($$.api, x.orgDomain()); +}; +c3_chart_internal_fn.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')); +}; +c3_chart_internal_fn.getDefaultExtent = function () { + var $$ = this, config = $$.config, + extent = isFunction(config.axis_x_extent) ? config.axis_x_extent($$.getXDomain($$.data.targets)) : config.axis_x_extent; + if ($$.isTimeSeries()) { + extent = [$$.parseDate(extent[0]), $$.parseDate(extent[1])]; + } + return extent; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/tail.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/tail.js new file mode 100644 index 0000000..7e78a25 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/tail.js @@ -0,0 +1,9 @@ + if (typeof define === 'function' && define.amd) { + define("c3", ["d3"], c3); + } else if ('undefined' !== typeof exports && 'undefined' !== typeof module) { + module.exports = c3; + } else { + window.c3 = c3; + } + +})(window); diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/text.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/text.js new file mode 100644 index 0000000..6574a76 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/text.js @@ -0,0 +1,122 @@ +c3_chart_internal_fn.initText = function () { + var $$ = this; + $$.main.select('.' + CLASS.chart).append("g") + .attr("class", CLASS.chartTexts); + $$.mainText = $$.d3.selectAll([]); +}; +c3_chart_internal_fn.updateTargetsForText = function (targets) { + var $$ = this, mainTextUpdate, mainTextEnter, + classChartText = $$.classChartText.bind($$), + classTexts = $$.classTexts.bind($$), + classFocus = $$.classFocus.bind($$); + mainTextUpdate = $$.main.select('.' + CLASS.chartTexts).selectAll('.' + CLASS.chartText) + .data(targets) + .attr('class', function (d) { return classChartText(d) + classFocus(d); }); + mainTextEnter = mainTextUpdate.enter().append('g') + .attr('class', classChartText) + .style('opacity', 0) + .style("pointer-events", "none"); + mainTextEnter.append('g') + .attr('class', classTexts); +}; +c3_chart_internal_fn.updateText = function (durationForExit) { + var $$ = this, config = $$.config, + barOrLineData = $$.barOrLineData.bind($$), + classText = $$.classText.bind($$); + $$.mainText = $$.main.selectAll('.' + CLASS.texts).selectAll('.' + CLASS.text) + .data(barOrLineData); + $$.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') + .style("fill", function (d) { return $$.color(d); }) + .style("fill-opacity", 0); + $$.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(); +}; +c3_chart_internal_fn.redrawText = function (xForText, yForText, forFlow, withTransition) { + return [ + (withTransition ? this.mainText.transition() : this.mainText) + .attr('x', xForText) + .attr('y', yForText) + .style("fill", this.color) + .style("fill-opacity", forFlow ? 0 : this.opacityForText.bind(this)) + ]; +}; +c3_chart_internal_fn.getTextRect = function (text, cls) { + 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), + rect; + svg.selectAll('.dummy') + .data([text]) + .enter().append('text') + .classed(cls ? cls : "", true) + .text(text) + .each(function () { rect = this.getBoundingClientRect(); }); + dummy.remove(); + return rect; +}; +c3_chart_internal_fn.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); + }; +}; +c3_chart_internal_fn.getXForText = function (points, d, textElement) { + var $$ = this, + box = textElement.getBoundingClientRect(), 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; +}; +c3_chart_internal_fn.getYForText = function (points, d, textElement) { + var $$ = this, + box = textElement.getBoundingClientRect(), + 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) { + 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; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/tooltip.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/tooltip.js new file mode 100644 index 0000000..6b0a7d4 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/tooltip.js @@ -0,0 +1,113 @@ +c3_chart_internal_fn.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"); + } +}; +c3_chart_internal_fn.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; }, + valueFormat = config.tooltip_format_value || defaultValueFormat, + text, i, title, value, name, bgcolor; + for (i = 0; i < d.length; i++) { + if (! (d[i] && (d[i].value || d[i].value === 0))) { continue; } + + if (! text) { + title = titleFormat ? titleFormat(d[i].x) : d[i].x; + text = "<table class='" + CLASS.tooltip + "'>" + (title || title === 0 ? "<tr><th colspan='2'>" + title + "</th></tr>" : ""); + } + + value = valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index); + if (value !== undefined) { + name = nameFormat(d[i].name, d[i].ratio, d[i].id, d[i].index); + bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id); + + text += "<tr class='" + CLASS.tooltipName + "-" + d[i].id + "'>"; + text += "<td class='name'><span style='background-color:" + bgcolor + "'></span>" + name + "</td>"; + text += "<td class='value'>" + value + "</td>"; + text += "</tr>"; + } + } + return text + "</table>"; +}; +c3_chart_internal_fn.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 = ($$.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 tooletip width + tooltipLeft -= tooltipRight - chartRight + 20; + } + if (tooltipTop + tHeight > $$.currentHeight) { + tooltipTop -= tHeight + 30; + } + } + if (tooltipTop < 0) { + tooltipTop = 0; + } + return {top: tooltipTop, left: tooltipLeft}; +}; +c3_chart_internal_fn.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 || c3_chart_internal_fn.tooltipPosition; + if (dataToShow.length === 0 || !config.tooltip_show) { + 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'); +}; +c3_chart_internal_fn.hideTooltip = function () { + this.tooltip.style("display", "none"); +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/type.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/type.js new file mode 100644 index 0000000..51511a5 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/type.js @@ -0,0 +1,91 @@ +c3_chart_internal_fn.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; + } +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.hasArcType = function (targets) { + return this.hasType('pie', targets) || this.hasType('donut', targets) || this.hasType('gauge', targets); +}; +c3_chart_internal_fn.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; +}; +c3_chart_internal_fn.isStepType = function (d) { + var id = isString(d) ? d : d.id; + return ['step', 'area-step'].indexOf(this.config.data_types[id]) >= 0; +}; +c3_chart_internal_fn.isSplineType = function (d) { + var id = isString(d) ? d : d.id; + return ['spline', 'area-spline'].indexOf(this.config.data_types[id]) >= 0; +}; +c3_chart_internal_fn.isAreaType = function (d) { + var id = isString(d) ? d : d.id; + return ['area', 'area-spline', 'area-step'].indexOf(this.config.data_types[id]) >= 0; +}; +c3_chart_internal_fn.isBarType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'bar'; +}; +c3_chart_internal_fn.isScatterType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'scatter'; +}; +c3_chart_internal_fn.isPieType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'pie'; +}; +c3_chart_internal_fn.isGaugeType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'gauge'; +}; +c3_chart_internal_fn.isDonutType = function (d) { + var id = isString(d) ? d : d.id; + return this.config.data_types[id] === 'donut'; +}; +c3_chart_internal_fn.isArcType = function (d) { + return this.isPieType(d) || this.isDonutType(d) || this.isGaugeType(d); +}; +c3_chart_internal_fn.lineData = function (d) { + return this.isLineType(d) ? [d] : []; +}; +c3_chart_internal_fn.arcData = function (d) { + return this.isArcType(d.data) ? [d] : []; +}; +/* not used + function scatterData(d) { + return isScatterType(d) ? d.values : []; + } + */ +c3_chart_internal_fn.barData = function (d) { + return this.isBarType(d) ? d.values : []; +}; +c3_chart_internal_fn.lineOrScatterData = function (d) { + return this.isLineType(d) || this.isScatterType(d) ? d.values : []; +}; +c3_chart_internal_fn.barOrLineData = function (d) { + return this.isBarType(d) || this.isLineType(d) ? d.values : []; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/ua.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/ua.js new file mode 100644 index 0000000..17fcde5 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/ua.js @@ -0,0 +1,8 @@ +c3_chart_internal_fn.isSafari = function () { + var ua = window.navigator.userAgent; + return ua.indexOf('Safari') >= 0 && ua.indexOf('Chrome') < 0; +}; +c3_chart_internal_fn.isChrome = function () { + var ua = window.navigator.userAgent; + return ua.indexOf('Chrome') >= 0; +}; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/util.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/util.js new file mode 100644 index 0000000..91cb48b --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/util.js @@ -0,0 +1,46 @@ +var isValue = c3_chart_internal_fn.isValue = function (v) { + return v || v === 0; +}, + isFunction = c3_chart_internal_fn.isFunction = function (o) { + return typeof o === 'function'; + }, + isString = c3_chart_internal_fn.isString = function (o) { + return typeof o === 'string'; + }, + isUndefined = c3_chart_internal_fn.isUndefined = function (v) { + return typeof v === 'undefined'; + }, + isDefined = c3_chart_internal_fn.isDefined = function (v) { + return typeof v !== 'undefined'; + }, + ceil10 = c3_chart_internal_fn.ceil10 = function (v) { + return Math.ceil(v / 10) * 10; + }, + asHalfPixel = c3_chart_internal_fn.asHalfPixel = function (n) { + return Math.ceil(n) + 0.5; + }, + diffDomain = c3_chart_internal_fn.diffDomain = function (d) { + return d[1] - d[0]; + }, + isEmpty = c3_chart_internal_fn.isEmpty = function (o) { + return !o || (isString(o) && o.length === 0) || (typeof o === 'object' && Object.keys(o).length === 0); + }, + notEmpty = c3_chart_internal_fn.notEmpty = function (o) { + return Object.keys(o).length > 0; + }, + getOption = c3_chart_internal_fn.getOption = function (options, key, defaultValue) { + return isDefined(options[key]) ? options[key] : defaultValue; + }, + hasValue = c3_chart_internal_fn.hasValue = function (dict, value) { + var found = false; + Object.keys(dict).forEach(function (key) { + if (dict[key] === value) { found = true; } + }); + return found; + }, + getPathBox = c3_chart_internal_fn.getPathBox = function (path) { + var box = path.getBoundingClientRect(), + 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}; + }; diff --git a/web/nms-public.gathering.org/old/speedometer/c3-master/src/zoom.js b/web/nms-public.gathering.org/old/speedometer/c3-master/src/zoom.js new file mode 100644 index 0000000..b46a0b1 --- /dev/null +++ b/web/nms-public.gathering.org/old/speedometer/c3-master/src/zoom.js @@ -0,0 +1,69 @@ +c3_chart_internal_fn.initZoom = function () { + var $$ = this, d3 = $$.d3, config = $$.config, startEvent; + + $$.zoom = d3.behavior.zoom() + .on("zoomstart", function () { + startEvent = d3.event.sourceEvent; + $$.zoom.altDomain = d3.event.sourceEvent.altKey ? $$.x.orgDomain() : null; + config.zoom_onzoomstart.call($$.api, d3.event.sourceEvent); + }) + .on("zoom", function () { + $$.redrawForZoom.call($$); + }) + .on('zoomend', function () { + var event = d3.event.sourceEvent; + // if click, do nothing. otherwise, click interaction will be canceled. + if (event && startEvent.clientX === event.clientX && startEvent.clientY === event.clientY) { + return; + } + $$.redrawEventRect(); + $$.updateZoom(); + config.zoom_onzoomend.call($$.api, $$.x.orgDomain()); + }); + $$.zoom.scale = function (scale) { + return config.axis_rotated ? this.y(scale) : this.x(scale); + }; + $$.zoom.orgScaleExtent = function () { + var extent = config.zoom_extent ? config.zoom_extent : [1, 10]; + return [extent[0], Math.max($$.getMaxDataCount() / extent[1], extent[1])]; + }; + $$.zoom.updateScaleExtent = function () { + var ratio = diffDomain($$.x.orgDomain()) / diffDomain($$.orgXDomain), + extent = this.orgScaleExtent(); + this.scaleExtent([extent[0] * ratio, extent[1] * ratio]); + return this; + }; +}; +c3_chart_internal_fn.updateZoom = function () { + var $$ = this, z = $$.config.zoom_enabled ? $$.zoom : function () {}; + $$.main.select('.' + CLASS.zoomRect).call(z).on("dblclick.zoom", null); + $$.main.selectAll('.' + CLASS.eventRect).call(z).on("dblclick.zoom", null); +}; +c3_chart_internal_fn.redrawForZoom = function () { + var $$ = this, d3 = $$.d3, config = $$.config, zoom = $$.zoom, x = $$.x; + if (!config.zoom_enabled) { + return; + } + if ($$.filterTargetsToShow($$.data.targets).length === 0) { + return; + } + if (d3.event.sourceEvent.type === 'mousemove' && zoom.altDomain) { + x.domain(zoom.altDomain); + zoom.scale(x).updateScaleExtent(); + 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.type === 'mousemove') { + $$.cancelClick = true; + } + config.zoom_onzoom.call($$.api, x.orgDomain()); +}; |