c3-rails 0.4.4 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19e82bdda3c512c5a70832b8b96bb713d69c2f03
4
- data.tar.gz: 01858e862092226457ad8b2c50e21c70dc4f4327
3
+ metadata.gz: b146b2e0a20b08790e02bfdc97eee99a0fee7dd8
4
+ data.tar.gz: 55b59236f5d3579ea71bafc84848ece8ad68eb6c
5
5
  SHA512:
6
- metadata.gz: e798f410c1f11d74a810fbfa7226b9adc12b83e454f9aff1268c1423ef0428da8333b98a9af7bb8294eeab7141b963eae99afb6554b317feb679dcfc95b61e10
7
- data.tar.gz: 946676c5e49156d8245d90e07bfe6476f8691fd2cb1ab8a8ffd8dbfeac527c4f640174f2cd7e94d4d2d9c27a91943e92c1d563f7a2d2d16b56717926f6630069
6
+ metadata.gz: 4f44857897edfcc2c2347b2fa25eea5afd357c566ac38e71538cf7a75d43f160fb5ef52a100ad209e9843e7e6ce0760def5c6bece2295f3c0e6a0f6f2dfa8477
7
+ data.tar.gz: b3f81b4d90d21b114439b433bbfbceaca3bd99d8a1e3c2923499728d8a1b0855b96e870c08ed31aef9f550ecc91764596f4ef661e1bdbbfbfa22f10c32d55c05
@@ -1,5 +1,5 @@
1
1
  module C3
2
2
  module Rails
3
- VERSION = "0.4.4"
3
+ VERSION = "0.4.8"
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  /*global define, module, exports, require */
5
5
 
6
- var c3 = { version: "0.4.4" };
6
+ var c3 = { version: "0.4.8" };
7
7
 
8
8
  var c3_chart_fn, c3_chart_internal_fn;
9
9
 
@@ -114,7 +114,7 @@
114
114
 
115
115
  $$.xOrient = config.axis_rotated ? "left" : "bottom";
116
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");
117
+ $$.y2Orient = config.axis_rotated ? (config.axis_y2_inner ? "bottom" : "top") : (config.axis_y2_inner ? "left" : "right");
118
118
  $$.subXOrient = config.axis_rotated ? "left" : "bottom";
119
119
 
120
120
  $$.isLegendRight = config.legend_position === 'right';
@@ -124,7 +124,6 @@
124
124
  $$.legendStep = 0;
125
125
  $$.legendItemWidth = 0;
126
126
  $$.legendItemHeight = 0;
127
- $$.legendOpacityForHidden = 0.15;
128
127
 
129
128
  $$.currentMaxTickWidths = {
130
129
  x: 0,
@@ -428,7 +427,9 @@
428
427
  c3_chart_internal_fn.redraw = function (options, transitions) {
429
428
  var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config;
430
429
  var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType);
431
- var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend, withEventRect, withDimension;
430
+ var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis,
431
+ withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend,
432
+ withEventRect, withDimension, withUpdateXAxis;
432
433
  var hideAxis = $$.hasArcType();
433
434
  var drawArea, drawBar, drawLine, xForText, yForText;
434
435
  var duration, durationForExit, durationForAxis;
@@ -444,6 +445,7 @@
444
445
  withUpdateXDomain = getOption(options, "withUpdateXDomain", false);
445
446
  withUpdateOrgXDomain = getOption(options, "withUpdateOrgXDomain", false);
446
447
  withTrimXDomain = getOption(options, "withTrimXDomain", true);
448
+ withUpdateXAxis = getOption(options, "withUpdateXAxis", withUpdateXDomain);
447
449
  withLegend = getOption(options, "withLegend", false);
448
450
  withEventRect = getOption(options, "withEventRect", true);
449
451
  withDimension = getOption(options, "withDimension", true);
@@ -507,7 +509,7 @@
507
509
  $$.updateAxisLabels(withTransition);
508
510
 
509
511
  // show/hide if manual culling needed
510
- if (withUpdateXDomain && targetsToShow.length) {
512
+ if ((withUpdateXDomain || withUpdateXAxis) && targetsToShow.length) {
511
513
  if (config.axis_x_tick_culling && tickValues) {
512
514
  for (i = 1; i < tickValues.length; i++) {
513
515
  if (tickValues.length / i < config.axis_x_tick_culling_max) {
@@ -736,8 +738,14 @@
736
738
  return d ? this.x(d.x) : null;
737
739
  };
738
740
  c3_chart_internal_fn.xv = function (d) {
739
- var $$ = this;
740
- return Math.ceil($$.x($$.isTimeSeries() ? $$.parseDate(d.value) : d.value));
741
+ var $$ = this, value = d.value;
742
+ if ($$.isTimeSeries()) {
743
+ value = $$.parseDate(d.value);
744
+ }
745
+ else if ($$.isCategorized() && typeof d.value === 'string') {
746
+ value = $$.config.axis_x_categories.indexOf(d.value);
747
+ }
748
+ return Math.ceil($$.x(value));
741
749
  };
742
750
  c3_chart_internal_fn.yv = function (d) {
743
751
  var $$ = this,
@@ -910,8 +918,8 @@
910
918
  var $$ = this, parsedDate;
911
919
  if (date instanceof Date) {
912
920
  parsedDate = date;
913
- } else if (typeof date === 'number') {
914
- parsedDate = new Date(date);
921
+ } else if (typeof date === 'number' || !isNaN(date)) {
922
+ parsedDate = new Date(+date);
915
923
  } else {
916
924
  parsedDate = $$.dataTimeFormat($$.config.data_xFormat).parse(date);
917
925
  }
@@ -1353,9 +1361,9 @@
1353
1361
  domainLength = Math.abs(yDomainMax - yDomainMin);
1354
1362
  padding = padding_top = padding_bottom = domainLength * 0.1;
1355
1363
 
1356
- if (center) {
1364
+ if (typeof center !== 'undefined') {
1357
1365
  yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
1358
- yDomainMax = yDomainAbs - center;
1366
+ yDomainMax = center + yDomainAbs;
1359
1367
  yDomainMin = center - yDomainAbs;
1360
1368
  }
1361
1369
  // add padding for data label
@@ -1367,16 +1375,16 @@
1367
1375
  padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1]));
1368
1376
  } else if (showVerticalDataLabel) {
1369
1377
  lengths = $$.getDataLabelLength(yDomainMin, yDomainMax, axisId, 'height');
1370
- padding_top += lengths[1];
1371
- padding_bottom += lengths[0];
1378
+ padding_top += this.convertPixelsToAxisPadding(lengths[1], domainLength);
1379
+ padding_bottom += this.convertPixelsToAxisPadding(lengths[0], domainLength);
1372
1380
  }
1373
1381
  if (axisId === 'y' && notEmpty(config.axis_y_padding)) {
1374
- padding_top = $$.getAxisPadding(config.axis_y_padding, 'top', padding, domainLength);
1375
- padding_bottom = $$.getAxisPadding(config.axis_y_padding, 'bottom', padding, domainLength);
1382
+ padding_top = $$.getAxisPadding(config.axis_y_padding, 'top', padding_top, domainLength);
1383
+ padding_bottom = $$.getAxisPadding(config.axis_y_padding, 'bottom', padding_bottom, domainLength);
1376
1384
  }
1377
1385
  if (axisId === 'y2' && notEmpty(config.axis_y2_padding)) {
1378
- padding_top = $$.getAxisPadding(config.axis_y2_padding, 'top', padding, domainLength);
1379
- padding_bottom = $$.getAxisPadding(config.axis_y2_padding, 'bottom', padding, domainLength);
1386
+ padding_top = $$.getAxisPadding(config.axis_y2_padding, 'top', padding_top, domainLength);
1387
+ padding_bottom = $$.getAxisPadding(config.axis_y2_padding, 'bottom', padding_bottom, domainLength);
1380
1388
  }
1381
1389
  // Bar/Area chart should be 0-based if all positive|negative
1382
1390
  if (isZeroBased) {
@@ -1787,8 +1795,8 @@
1787
1795
 
1788
1796
  // find mouseovering bar
1789
1797
  values.filter(function (v) { return v && $$.isBarType(v.id); }).forEach(function (v) {
1790
- var shape = $$.d3.select('.' + CLASS.bars + $$.getTargetSelectorSuffix(v.id) + ' .' + CLASS.bar + '-' + v.index).node();
1791
- if ($$.isWithinBar(shape)) {
1798
+ var shape = $$.main.select('.' + CLASS.bars + $$.getTargetSelectorSuffix(v.id) + ' .' + CLASS.bar + '-' + v.index).node();
1799
+ if (!closest && $$.isWithinBar(shape)) {
1792
1800
  closest = v;
1793
1801
  }
1794
1802
  });
@@ -2271,7 +2279,7 @@
2271
2279
 
2272
2280
  // Call event handler
2273
2281
  $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) {
2274
- config.data_onmouseover.call($$, d);
2282
+ config.data_onmouseover.call($$.api, d);
2275
2283
  });
2276
2284
  })
2277
2285
  .on('mouseout', function (d) {
@@ -2284,7 +2292,7 @@
2284
2292
  $$.unexpandBars();
2285
2293
  // Call event handler
2286
2294
  $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) {
2287
- config.data_onmouseout.call($$, d);
2295
+ config.data_onmouseout.call($$.api, d);
2288
2296
  });
2289
2297
  })
2290
2298
  .on('mousemove', function (d) {
@@ -2399,7 +2407,7 @@
2399
2407
  closest = $$.findClosestFromTargets(targetsToShow, mouse);
2400
2408
 
2401
2409
  if ($$.mouseover && (!closest || closest.id !== $$.mouseover.id)) {
2402
- config.data_onmouseout.call($$, $$.mouseover);
2410
+ config.data_onmouseout.call($$.api, $$.mouseover);
2403
2411
  $$.mouseover = undefined;
2404
2412
  }
2405
2413
 
@@ -2433,7 +2441,7 @@
2433
2441
  if ($$.isBarType(closest.id) || $$.dist(closest, mouse) < 100) {
2434
2442
  $$.svg.select('.' + CLASS.eventRect).style('cursor', 'pointer');
2435
2443
  if (!$$.mouseover) {
2436
- config.data_onmouseover.call($$, closest);
2444
+ config.data_onmouseover.call($$.api, closest);
2437
2445
  $$.mouseover = closest;
2438
2446
  }
2439
2447
  }
@@ -2517,7 +2525,7 @@
2517
2525
  } else if (config.axis_rotated) {
2518
2526
  return defaultPadding + legendWidthOnRight;
2519
2527
  } else if (!config.axis_y2_show || config.axis_y2_inner) { // && !config.axis_rotated
2520
- return defaultPadding + legendWidthOnRight + ($$.getY2AxisLabelPosition().isOuter ? 20 : 0);
2528
+ return 2 + legendWidthOnRight + ($$.getY2AxisLabelPosition().isOuter ? 20 : 0);
2521
2529
  } else {
2522
2530
  return ceil10($$.getAxisWidthByAxisId('y2')) + legendWidthOnRight;
2523
2531
  }
@@ -2545,9 +2553,10 @@
2545
2553
 
2546
2554
  c3_chart_internal_fn.getSvgLeft = function (withoutRecompute) {
2547
2555
  var $$ = this, config = $$.config,
2556
+ hasLeftAxisRect = config.axis_rotated || (!config.axis_rotated && !config.axis_y_inner),
2548
2557
  leftAxisClass = config.axis_rotated ? CLASS.axisX : CLASS.axisY,
2549
2558
  leftAxis = $$.main.select('.' + leftAxisClass).node(),
2550
- svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0},
2559
+ svgRect = leftAxis && hasLeftAxisRect ? leftAxis.getBoundingClientRect() : {right: 0},
2551
2560
  chartRect = $$.selectChart.node().getBoundingClientRect(),
2552
2561
  hasArc = $$.hasArcType(),
2553
2562
  svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : $$.getCurrentPaddingLeft(withoutRecompute));
