c3-rails 0.4.0 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/c3/rails/version.rb +1 -1
- data/vendor/assets/javascripts/c3.js +86 -64
- 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: 2af42ee06a4a8faf8c82e37002f9b742b62b7936
|
4
|
+
data.tar.gz: 1778852ef17eea288816f5bc1dd356d5c8a4f588
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dde6172793ab7cee798a676d5bcace2ab3f738c8c928c752fb6dc3d17091e1c883eb27658291cce1a308a2aec3124350a199e94e475e2586828b229bf4765a5
|
7
|
+
data.tar.gz: fc67f6469210f021304d442a3d6ad0f5414cb68ec234b8e4d6952b46756873d1d7d5b78eb74cb012fb28ef038b015b41c06aeb23ada3f0170690c2ab5179a964
|
data/README.md
CHANGED
@@ -62,11 +62,12 @@ you can install by putting this line in the `Gemfile` instead:
|
|
62
62
|
Then you'll be able to include files like
|
63
63
|
|
64
64
|
```
|
65
|
+
//= require c3/c3
|
65
66
|
//= require c3/c3.min
|
66
|
-
//= require c3/c3.old
|
67
67
|
//= require c3/extensions/js/c3ext
|
68
68
|
|
69
69
|
*= require c3/c3
|
70
|
+
*= require c3/c3.min
|
70
71
|
*= require c3/htdocs/css/bootstrap.min
|
71
72
|
```
|
72
73
|
|
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.3" };
|
7
7
|
|
8
8
|
var c3_chart_fn, c3_chart_internal_fn;
|
9
9
|
|
@@ -484,7 +484,7 @@
|
|
484
484
|
$$.subXAxis.tickValues([]);
|
485
485
|
}
|
486
486
|
|
487
|
-
if (
|
487
|
+
if (config.zoom_rescale && !options.flow) {
|
488
488
|
xDomainForZoom = $$.x.orgDomain();
|
489
489
|
}
|
490
490
|
|
@@ -552,7 +552,7 @@
|
|
552
552
|
.style('opacity', targetsToShow.length ? 0 : 1);
|
553
553
|
|
554
554
|
// grid
|
555
|
-
$$.redrawGrid(duration
|
555
|
+
$$.redrawGrid(duration);
|
556
556
|
|
557
557
|
// rect for regions
|
558
558
|
$$.redrawRegion(duration);
|
@@ -590,9 +590,12 @@
|
|
590
590
|
if ($$.updateZoom) { $$.updateZoom(); }
|
591
591
|
}
|
592
592
|
|
593
|
+
// update circleY based on updated parameters
|
594
|
+
$$.updateCircleY();
|
595
|
+
|
593
596
|
// generate circle x/y functions depending on updated params
|
594
|
-
cx = ($$.config.axis_rotated ? $$.
|
595
|
-
cy = ($$.config.axis_rotated ? $$.circleX : $$.
|
597
|
+
cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$);
|
598
|
+
cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$);
|
596
599
|
|
597
600
|
// transition should be derived from one transition
|
598
601
|
d3.transition().duration(duration).each(function () {
|
@@ -661,6 +664,14 @@
|
|
661
664
|
// Draw with new sizes & scales
|
662
665
|
$$.redraw(options, transitions);
|
663
666
|
};
|
667
|
+
c3_chart_internal_fn.redrawWithoutRescale = function () {
|
668
|
+
this.redraw({
|
669
|
+
withY: false,
|
670
|
+
withSubchart: false,
|
671
|
+
withEventRect: false,
|
672
|
+
withTransitionForAxis: false
|
673
|
+
});
|
674
|
+
};
|
664
675
|
|
665
676
|
c3_chart_internal_fn.isTimeSeries = function () {
|
666
677
|
return this.config.axis_x_type === 'timeseries';
|
@@ -1561,13 +1572,20 @@
|
|
1561
1572
|
})
|
1562
1573
|
};
|
1563
1574
|
};
|
1575
|
+
c3_chart_internal_fn.updateXs = function () {
|
1576
|
+
var $$ = this;
|
1577
|
+
$$.xs = [];
|
1578
|
+
$$.data.targets[0].values.forEach(function (v) {
|
1579
|
+
$$.xs[v.index] = v.x;
|
1580
|
+
});
|
1581
|
+
};
|
1564
1582
|
c3_chart_internal_fn.getPrevX = function (i) {
|
1565
|
-
var
|
1566
|
-
return
|
1583
|
+
var x = this.xs[i - 1];
|
1584
|
+
return typeof x !== 'undefined' ? x : null;
|
1567
1585
|
};
|
1568
1586
|
c3_chart_internal_fn.getNextX = function (i) {
|
1569
|
-
var
|
1570
|
-
return
|
1587
|
+
var x = this.xs[i + 1];
|
1588
|
+
return typeof x !== 'undefined' ? x : null;
|
1571
1589
|
};
|
1572
1590
|
c3_chart_internal_fn.getMaxDataCount = function () {
|
1573
1591
|
var $$ = this;
|
@@ -1780,10 +1798,11 @@
|
|
1780
1798
|
};
|
1781
1799
|
c3_chart_internal_fn.dist = function (data, pos) {
|
1782
1800
|
var $$ = this, config = $$.config,
|
1783
|
-
yScale = $$.getAxisId(data.id) === 'y' ? $$.y : $$.y2,
|
1784
1801
|
xIndex = config.axis_rotated ? 1 : 0,
|
1785
|
-
yIndex = config.axis_rotated ? 0 : 1
|
1786
|
-
|
1802
|
+
yIndex = config.axis_rotated ? 0 : 1,
|
1803
|
+
y = $$.circleY(data, data.index),
|
1804
|
+
x = $$.x(data.x);
|
1805
|
+
return Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2);
|
1787
1806
|
};
|
1788
1807
|
c3_chart_internal_fn.convertValuesToStep = function (values) {
|
1789
1808
|
var converted = [].concat(values), i;
|
@@ -2161,6 +2180,10 @@
|
|
2161
2180
|
}
|
2162
2181
|
else {
|
2163
2182
|
if (($$.isCustomX() || $$.isTimeSeries()) && !$$.isCategorized()) {
|
2183
|
+
|
2184
|
+
// update index for x that is used by prevX and nextX
|
2185
|
+
$$.updateXs();
|
2186
|
+
|
2164
2187
|
rectW = function (d) {
|
2165
2188
|
var prevX = $$.getPrevX(d.index), nextX = $$.getNextX(d.index);
|
2166
2189
|
|
@@ -2935,16 +2958,16 @@
|
|
2935
2958
|
c3_chart_internal_fn.circleX = function (d) {
|
2936
2959
|
return d.x || d.x === 0 ? this.x(d.x) : null;
|
2937
2960
|
};
|
2938
|
-
c3_chart_internal_fn.
|
2961
|
+
c3_chart_internal_fn.updateCircleY = function () {
|
2939
2962
|
var $$ = this, lineIndices, getPoints;
|
2940
2963
|
if ($$.config.data_groups.length > 0) {
|
2941
2964
|
lineIndices = $$.getShapeIndices($$.isLineType),
|
2942
2965
|
getPoints = $$.generateGetLinePoints(lineIndices);
|
2943
|
-
|
2966
|
+
$$.circleY = function (d, i) {
|
2944
2967
|
return getPoints(d, i)[0][1];
|
2945
2968
|
};
|
2946
2969
|
} else {
|
2947
|
-
|
2970
|
+
$$.circleY = function (d) {
|
2948
2971
|
return $$.getYScale(d.id)(d.value);
|
2949
2972
|
};
|
2950
2973
|
}
|
@@ -3370,7 +3393,7 @@
|
|
3370
3393
|
};
|
3371
3394
|
|
3372
3395
|
|
3373
|
-
c3_chart_internal_fn.redrawGrid = function (duration
|
3396
|
+
c3_chart_internal_fn.redrawGrid = function (duration) {
|
3374
3397
|
var $$ = this, main = $$.main, config = $$.config,
|
3375
3398
|
xgridLine, ygridLine, yv;
|
3376
3399
|
|
@@ -3402,43 +3425,41 @@
|
|
3402
3425
|
.remove();
|
3403
3426
|
|
3404
3427
|
// Y-Grid
|
3405
|
-
if (
|
3428
|
+
if (config.grid_y_show) {
|
3406
3429
|
$$.updateYGrid();
|
3407
3430
|
}
|
3408
|
-
|
3409
|
-
|
3410
|
-
|
3411
|
-
|
3412
|
-
|
3413
|
-
|
3414
|
-
|
3415
|
-
|
3416
|
-
|
3417
|
-
|
3418
|
-
|
3419
|
-
|
3420
|
-
|
3421
|
-
|
3422
|
-
|
3423
|
-
|
3424
|
-
|
3425
|
-
|
3426
|
-
|
3427
|
-
|
3428
|
-
|
3429
|
-
|
3430
|
-
|
3431
|
-
|
3432
|
-
|
3433
|
-
|
3434
|
-
|
3435
|
-
|
3436
|
-
|
3437
|
-
|
3438
|
-
|
3439
|
-
|
3440
|
-
.remove();
|
3441
|
-
}
|
3431
|
+
$$.ygridLines = main.select('.' + CLASS.ygridLines).selectAll('.' + CLASS.ygridLine)
|
3432
|
+
.data(config.grid_y_lines);
|
3433
|
+
// enter
|
3434
|
+
ygridLine = $$.ygridLines.enter().append('g')
|
3435
|
+
.attr("class", function (d) { return CLASS.ygridLine + (d['class'] ? ' ' + d['class'] : ''); });
|
3436
|
+
ygridLine.append('line')
|
3437
|
+
.style("opacity", 0);
|
3438
|
+
ygridLine.append('text')
|
3439
|
+
.attr("text-anchor", "end")
|
3440
|
+
.attr("transform", config.axis_rotated ? "rotate(-90)" : "")
|
3441
|
+
.attr('dx', config.axis_rotated ? 0 : -$$.margin.top)
|
3442
|
+
.attr('dy', -5)
|
3443
|
+
.style("opacity", 0);
|
3444
|
+
// update
|
3445
|
+
yv = $$.yv.bind($$);
|
3446
|
+
$$.ygridLines.select('line')
|
3447
|
+
.transition().duration(duration)
|
3448
|
+
.attr("x1", config.axis_rotated ? yv : 0)
|
3449
|
+
.attr("x2", config.axis_rotated ? yv : $$.width)
|
3450
|
+
.attr("y1", config.axis_rotated ? 0 : yv)
|
3451
|
+
.attr("y2", config.axis_rotated ? $$.height : yv)
|
3452
|
+
.style("opacity", 1);
|
3453
|
+
$$.ygridLines.select('text')
|
3454
|
+
.transition().duration(duration)
|
3455
|
+
.attr("x", config.axis_rotated ? 0 : $$.width)
|
3456
|
+
.attr("y", yv)
|
3457
|
+
.text(function (d) { return d.text; })
|
3458
|
+
.style("opacity", 1);
|
3459
|
+
// exit
|
3460
|
+
$$.ygridLines.exit().transition().duration(duration)
|
3461
|
+
.style("opacity", 0)
|
3462
|
+
.remove();
|
3442
3463
|
};
|
3443
3464
|
c3_chart_internal_fn.addTransitionForGrid = function (transitions) {
|
3444
3465
|
var $$ = this, config = $$.config, xv = $$.xv.bind($$);
|
@@ -3503,7 +3524,7 @@
|
|
3503
3524
|
return params ? function (line) {
|
3504
3525
|
var found = false;
|
3505
3526
|
[].concat(params).forEach(function (param) {
|
3506
|
-
if ((('value' in param && line.value ===
|
3527
|
+
if ((('value' in param && line.value === param.value) || ('class' in param && line['class'] === param['class']))) {
|
3507
3528
|
found = true;
|
3508
3529
|
}
|
3509
3530
|
});
|
@@ -4328,7 +4349,7 @@
|
|
4328
4349
|
return forHorizontal ? -(1 + left) : -(left - 1);
|
4329
4350
|
};
|
4330
4351
|
c3_chart_internal_fn.getAxisClipY = function (forHorizontal) {
|
4331
|
-
return forHorizontal ? -20 : -
|
4352
|
+
return forHorizontal ? -20 : -this.margin.top;
|
4332
4353
|
};
|
4333
4354
|
c3_chart_internal_fn.getXAxisClipX = function () {
|
4334
4355
|
var $$ = this;
|
@@ -4354,7 +4375,7 @@
|
|
4354
4375
|
return forHorizontal ? $$.width + 2 + left + right : $$.margin.left + 20;
|
4355
4376
|
};
|
4356
4377
|
c3_chart_internal_fn.getAxisClipHeight = function (forHorizontal) {
|
4357
|
-
return (forHorizontal ? this.margin.bottom : this.height) + 8;
|
4378
|
+
return (forHorizontal ? this.margin.bottom : (this.margin.top + this.height)) + 8;
|
4358
4379
|
};
|
4359
4380
|
c3_chart_internal_fn.getXAxisClipWidth = function () {
|
4360
4381
|
var $$ = this;
|
@@ -4928,8 +4949,8 @@
|
|
4928
4949
|
|
4929
4950
|
c3_chart_internal_fn.selectPoint = function (target, d, i) {
|
4930
4951
|
var $$ = this, config = $$.config,
|
4931
|
-
cx = (config.axis_rotated ? $$.
|
4932
|
-
cy = (config.axis_rotated ? $$.circleX : $$.
|
4952
|
+
cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$),
|
4953
|
+
cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$),
|
4933
4954
|
r = $$.pointSelectR.bind($$);
|
4934
4955
|
config.data_onselected.call($$.api, d, target.node());
|
4935
4956
|
// add selected-circle on low layer g
|
@@ -5523,7 +5544,7 @@
|
|
5523
5544
|
return CLASS.chartArc + this.classTarget(d.data.id);
|
5524
5545
|
};
|
5525
5546
|
c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) {
|
5526
|
-
return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s
|
5547
|
+
return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]/|~`{}\\]/g, '-') : '';
|
5527
5548
|
};
|
5528
5549
|
c3_chart_internal_fn.selectorTarget = function (id, prefix) {
|
5529
5550
|
return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id);
|
@@ -5699,7 +5720,8 @@
|
|
5699
5720
|
domain = domain.map(function (x) { return $$.parseDate(x); });
|
5700
5721
|
}
|
5701
5722
|
$$.brush.extent(domain);
|
5702
|
-
$$.redraw({withUpdateXDomain: true});
|
5723
|
+
$$.redraw({withUpdateXDomain: true, withY: $$.config.zoom_rescale});
|
5724
|
+
$$.config.zoom_onzoom.call(this, $$.x.orgDomain());
|
5703
5725
|
}
|
5704
5726
|
return $$.brush.extent();
|
5705
5727
|
};
|
@@ -6143,7 +6165,7 @@
|
|
6143
6165
|
var $$ = this.internal, config = $$.config;
|
6144
6166
|
if (! grids) { return config.grid_x_lines; }
|
6145
6167
|
config.grid_x_lines = grids;
|
6146
|
-
$$.
|
6168
|
+
$$.redrawWithoutRescale();
|
6147
6169
|
return config.grid_x_lines;
|
6148
6170
|
};
|
6149
6171
|
c3_chart_fn.xgrids.add = function (grids) {
|
@@ -6159,7 +6181,7 @@
|
|
6159
6181
|
var $$ = this.internal, config = $$.config;
|
6160
6182
|
if (! grids) { return config.grid_y_lines; }
|
6161
6183
|
config.grid_y_lines = grids;
|
6162
|
-
$$.
|
6184
|
+
$$.redrawWithoutRescale();
|
6163
6185
|
return config.grid_y_lines;
|
6164
6186
|
};
|
6165
6187
|
c3_chart_fn.ygrids.add = function (grids) {
|
@@ -6175,14 +6197,14 @@
|
|
6175
6197
|
var $$ = this.internal, config = $$.config;
|
6176
6198
|
if (!regions) { return config.regions; }
|
6177
6199
|
config.regions = regions;
|
6178
|
-
$$.
|
6200
|
+
$$.redrawWithoutRescale();
|
6179
6201
|
return config.regions;
|
6180
6202
|
};
|
6181
6203
|
c3_chart_fn.regions.add = function (regions) {
|
6182
6204
|
var $$ = this.internal, config = $$.config;
|
6183
6205
|
if (!regions) { return config.regions; }
|
6184
6206
|
config.regions = config.regions.concat(regions);
|
6185
|
-
$$.
|
6207
|
+
$$.redrawWithoutRescale();
|
6186
6208
|
return config.regions;
|
6187
6209
|
};
|
6188
6210
|
c3_chart_fn.regions.remove = function (options) {
|
@@ -6517,7 +6539,7 @@
|
|
6517
6539
|
}
|
6518
6540
|
|
6519
6541
|
if (!maxWidth || maxWidth <= 0) {
|
6520
|
-
maxWidth = isVertical ? 95 : params.isCategory ? (
|
6542
|
+
maxWidth = isVertical ? 95 : params.isCategory ? (Math.ceil(scale1(ticks[1]) - scale1(ticks[0])) - 10) : 110;
|
6521
6543
|
}
|
6522
6544
|
|
6523
6545
|
function split(splitted, text) {
|
@@ -6548,7 +6570,7 @@
|
|
6548
6570
|
if (orient === 'left' || orient === 'right') {
|
6549
6571
|
dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - (params.isCategory ? 2 : 3));
|
6550
6572
|
} else {
|
6551
|
-
dy =
|
6573
|
+
dy = ".71em";
|
6552
6574
|
}
|
6553
6575
|
}
|
6554
6576
|
return dy;
|
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.3
|
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-18 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:
|