Browse Source

:despair:

v1-dev
Ændrew Rininsland 8 years ago
parent
commit
1cb60ed877
No known key found for this signature in database
GPG Key ID: ADBCD4C867F9B2DA
  1. 13
      .babelrc
  2. 8
      c3.js
  3. 2
      c3.js.map
  4. 2
      package.json
  5. 11
      spec-mocha/api.axis-spec.js
  6. 34
      spec-mocha/api.data-spec.js
  7. 22
      spec-mocha/c3-helper.js
  8. 4
      src/chart/api.chart.js
  9. 4
      src/internals/arc.js
  10. 5
      src/internals/clip.js
  11. 4
      src/internals/index.js
  12. 4
      src/internals/interaction.js
  13. 4
      src/internals/ua.js

13
.babelrc

@ -1,13 +0,0 @@
{
"presets": [
[
"es2015",
{
"modules": false
}
]
],
"plugins": [
"external-helpers"
]
}

8
c3.js

@ -1565,8 +1565,9 @@ var categoryName = function categoryName(i) {
};
var getClipPath = function getClipPath(id) {
var isIE9 = window.navigator.appVersion.toLowerCase().indexOf('msie 9.') >= 0;
return 'url(' + (isIE9 ? '' : document.URL.split('#')[0]) + '#' + id + ')';
var isIE9 = typeof window !== 'undefined' && window.navigator.appVersion.toLowerCase().indexOf('msie 9.') >= 0;
var isBrowser = typeof document !== 'undefined';
return 'url(' + (isIE9 ? '' : isBrowser ? document.URL.split('#')[0] : Date.now()) + '#' + id + ')';
};
var appendClip = function appendClip(parent, id) {
return parent.append('clipPath').attr('id', id).append('rect');
@ -6073,6 +6074,7 @@ var asHalfPixel$$1 = asHalfPixel$1;
var isEmpty$$1 = isEmpty$1;
var notEmpty$$1 = notEmpty$1;
var getOption$$1 = getOption$1;
// Start ChartInternal!!!!
function ChartInternal(api) {
var $$ = this;
$$.d3 = d3;
@ -8384,7 +8386,7 @@ c3_chart_fn.unzoom = unzoom;
* License: MIT
*/
var version = '0.4.11';
var version = '1.0.0';
var generate = function generate(config) {
return new Chart(config);

2
c3.js.map

File diff suppressed because one or more lines are too long

2
package.json

@ -1,6 +1,6 @@
{
"name": "c3",
"version": "0.4.11",
"version": "1.0.0",
"description": "D3-based reusable chart library",
"main": "c3.js",
"scripts": {

11
spec-mocha/api.axis-spec.js

@ -1,15 +1,15 @@
var expect = require('chai').expect;
import d3 from 'd3';
import { expect } from 'chai';
import { initChart } from './c3-helper';
describe('c3 api axis', function () {
var chart, args;
beforeEach(function (done) {
chart = window.initChart(chart, args, done);
chart = initChart(chart, args, done);
});
describe('axis.labels', function () {
it('should update args', function () {
args = {
data: {
@ -32,11 +32,10 @@ describe('c3 api axis', function () {
}
}
};
});
it('should update y axis label', function () {
chart.axis.labels({y: 'New Y Axis Label'});
chart.axis.labels({ y: 'New Y Axis Label' });
var label = d3.select('.c3-axis-y-label');
expect(label.text()).to.equal('New Y Axis Label');
expect(label.attr('dx')).to.equal('-0.5em');

34
spec-mocha/api.data-spec.js

@ -1,8 +1,11 @@
var chai = require('chai');
var chaiColors = require('chai-color-helpers');
var expect = chai.expect;
import * as chai from 'chai';
import chaiColors from 'chai-colors';
import * as d3 from 'd3';
import { initChart } from './c3-helper';
chai.use(chaiColors);
const expect = chai.expect;
describe('c3 api data', function () {
var chart;
@ -34,11 +37,10 @@ describe('c3 api data', function () {
};
beforeEach(function (done) {
chart = window.initChart(chart, args, done);
chart = initChart(chart, args, done);
});
describe('data()', function () {
it('should return all of data if no argument given', function () {
var results = chart.data(),
expected = ['data1', 'data2'];
@ -59,11 +61,9 @@ describe('c3 api data', function () {
expect(results[0].id).to.equal('data1');
expect(results[1].id).to.equal('data2');
});
});
describe('data.shown()', function () {
it('should return only shown targets', function () {
var results;
chart.hide('data1');
@ -71,11 +71,9 @@ describe('c3 api data', function () {
expect(results.length).to.equal(1);
expect(results[0].id).to.equal('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];
@ -89,11 +87,9 @@ describe('c3 api data', function () {
var values = chart.data.values();
expect(values).to.be.null;
});
});
describe('data.names()', function () {
it('should return data.names specified as argument', function () {
var results = chart.data.names();
expect(results.data1).to.equal('Data Name 1');
@ -110,14 +106,12 @@ describe('c3 api data', function () {
});
it('should set data.names specified as api', function () {
expect(d3.select('.c3-legend-item-data1 text').text()).to.equal("New Data Name 1");
expect(d3.select('.c3-legend-item-data2 text').text()).to.equal("New Data Name 2");
expect(d3.select('.c3-legend-item-data1 text').text()).to.equal('New Data Name 1');
expect(d3.select('.c3-legend-item-data2 text').text()).to.equal('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).to.be.color('#FF0000');
@ -134,16 +128,14 @@ describe('c3 api data', function () {
});
it('should set data.colors specified as api', function () {
expect(d3.select('.c3-line-data1').style('stroke')).to.be.color("#00ff00");
expect(d3.select('.c3-line-data2').style('stroke')).to.be.color("#ff0000");
expect(d3.select('.c3-legend-item-data1 .c3-legend-item-tile').style('stroke')).to.be.color("#00ff00");
expect(d3.select('.c3-legend-item-data2 .c3-legend-item-tile').style('stroke')).to.be.color("#ff0000");
expect(d3.select('.c3-line-data1').style('stroke')).to.be.color('#00ff00');
expect(d3.select('.c3-line-data2').style('stroke')).to.be.color('#ff0000');
expect(d3.select('.c3-legend-item-data1 .c3-legend-item-tile').style('stroke')).to.be.color('#00ff00');
expect(d3.select('.c3-legend-item-data2 .c3-legend-item-tile').style('stroke')).to.be.color('#ff0000');
});
});
describe('data.axes()', function () {
it('should return data.axes specified as argument', function () {
var results = chart.data.axes();
expect(results.data1).to.equal('y');

22
spec-mocha/c3-helper.js

@ -1,13 +1,13 @@
import { jsdom } from 'jsdom';
import * as c3 from '../src/index';
import * as c3 from '../c3';
export function initDom() {
var div = jsdom('<div></div>');
div.id = 'chart';
var document = jsdom('<div id="chart"></div>');
var div = document.getElementById('chart');
div.style.width = '640px';
div.style.height = '480px';
document.body.appendChild(div);
document.body.style.margin = '0px';
return div;
}
// export function setMouseEvent(chart, name, x, y, element) {
@ -20,20 +20,14 @@ export function initDom() {
// if (element) { element.dispatchEvent(event); }
// }
export function initChart(chart, args, done) {
export function initChart(chart, args = {}, done) {
if (typeof chart === 'undefined') {
initDom();
args.bindto = initDom();
}
if (args) {
chart = c3.generate(args);
global.d3 = chart.internal.d3;
global.d3.select('.jasmine_html-reporter')
.style('position', 'absolute')
.style('width', '640px')
.style('right', 0);
}
window.setTimeout(function () {
setTimeout(function () {
done();
}, 10);

4
src/chart/api.chart.js

@ -1,3 +1,7 @@
if (!window) {
const window = global;
}
const resize = function (size) {
let $$ = this.internal, config = $$.config;
config.size_width = size ? size.width : null;

4
src/internals/arc.js

@ -1,6 +1,10 @@
import { CLASS } from './class';
import { isFunction } from './util';
if (!window) {
const window = global;
}
const initPie = function () {
let $$ = this, d3 = $$.d3, config = $$.config;
$$.pie = d3.layout.pie().value((d) => {

5
src/internals/clip.js

@ -1,6 +1,7 @@
const getClipPath = function (id) {
const isIE9 = window.navigator.appVersion.toLowerCase().indexOf('msie 9.') >= 0;
return 'url(' + (isIE9 ? '' : document.URL.split('#')[0]) + '#' + id + ')';
const isIE9 = typeof window !== 'undefined' && window.navigator.appVersion.toLowerCase().indexOf('msie 9.') >= 0;
const isBrowser = typeof document !== 'undefined';
return 'url(' + (isIE9 ? '' : isBrowser ? document.URL.split('#')[0] : Date.now()) + '#' + id + ')';
};
const appendClip = function (parent, id) {
return parent.append('clipPath').attr('id', id).append('rect');

4
src/internals/index.js

@ -449,6 +449,10 @@ export const {
getPathBox,
} = util;
if (!window) {
const window = global;
}
// Start ChartInternal!!!!
function ChartInternal(api) {
const $$ = this;

4
src/internals/interaction.js

@ -1,5 +1,9 @@
import { CLASS } from './class';
if (!window) {
const window = global;
}
const initEventRect = function () {
const $$ = this;
$$.main.select('.' + CLASS.chart).append('g')

4
src/internals/ua.js

@ -1,3 +1,7 @@
if (!window) {
const window = global;
}
const isSafari = function () {
const ua = window.navigator.userAgent;
return ua.indexOf('Safari') >= 0 && ua.indexOf('Chrome') < 0;

Loading…
Cancel
Save