@@ -3230,7 +3239,15 @@
3230
3239
  } else {
3231
3240
  xPos = $$.hasType('bar') ? (points[2][0] + points[0][0]) / 2 : points[0][0];
3232
3241
  }
3233
- return d.value !== null ? xPos : xPos > $$.width ? $$.width - box.width : xPos;
3242
+ // show labels regardless of the domain if value is null
3243
+ if (d.value === null) {
3244
+ if (xPos > $$.width) {
3245
+ xPos = $$.width - box.width;
3246
+ } else if (xPos < 0) {
3247
+ xPos = 4;
3248
+ }
3249
+ }
3250
+ return xPos;
3234
3251
  };
3235
3252
  c3_chart_internal_fn.getYForText = function (points, d, textElement) {
3236
3253
  var $$ = this,
@@ -3240,7 +3257,15 @@
3240
3257
  } else {
3241
3258
  yPos = points[2][1] + (d.value < 0 ? box.height : $$.isBarType(d) ? -3 : -6);
3242
3259
  }
3243
- return d.value !== null ? yPos : yPos < box.height ? box.height : yPos;
3260
+ // show labels regardless of the domain if value is null
3261
+ if (d.value === null && !$$.config.axis_rotated) {
3262
+ if (yPos < box.height) {
3263
+ yPos = box.height;
3264
+ } else if (yPos > this.height) {
3265
+ yPos = this.height - 4;
3266
+ }
3267
+ }
3268
+ return yPos;
3244
3269
  };
3245
3270
 
3246
3271
  c3_chart_internal_fn.setTargetType = function (targetIds, type) {
@@ -3263,10 +3288,12 @@
3263
3288
  has = true;
3264
3289
  }
3265
3290
  });
3266
- } else {
3291
+ } else if (Object.keys(types).length) {
3267
3292
  Object.keys(types).forEach(function (id) {
3268
3293
  if (types[id] === type) { has = true; }
3269
3294
  });
3295
+ } else {
3296
+ has = $$.config.data_type === type;
3270
3297
  }
3271
3298
  return has;
3272
3299
  };
@@ -3662,13 +3689,19 @@
3662
3689
 
3663
3690
  c3_chart_internal_fn.initLegend = function () {
3664
3691
  var $$ = this;
3692
+ $$.legendHasRendered = false;
3665
3693
  $$.legend = $$.svg.append("g").attr("transform", $$.getTranslate('legend'));
3666
3694
  if (!$$.config.legend_show) {
3667
3695
  $$.legend.style('visibility', 'hidden');
3668
3696
  $$.hiddenLegendIds = $$.mapToIds($$.data.targets);
3697
+ return;
3669
3698
  }
3670
3699
  // MEMO: call here to update legend box and tranlate for all
3671
3700
  // MEMO: translate will be upated by this, so transform not needed in updateLegend()
3701
+ $$.updateLegendWithDefaults();
3702
+ };
3703
+ c3_chart_internal_fn.updateLegendWithDefaults = function () {
3704
+ var $$ = this;
3672
3705
  $$.updateLegend($$.mapToIds($$.data.targets), {withTransform: false, withTransitionForTransform: false, withTransition: false});
3673
3706
  };
3674
3707
  c3_chart_internal_fn.updateSizeForLegend = function (legendHeight, legendWidth) {
@@ -3713,23 +3746,20 @@
3713
3746
  return h;
3714
3747
  };
