Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

c3

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

c3 - npm Package Compare versions

Comparing version 0.4.17 to 0.4.18

2

component.json

@@ -5,3 +5,3 @@ {

"description": "A D3-based reusable chart library",
"version": "0.4.17",
"version": "0.4.18",
"keywords": [],

@@ -8,0 +8,0 @@ "dependencies": {

{
"name": "c3",
"version": "0.4.17",
"version": "0.4.18",
"description": "D3-based reusable chart library",

@@ -63,3 +63,3 @@ "main": "c3.js",

"nodemon": "^1.11.0",
"rollup": "^0.47.4",
"rollup": "^0.49.0",
"rollup-plugin-babel": "^3.0.0",

@@ -66,0 +66,0 @@ "uglify-js": "^3.0.15",

@@ -100,2 +100,78 @@ describe('c3 chart arc', function () {

describe('sort pie chart', function() {
var createPie = function(order) {
return {
data: {
order: order,
columns: [
['data1', 30],
['data2', 150],
['data3', 120]
],
type: 'pie'
}
};
};
var collectArcs = function() {
return d3.selectAll('.c3-arc')
.data()
.sort(function(a, b) {
return a.startAngle - b.startAngle;
})
.map(function(item) {
return item.data.id;
});
};
it('should update data_order to desc', function () {
args = createPie('desc');
expect(true).toBeTruthy();
});
it('it should have descending ordering', function () {
expect(collectArcs()).toEqual([ 'data2', 'data3', 'data1' ]);
});
it('should update data_order to asc', function () {
args = createPie('asc');
expect(true).toBeTruthy();
});
it('it should have ascending ordering', function () {
expect(collectArcs()).toEqual([ 'data1', 'data3', 'data2' ]);
});
it('should update data_order to NULL', function () {
args = createPie(null);
expect(true).toBeTruthy();
});
it('it should have no ordering', function () {
expect(collectArcs()).toEqual([ 'data1', 'data2', 'data3' ]);
});
it('should update data_order to Array', function () {
args = createPie([ 'data3', 'data2', 'data1' ]);
expect(true).toBeTruthy();
});
it('it should have array specified ordering', function () {
expect(collectArcs()).toEqual([ 'data3', 'data2', 'data1' ]);
});
it('should update data_order to Function', function () {
var names = [ 'data2', 'data1', 'data3' ];
args = createPie(function(a, b) {
return names.indexOf(a.id) - names.indexOf(b.id);
});
expect(true).toBeTruthy();
});
it('it should have array specified ordering', function () {
expect(collectArcs()).toEqual([ 'data2', 'data1', 'data3' ]);
});
});
describe('show gauge', function () {

@@ -102,0 +178,0 @@

@@ -238,3 +238,3 @@ describe('c3 chart axis', function () {

var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'),
expectedTexts = ['very long tick text', 'on x axis'],
expectedTexts = ['very long tick text on x', 'axis'],
expectedX = '0';

@@ -319,3 +319,3 @@ expect(ticks.size()).toBe(6);

var ticks = chart.internal.main.select('.c3-axis-x').selectAll('g.tick'),
expectedTexts = ['very long tick', 'text on x axis'],
expectedTexts = ['very long tick text on', 'x axis'],
expectedX = '-9';

@@ -411,5 +411,5 @@ expect(ticks.size()).toBe(6);

expectedTickTexts = [
'this is a very',
'long tick text',
'on category axis'
'this is a very long',
'tick text on category',
'axis'
],

@@ -459,5 +459,5 @@ expectedX = '0';

expectedTickTexts = [
'this is a very',
'long tick text on',
'category axis'
'this is a very long',
'tick text on category',
'axis'
],

@@ -511,4 +511,4 @@ expectedX = '-9';

expectedTickTexts = [
'this is a very long tick',
'text on category axis'
'this is a very long tick text on',
'category axis'
],

@@ -515,0 +515,0 @@ expectedX = '-9';

@@ -1097,3 +1097,3 @@ describe('c3 chart data', function () {

var domain = chart.internal.y.domain();
expect(domain[0]).toBeCloseTo(-259, -1);
expect(domain[0]).toBeCloseTo(-253, -1);
expect(domain[1]).toBeCloseTo(260, -1);

@@ -1121,3 +1121,3 @@ });

var domain = chart.internal.y.domain();
expect(domain[0]).toBeCloseTo(-259, -1);
expect(domain[0]).toBeCloseTo(-253, -1);
expect(domain[1]).toBeCloseTo(260, -1);

@@ -1354,4 +1354,4 @@ });

var domain = chart.internal.y.domain();
expect(domain[0]).toBeCloseTo(-899, -1);
expect(domain[1]).toBeCloseTo(101, -1.2);
expect(domain[0]).toBeCloseTo(-893, -1);
expect(domain[1]).toBeCloseTo(93, -1);
});

@@ -1358,0 +1358,0 @@

@@ -6,9 +6,7 @@ import CLASS from './class';

c3_chart_internal_fn.initPie = function () {
var $$ = this, d3 = $$.d3, config = $$.config;
var $$ = this, d3 = $$.d3;
$$.pie = d3.layout.pie().value(function (d) {
return d.values.reduce(function (a, b) { return a + b.value; }, 0);
});
if (!config.data_order) {
$$.pie.sort(null);
}
$$.pie.sort($$.getOrderFunction() || null);
};

@@ -15,0 +13,0 @@

import CLASS from './class';
import { inherit, API } from './core';
import { Component } from './core';
import { isValue, isFunction, isString, isEmpty } from './util';
import c3_axis from './c3.axis';
export default function Axis(owner) {
API.call(this, owner);
export var c3_axis_fn;
export var c3_axis_internal_fn;
function AxisInternal(component, params) {
var internal = this;
internal.component = component;
internal.params = params || {};
internal.d3 = component.d3;
internal.scale = internal.d3.scale.linear();
internal.range;
internal.orient = "bottom";
internal.innerTickSize = 6;
internal.outerTickSize = this.params.withOuterTick ? 6 : 0;
internal.tickPadding = 3;
internal.tickValues = null;
internal.tickFormat;
internal.tickArguments;
internal.tickOffset = 0;
internal.tickCulling = true;
internal.tickCentered;
internal.tickTextCharSize;
internal.tickTextRotate = internal.params.tickTextRotate;
internal.tickLength;
internal.axis = internal.generateAxis();
}
c3_axis_internal_fn = AxisInternal.prototype;
inherit(API, Axis);
c3_axis_internal_fn.axisX = function (selection, x, tickOffset) {
selection.attr("transform", function (d) {
return "translate(" + Math.ceil(x(d) + tickOffset) + ", 0)";
});
};
c3_axis_internal_fn.axisY = function (selection, y) {
selection.attr("transform", function (d) {
return "translate(0," + Math.ceil(y(d)) + ")";
});
};
c3_axis_internal_fn.scaleExtent = function (domain) {
var start = domain[0], stop = domain[domain.length - 1];
return start < stop ? [ start, stop ] : [ stop, start ];
};
c3_axis_internal_fn.generateTicks = function (scale) {
var internal = this;
var i, domain, ticks = [];
if (scale.ticks) {
return scale.ticks.apply(scale, internal.tickArguments);
}
domain = scale.domain();
for (i = Math.ceil(domain[0]); i < domain[1]; i++) {
ticks.push(i);
}
if (ticks.length > 0 && ticks[0] > 0) {
ticks.unshift(ticks[0] - (ticks[1] - ticks[0]));
}
return ticks;
};
c3_axis_internal_fn.copyScale = function () {
var internal = this;
var newScale = internal.scale.copy(), domain;
if (internal.params.isCategory) {
domain = internal.scale.domain();
newScale.domain([domain[0], domain[1] - 1]);
}
return newScale;
};
c3_axis_internal_fn.textFormatted = function (v) {
var internal = this,
formatted = internal.tickFormat ? internal.tickFormat(v) : v;
return typeof formatted !== 'undefined' ? formatted : '';
};
c3_axis_internal_fn.updateRange = function () {
var internal = this;
internal.range = internal.scale.rangeExtent ? internal.scale.rangeExtent() : internal.scaleExtent(internal.scale.range());
return internal.range;
};
c3_axis_internal_fn.updateTickTextCharSize = function (tick) {
var internal = this;
if (internal.tickTextCharSize) {
return internal.tickTextCharSize;
}
var size = {
h: 11.5,
w: 5.5
};
tick.select('text').text(function(d) { return internal.textFormatted(d); }).each(function (d) {
var box = this.getBoundingClientRect(),
text = internal.textFormatted(d),
h = box.height,
w = text ? (box.width / text.length) : undefined;
if (h && w) {
size.h = h;
size.w = w;
}
}).text('');
internal.tickTextCharSize = size;
return size;
};
c3_axis_internal_fn.transitionise = function (selection) {
return this.params.withoutTransition ? selection : this.d3.transition(selection);
};
c3_axis_internal_fn.isVertical = function () {
return this.orient === 'left' || this.orient === 'right';
};
c3_axis_internal_fn.tspanData = function (d, i, ticks, scale) {
var internal = this;
var splitted = internal.params.tickMultiline ? internal.splitTickText(d, ticks, scale) : [].concat(internal.textFormatted(d));
return splitted.map(function (s) {
return { index: i, splitted: s, length: splitted.length };
});
};
c3_axis_internal_fn.splitTickText = function (d, ticks, scale) {
var internal = this,
tickText = internal.textFormatted(d),
maxWidth = internal.params.tickWidth,
subtext, spaceIndex, textWidth, splitted = [];
Axis.prototype.init = function init() {
if (Object.prototype.toString.call(tickText) === "[object Array]") {
return tickText;
}
if (!maxWidth || maxWidth <= 0) {
maxWidth = internal.isVertical() ? 95 : internal.params.isCategory ? (Math.ceil(scale(ticks[1]) - scale(ticks[0])) - 12) : 110;
}
function split(splitted, text) {
spaceIndex = undefined;
for (var i = 1; i < text.length; i++) {
if (text.charAt(i) === ' ') {
spaceIndex = i;
}
subtext = text.substr(0, i + 1);
textWidth = internal.tickTextCharSize.w * subtext.length;
// if text width gets over tick width, split by space index or crrent index
if (maxWidth < textWidth) {
return split(
splitted.concat(text.substr(0, spaceIndex ? spaceIndex : i)),
text.slice(spaceIndex ? spaceIndex + 1 : i)
);
}
}
return splitted.concat(text);
}
return split(splitted, tickText + "");
};
c3_axis_internal_fn.updateTickLength = function () {
var internal = this;
internal.tickLength = Math.max(internal.innerTickSize, 0) + internal.tickPadding;
};
c3_axis_internal_fn.lineY2 = function (d) {
var internal = this,
tickPosition = internal.scale(d) + (internal.tickCentered ? 0 : internal.tickOffset);
return internal.range[0] < tickPosition && tickPosition < internal.range[1] ? internal.innerTickSize : 0;
};
c3_axis_internal_fn.textY = function (){
var internal = this, rotate = internal.tickTextRotate;
return rotate ? 11.5 - 2.5 * (rotate / 15) * (rotate > 0 ? 1 : -1) : internal.tickLength;
};
c3_axis_internal_fn.textTransform = function () {
var internal = this, rotate = internal.tickTextRotate;
return rotate ? "rotate(" + rotate + ")" : "";
};
c3_axis_internal_fn.textTextAnchor = function () {
var internal = this, rotate = internal.tickTextRotate;
return rotate ? (rotate > 0 ? "start" : "end") : "middle";
};
c3_axis_internal_fn.tspanDx = function () {
var internal = this, rotate = internal.tickTextRotate;
return rotate ? 8 * Math.sin(Math.PI * (rotate / 180)) : 0;
};
c3_axis_internal_fn.tspanDy = function (d, i) {
var internal = this,
dy = internal.tickTextCharSize.h;
if (i === 0) {
if (internal.isVertical()) {
dy = -((d.length - 1) * (internal.tickTextCharSize.h / 2) - 3);
} else {
dy = ".71em";
}
}
return dy;
};
c3_axis_internal_fn.generateAxis = function () {
var internal = this, d3 = internal.d3, params = internal.params;
function axis(g) {
g.each(function () {
var g = axis.g = d3.select(this);
var scale0 = this.__chart__ || internal.scale,
scale1 = this.__chart__ = internal.copyScale();
var ticks = internal.tickValues ? internal.tickValues : internal.generateTicks(scale1),
tick = g.selectAll(".tick").data(ticks, scale1),
tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", 1e-6),
// MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks.
tickExit = tick.exit().remove(),
tickUpdate = internal.transitionise(tick).style("opacity", 1),
tickTransform, tickX, tickY;
if (params.isCategory) {
internal.tickOffset = Math.ceil((scale1(1) - scale1(0)) / 2);
tickX = internal.tickCentered ? 0 : internal.tickOffset;
tickY = internal.tickCentered ? internal.tickOffset : 0;
} else {
internal.tickOffset = tickX = 0;
}
tickEnter.append("line");
tickEnter.append("text");
internal.updateRange();
internal.updateTickLength();
internal.updateTickTextCharSize(g.select('.tick'));
var lineUpdate = tickUpdate.select("line"),
textUpdate = tickUpdate.select("text"),
tspanUpdate = tick.select("text").selectAll('tspan')
.data(function (d, i) { return internal.tspanData(d, i, ticks, scale1); });
tspanUpdate.enter().append('tspan');
tspanUpdate.exit().remove();
tspanUpdate.text(function (d) { return d.splitted; });
var path = g.selectAll(".domain").data([ 0 ]),
pathUpdate = (path.enter().append("path").attr("class", "domain"), internal.transitionise(path));
// TODO: each attr should be one function and change its behavior by internal.orient, probably
switch (internal.orient) {
case "bottom":
{
tickTransform = internal.axisX;
lineUpdate.attr("x1", tickX)
.attr("x2", tickX)
.attr("y2", function (d, i) { return internal.lineY2(d, i); });
textUpdate.attr("x", 0)
.attr("y", function (d, i) { return internal.textY(d, i); })
.attr("transform", function (d, i) { return internal.textTransform(d, i); })
.style("text-anchor", function (d, i) { return internal.textTextAnchor(d, i); });
tspanUpdate.attr('x', 0)
.attr("dy", function (d, i) { return internal.tspanDy(d, i); })
.attr('dx', function (d, i) { return internal.tspanDx(d, i); });
pathUpdate.attr("d", "M" + internal.range[0] + "," + internal.outerTickSize + "V0H" + internal.range[1] + "V" + internal.outerTickSize);
break;
}
case "top":
{
// TODO: rotated tick text
tickTransform = internal.axisX;
lineUpdate.attr("x2", 0)
.attr("y2", -internal.innerTickSize);
textUpdate.attr("x", 0)
.attr("y", -internal.tickLength)
.style("text-anchor", "middle");
tspanUpdate.attr('x', 0)
.attr("dy", "0em");
pathUpdate.attr("d", "M" + internal.range[0] + "," + -internal.outerTickSize + "V0H" + internal.range[1] + "V" + -internal.outerTickSize);
break;
}
case "left":
{
tickTransform = internal.axisY;
lineUpdate.attr("x2", -internal.innerTickSize)
.attr("y1", tickY)
.attr("y2", tickY);
textUpdate.attr("x", -internal.tickLength)
.attr("y", internal.tickOffset)
.style("text-anchor", "end");
tspanUpdate.attr('x', -internal.tickLength)
.attr("dy", function (d, i) { return internal.tspanDy(d, i); });
pathUpdate.attr("d", "M" + -internal.outerTickSize + "," + internal.range[0] + "H0V" + internal.range[1] + "H" + -internal.outerTickSize);
break;
}
case "right":
{
tickTransform = internal.axisY;
lineUpdate.attr("x2", internal.innerTickSize)
.attr("y2", 0);
textUpdate.attr("x", internal.tickLength)
.attr("y", 0)
.style("text-anchor", "start");
tspanUpdate.attr('x', internal.tickLength)
.attr("dy", function (d, i) { return internal.tspanDy(d, i); });
pathUpdate.attr("d", "M" + internal.outerTickSize + "," + internal.range[0] + "H0V" + internal.range[1] + "H" + internal.outerTickSize);
break;
}
}
if (scale1.rangeBand) {
var x = scale1, dx = x.rangeBand() / 2;
scale0 = scale1 = function (d) {
return x(d) + dx;
};
} else if (scale0.rangeBand) {
scale0 = scale1;
} else {
tickExit.call(tickTransform, scale1, internal.tickOffset);
}
tickEnter.call(tickTransform, scale0, internal.tickOffset);
tickUpdate.call(tickTransform, scale1, internal.tickOffset);
});
}
axis.scale = function (x) {
if (!arguments.length) { return internal.scale; }
internal.scale = x;
return axis;
};
axis.orient = function (x) {
if (!arguments.length) { return internal.orient; }
internal.orient = x in {top: 1, right: 1, bottom: 1, left: 1} ? x + "" : "bottom";
return axis;
};
axis.tickFormat = function (format) {
if (!arguments.length) { return internal.tickFormat; }
internal.tickFormat = format;
return axis;
};
axis.tickCentered = function (isCentered) {
if (!arguments.length) { return internal.tickCentered; }
internal.tickCentered = isCentered;
return axis;
};
axis.tickOffset = function () {
return internal.tickOffset;
};
axis.tickInterval = function () {
var interval, length;
if (params.isCategory) {
interval = internal.tickOffset * 2;
}
else {
length = axis.g.select('path.domain').node().getTotalLength() - internal.outerTickSize * 2;
interval = length / axis.g.selectAll('line').size();
}
return interval === Infinity ? 0 : interval;
};
axis.ticks = function () {
if (!arguments.length) { return internal.tickArguments; }
internal.tickArguments = arguments;
return axis;
};
axis.tickCulling = function (culling) {
if (!arguments.length) { return internal.tickCulling; }
internal.tickCulling = culling;
return axis;
};
axis.tickValues = function (x) {
if (typeof x === 'function') {
internal.tickValues = function () {
return x(internal.scale.domain());
};
}
else {
if (!arguments.length) { return internal.tickValues; }
internal.tickValues = x;
}
return axis;
};
return axis;
};
export default class Axis extends Component {
constructor (owner) {
var fn = {
fn: c3_axis_fn,
internal: {
fn: c3_axis_internal_fn
}
};
super(owner, 'axis', fn);
this.d3 = owner.d3;
this.internal = AxisInternal;
}
}
c3_axis_fn = Axis.prototype;
c3_axis_fn.init = function init() {
var $$ = this.owner, config = $$.config, main = $$.main;

@@ -44,3 +415,3 @@ $$.axes.x = main.append("g")

};
Axis.prototype.getXAxis = function getXAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) {
c3_axis_fn.getXAxis = function getXAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) {
var $$ = this.owner, config = $$.config,

@@ -55,3 +426,3 @@ axisParams = {

},
axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient);
axis = new this.internal(this, axisParams).axis.scale(scale).orient(orient);

@@ -73,3 +444,3 @@ if ($$.isTimeSeries() && tickValues && typeof tickValues !== "function") {

};
Axis.prototype.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) {
c3_axis_fn.updateXAxisTickValues = function updateXAxisTickValues(targets, axis) {
var $$ = this.owner, config = $$.config, tickValues;

@@ -87,3 +458,3 @@ if (config.axis_x_tick_fit || config.axis_x_tick_count) {

};
Axis.prototype.getYAxis = function getYAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) {
c3_axis_fn.getYAxis = function getYAxis(scale, orient, tickFormat, tickValues, withOuterTick, withoutTransition, withoutRotateTickText) {
var $$ = this.owner, config = $$.config,

@@ -95,3 +466,3 @@ axisParams = {

},
axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat);
axis = new this.internal(this, axisParams).axis.scale(scale).orient(orient).tickFormat(tickFormat);
if ($$.isTimeSeriesY()) {

@@ -104,7 +475,7 @@ axis.ticks($$.d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval);

};
Axis.prototype.getId = function getId(id) {
c3_axis_fn.getId = function getId(id) {
var config = this.owner.config;
return id in config.data_axes ? config.data_axes[id] : 'y';
};
Axis.prototype.getXAxisTickFormat = function getXAxisTickFormat() {
c3_axis_fn.getXAxisTickFormat = function getXAxisTickFormat() {
var $$ = this.owner, config = $$.config,

@@ -123,15 +494,15 @@ format = $$.isTimeSeries() ? $$.defaultAxisTimeFormat : $$.isCategorized() ? $$.categoryName : function (v) { return v < 0 ? v.toFixed(0) : v; };

};
Axis.prototype.getTickValues = function getTickValues(tickValues, axis) {
c3_axis_fn.getTickValues = function getTickValues(tickValues, axis) {
return tickValues ? tickValues : axis ? axis.tickValues() : undefined;
};
Axis.prototype.getXAxisTickValues = function getXAxisTickValues() {
c3_axis_fn.getXAxisTickValues = function getXAxisTickValues() {
return this.getTickValues(this.owner.config.axis_x_tick_values, this.owner.xAxis);
};
Axis.prototype.getYAxisTickValues = function getYAxisTickValues() {
c3_axis_fn.getYAxisTickValues = function getYAxisTickValues() {
return this.getTickValues(this.owner.config.axis_y_tick_values, this.owner.yAxis);
};
Axis.prototype.getY2AxisTickValues = function getY2AxisTickValues() {
c3_axis_fn.getY2AxisTickValues = function getY2AxisTickValues() {
return this.getTickValues(this.owner.config.axis_y2_tick_values, this.owner.y2Axis);
};
Axis.prototype.getLabelOptionByAxisId = function getLabelOptionByAxisId(axisId) {
c3_axis_fn.getLabelOptionByAxisId = function getLabelOptionByAxisId(axisId) {
var $$ = this.owner, config = $$.config, option;

@@ -147,7 +518,7 @@ if (axisId === 'y') {

};
Axis.prototype.getLabelText = function getLabelText(axisId) {
c3_axis_fn.getLabelText = function getLabelText(axisId) {
var option = this.getLabelOptionByAxisId(axisId);
return isString(option) ? option : option ? option.text : null;
};
Axis.prototype.setLabelText = function setLabelText(axisId, text) {
c3_axis_fn.setLabelText = function setLabelText(axisId, text) {
var $$ = this.owner, config = $$.config,

@@ -167,3 +538,3 @@ option = this.getLabelOptionByAxisId(axisId);

};
Axis.prototype.getLabelPosition = function getLabelPosition(axisId, defaultPosition) {
c3_axis_fn.getLabelPosition = function getLabelPosition(axisId, defaultPosition) {
var option = this.getLabelOptionByAxisId(axisId),

@@ -182,24 +553,24 @@ position = (option && typeof option === 'object' && option.position) ? option.position : defaultPosition;

};
Axis.prototype.getXAxisLabelPosition = function getXAxisLabelPosition() {
c3_axis_fn.getXAxisLabelPosition = function getXAxisLabelPosition() {
return this.getLabelPosition('x', this.owner.config.axis_rotated ? 'inner-top' : 'inner-right');
};
Axis.prototype.getYAxisLabelPosition = function getYAxisLabelPosition() {
c3_axis_fn.getYAxisLabelPosition = function getYAxisLabelPosition() {
return this.getLabelPosition('y', this.owner.config.axis_rotated ? 'inner-right' : 'inner-top');
};
Axis.prototype.getY2AxisLabelPosition = function getY2AxisLabelPosition() {
c3_axis_fn.getY2AxisLabelPosition = function getY2AxisLabelPosition() {
return this.getLabelPosition('y2', this.owner.config.axis_rotated ? 'inner-right' : 'inner-top');
};
Axis.prototype.getLabelPositionById = function getLabelPositionById(id) {
c3_axis_fn.getLabelPositionById = function getLabelPositionById(id) {
return id === 'y2' ? this.getY2AxisLabelPosition() : id === 'y' ? this.getYAxisLabelPosition() : this.getXAxisLabelPosition();
};
Axis.prototype.textForXAxisLabel = function textForXAxisLabel() {
c3_axis_fn.textForXAxisLabel = function textForXAxisLabel() {
return this.getLabelText('x');
};
Axis.prototype.textForYAxisLabel = function textForYAxisLabel() {
c3_axis_fn.textForYAxisLabel = function textForYAxisLabel() {
return this.getLabelText('y');
};
Axis.prototype.textForY2AxisLabel = function textForY2AxisLabel() {
c3_axis_fn.textForY2AxisLabel = function textForY2AxisLabel() {
return this.getLabelText('y2');
};
Axis.prototype.xForAxisLabel = function xForAxisLabel(forHorizontal, position) {
c3_axis_fn.xForAxisLabel = function xForAxisLabel(forHorizontal, position) {
var $$ = this.owner;

@@ -212,3 +583,3 @@ if (forHorizontal) {

};
Axis.prototype.dxForAxisLabel = function dxForAxisLabel(forHorizontal, position) {
c3_axis_fn.dxForAxisLabel = function dxForAxisLabel(forHorizontal, position) {
if (forHorizontal) {

@@ -220,3 +591,3 @@ return position.isLeft ? "0.5em" : position.isRight ? "-0.5em" : "0";

};
Axis.prototype.textAnchorForAxisLabel = function textAnchorForAxisLabel(forHorizontal, position) {
c3_axis_fn.textAnchorForAxisLabel = function textAnchorForAxisLabel(forHorizontal, position) {
if (forHorizontal) {

@@ -228,21 +599,21 @@ return position.isLeft ? 'start' : position.isCenter ? 'middle' : 'end';

};
Axis.prototype.xForXAxisLabel = function xForXAxisLabel() {
c3_axis_fn.xForXAxisLabel = function xForXAxisLabel() {
return this.xForAxisLabel(!this.owner.config.axis_rotated, this.getXAxisLabelPosition());
};
Axis.prototype.xForYAxisLabel = function xForYAxisLabel() {
c3_axis_fn.xForYAxisLabel = function xForYAxisLabel() {
return this.xForAxisLabel(this.owner.config.axis_rotated, this.getYAxisLabelPosition());
};
Axis.prototype.xForY2AxisLabel = function xForY2AxisLabel() {
c3_axis_fn.xForY2AxisLabel = function xForY2AxisLabel() {
return this.xForAxisLabel(this.owner.config.axis_rotated, this.getY2AxisLabelPosition());
};
Axis.prototype.dxForXAxisLabel = function dxForXAxisLabel() {
c3_axis_fn.dxForXAxisLabel = function dxForXAxisLabel() {
return this.dxForAxisLabel(!this.owner.config.axis_rotated, this.getXAxisLabelPosition());
};
Axis.prototype.dxForYAxisLabel = function dxForYAxisLabel() {
c3_axis_fn.dxForYAxisLabel = function dxForYAxisLabel() {
return this.dxForAxisLabel(this.owner.config.axis_rotated, this.getYAxisLabelPosition());
};
Axis.prototype.dxForY2AxisLabel = function dxForY2AxisLabel() {
c3_axis_fn.dxForY2AxisLabel = function dxForY2AxisLabel() {
return this.dxForAxisLabel(this.owner.config.axis_rotated, this.getY2AxisLabelPosition());
};
Axis.prototype.dyForXAxisLabel = function dyForXAxisLabel() {
c3_axis_fn.dyForXAxisLabel = function dyForXAxisLabel() {
var $$ = this.owner, config = $$.config,

@@ -256,3 +627,3 @@ position = this.getXAxisLabelPosition();

};
Axis.prototype.dyForYAxisLabel = function dyForYAxisLabel() {
c3_axis_fn.dyForYAxisLabel = function dyForYAxisLabel() {
var $$ = this.owner,

@@ -266,3 +637,3 @@ position = this.getYAxisLabelPosition();

};
Axis.prototype.dyForY2AxisLabel = function dyForY2AxisLabel() {
c3_axis_fn.dyForY2AxisLabel = function dyForY2AxisLabel() {
var $$ = this.owner,

@@ -276,15 +647,15 @@ position = this.getY2AxisLabelPosition();

};
Axis.prototype.textAnchorForXAxisLabel = function textAnchorForXAxisLabel() {
c3_axis_fn.textAnchorForXAxisLabel = function textAnchorForXAxisLabel() {
var $$ = this.owner;
return this.textAnchorForAxisLabel(!$$.config.axis_rotated, this.getXAxisLabelPosition());
};
Axis.prototype.textAnchorForYAxisLabel = function textAnchorForYAxisLabel() {
c3_axis_fn.textAnchorForYAxisLabel = function textAnchorForYAxisLabel() {
var $$ = this.owner;
return this.textAnchorForAxisLabel($$.config.axis_rotated, this.getYAxisLabelPosition());
};
Axis.prototype.textAnchorForY2AxisLabel = function textAnchorForY2AxisLabel() {
c3_axis_fn.textAnchorForY2AxisLabel = function textAnchorForY2AxisLabel() {
var $$ = this.owner;
return this.textAnchorForAxisLabel($$.config.axis_rotated, this.getY2AxisLabelPosition());
};
Axis.prototype.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) {
c3_axis_fn.getMaxTickWidth = function getMaxTickWidth(id, withoutRecompute) {
var $$ = this.owner, config = $$.config,

@@ -322,3 +693,3 @@ maxWidth = 0, targetsToShow, scale, axis, dummy, svg;

Axis.prototype.updateLabels = function updateLabels(withTransition) {
c3_axis_fn.updateLabels = function updateLabels(withTransition) {
var $$ = this.owner;

@@ -344,3 +715,3 @@ var axisXLabel = $$.main.select('.' + CLASS.axisX + ' .' + CLASS.axisXLabel),

};
Axis.prototype.getPadding = function getPadding(padding, key, defaultValue, domainLength) {
c3_axis_fn.getPadding = function getPadding(padding, key, defaultValue, domainLength) {
var p = typeof padding === 'number' ? padding : padding[key];

@@ -356,3 +727,3 @@ if (!isValue(p)) {

};
Axis.prototype.convertPixelsToAxisPadding = function convertPixelsToAxisPadding(pixels, domainLength) {
c3_axis_fn.convertPixelsToAxisPadding = function convertPixelsToAxisPadding(pixels, domainLength) {
var $$ = this.owner,

@@ -362,3 +733,3 @@ length = $$.config.axis_rotated ? $$.width : $$.height;

};
Axis.prototype.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) {
c3_axis_fn.generateTickValues = function generateTickValues(values, tickCount, forTimeSeries) {
var tickValues = values, targetCount, start, end, count, interval, i, tickValue;

@@ -389,3 +760,3 @@ if (tickCount) {

};
Axis.prototype.generateTransitions = function generateTransitions(duration) {
c3_axis_fn.generateTransitions = function generateTransitions(duration) {
var $$ = this.owner, axes = $$.axes;

@@ -399,3 +770,3 @@ return {

};
Axis.prototype.redraw = function redraw(transitions, isHidden) {
c3_axis_fn.redraw = function redraw(transitions, isHidden) {
var $$ = this.owner;

@@ -402,0 +773,0 @@ $$.axes.x.style("opacity", isHidden ? 0 : 1);

@@ -5,27 +5,12 @@ import Axis from './axis';

export var c3 = { version: "0.4.17" };
export var c3 = { version: "0.4.18" };
export var c3_chart_fn;
export var c3_chart_internal_fn;
export var c3_chart_internal_axis_fn;
export function API(owner) {
export function Component(owner, componentKey, fn) {
this.owner = owner;
c3.chart.internal[componentKey] = fn;
}
export function inherit(base, derived) {
if (Object.create) {
derived.prototype = Object.create(base.prototype);
} else {
var f = function f() {};
f.prototype = base.prototype;
derived.prototype = new f();
}
derived.prototype.constructor = derived;
return derived;
}
function Chart(config) {

@@ -68,5 +53,2 @@ var $$ = this.internal = new ChartInternal(this);

fn: ChartInternal.prototype,
axis: {
fn: Axis.prototype
}
}

@@ -76,3 +58,2 @@ };

c3_chart_internal_fn = c3.chart.internal.fn;
c3_chart_internal_axis_fn = c3.chart.internal.axis.fn;

@@ -79,0 +60,0 @@ c3_chart_internal_fn.beforeInit = function () {

@@ -239,18 +239,28 @@ import CLASS from './class';

};
c3_chart_internal_fn.orderTargets = function (targets) {
c3_chart_internal_fn.getOrderFunction = function() {
var $$ = this, config = $$.config, orderAsc = $$.isOrderAsc(), orderDesc = $$.isOrderDesc();
if (orderAsc || orderDesc) {
targets.sort(function (t1, t2) {
return function (t1, t2) {
var reducer = function (p, c) { return p + Math.abs(c.value); };
var t1Sum = t1.values.reduce(reducer, 0),
t2Sum = t2.values.reduce(reducer, 0);
return orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum;
});
return orderDesc ? t2Sum - t1Sum : t1Sum - t2Sum;
};
} else if (isFunction(config.data_order)) {
targets.sort(config.data_order);
return config.data_order;
} else if (isArray(config.data_order)) {
targets.sort(function (t1, t2) {
return config.data_order.indexOf(t1.id) - config.data_order.indexOf(t2.id);
});
var order = config.data_order;
return function (t1, t2) {
return order.indexOf(t1.id) - order.indexOf(t2.id);
};
}
};
c3_chart_internal_fn.orderTargets = function (targets) {
var fct = this.getOrderFunction();
if (fct) {
targets.sort(fct);
if (this.isOrderAsc() || this.isOrderDesc()) {
targets.reverse();
}
}
return targets;

@@ -257,0 +267,0 @@ };

@@ -25,3 +25,2 @@ import { c3 } from './core';

import './axis';
import './c3.axis';
import './cache';

@@ -28,0 +27,0 @@ import './category';

@@ -375,3 +375,7 @@ import CLASS from './class';

var $$ = this, config = $$.config;
return config.point_focus_expand_enabled ? (config.point_focus_expand_r ? config.point_focus_expand_r : $$.pointR(d) * 1.75) : $$.pointR(d);
if (config.point_focus_expand_enabled) {
return isFunction(config.point_focus_expand_r) ? config.point_focus_expand_r(d) : ((config.point_focus_expand_r) ? config.point_focus_expand_r : $$.pointR(d) * 1.75);
} else {
return $$.pointR(d);
}
};

@@ -378,0 +382,0 @@ c3_chart_internal_fn.pointSelectR = function (d) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc