first commit
This commit is contained in:
1
libraries/framework/vendor/plugins/c3charts/c3.min.css
vendored
Normal file
1
libraries/framework/vendor/plugins/c3charts/c3.min.css
vendored
Normal file
@@ -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-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}.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 .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}
|
||||
5
libraries/framework/vendor/plugins/c3charts/c3.min.js
vendored
Normal file
5
libraries/framework/vendor/plugins/c3charts/c3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
libraries/framework/vendor/plugins/c3charts/d3.min.js
vendored
Normal file
5
libraries/framework/vendor/plugins/c3charts/d3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
11
libraries/framework/vendor/plugins/c3charts/extensions/exporter/config.json
vendored
Normal file
11
libraries/framework/vendor/plugins/c3charts/extensions/exporter/config.json
vendored
Normal file
@@ -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>"
|
||||
}
|
||||
140
libraries/framework/vendor/plugins/c3charts/extensions/exporter/phantom-exporter.js
vendored
Normal file
140
libraries/framework/vendor/plugins/c3charts/extensions/exporter/phantom-exporter.js
vendored
Normal file
@@ -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);
|
||||
BIN
libraries/framework/vendor/plugins/c3charts/extensions/exporter/test.png
vendored
Normal file
BIN
libraries/framework/vendor/plugins/c3charts/extensions/exporter/test.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
380
libraries/framework/vendor/plugins/c3charts/extensions/js/c3ext.js
vendored
Normal file
380
libraries/framework/vendor/plugins/c3charts/extensions/js/c3ext.js
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
36
libraries/framework/vendor/plugins/c3charts/require.js
vendored
Normal file
36
libraries/framework/vendor/plugins/c3charts/require.js
vendored
Normal file
@@ -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);
|
||||
170
libraries/framework/vendor/plugins/c3charts/spec/api.data-spec.js
vendored
Normal file
170
libraries/framework/vendor/plugins/c3charts/spec/api.data-spec.js
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 api data', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
433
libraries/framework/vendor/plugins/c3charts/spec/api.focus-spec.js
vendored
Normal file
433
libraries/framework/vendor/plugins/c3charts/spec/api.focus-spec.js
vendored
Normal file
@@ -0,0 +1,433 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 api load', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
});
|
||||
}, 500);
|
||||
|
||||
});
|
||||
|
||||
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.style('opacity')).toBeCloseTo(1);
|
||||
});
|
||||
done();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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.style('opacity')).toBeCloseTo(1);
|
||||
});
|
||||
done();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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);
|
||||
done();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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);
|
||||
done();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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);
|
||||
done();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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);
|
||||
done();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
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();
|
||||
}, 500);
|
||||
}, 500);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
122
libraries/framework/vendor/plugins/c3charts/spec/api.grid-spec.js
vendored
Normal file
122
libraries/framework/vendor/plugins/c3charts/spec/api.grid-spec.js
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 api grid', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
var args = {
|
||||
data: {
|
||||
columns: [
|
||||
['data1', 30, 200, 100, 400, 150, 250]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
chart = window.initChart(chart, args, done);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
describe('ygrid.add and ygrid.remove', function () {
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
124
libraries/framework/vendor/plugins/c3charts/spec/api.load-spec.js
vendored
Normal file
124
libraries/framework/vendor/plugins/c3charts/spec/api.load-spec.js
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 api load', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
var args = {
|
||||
data: {
|
||||
columns: [
|
||||
['data1', 30, 200, 100, 400, 150, 250],
|
||||
['data2', 5000, 2000, 1000, 4000, 1500, 2500]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
chart = window.initChart(chart, args, done);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
describe('indexed data', function () {
|
||||
|
||||
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');
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
126
libraries/framework/vendor/plugins/c3charts/spec/api.zoom-spec.js
vendored
Normal file
126
libraries/framework/vendor/plugins/c3charts/spec/api.zoom-spec.js
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 api zoom', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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]
|
||||
]
|
||||
},
|
||||
zoom: {
|
||||
enabled: true
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
if (typeof chart === 'undefined') {
|
||||
window.initDom();
|
||||
}
|
||||
chart = window.c3.generate(args);
|
||||
d3 = chart.internal.d3;
|
||||
// chart.internal.d3.select('.jasmine_html-reporter').style('display', 'none');
|
||||
|
||||
window.setTimeout(function () {
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
|
||||
describe('zoom', function () {
|
||||
|
||||
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]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
78
libraries/framework/vendor/plugins/c3charts/spec/arc-spec.js
vendored
Normal file
78
libraries/framework/vendor/plugins/c3charts/spec/arc-spec.js
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart axis', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3, args;
|
||||
|
||||
beforeEach(function (done) {
|
||||
if (typeof chart === 'undefined') {
|
||||
window.initDom();
|
||||
}
|
||||
chart = window.c3.generate(args);
|
||||
d3 = chart.internal.d3;
|
||||
chart.internal.d3.select('.jasmine_html-reporter')
|
||||
.style('position', 'absolute')
|
||||
.style('right', 0);
|
||||
|
||||
window.setTimeout(function () {
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
||||
describe('show pie chart', function () {
|
||||
|
||||
args = {
|
||||
data: {
|
||||
columns: [
|
||||
['data1', 30],
|
||||
['data2', 150],
|
||||
['data3', 120]
|
||||
],
|
||||
type: 'pie'
|
||||
}
|
||||
};
|
||||
|
||||
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 () {
|
||||
expect(d3.select('.c3-arc-black').attr('d')).toMatch(/M-124\..+,-171\..+A211\..+,211\..+ 0 0,1 -3\..+,-211\..+L0,0Z/);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
767
libraries/framework/vendor/plugins/c3charts/spec/axis-spec.js
vendored
Normal file
767
libraries/framework/vendor/plugins/c3charts/spec/axis-spec.js
vendored
Normal file
@@ -0,0 +1,767 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart axis', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
describe('axis.y.tick.count', function () {
|
||||
|
||||
var i = 1;
|
||||
|
||||
beforeEach(function () {
|
||||
args.axis.y.tick.count = i++;
|
||||
chart = window.c3.generate(args);
|
||||
});
|
||||
|
||||
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 have 2 ticks on y axis', function () {
|
||||
var ticksSize = d3.select('.c3-axis-y').selectAll('g.tick').size();
|
||||
expect(ticksSize).toBe(2);
|
||||
});
|
||||
|
||||
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];
|
||||
|
||||
beforeEach(function () {
|
||||
args.axis.y.tick.values = values;
|
||||
chart = window.c3.generate(args);
|
||||
});
|
||||
|
||||
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 () {
|
||||
|
||||
var args = {
|
||||
data: {
|
||||
columns: [
|
||||
["times", 60000, 120000, 180000, 240000]
|
||||
]
|
||||
},
|
||||
axis: {
|
||||
y: {
|
||||
type : 'timeseries',
|
||||
tick: {
|
||||
time: {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
chart = window.c3.generate(args);
|
||||
});
|
||||
|
||||
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(4);
|
||||
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();
|
||||
expect(box.height).toBeGreaterThan(50);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
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).toBe(50);
|
||||
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(39);
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
43
libraries/framework/vendor/plugins/c3charts/spec/c3-helper.js
vendored
Normal file
43
libraries/framework/vendor/plugins/c3charts/spec/c3-helper.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
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();
|
||||
}
|
||||
chart = window.c3.generate(args);
|
||||
chart.internal.d3.select('.jasmine_html-reporter')
|
||||
.style('position', 'absolute')
|
||||
.style('right', 0);
|
||||
|
||||
window.setTimeout(function () {
|
||||
done();
|
||||
}, 10);
|
||||
|
||||
return chart;
|
||||
}
|
||||
typeof initChart !== 'undefined';
|
||||
15
libraries/framework/vendor/plugins/c3charts/spec/c3-spec.js
vendored
Normal file
15
libraries/framework/vendor/plugins/c3charts/spec/c3-spec.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it;
|
||||
|
||||
describe('c3', function () {
|
||||
'use strict';
|
||||
|
||||
var c3 = window.c3;
|
||||
|
||||
it('exists', function () {
|
||||
expect(c3).not.toBeNull();
|
||||
expect(typeof c3).toBe('object');
|
||||
});
|
||||
});
|
||||
|
||||
67
libraries/framework/vendor/plugins/c3charts/spec/class-spec.js
vendored
Normal file
67
libraries/framework/vendor/plugins/c3charts/spec/class-spec.js
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart class', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
118
libraries/framework/vendor/plugins/c3charts/spec/core-spec.js
vendored
Normal file
118
libraries/framework/vendor/plugins/c3charts/spec/core-spec.js
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
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 () {
|
||||
|
||||
it('should accept d3.selection object', function () {
|
||||
args.bindto = d3.select('#chart');
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be created', function () {
|
||||
var svg = d3.select('#chart svg');
|
||||
expect(svg).not.toBeNull();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
831
libraries/framework/vendor/plugins/c3charts/spec/data-spec.js
vendored
Normal file
831
libraries/framework/vendor/plugins/c3charts/spec/data-spec.js
vendored
Normal file
@@ -0,0 +1,831 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart data', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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]
|
||||
],
|
||||
order: function () {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
chart = window.initChart(chart, args, done);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
describe('function in data.order', function () {
|
||||
it('should return false in isOrderAsc and isOrderDesc functions', function () {
|
||||
expect(chart.internal.isOrderAsc() || chart.internal.isOrderDesc()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('data.xs', function () {
|
||||
|
||||
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 () {
|
||||
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('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(+new Date(2014, 11, 3, 16, 1, 1, 123));
|
||||
expect(+xs.data1[1]).toBe(+new Date(2014, 11, 3, 16, 2, 2, 345));
|
||||
expect(+xs.data2[0]).toBe(+new Date(2014, 11, 3, 16, 1, 1, 123));
|
||||
expect(+xs.data2[1]).toBe(+new Date(2014, 11, 3, 16, 2, 2, 345));
|
||||
});
|
||||
});
|
||||
|
||||
describe('as unixtime string', function () {
|
||||
|
||||
it('should upate 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',
|
||||
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, 11, 3, 16, 1, 1, 123));
|
||||
expect(+xs.data1[1]).toBe(+new Date(2014, 11, 3, 16, 2, 2, 345));
|
||||
expect(+xs.data2[0]).toBe(+new Date(2014, 11, 3, 16, 1, 1, 123));
|
||||
expect(+xs.data2[1]).toBe(+new Date(2014, 11, 3, 16, 2, 2, 345));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('data.label', function () {
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
116
libraries/framework/vendor/plugins/c3charts/spec/domain-spec.js
vendored
Normal file
116
libraries/framework/vendor/plugins/c3charts/spec/domain-spec.js
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart axis', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
131
libraries/framework/vendor/plugins/c3charts/spec/grid-spec.js
vendored
Normal file
131
libraries/framework/vendor/plugins/c3charts/spec/grid-spec.js
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart grid', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
var args = {
|
||||
data: {
|
||||
columns: [
|
||||
['data1', 30, 200, 100, 400, 150, 250]
|
||||
]
|
||||
},
|
||||
axis: {
|
||||
y: {
|
||||
tick: {
|
||||
}
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
y: {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
chart = window.initChart(chart, args, done);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
describe('y grid', function () {
|
||||
|
||||
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('x grid lines', function () {
|
||||
|
||||
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], -1);
|
||||
expect(t.text()).toBe(expectedText[i]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
132
libraries/framework/vendor/plugins/c3charts/spec/interaction-spec.js
vendored
Normal file
132
libraries/framework/vendor/plugins/c3charts/spec/interaction-spec.js
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart interaction', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
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).toBe(lefts[i]);
|
||||
expect(box.width).toBe(widths[i]);
|
||||
});
|
||||
});
|
||||
|
||||
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).toBe(40.5);
|
||||
expect(box.width).toBe(598);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
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).toBe(lefts[i]);
|
||||
expect(box.width).toBe(widths[i]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
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).toBe(40.5);
|
||||
expect(box.width).toBe(598);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
186
libraries/framework/vendor/plugins/c3charts/spec/legend-spec.js
vendored
Normal file
186
libraries/framework/vendor/plugins/c3charts/spec/legend-spec.js
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart legend', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
var args = {
|
||||
data: {
|
||||
columns: [
|
||||
['data1', 30, 200, 100, 400, 150, 250],
|
||||
['data2', 50, 20, 10, 40, 15, 25]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
if (typeof chart === 'undefined') {
|
||||
window.initDom();
|
||||
}
|
||||
chart = window.c3.generate(args);
|
||||
d3 = chart.internal.d3;
|
||||
chart.internal.d3.select('.jasmine_html-reporter')
|
||||
.style('position', 'absolute')
|
||||
.style('right', 0);
|
||||
|
||||
window.setTimeout(function () {
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
|
||||
describe('legend position', function () {
|
||||
|
||||
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.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).toBe(60.5);
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
91
libraries/framework/vendor/plugins/c3charts/spec/shape.bar-spec.js
vendored
Normal file
91
libraries/framework/vendor/plugins/c3charts/spec/shape.bar-spec.js
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
var setMouseEvent = window.setMouseEvent;
|
||||
|
||||
describe('c3 chart shape bar', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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]
|
||||
],
|
||||
type: 'bar'
|
||||
},
|
||||
axis: {
|
||||
rotated: false
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
chart = window.initChart(chart, args, done);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
describe('internal.isWithinBar', function () {
|
||||
|
||||
describe('with normal axis', function () {
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
102
libraries/framework/vendor/plugins/c3charts/spec/shape.line-spec.js
vendored
Normal file
102
libraries/framework/vendor/plugins/c3charts/spec/shape.line-spec.js
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart shape line', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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]
|
||||
],
|
||||
type: 'line'
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
chart = window.initChart(chart, args, done);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
describe('shape-rendering for line chart', function () {
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
69
libraries/framework/vendor/plugins/c3charts/spec/tooltip-spec.js
vendored
Normal file
69
libraries/framework/vendor/plugins/c3charts/spec/tooltip-spec.js
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart tooltip', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
describe('tooltip position', function () {
|
||||
|
||||
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 = 307;
|
||||
expect(top).toBe(topExpected);
|
||||
expect(left).toBe(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 = 307;
|
||||
expect(top).toBe(topExpected);
|
||||
expect(left).toBe(leftExpected);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
140
libraries/framework/vendor/plugins/c3charts/spec/type-spec.js
vendored
Normal file
140
libraries/framework/vendor/plugins/c3charts/spec/type-spec.js
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart types', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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]
|
||||
],
|
||||
type: 'pie'
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
chart = window.initChart(chart, args, done);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
describe('internal.hasArcType', function () {
|
||||
|
||||
describe('with data', function () {
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
73
libraries/framework/vendor/plugins/c3charts/spec/zoom-spec.js
vendored
Normal file
73
libraries/framework/vendor/plugins/c3charts/spec/zoom-spec.js
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
var describe = window.describe,
|
||||
expect = window.expect,
|
||||
it = window.it,
|
||||
beforeEach = window.beforeEach;
|
||||
|
||||
describe('c3 chart zoom', function () {
|
||||
'use strict';
|
||||
|
||||
var chart, d3;
|
||||
|
||||
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);
|
||||
d3 = chart.internal.d3;
|
||||
});
|
||||
|
||||
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]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user