3715
3748
  c3_chart_internal_fn.opacityForLegend = function (legendItem) {
3716
- var $$ = this;
3717
- return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 1;
3749
+ return legendItem.classed(CLASS.legendItemHidden) ? null : 1;
3718
3750
  };
3719
3751
  c3_chart_internal_fn.opacityForUnfocusedLegend = function (legendItem) {
3720
- var $$ = this;
3721
- return legendItem.classed(CLASS.legendItemHidden) ? $$.legendOpacityForHidden : 0.3;
3752
+ return legendItem.classed(CLASS.legendItemHidden) ? null : 0.3;
3722
3753
  };
3723
3754
  c3_chart_internal_fn.toggleFocusLegend = function (targetIds, focus) {
3724
3755
  var $$ = this;
3725
3756
  targetIds = $$.mapToTargetIds(targetIds);
3726
3757
  $$.legend.selectAll('.' + CLASS.legendItem)
3727
- .classed(CLASS.legendItemFocused, function (id) {
3728
- return targetIds.indexOf(id) >= 0 && focus;
3729
- })
3730
- .transition().duration(100)
3731
- .style('opacity', function (id) {
3732
- var opacity = targetIds.indexOf(id) >= 0 && focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
3758
+ .filter(function (id) { return targetIds.indexOf(id) >= 0; })
3759
+ .classed(CLASS.legendItemFocused, focus)
3760
+ .transition().duration(100)
3761
+ .style('opacity', function () {
3762
+ var opacity = focus ? $$.opacityForLegend : $$.opacityForUnfocusedLegend;
3733
3763
  return opacity.call($$, $$.d3.select(this));
3734
3764
  });
3735
3765
  };
@@ -3745,6 +3775,9 @@
3745
3775
  if (!config.legend_show) {
3746
3776
  config.legend_show = true;
3747
3777
  $$.legend.style('visibility', 'visible');
3778
+ if (!$$.legendHasRendered) {
3779
+ $$.updateLegendWithDefaults();
3780
+ }
3748
3781
  }
3749
3782
  $$.removeHiddenLegendIds(targetIds);
3750
3783
  $$.legend.selectAll($$.selectorLegends(targetIds))
@@ -3764,6 +3797,9 @@
3764
3797
  .style('visibility', 'hidden');
3765
3798
  };
3766
3799
  var legendItemTextBox = {};
3800
+ c3_chart_internal_fn.clearLegendItemTextBoxCache = function () {
3801
+ legendItemTextBox = {};
3802
+ };
3767
3803
  c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) {
3768
3804
  var $$ = this, config = $$.config;
3769
3805
  var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect;
@@ -3967,7 +4003,7 @@
3967
4003
  if ($$.isTargetToShow(id)) {
3968
4004
  return !hasFocused || This.classed(CLASS.legendItemFocused) ? $$.opacityForLegend(This) : $$.opacityForUnfocusedLegend(This);
3969
4005
  } else {
3970
- return $$.legendOpacityForHidden;
4006
+ return null; // c3-legend-item-hidden will be applied
3971
4007
  }
3972
4008
  });
3973
4009
 
@@ -3981,6 +4017,7 @@
3981
4017
  $$.updateSvgSize();
3982
4018
  // Update g positions
3983
4019
  $$.transformAll(withTransitionForTransform, transitions);
4020
+ $$.legendHasRendered = true;
3984
4021
  };
3985
4022
 
3986
4023
  c3_chart_internal_fn.initAxis = function () {
@@ -4300,9 +4337,19 @@
4300
4337
  .text($$.textForY2AxisLabel.bind($$));
4301
4338
  };
4302
4339
 
