c3-rails 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/c3/rails/version.rb +1 -1
- data/vendor/assets/javascripts/c3.js +71 -39
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19e82bdda3c512c5a70832b8b96bb713d69c2f03
|
4
|
+
data.tar.gz: 01858e862092226457ad8b2c50e21c70dc4f4327
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e798f410c1f11d74a810fbfa7226b9adc12b83e454f9aff1268c1423ef0428da8333b98a9af7bb8294eeab7141b963eae99afb6554b317feb679dcfc95b61e10
|
7
|
+
data.tar.gz: 946676c5e49156d8245d90e07bfe6476f8691fd2cb1ab8a8ffd8dbfeac527c4f640174f2cd7e94d4d2d9c27a91943e92c1d563f7a2d2d16b56717926f6630069
|
data/lib/c3/rails/version.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
/*global define, module, exports, require */
|
5
5
|
|
6
|
-
var c3 = { version: "0.4.
|
6
|
+
var c3 = { version: "0.4.4" };
|
7
7
|
|
8
8
|
var c3_chart_fn, c3_chart_internal_fn;
|
9
9
|
|
@@ -113,8 +113,8 @@
|
|
113
113
|
$$.defocusedTargetIds = [];
|
114
114
|
|
115
115
|
$$.xOrient = config.axis_rotated ? "left" : "bottom";
|
116
|
-
$$.yOrient = config.axis_rotated ? "bottom" : "left";
|
117
|
-
$$.y2Orient = config.axis_rotated ? "top" : "right";
|
116
|
+
$$.yOrient = config.axis_rotated ? (config.axis_y_inner ? "top" : "bottom") : (config.axis_y_inner ? "right" : "left");
|
117
|
+
$$.y2Orient = config.axis_rotated ? (config.axis_y_inner ? "bottom" : "top") : (config.axis_y_inner ? "left" : "right");
|
118
118
|
$$.subXOrient = config.axis_rotated ? "left" : "bottom";
|
119
119
|
|
120
120
|
$$.isLegendRight = config.legend_position === 'right';
|
@@ -143,6 +143,14 @@
|
|
143
143
|
$$.axes.subx = d3.selectAll([]); // needs when excluding subchart.js
|
144
144
|
};
|
145
145
|
|
146
|
+
c3_chart_internal_fn.initChartElements = function () {
|
147
|
+
if (this.initBar) { this.initBar(); }
|
148
|
+
if (this.initLine) { this.initLine(); }
|
149
|
+
if (this.initArc) { this.initArc(); }
|
150
|
+
if (this.initGauge) { this.initGauge(); }
|
151
|
+
if (this.initText) { this.initText(); }
|
152
|
+
};
|
153
|
+
|
146
154
|
c3_chart_internal_fn.initWithData = function (data) {
|
147
155
|
var $$ = this, d3 = $$.d3, config = $$.config;
|
148
156
|
var defs, main, binding = true;
|
@@ -171,6 +179,9 @@
|
|
171
179
|
if (config.data_hide) {
|
172
180
|
$$.addHiddenTargetIds(config.data_hide === true ? $$.mapToIds($$.data.targets) : config.data_hide);
|
173
181
|
}
|
182
|
+
if (config.legend_hide) {
|
183
|
+
$$.addHiddenLegendIds(config.legend_hide === true ? $$.mapToIds($$.data.targets) : config.legend_hide);
|
184
|
+
}
|
174
185
|
|
175
186
|
// when gauge, hide legend // TODO: fix
|
176
187
|
if ($$.hasType('gauge')) {
|
@@ -245,18 +256,8 @@
|
|
245
256
|
// Cover whole with rects for events
|
246
257
|
$$.initEventRect();
|
247
258
|
|
248
|
-
// Define g for
|
249
|
-
|
250
|
-
|
251
|
-
// Define g for line chart area
|
252
|
-
if ($$.initLine) { $$.initLine(); }
|
253
|
-
|
254
|
-
// Define g for arc chart area
|
255
|
-
if ($$.initArc) { $$.initArc(); }
|
256
|
-
if ($$.initGauge) { $$.initGauge(); }
|
257
|
-
|
258
|
-
// Define g for text area
|
259
|
-
if ($$.initText) { $$.initText(); }
|
259
|
+
// Define g for chart
|
260
|
+
$$.initChartElements();
|
260
261
|
|
261
262
|
// if zoom privileged, insert rect to forefront
|
262
263
|
// TODO: is this needed?
|
@@ -427,7 +428,7 @@
|
|
427
428
|
c3_chart_internal_fn.redraw = function (options, transitions) {
|
428
429
|
var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config;
|
429
430
|
var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType);
|
430
|
-
var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend, withEventRect;
|
431
|
+
var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend, withEventRect, withDimension;
|
431
432
|
var hideAxis = $$.hasArcType();
|
432
433
|
var drawArea, drawBar, drawLine, xForText, yForText;
|
433
434
|
var duration, durationForExit, durationForAxis;
|
@@ -445,6 +446,7 @@
|
|
445
446
|
withTrimXDomain = getOption(options, "withTrimXDomain", true);
|
446
447
|
withLegend = getOption(options, "withLegend", false);
|
447
448
|
withEventRect = getOption(options, "withEventRect", true);
|
449
|
+
withDimension = getOption(options, "withDimension", true);
|
448
450
|
withTransitionForExit = getOption(options, "withTransitionForExit", withTransition);
|
449
451
|
withTransitionForAxis = getOption(options, "withTransitionForAxis", withTransition);
|
450
452
|
|
@@ -457,7 +459,7 @@
|
|
457
459
|
// update legend and transform each g
|
458
460
|
if (withLegend && config.legend_show) {
|
459
461
|
$$.updateLegend($$.mapToIds($$.data.targets), options, transitions);
|
460
|
-
} else if (
|
462
|
+
} else if (withDimension) {
|
461
463
|
// need to update dimension (e.g. axis.y.tick.values) because y tick values should change
|
462
464
|
// no need to update axis in it because they will be updated in redraw()
|
463
465
|
$$.updateDimension(true);
|
@@ -724,7 +726,8 @@
|
|
724
726
|
return d.value !== null && this.withoutFadeIn[d.id] ? this.opacityForCircle(d) : 0;
|
725
727
|
};
|
726
728
|
c3_chart_internal_fn.opacityForCircle = function (d) {
|
727
|
-
|
729
|
+
var opacity = this.config.point_show ? 1 : 0;
|
730
|
+
return isValue(d.value) ? (this.isScatterType(d) ? 0.5 : opacity) : 0;
|
728
731
|
};
|
729
732
|
c3_chart_internal_fn.opacityForText = function () {
|
730
733
|
return this.hasDataLabel() ? 1 : 0;
|
@@ -988,6 +991,7 @@
|
|
988
991
|
color_threshold: {},
|
989
992
|
// legend
|
990
993
|
legend_show: true,
|
994
|
+
legend_hide: false,
|
991
995
|
legend_position: 'bottom',
|
992
996
|
legend_inset_anchor: 'top-left',
|
993
997
|
legend_inset_x: 10,
|
@@ -1025,6 +1029,7 @@
|
|
1025
1029
|
axis_y_max: undefined,
|
1026
1030
|
axis_y_min: undefined,
|
1027
1031
|
axis_y_center: undefined,
|
1032
|
+
axis_y_inner: undefined,
|
1028
1033
|
axis_y_label: {},
|
1029
1034
|
axis_y_tick_format: undefined,
|
1030
1035
|
axis_y_tick_outer: true,
|
@@ -1038,6 +1043,7 @@
|
|
1038
1043
|
axis_y2_max: undefined,
|
1039
1044
|
axis_y2_min: undefined,
|
1040
1045
|
axis_y2_center: undefined,
|
1046
|
+
axis_y2_inner: undefined,
|
1041
1047
|
axis_y2_label: {},
|
1042
1048
|
axis_y2_tick_format: undefined,
|
1043
1049
|
axis_y2_tick_outer: true,
|
@@ -1574,10 +1580,12 @@
|
|
1574
1580
|
};
|
1575
1581
|
c3_chart_internal_fn.updateXs = function () {
|
1576
1582
|
var $$ = this;
|
1577
|
-
$$.
|
1578
|
-
|
1579
|
-
$$.
|
1580
|
-
|
1583
|
+
if ($$.data.targets.length) {
|
1584
|
+
$$.xs = [];
|
1585
|
+
$$.data.targets[0].values.forEach(function (v) {
|
1586
|
+
$$.xs[v.index] = v.x;
|
1587
|
+
});
|
1588
|
+
}
|
1581
1589
|
};
|
1582
1590
|
c3_chart_internal_fn.getPrevX = function (i) {
|
1583
1591
|
var x = this.xs[i - 1];
|
@@ -2495,8 +2503,10 @@
|
|
2495
2503
|
return config.padding_left;
|
2496
2504
|
} else if (config.axis_rotated) {
|
2497
2505
|
return !config.axis_x_show ? 1 : Math.max(ceil10($$.getAxisWidthByAxisId('x', withoutRecompute)), 40);
|
2506
|
+
} else if (!config.axis_y_show || config.axis_y_inner) { // && !config.axis_rotated
|
2507
|
+
return $$.getYAxisLabelPosition().isOuter ? 30 : 1;
|
2498
2508
|
} else {
|
2499
|
-
return
|
2509
|
+
return ceil10($$.getAxisWidthByAxisId('y', withoutRecompute));
|
2500
2510
|
}
|
2501
2511
|
};
|
2502
2512
|
c3_chart_internal_fn.getCurrentPaddingRight = function () {
|
@@ -2506,8 +2516,10 @@
|
|
2506
2516
|
return config.padding_right + 1; // 1 is needed not to hide tick line
|
2507
2517
|
} else if (config.axis_rotated) {
|
2508
2518
|
return defaultPadding + legendWidthOnRight;
|
2519
|
+
} else if (!config.axis_y2_show || config.axis_y2_inner) { // && !config.axis_rotated
|
2520
|
+
return defaultPadding + legendWidthOnRight + ($$.getY2AxisLabelPosition().isOuter ? 20 : 0);
|
2509
2521
|
} else {
|
2510
|
-
return
|
2522
|
+
return ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight;
|
2511
2523
|
}
|
2512
2524
|
};
|
2513
2525
|
|
@@ -3751,6 +3763,7 @@
|
|
3751
3763
|
.style('opacity', 0)
|
3752
3764
|
.style('visibility', 'hidden');
|
3753
3765
|
};
|
3766
|
+
var legendItemTextBox = {};
|
3754
3767
|
c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
|
3755
3768
|
var $$ = this, config = $$.config;
|
3756
3769
|
var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect;
|
@@ -3764,9 +3777,16 @@
|
|
3764
3777
|
withTransition = getOption(options, "withTransition", true);
|
3765
3778
|
withTransitionForTransform = getOption(options, "withTransitionForTransform", true);
|
3766
3779
|
|
3780
|
+
function getTextBox(textElement, id) {
|
3781
|
+
if (!legendItemTextBox[id]) {
|
3782
|
+
legendItemTextBox[id] = $$.getTextRect(textElement.textContent, CLASS.legendItem);
|
3783
|
+
}
|
3784
|
+
return legendItemTextBox[id];
|
3785
|
+
}
|
3786
|
+
|
3767
3787
|
function updatePositions(textElement, id, index) {
|
3768
3788
|
var reset = index === 0, isLast = index === targetIds.length - 1,
|
3769
|
-
box =
|
3789
|
+
box = getTextBox(textElement, id),
|
3770
3790
|
itemWidth = box.width + tileWidth + (isLast && !($$.isLegendRight || $$.isLegendInset) ? 0 : paddingRight),
|
3771
3791
|
itemHeight = box.height + paddingTop,
|
3772
3792
|
itemLength = $$.isLegendRight || $$.isLegendInset ? itemHeight : itemWidth,
|
@@ -3977,7 +3997,7 @@
|
|
3977
3997
|
|
3978
3998
|
$$.axes.y = main.append("g")
|
3979
3999
|
.attr("class", CLASS.axis + ' ' + CLASS.axisY)
|
3980
|
-
.attr("clip-path", $$.clipPathForYAxis)
|
4000
|
+
.attr("clip-path", config.axis_y_inner ? "" : $$.clipPathForYAxis)
|
3981
4001
|
.attr("transform", $$.getTranslate('y'))
|
3982
4002
|
.style("visibility", config.axis_y_show ? 'visible' : 'hidden');
|
3983
4003
|
$$.axes.y.append("text")
|
@@ -4188,7 +4208,7 @@
|
|
4188
4208
|
if ($$.config.axis_rotated) {
|
4189
4209
|
return position.isInner ? "-0.5em" : "3em";
|
4190
4210
|
} else {
|
4191
|
-
return position.isInner ? "1.2em" : -
|
4211
|
+
return position.isInner ? "1.2em" : -10 - ($$.config.axis_y_inner ? 0 : ($$.getMaxTickWidth('y') + 10));
|
4192
4212
|
}
|
4193
4213
|
};
|
4194
4214
|
c3_chart_internal_fn.dyForY2AxisLabel = function () {
|
@@ -4197,7 +4217,7 @@
|
|
4197
4217
|
if ($$.config.axis_rotated) {
|
4198
4218
|
return position.isInner ? "1.2em" : "-2.2em";
|
4199
4219
|
} else {
|
4200
|
-
return position.isInner ? "-0.5em" :
|
4220
|
+
return position.isInner ? "-0.5em" : 15 + ($$.config.axis_y2_inner ? 0 : (this.getMaxTickWidth('y2') + 15));
|
4201
4221
|
}
|
4202
4222
|
};
|
4203
4223
|
c3_chart_internal_fn.textAnchorForXAxisLabel = function () {
|
@@ -4361,7 +4381,7 @@
|
|
4361
4381
|
};
|
4362
4382
|
c3_chart_internal_fn.getYAxisClipX = function () {
|
4363
4383
|
var $$ = this;
|
4364
|
-
return $$.getAxisClipX($$.config.axis_rotated);
|
4384
|
+
return $$.config.axis_y_inner ? -1 : $$.getAxisClipX($$.config.axis_rotated);
|
4365
4385
|
};
|
4366
4386
|
c3_chart_internal_fn.getYAxisClipY = function () {
|
4367
4387
|
var $$ = this;
|
@@ -4387,7 +4407,7 @@
|
|
4387
4407
|
};
|
4388
4408
|
c3_chart_internal_fn.getYAxisClipWidth = function () {
|
4389
4409
|
var $$ = this;
|
4390
|
-
return $$.getAxisClipWidth($$.config.axis_rotated);
|
4410
|
+
return $$.getAxisClipWidth($$.config.axis_rotated) + ($$.config.axis_y_inner ? 20 : 0);
|
4391
4411
|
};
|
4392
4412
|
c3_chart_internal_fn.getYAxisClipHeight = function () {
|
4393
4413
|
var $$ = this;
|
@@ -5191,7 +5211,8 @@
|
|
5191
5211
|
withTransition: false,
|
5192
5212
|
withY: $$.config.zoom_rescale,
|
5193
5213
|
withSubchart: false,
|
5194
|
-
withUpdateXDomain: true
|
5214
|
+
withUpdateXDomain: true,
|
5215
|
+
withDimension: false
|
5195
5216
|
});
|
5196
5217
|
$$.config.subchart_onbrush.call($$.api, x.orgDomain());
|
5197
5218
|
};
|
@@ -5276,7 +5297,8 @@
|
|
5276
5297
|
withTransition: false,
|
5277
5298
|
withY: config.zoom_rescale,
|
5278
5299
|
withSubchart: false,
|
5279
|
-
withEventRect: false
|
5300
|
+
withEventRect: false,
|
5301
|
+
withDimension: false
|
5280
5302
|
});
|
5281
5303
|
if (d3.event.sourceEvent.type === 'mousemove') {
|
5282
5304
|
$$.cancelClick = true;
|
@@ -5544,7 +5566,7 @@
|
|
5544
5566
|
return CLASS.chartArc + this.classTarget(d.data.id);
|
5545
5567
|
};
|
5546
5568
|
c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) {
|
5547
|
-
return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]
|
5569
|
+
return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g, '-') : '';
|
5548
5570
|
};
|
5549
5571
|
c3_chart_internal_fn.selectorTarget = function (id, prefix) {
|
5550
5572
|
return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id);
|
@@ -6240,12 +6262,16 @@
|
|
6240
6262
|
return [].concat(targetIds).indexOf(t.id) >= 0;
|
6241
6263
|
});
|
6242
6264
|
};
|
6243
|
-
c3_chart_fn.data.shown = function (
|
6244
|
-
return this.internal.filterTargetsToShow(this.data(
|
6265
|
+
c3_chart_fn.data.shown = function (targetIds) {
|
6266
|
+
return this.internal.filterTargetsToShow(this.data(targetIds));
|
6245
6267
|
};
|
6246
6268
|
c3_chart_fn.data.values = function (targetId) {
|
6247
|
-
var
|
6248
|
-
|
6269
|
+
var targets, values = null;
|
6270
|
+
if (targetId) {
|
6271
|
+
targets = this.data(targetId);
|
6272
|
+
values = targets[0] ? targets[0].values.map(function (d) { return d.value; }) : null;
|
6273
|
+
}
|
6274
|
+
return values;
|
6249
6275
|
};
|
6250
6276
|
c3_chart_fn.data.names = function (names) {
|
6251
6277
|
return this.internal.updateDataAttributes('names', names);
|
@@ -6429,6 +6455,8 @@
|
|
6429
6455
|
// Features:
|
6430
6456
|
// 1. category axis
|
6431
6457
|
// 2. ceil values of translate/x/y to int for half pixel antialiasing
|
6458
|
+
// 3. multiline tick text
|
6459
|
+
var tickTextCharSize;
|
6432
6460
|
function c3_axis(d3, params) {
|
6433
6461
|
var scale = d3.scale.linear(), orient = "bottom", innerTickSize = 6, outerTickSize, tickPadding = 3, tickValues = null, tickFormat, tickArguments;
|
6434
6462
|
|
@@ -6477,6 +6505,9 @@
|
|
6477
6505
|
return tickFormat ? tickFormat(v) : v;
|
6478
6506
|
}
|
6479
6507
|
function getSizeFor1Char(tick) {
|
6508
|
+
if (tickTextCharSize) {
|
6509
|
+
return tickTextCharSize;
|
6510
|
+
}
|
6480
6511
|
var size = {
|
6481
6512
|
h: 11.5,
|
6482
6513
|
w: 5.5
|
@@ -6491,6 +6522,7 @@
|
|
6491
6522
|
size.w = w;
|
6492
6523
|
}
|
6493
6524
|
}).text('');
|
6525
|
+
tickTextCharSize = size;
|
6494
6526
|
return size;
|
6495
6527
|
}
|
6496
6528
|
function axis(g) {
|
@@ -6525,7 +6557,7 @@
|
|
6525
6557
|
tickOffset = tickX = 0;
|
6526
6558
|
}
|
6527
6559
|
|
6528
|
-
var text, tspan, sizeFor1Char = getSizeFor1Char(tick), counts = [];
|
6560
|
+
var text, tspan, sizeFor1Char = getSizeFor1Char(g.select('.tick')), counts = [];
|
6529
6561
|
var tickLength = Math.max(innerTickSize, 0) + tickPadding,
|
6530
6562
|
isVertical = orient === 'left' || orient === 'right';
|
6531
6563
|
|
@@ -6539,7 +6571,7 @@
|
|
6539
6571
|
}
|
6540
6572
|
|
6541
6573
|
if (!maxWidth || maxWidth <= 0) {
|
6542
|
-
maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) -
|
6574
|
+
maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 12) : 110;
|
6543
6575
|
}
|
6544
6576
|
|
6545
6577
|
function split(splitted, text) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: c3-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunny Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem provides "c3 - A D3-based reusable chart library" for Rails
|
14
14
|
email:
|