Skip to content

Commit

Permalink
Merge branch 'master' into configurable-logo
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderby committed Aug 2, 2016
2 parents 17800bd + 0db0bc9 commit 5eb8b69
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 33 deletions.
8 changes: 8 additions & 0 deletions Gruntfile.js
Expand Up @@ -159,6 +159,14 @@ module.exports = function (grunt) {
{
src: 'plugins/quick-filter.js',
dest: 'build/development/plugins/tauCharts.quick-filter.js'
},
{
src: 'plugins/floating-axes.js',
dest: 'build/development/plugins/tauCharts.floating-axes.js'
},
{
src: 'plugins/box-whiskers.js',
dest: 'build/development/plugins/tauCharts.box-whiskers.js'
}
].concat(cssConfig.css)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "taucharts",
"version": "0.9.2-beta.5",
"version": "0.9.3-beta.0",
"homepage": "https://github.com/TargetProcess/tauCharts",
"description": "D3 based data-focused charting library",
"author": {
Expand Down
20 changes: 6 additions & 14 deletions plugins/box-whiskers.js
Expand Up @@ -124,20 +124,12 @@
node.screenModel.model.scaleY.fixup(function (yScaleConfig) {
var newConf = {};

var fixed = false;

if (!yScaleConfig.hasOwnProperty('max') || yScaleConfig.max < maxY) {
newConf.max = maxY;
fixed = true;
}

if (!yScaleConfig.hasOwnProperty('min') || yScaleConfig.min > minY) {
newConf.min = minY;
fixed = true;
}

if (fixed) {
newConf.source = '?';
if (!yScaleConfig.hasOwnProperty('series')) {
newConf.series = [minY, maxY];
} else {
var min = Math.min(yScaleConfig.series[0], minY);
var max = Math.max(yScaleConfig.series[1], maxY);
newConf.series = [min, max];
}

return newConf;
Expand Down
4 changes: 2 additions & 2 deletions src/elements/coords.geomap.js
Expand Up @@ -424,7 +424,7 @@ export class GeoMap extends Element {

var updateGroups = function () {

this.attr('class', (f) => `frame-id-${options.uid} frame-${f.hash}`)
this.attr('class', (f) => `frame frame-${f.hash}`)
.call(function () {
var points = this
.selectAll('circle')
Expand All @@ -444,7 +444,7 @@ export class GeoMap extends Element {
var mapper = (f) => ({tags: f.key || {}, hash: f.hash(), data: f.part()});

var frameGroups = xmap
.selectAll('.frame-id-' + options.uid)
.selectAll('.frame')
.data(frames.map(mapper), (f) => f.hash);
frameGroups
.exit()
Expand Down
3 changes: 1 addition & 2 deletions src/elements/element.area.js
Expand Up @@ -50,12 +50,11 @@ export class Area extends BasePath {
};

var guide = this.config.guide;
var options = this.config.options;
var countCss = getLineClassesByCount(screenModel.model.scaleColor.domain().length);

const groupPref = `${CSS_PREFIX}area area i-role-path ${countCss} ${guide.cssClass} `;
baseModel.groupAttributes = {
class: (fiber) => `${groupPref} ${baseModel.class(fiber[0])} frame-${options.uid}`
class: (fiber) => `${groupPref} ${baseModel.class(fiber[0])} frame`
};

var areaPoints = (xi, yi, x0, y0) => {
Expand Down
5 changes: 2 additions & 3 deletions src/elements/element.interval.js
Expand Up @@ -138,7 +138,6 @@ export class Interval extends Element {
var self = this;

var options = this.config.options;
var uid = options.uid;
var config = this.config;
var prettify = config.guide.prettify;
var baseCssClass = this.baseCssClass;
Expand All @@ -154,7 +153,7 @@ export class Interval extends Element {
var barH = config.flip ? 'width' : 'height';
var barW = config.flip ? 'height' : 'width';
var updateBarContainer = function () {
this.attr('class', `frame-id-${uid} i-role-bar-group`);
this.attr('class', 'frame i-role-bar-group');
var bars = this.selectAll('.bar')
.data((fiber) => fiber, self.screenModel.id);
bars.exit()
Expand Down Expand Up @@ -201,7 +200,7 @@ export class Interval extends Element {

var elements = options
.container
.selectAll(`.frame-id-${uid}`)
.selectAll('.frame')
.data(fibers);
elements
.exit()
Expand Down
2 changes: 1 addition & 1 deletion src/elements/element.line.js
Expand Up @@ -112,7 +112,7 @@ export class Line extends BasePath {
.y(baseModel.y);

baseModel.groupAttributes = {
class: (fiber) => `${groupPref} ${baseModel.class(fiber[0])} frame-${options.uid}`
class: (fiber) => `${groupPref} ${baseModel.class(fiber[0])} frame`
};

baseModel.pathElement = this.isEmptySize ? 'path' : 'polygon';
Expand Down
2 changes: 1 addition & 1 deletion src/elements/element.path.base.js
Expand Up @@ -253,7 +253,7 @@ export class BasePath extends Element {

var frameGroups = options
.container
.selectAll(`.frame-${options.uid}`)
.selectAll('.frame')
.data(fibers);
frameGroups
.exit()
Expand Down
3 changes: 1 addition & 2 deletions src/elements/element.path.js
Expand Up @@ -44,12 +44,11 @@ export class Path extends BasePath {
};

var guide = this.config.guide;
var options = this.config.options;
var countCss = getLineClassesByCount(screenModel.model.scaleColor.domain().length);

const groupPref = `${CSS_PREFIX}area area i-role-path ${countCss} ${guide.cssClass} `;
baseModel.groupAttributes = {
class: (fiber) => `${groupPref} ${baseModel.class(fiber[0])} frame-${options.uid}`
class: (fiber) => `${groupPref} ${baseModel.class(fiber[0])} frame`
};

var pathPoints = (x, y) => {
Expand Down
4 changes: 2 additions & 2 deletions src/elements/element.point.js
Expand Up @@ -151,7 +151,7 @@ export class Point extends Element {

var updateGroups = function () {

this.attr('class', `frame-id-${options.uid}`)
this.attr('class', 'frame')
.call(function () {
var dots = this
.selectAll('circle')
Expand All @@ -177,7 +177,7 @@ export class Point extends Element {
.reduce((memo, k) => memo.concat([groups[k]]), []);

var frameGroups = options.container
.selectAll(`.frame-id-${options.uid}`)
.selectAll('.frame')
.data(fibers);
frameGroups
.exit()
Expand Down
11 changes: 6 additions & 5 deletions src/scales/base.js
Expand Up @@ -108,10 +108,11 @@ export class BaseScale {
}

getVarSet(arr, scale) {
return _(arr)
.chain()
.pluck(scale.dim)
.uniq(map_value(scale.dimType))
.value();

var series = scale.hasOwnProperty('series') ?
scale.series :
arr.map((row) => row[scale.dim]);

return _.uniq(series, map_value(scale.dimType));
}
}
50 changes: 50 additions & 0 deletions test/scales-factory.test.js
Expand Up @@ -906,5 +906,55 @@ define(function (require) {
expect(scale1(0)).to.equal('#eeeeee');
expect(scale1(110)).to.equal('#0000ff');
});

it('should support fixed series property in linear scale config', function () {

var scale0 = new LinearScale(
xSrc,
{
dim: 'i'
}).create([0, 100]);

expect(scale0.domain()).to.deep.equal([1, 3]);
expect(scale0(3)).to.equal(100);
expect(scale0.isContains(2)).to.equal(true);
expect(scale0.isContains(100)).to.equal(false);

var scale1 = new LinearScale(
xSrc,
{
dim: 'i',
series: [0, 100]
}).create([0, 100]);

expect(scale1.domain()).to.deep.equal([0, 100]);
expect(scale1(50)).to.equal(50);
expect(scale1.isContains(100)).to.equal(true);
expect(scale1.isContains(200)).to.equal(false);
});

it('should support fixed series property in ordinal scale config', function () {

var scale0 = new OrdinalScale(
xSrc,
{
dim: 'x'
}).create([0, 90]);

expect(scale0.domain()).to.deep.equal(['high', 'low', 'medium']);

var scale1 = new OrdinalScale(
xSrc,
{
dim: 'x',
series: ['A', 'B', 'C', 'D']
}).create([0, 100]);

expect(scale1.domain()).to.deep.equal(['A', 'B', 'C', 'D']);
expect(scale1.isContains('A')).to.equal(true);
expect(scale1.isContains('E')).to.equal(false);
expect(scale1('A')).to.equal(12.5);
expect(scale1('D')).to.equal(87.5);
});
});
});

0 comments on commit 5eb8b69

Please sign in to comment.