4303
- c3_chart_internal_fn.getAxisPadding = function (padding, key, defaultValue, all) {
4304
- var ratio = padding.unit === 'ratio' ? all : 1;
4305
- return isValue(padding[key]) ? padding[key] * ratio : defaultValue;
4340
+ c3_chart_internal_fn.getAxisPadding = function (padding, key, defaultValue, domainLength) {
4341
+ if (!isValue(padding[key])) {
4342
+ return defaultValue;
4343
+ }
4344
+ if (padding.unit === 'ratio') {
4345
+ return padding[key] * domainLength;
4346
+ }
4347
+ // assume padding is pixels if unit is not specified
4348
+ return this.convertPixelsToAxisPadding(padding[key], domainLength);
4349
+ };
4350
+ c3_chart_internal_fn.convertPixelsToAxisPadding = function (pixels, domainLength) {
4351
+ var length = this.config.axis_rotated ? this.width : this.height;
4352
+ return domainLength * (pixels / length);
4306
4353
  };
4307
4354
 
4308
4355
  c3_chart_internal_fn.generateTickValues = function (values, tickCount, forTimeSeries) {
@@ -4353,6 +4400,7 @@
4353
4400
  // rotate tick text if needed
4354
4401
  if (!config.axis_rotated && config.axis_x_tick_rotate) {
4355
4402
  $$.rotateTickText($$.axes.x, transitions.axisX, config.axis_x_tick_rotate);
4403
+ $$.rotateTickText($$.axes.subx, transitions.axisSubX, config.axis_x_tick_rotate);
4356
4404
  }
4357
4405
  };
4358
4406
 
@@ -4395,7 +4443,8 @@
4395
4443
  return forHorizontal ? $$.width + 2 + left + right : $$.margin.left + 20;
4396
4444
  };
4397
4445
  c3_chart_internal_fn.getAxisClipHeight = function (forHorizontal) {
4398
- return (forHorizontal ? this.margin.bottom : (this.margin.top + this.height)) + 8;
4446
+ // less than 20 is not enough to show the axis label 'outer' without legend
4447
+ return (forHorizontal ? this.margin.bottom : (this.margin.top + this.height)) + 20;
4399
4448
  };
