|
1 |
| -/* @license C3.js v0.7.7 | (c) C3 Team and other contributors | http://c3js.org/ */ |
| 1 | +/* @license C3.js v0.7.8 | (c) C3 Team and other contributors | http://c3js.org/ */ |
2 | 2 | (function (global, factory) {
|
3 | 3 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
4 | 4 | typeof define === 'function' && define.amd ? define(factory) :
|
|
94 | 94 | })(Chart.prototype, this, this);
|
95 | 95 | }
|
96 | 96 |
|
| 97 | + var asHalfPixel = function asHalfPixel(n) { |
| 98 | + return Math.ceil(n) + 0.5; |
| 99 | + }; |
| 100 | + var ceil10 = function ceil10(v) { |
| 101 | + return Math.ceil(v / 10) * 10; |
| 102 | + }; |
| 103 | + var diffDomain = function diffDomain(d) { |
| 104 | + return d[1] - d[0]; |
| 105 | + }; |
| 106 | + var getOption = function getOption(options, key, defaultValue) { |
| 107 | + return isDefined(options[key]) ? options[key] : defaultValue; |
| 108 | + }; |
| 109 | + var getPathBox = function getPathBox(path) { |
| 110 | + var box = getBBox(path), |
| 111 | + items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)], |
| 112 | + minX = items[0].x, |
| 113 | + minY = Math.min(items[0].y, items[1].y); |
| 114 | + return { |
| 115 | + x: minX, |
| 116 | + y: minY, |
| 117 | + width: box.width, |
| 118 | + height: box.height |
| 119 | + }; |
| 120 | + }; |
| 121 | + var getBBox = function getBBox(element) { |
| 122 | + try { |
| 123 | + return element.getBBox(); |
| 124 | + } catch (ignore) { |
| 125 | + // Firefox will throw an exception if getBBox() is called whereas the |
| 126 | + // element is rendered with display:none |
| 127 | + // See https://github.com/c3js/c3/issues/2692 |
| 128 | + // The previous code was using `getBoundingClientRect` which was returning |
| 129 | + // everything at 0 in this case so let's reproduce this behavior here. |
| 130 | + return { |
| 131 | + x: 0, |
| 132 | + y: 0, |
| 133 | + width: 0, |
| 134 | + height: 0 |
| 135 | + }; |
| 136 | + } |
| 137 | + }; |
| 138 | + var hasValue = function hasValue(dict, value) { |
| 139 | + var found = false; |
| 140 | + Object.keys(dict).forEach(function (key) { |
| 141 | + if (dict[key] === value) { |
| 142 | + found = true; |
| 143 | + } |
| 144 | + }); |
| 145 | + return found; |
| 146 | + }; |
| 147 | + var isArray = function isArray(o) { |
| 148 | + return Array.isArray(o); |
| 149 | + }; |
| 150 | + var isDefined = function isDefined(v) { |
| 151 | + return typeof v !== 'undefined'; |
| 152 | + }; |
| 153 | + var isEmpty = function isEmpty(o) { |
| 154 | + return typeof o === 'undefined' || o === null || isString(o) && o.length === 0 || _typeof(o) === 'object' && Object.keys(o).length === 0; |
| 155 | + }; |
| 156 | + var isFunction = function isFunction(o) { |
| 157 | + return typeof o === 'function'; |
| 158 | + }; |
| 159 | + var isNumber = function isNumber(o) { |
| 160 | + return typeof o === 'number'; |
| 161 | + }; |
| 162 | + var isString = function isString(o) { |
| 163 | + return typeof o === 'string'; |
| 164 | + }; |
| 165 | + var isUndefined = function isUndefined(v) { |
| 166 | + return typeof v === 'undefined'; |
| 167 | + }; |
| 168 | + var isValue = function isValue(v) { |
| 169 | + return v || v === 0; |
| 170 | + }; |
| 171 | + var notEmpty = function notEmpty(o) { |
| 172 | + return !isEmpty(o); |
| 173 | + }; |
| 174 | + var sanitise = function sanitise(str) { |
| 175 | + return typeof str === 'string' ? str.replace(/</g, '<').replace(/>/g, '>') : str; |
| 176 | + }; |
| 177 | + var flattenArray = function flattenArray(arr) { |
| 178 | + var _ref; |
| 179 | + |
| 180 | + return Array.isArray(arr) ? (_ref = []).concat.apply(_ref, _toConsumableArray(arr)) : []; |
| 181 | + }; |
| 182 | + |
97 | 183 | function AxisInternal(component, params) {
|
98 | 184 | var internal = this;
|
99 | 185 | internal.component = component;
|
|
197 | 283 | tick.select('text').text(function (d) {
|
198 | 284 | return internal.textFormatted(d);
|
199 | 285 | }).each(function (d) {
|
200 |
| - var box = this.getBBox(), |
| 286 | + var box = getBBox(this), |
201 | 287 | text = internal.textFormatted(d),
|
202 | 288 | h = box.height,
|
203 | 289 | w = text ? box.width / text.length : undefined;
|
|
660 | 746 | INCLUDED: '_included_'
|
661 | 747 | };
|
662 | 748 |
|
663 |
| - var asHalfPixel = function asHalfPixel(n) { |
664 |
| - return Math.ceil(n) + 0.5; |
665 |
| - }; |
666 |
| - var ceil10 = function ceil10(v) { |
667 |
| - return Math.ceil(v / 10) * 10; |
668 |
| - }; |
669 |
| - var diffDomain = function diffDomain(d) { |
670 |
| - return d[1] - d[0]; |
671 |
| - }; |
672 |
| - var getOption = function getOption(options, key, defaultValue) { |
673 |
| - return isDefined(options[key]) ? options[key] : defaultValue; |
674 |
| - }; |
675 |
| - var getPathBox = function getPathBox(path) { |
676 |
| - var box = path.getBBox(), |
677 |
| - items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)], |
678 |
| - minX = items[0].x, |
679 |
| - minY = Math.min(items[0].y, items[1].y); |
680 |
| - return { |
681 |
| - x: minX, |
682 |
| - y: minY, |
683 |
| - width: box.width, |
684 |
| - height: box.height |
685 |
| - }; |
686 |
| - }; |
687 |
| - var hasValue = function hasValue(dict, value) { |
688 |
| - var found = false; |
689 |
| - Object.keys(dict).forEach(function (key) { |
690 |
| - if (dict[key] === value) { |
691 |
| - found = true; |
692 |
| - } |
693 |
| - }); |
694 |
| - return found; |
695 |
| - }; |
696 |
| - var isArray = function isArray(o) { |
697 |
| - return Array.isArray(o); |
698 |
| - }; |
699 |
| - var isDefined = function isDefined(v) { |
700 |
| - return typeof v !== 'undefined'; |
701 |
| - }; |
702 |
| - var isEmpty = function isEmpty(o) { |
703 |
| - return typeof o === 'undefined' || o === null || isString(o) && o.length === 0 || _typeof(o) === 'object' && Object.keys(o).length === 0; |
704 |
| - }; |
705 |
| - var isFunction = function isFunction(o) { |
706 |
| - return typeof o === 'function'; |
707 |
| - }; |
708 |
| - var isNumber = function isNumber(o) { |
709 |
| - return typeof o === 'number'; |
710 |
| - }; |
711 |
| - var isString = function isString(o) { |
712 |
| - return typeof o === 'string'; |
713 |
| - }; |
714 |
| - var isUndefined = function isUndefined(v) { |
715 |
| - return typeof v === 'undefined'; |
716 |
| - }; |
717 |
| - var isValue = function isValue(v) { |
718 |
| - return v || v === 0; |
719 |
| - }; |
720 |
| - var notEmpty = function notEmpty(o) { |
721 |
| - return !isEmpty(o); |
722 |
| - }; |
723 |
| - var sanitise = function sanitise(str) { |
724 |
| - return typeof str === 'string' ? str.replace(/</g, '<').replace(/>/g, '>') : str; |
725 |
| - }; |
726 |
| - var flattenArray = function flattenArray(arr) { |
727 |
| - var _ref; |
728 |
| - |
729 |
| - return Array.isArray(arr) ? (_ref = []).concat.apply(_ref, _toConsumableArray(arr)) : []; |
730 |
| - }; |
731 |
| - |
732 | 749 | var Axis = function Axis(owner) {
|
733 | 750 | _classCallCheck(this, Axis);
|
734 | 751 |
|
|
1090 | 1107 | dummy = $$.d3.select('body').append('div').classed('c3', true);
|
1091 | 1108 | svg = dummy.append("svg").style('visibility', 'hidden').style('position', 'fixed').style('top', 0).style('left', 0), svg.append('g').call(axis).each(function () {
|
1092 | 1109 | $$.d3.select(this).selectAll('text').each(function () {
|
1093 |
| - var box = this.getBBox(); |
| 1110 | + var box = getBBox(this); |
1094 | 1111 |
|
1095 | 1112 | if (maxWidth < box.width) {
|
1096 | 1113 | maxWidth = box.width;
|
|
1199 | 1216 | };
|
1200 | 1217 |
|
1201 | 1218 | var c3 = {
|
1202 |
| - version: "0.7.7", |
| 1219 | + version: "0.7.8", |
1203 | 1220 | chart: {
|
1204 | 1221 | fn: Chart.prototype,
|
1205 | 1222 | internal: {
|
|
7393 | 7410 | $$.selectChart.select('svg').selectAll('.dummy').data([min, max]).enter().append('text').text(function (d) {
|
7394 | 7411 | return $$.dataLabelFormat(d.id)(d);
|
7395 | 7412 | }).each(function (d, i) {
|
7396 |
| - lengths[i] = this.getBBox()[key] * paddingCoef; |
| 7413 | + lengths[i] = getBBox(this)[key] * paddingCoef; |
7397 | 7414 | }).remove();
|
7398 | 7415 | return lengths;
|
7399 | 7416 | };
|
|
9439 | 9456 | return false;
|
9440 | 9457 | }
|
9441 | 9458 |
|
9442 |
| - var box = that.getBBox(), |
| 9459 | + var box = getBBox(that), |
9443 | 9460 | seg0 = that.pathSegList.getItem(0),
|
9444 | 9461 | seg1 = that.pathSegList.getItem(1),
|
9445 | 9462 | x = Math.min(seg0.x, seg1.x),
|
|
9952 | 9969 | ChartInternal.prototype.updateCircle = function (cx, cy) {
|
9953 | 9970 | var $$ = this;
|
9954 | 9971 | var mainCircle = $$.main.selectAll('.' + CLASS.circles).selectAll('.' + CLASS.circle).data($$.lineOrScatterOrStanfordData.bind($$));
|
9955 |
| - var mainCircleEnter = mainCircle.enter().append("circle").attr('shape-rendering', 'crispEdges').attr("class", $$.classCircle.bind($$)).attr("cx", cx).attr("cy", cy).attr("r", $$.pointR.bind($$)).style("fill", $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color); |
| 9972 | + var mainCircleEnter = mainCircle.enter().append("circle").attr('shape-rendering', $$.isStanfordGraphType() ? 'crispEdges' : '').attr("class", $$.classCircle.bind($$)).attr("cx", cx).attr("cy", cy).attr("r", $$.pointR.bind($$)).style("color", $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color); |
9956 | 9973 | $$.mainCircle = mainCircleEnter.merge(mainCircle).style("opacity", $$.isStanfordGraphType() ? 1 : $$.initialOpacityForCircle.bind($$));
|
9957 | 9974 | mainCircle.exit().style("opacity", 0);
|
9958 | 9975 | };
|
9959 | 9976 |
|
9960 | 9977 | ChartInternal.prototype.redrawCircle = function (cx, cy, withTransition, transition) {
|
9961 | 9978 | var $$ = this,
|
9962 | 9979 | selectedCircles = $$.main.selectAll('.' + CLASS.selectedCircle);
|
9963 |
| - return [(withTransition ? $$.mainCircle.transition(transition) : $$.mainCircle).style('opacity', this.opacityForCircle.bind($$)).style("fill", $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color).attr("cx", cx).attr("cy", cy), (withTransition ? selectedCircles.transition(transition) : selectedCircles).attr("cx", cx).attr("cy", cy)]; |
| 9980 | + return [(withTransition ? $$.mainCircle.transition(transition) : $$.mainCircle).style('opacity', this.opacityForCircle.bind($$)).style("color", $$.isStanfordGraphType() ? $$.getStanfordPointColor.bind($$) : $$.color).attr("cx", cx).attr("cy", cy), (withTransition ? selectedCircles.transition(transition) : selectedCircles).attr("cx", cx).attr("cy", cy)]; |
9964 | 9981 | };
|
9965 | 9982 |
|
9966 | 9983 | ChartInternal.prototype.circleX = function (d) {
|
|
10523 | 10540 | font = this.d3.select(element).style('font'),
|
10524 | 10541 | rect;
|
10525 | 10542 | svg.selectAll('.dummy').data([text]).enter().append('text').classed(cls ? cls : "", true).style('font', font).text(text).each(function () {
|
10526 |
| - rect = this.getBBox(); |
| 10543 | + rect = getBBox(this); |
10527 | 10544 | });
|
10528 | 10545 | dummy.remove();
|
10529 | 10546 | return rect;
|
|
10543 | 10560 |
|
10544 | 10561 | ChartInternal.prototype.getXForText = function (points, d, textElement) {
|
10545 | 10562 | var $$ = this,
|
10546 |
| - box = textElement.getBBox(), |
| 10563 | + box = getBBox(textElement), |
10547 | 10564 | xPos,
|
10548 | 10565 | padding;
|
10549 | 10566 |
|
|
10568 | 10585 |
|
10569 | 10586 | ChartInternal.prototype.getYForText = function (points, d, textElement) {
|
10570 | 10587 | var $$ = this,
|
10571 |
| - box = textElement.getBBox(), |
| 10588 | + box = getBBox(textElement), |
10572 | 10589 | yPos;
|
10573 | 10590 |
|
10574 | 10591 | if ($$.config.axis_rotated) {
|
|
10708 | 10725 |
|
10709 | 10726 | ChartInternal.prototype.xForColorScale = function () {
|
10710 | 10727 | var $$ = this;
|
10711 |
| - return $$.config.stanford_padding.right + $$.colorScale.node().getBBox().width; |
| 10728 | + return $$.config.stanford_padding.right + getBBox($$.colorScale.node()).width; |
10712 | 10729 | };
|
10713 | 10730 |
|
10714 | 10731 | ChartInternal.prototype.getColorScalePadding = function () {
|
|
0 commit comments