4400
4449
  c3_chart_internal_fn.getXAxisClipWidth = function () {
4401
4450
  var $$ = this;
@@ -4661,15 +4710,18 @@
4661
4710
  mainArc.enter().append('path')
4662
4711
  .attr("class", $$.classArc.bind($$))
4663
4712
  .style("fill", function (d) { return $$.color(d.data); })
4664
- .style("cursor", function (d) { return config.data_selection_isselectable(d) ? "pointer" : null; })
4713
+ .style("cursor", function (d) { return config.interaction_enabled && config.data_selection_isselectable(d) ? "pointer" : null; })
4665
4714
  .style("opacity", 0)
4666
4715
  .each(function (d) {
4667
4716
  if ($$.isGaugeType(d.data)) {
4668
4717
  d.startAngle = d.endAngle = -1 * (Math.PI / 2);
4669
4718
  }
4670
4719
  this._current = d;
4671
- })
4672
- .on('mouseover', function (d) {
4720
+ });
4721
+ mainArc
4722
+ .attr("transform", function (d) { return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : ""; })
4723
+ .style("opacity", function (d) { return d === this._current ? 0 : 1; })
4724
+ .on('mouseover', config.interaction_enabled ? function (d) {
4673
4725
  var updated, arcData;
4674
4726
  if ($$.transiting) { // skip while transiting
4675
4727
  return;
@@ -4681,14 +4733,14 @@
4681
4733
  $$.api.focus(updated.data.id);
4682
4734
  $$.toggleFocusLegend(updated.data.id, true);
4683
4735
  $$.config.data_onmouseover(arcData, this);
4684
- })
4685
- .on('mousemove', function (d) {
4736
+ } : null)
4737
+ .on('mousemove', config.interaction_enabled ? function (d) {
4686
4738
  var updated = $$.updateAngle(d),
4687
4739
  arcData = $$.convertToArcData(updated),
4688
4740
  selectedData = [arcData];
4689
4741
  $$.showTooltip(selectedData, d3.mouse(this));
4690
- })
4691
- .on('mouseout', function (d) {
4742
+ } : null)
4743
+ .on('mouseout', config.interaction_enabled ? function (d) {
4692
4744
  var updated, arcData;
4693
4745
  if ($$.transiting) { // skip while transiting
4694
4746
  return;
@@ -4701,16 +4753,13 @@
4701
4753
  $$.revertLegend();
4702
4754
  $$.hideTooltip();
4703
4755
  $$.config.data_onmouseout(arcData, this);
4704
- })
4705
- .on('click', function (d, i) {
4756
+ } : null)
4757
+ .on('click', config.interaction_enabled ? function (d, i) {
4706
4758
  var updated = $$.updateAngle(d),
4707
4759
  arcData = $$.convertToArcData(updated);
4708
4760
  if ($$.toggleShape) { $$.toggleShape(this, arcData, i); }
4709
4761
  $$.config.data_onclick.call($$.api, arcData, this);
4710
- });
4711
- mainArc
4712
- .attr("transform", function (d) { return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : ""; })
4713
- .style("opacity", function (d) { return d === this._current ? 0 : 1; })
4762
+ } : null)
4714
4763
  .each(function () { $$.transiting = true; })
4715
4764
  .transition().duration(duration)
4716
4765
  .attrTween("d", function (d) {
@@ -4949,7 +4998,7 @@
4949
4998
  .attr('class', CLASS.dragarea)
4950
4999
  .style('opacity', 0.1);
4951
5000
  $$.dragging = true;
4952
- $$.config.data_ondragstart();
5001
+ $$.config.data_ondragstart.call($$.api);
4953
5002
  };
4954
5003
 
4955
5004
  c3_chart_internal_fn.dragend = function () {
@@ -4963,7 +5012,7 @@
4963
5012
  $$.main.selectAll('.' + CLASS.shape)
4964
5013
  .classed(CLASS.INCLUDED, false);
4965
5014
  $$.dragging = false;
4966
- $$.config.data_ondragend();
5015
+ $$.config.data_ondragend.call($$.api);
4967
5016
  };
4968
5017
 
4969
5018
 
@@ -5144,11 +5193,6 @@
5144
5193
  // update subchart elements if needed
5145
5194
  if (withSubchart) {
5146
5195
 
5147
- // rotate tick text if needed
5148
- if (!config.axis_rotated && config.axis_x_tick_rotate) {
5149
- $$.rotateTickText($$.axes.subx, transitions.axisSubX, config.axis_x_tick_rotate);
5150
- }
5151
-
5152
5196
  // extent rect
5153
5197
  if (!$$.brush.empty()) {
5154
5198
  $$.brush.extent($$.x.orgDomain()).update();
@@ -5251,7 +5295,7 @@
5251
5295
  .on('zoomend', function () {
5252
5296
  var event = d3.event.sourceEvent;
5253
5297
  // if click, do nothing. otherwise, click interaction will be canceled.
5254
- if (event && startEvent.x === event.x && startEvent.y === event.y) {
5298
+ if (event && startEvent.clientX === event.clientX && startEvent.clientY === event.clientY) {
5255
5299
  return;
5256
5300
  }
5257
5301
  $$.redrawEventRect();
@@ -5581,7 +5625,7 @@
5581
5625
  };
5582
5626
  c3_chart_internal_fn.selectorLegends = function (ids) {
5583
5627
  var $$ = this;
5584
- return ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null;
5628
+ return ids && ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null;
5585
5629
  };
5586
5630
 
5587
5631
  var isValue = c3_chart_internal_fn.isValue = function (v) {
@@ -5680,7 +5724,9 @@
5680
5724
  if ($$.hasArcType()) {
5681
5725
  $$.unexpandArc(targetIds);
5682
5726
  }
5683
- $$.revertLegend();
5727
+ if ($$.config.legend_show) {
5728
+ $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
5729
+ }
5684
5730
 
5685
5731
  $$.focusedTargetIds = [];
5686
5732
  $$.defocusedTargetIds = [];
@@ -5730,9 +5776,11 @@
5730
5776
  $$.redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true});
5731
5777
  };
5732
5778
 
5733
- c3_chart_fn.toggle = function (targetId) {
5734
- var $$ = this.internal;
5735
- $$.isTargetToShow(targetId) ? this.hide(targetId) : this.show(targetId);
5779
+ c3_chart_fn.toggle = function (targetIds) {
5780
+ var that = this, $$ = this.internal;
5781
+ $$.mapToTargetIds(targetIds).forEach(function (targetId) {
5782
+ $$.isTargetToShow(targetId) ? that.hide(targetId) : that.show(targetId);
5783
+ });
5736
5784
  };
5737
5785
 
5738
5786
  c3_chart_fn.zoom = function (domain) {
@@ -5948,7 +5996,8 @@
5948
5996
  },
5949
5997
  withLegend: true,
5950
5998
  withTransition: orgDataCount > 1,
5951
- withTrimXDomain: false
5999
+ withTrimXDomain: false,
6000
+ withUpdateXAxis: true,
5952
6001
  });
5953
6002
  };
5954
6003
 
@@ -6274,6 +6323,7 @@
6274
6323
  return values;
6275
6324
  };
6276
6325
  c3_chart_fn.data.names = function (names) {
6326
+ this.internal.clearLegendItemTextBoxCache();
6277
6327
  return this.internal.updateDataAttributes('names', names);
6278
6328
  };
6279
6329
  c3_chart_fn.data.colors = function (colors) {
@@ -6600,7 +6650,7 @@
6600
6650
  var dy = sizeFor1Char.h;
6601
6651
  if (i === 0) {
6602
6652
  if (orient === 'left' || orient === 'right') {
6603
- dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - (params.isCategory ? 2 : 3));
6653
+ dy = -((counts[d.index] - 1) * (sizeFor1Char.h / 2) - 3);
6604
6654
  } else {
6605
6655
  dy = ".71em";
6606
6656
  }
@@ -6609,7 +6659,7 @@
6609
6659
  }
6610
6660
 
6611
6661
  function tickSize(d) {
6612
- var tickPosition = scale(d) + tickOffset;
6662
+ var tickPosition = scale(d) + (tickCentered ? 0 : tickOffset);
6613
6663
  return range[0] < tickPosition && tickPosition < range[1] ? innerTickSize : 0;
6614
6664
  }
6615
6665
 
@@ -6621,9 +6671,10 @@
6621
6671
  return splitted.map(function (s) {
6622
6672
  return { index: i, splitted: s };
6623
6673
  });
6624
- })
6625
- .enter().append('tspan')
6626
- .text(function (d) { return d.splitted; });
6674
+ });
6675
+ tspan.enter().append('tspan');
6676
+ tspan.exit().remove();
6677
+ tspan.text(function (d) { return d.splitted; });
6627
6678
 
6628
6679
  switch (orient) {
6629
6680
  case "bottom":
@@ -99,6 +99,7 @@
99
99
  /*-- Arc --*/
100
100
 
101
101
  .c3-chart-arcs-title {
102
+ dominant-baseline: middle;
102
103
  font-size: 1.3em;
103
104
  }
104
105
 
@@ -138,6 +139,9 @@
138
139
  .c3-legend-item {
139
140
  font-size: 12px;
140
141
  }
142
+ .c3-legend-item-hidden {
143
+ opacity: 0.15;
144
+ }
141
145
 
142
146
  .c3-legend-background {
143
147
  opacity: 0.75;
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
4
+ version: 0.4.8
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-25 00:00:00.000000000 Z
11
+ date: 2014-12-16 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: