|
1 | 1 | /*!
|
2 |
| - * ApexCharts v3.35.0 |
| 2 | + * ApexCharts v3.35.1 |
3 | 3 | * (c) 2018-2022 ApexCharts
|
4 | 4 | * Released under the MIT License.
|
5 | 5 | */
|
|
1613 | 1613 | return g;
|
1614 | 1614 | }
|
1615 | 1615 | }, {
|
1616 |
| - key: "drawText", |
1617 |
| - value: function drawText(_ref3) { |
1618 |
| - var x = _ref3.x, |
1619 |
| - y = _ref3.y, |
1620 |
| - text = _ref3.text, |
1621 |
| - textAnchor = _ref3.textAnchor, |
| 1616 | + key: "getTextBasedOnMaxWidth", |
| 1617 | + value: function getTextBasedOnMaxWidth(_ref3) { |
| 1618 | + var text = _ref3.text, |
| 1619 | + maxWidth = _ref3.maxWidth, |
1622 | 1620 | fontSize = _ref3.fontSize,
|
1623 |
| - fontFamily = _ref3.fontFamily, |
1624 |
| - fontWeight = _ref3.fontWeight, |
1625 |
| - foreColor = _ref3.foreColor, |
1626 |
| - opacity = _ref3.opacity, |
1627 |
| - _ref3$cssClass = _ref3.cssClass, |
1628 |
| - cssClass = _ref3$cssClass === void 0 ? '' : _ref3$cssClass, |
1629 |
| - _ref3$isPlainText = _ref3.isPlainText, |
1630 |
| - isPlainText = _ref3$isPlainText === void 0 ? true : _ref3$isPlainText; |
| 1621 | + fontFamily = _ref3.fontFamily; |
| 1622 | + var tRects = this.getTextRects(text, fontSize, fontFamily); |
| 1623 | + var wordWidth = tRects.width / text.length; |
| 1624 | + var wordsBasedOnWidth = Math.floor(maxWidth / wordWidth); |
| 1625 | + |
| 1626 | + if (maxWidth < tRects.width) { |
| 1627 | + return text.slice(0, wordsBasedOnWidth - 3) + '...'; |
| 1628 | + } |
| 1629 | + |
| 1630 | + return text; |
| 1631 | + } |
| 1632 | + }, { |
| 1633 | + key: "drawText", |
| 1634 | + value: function drawText(_ref4) { |
| 1635 | + var _this = this; |
| 1636 | + |
| 1637 | + var x = _ref4.x, |
| 1638 | + y = _ref4.y, |
| 1639 | + text = _ref4.text, |
| 1640 | + textAnchor = _ref4.textAnchor, |
| 1641 | + fontSize = _ref4.fontSize, |
| 1642 | + fontFamily = _ref4.fontFamily, |
| 1643 | + fontWeight = _ref4.fontWeight, |
| 1644 | + foreColor = _ref4.foreColor, |
| 1645 | + opacity = _ref4.opacity, |
| 1646 | + maxWidth = _ref4.maxWidth, |
| 1647 | + _ref4$cssClass = _ref4.cssClass, |
| 1648 | + cssClass = _ref4$cssClass === void 0 ? '' : _ref4$cssClass, |
| 1649 | + _ref4$isPlainText = _ref4.isPlainText, |
| 1650 | + isPlainText = _ref4$isPlainText === void 0 ? true : _ref4$isPlainText; |
1631 | 1651 | var w = this.w;
|
1632 | 1652 | if (typeof text === 'undefined') text = '';
|
| 1653 | + var truncatedText = text; |
1633 | 1654 |
|
1634 | 1655 | if (!textAnchor) {
|
1635 | 1656 | textAnchor = 'start';
|
|
1640 | 1661 | }
|
1641 | 1662 |
|
1642 | 1663 | fontFamily = fontFamily || w.config.chart.fontFamily;
|
| 1664 | + fontSize = fontSize || '11px'; |
1643 | 1665 | fontWeight = fontWeight || 'regular';
|
| 1666 | + var commonProps = { |
| 1667 | + maxWidth: maxWidth, |
| 1668 | + fontSize: fontSize, |
| 1669 | + fontFamily: fontFamily |
| 1670 | + }; |
1644 | 1671 | var elText;
|
1645 | 1672 |
|
1646 | 1673 | if (Array.isArray(text)) {
|
1647 | 1674 | elText = w.globals.dom.Paper.text(function (add) {
|
1648 | 1675 | for (var i = 0; i < text.length; i++) {
|
1649 |
| - i === 0 ? add.tspan(text[i]) : add.tspan(text[i]).newLine(); |
| 1676 | + if (maxWidth) { |
| 1677 | + truncatedText = _this.getTextBasedOnMaxWidth(_objectSpread2({ |
| 1678 | + text: text[i] |
| 1679 | + }, commonProps)); |
| 1680 | + } |
| 1681 | + |
| 1682 | + i === 0 ? add.tspan(truncatedText) : add.tspan(truncatedText).newLine(); |
1650 | 1683 | }
|
1651 | 1684 | });
|
1652 | 1685 | } else {
|
| 1686 | + if (maxWidth) { |
| 1687 | + truncatedText = this.getTextBasedOnMaxWidth(_objectSpread2({ |
| 1688 | + text: text |
| 1689 | + }, commonProps)); |
| 1690 | + } |
| 1691 | + |
1653 | 1692 | elText = isPlainText ? w.globals.dom.Paper.plain(text) : w.globals.dom.Paper.text(function (add) {
|
1654 |
| - return add.tspan(text); |
| 1693 | + return add.tspan(truncatedText); |
1655 | 1694 | });
|
1656 | 1695 | }
|
1657 | 1696 |
|
|
1836 | 1875 |
|
1837 | 1876 | if (activeFilter !== 'none') {
|
1838 | 1877 | filters.applyFilter(path, i, activeFilter.type, activeFilter.value);
|
| 1878 | + } else { |
| 1879 | + // Reapply the hover filter in case it was removed by `deselect`when there is no active filter and it is not a touch device |
| 1880 | + if (w.config.states.hover.filter !== 'none') { |
| 1881 | + if (!w.globals.isTouchDevice) { |
| 1882 | + var hoverFilter = w.config.states.hover.filter; |
| 1883 | + filters.applyFilter(path, i, hoverFilter.type, hoverFilter.value); |
| 1884 | + } |
| 1885 | + } |
1839 | 1886 | }
|
1840 | 1887 | } else {
|
| 1888 | + // If the item was deselected, apply hover state filter if it is not a touch device |
1841 | 1889 | if (w.config.states.active.filter.type !== 'none') {
|
1842 |
| - filters.getDefaultFilter(path, i); |
| 1890 | + if (w.config.states.hover.filter.type !== 'none' && !w.globals.isTouchDevice) { |
| 1891 | + var hoverFilter = w.config.states.hover.filter; |
| 1892 | + filters.applyFilter(path, i, hoverFilter.type, hoverFilter.value); |
| 1893 | + } else { |
| 1894 | + filters.getDefaultFilter(path, i); |
| 1895 | + } |
1843 | 1896 | }
|
1844 | 1897 | }
|
1845 | 1898 |
|
|
3826 | 3879 | width: 2,
|
3827 | 3880 | colors: undefined,
|
3828 | 3881 | // array of colors
|
3829 |
| - dashArray: 0 // single value or array of values |
3830 |
| - |
| 3882 | + dashArray: 0, |
| 3883 | + // single value or array of values |
| 3884 | + fill: { |
| 3885 | + type: 'solid', |
| 3886 | + colors: undefined, |
| 3887 | + // array of colors |
| 3888 | + opacity: 0.85, |
| 3889 | + gradient: { |
| 3890 | + shade: 'dark', |
| 3891 | + type: 'horizontal', |
| 3892 | + shadeIntensity: 0.5, |
| 3893 | + gradientToColors: undefined, |
| 3894 | + inverseColors: true, |
| 3895 | + opacityFrom: 1, |
| 3896 | + opacityTo: 1, |
| 3897 | + stops: [0, 50, 100], |
| 3898 | + colorStops: [] |
| 3899 | + } |
| 3900 | + } |
3831 | 3901 | },
|
3832 | 3902 | tooltip: {
|
3833 | 3903 | enabled: true,
|
|
3921 | 3991 | hour: 'HH:mm',
|
3922 | 3992 | minute: 'HH:mm:ss',
|
3923 | 3993 | second: 'HH:mm:ss'
|
3924 |
| - }, |
3925 |
| - group: { |
3926 |
| - groups: [], |
3927 |
| - style: { |
3928 |
| - colors: [], |
3929 |
| - fontSize: '12px', |
3930 |
| - fontWeight: 400, |
3931 |
| - fontFamily: undefined, |
3932 |
| - cssClass: '' |
3933 |
| - } |
| 3994 | + } |
| 3995 | + }, |
| 3996 | + group: { |
| 3997 | + groups: [], |
| 3998 | + style: { |
| 3999 | + colors: [], |
| 4000 | + fontSize: '12px', |
| 4001 | + fontWeight: 400, |
| 4002 | + fontFamily: undefined, |
| 4003 | + cssClass: '' |
3934 | 4004 | }
|
3935 | 4005 | },
|
3936 | 4006 | axisBorder: {
|
|
8130 | 8200 | value: function area() {
|
8131 | 8201 | return {
|
8132 | 8202 | stroke: {
|
8133 |
| - width: 4 |
| 8203 | + width: 4, |
| 8204 | + fill: { |
| 8205 | + type: 'solid', |
| 8206 | + gradient: { |
| 8207 | + inverseColors: false, |
| 8208 | + shade: 'light', |
| 8209 | + type: 'vertical', |
| 8210 | + opacityFrom: 0.65, |
| 8211 | + opacityTo: 0.5, |
| 8212 | + stops: [0, 100, 100] |
| 8213 | + } |
| 8214 | + } |
8134 | 8215 | },
|
8135 | 8216 | fill: {
|
8136 | 8217 | type: 'gradient',
|
|
9573 | 9654 | var dt = new DateTime(ctx);
|
9574 | 9655 | var xlabels = cnf.labels.length > 0 ? cnf.labels.slice() : cnf.xaxis.categories.slice();
|
9575 | 9656 | gl.isRangeBar = cnf.chart.type === 'rangeBar' && gl.isBarHorizontal;
|
9576 |
| - gl.hasGroups = cnf.xaxis.type === 'category' && typeof cnf.xaxis.group !== 'undefined' && typeof cnf.xaxis.group.groups !== 'undefined' && cnf.xaxis.group.groups.length > 0; |
| 9657 | + gl.hasGroups = cnf.xaxis.type === 'category' && cnf.xaxis.group.groups.length > 0; |
9577 | 9658 |
|
9578 | 9659 | if (gl.hasGroups) {
|
9579 | 9660 | gl.groups = cnf.xaxis.group.groups;
|
|
11065 | 11146 |
|
11066 | 11147 |
|
11067 | 11148 | for (var _xat2 = 0; _xat2 < xAxisTextsInversed.length; _xat2++) {
|
11068 |
| - graphics.placeTextWithEllipsis(xAxisTextsInversed[_xat2], xAxisTextsInversed[_xat2].textContent, w.config.yaxis[0].labels.maxWidth - parseFloat(w.config.yaxis[0].title.style.fontSize) * 2 - 20); |
| 11149 | + graphics.placeTextWithEllipsis(xAxisTextsInversed[_xat2], xAxisTextsInversed[_xat2].textContent, w.config.yaxis[0].labels.maxWidth - (w.config.yaxis[0].title.text ? parseFloat(w.config.yaxis[0].title.style.fontSize) * 2 : 0) - 15); |
11069 | 11150 | }
|
11070 | 11151 | }
|
11071 | 11152 | } // renderXAxisBands() {
|
|
11229 | 11310 |
|
11230 | 11311 | var y_2 = 0;
|
11231 | 11312 |
|
11232 |
| - if (w.globals.hasGroups && (typeof w.config.xaxis.tickAmount === 'undefined' || w.config.xaxis.tickAmount === 'dataPoints') && w.config.xaxis.tickPlacement === 'between') { |
| 11313 | + if (w.globals.hasGroups && w.config.xaxis.tickPlacement === 'between') { |
11233 | 11314 | var groups = w.globals.groups;
|
11234 | 11315 |
|
11235 | 11316 | if (groups) {
|
|
11324 | 11405 | x2 = _ref6.x2,
|
11325 | 11406 | y2 = _ref6.y2;
|
11326 | 11407 |
|
11327 |
| - if (typeof w.config.xaxis.tickAmount !== 'undefined' && w.config.xaxis.tickAmount !== 'dataPoints') { |
| 11408 | + if (typeof w.config.xaxis.tickAmount !== 'undefined' && w.config.xaxis.tickAmount !== 'dataPoints' && w.config.xaxis.tickPlacement === 'on') { |
11328 | 11409 | // user has specified tickamount in a category x-axis chart
|
11329 | 11410 | var visibleLabels = w.globals.dom.baseEl.querySelectorAll('.apexcharts-text.apexcharts-xaxis-label tspan:not(:empty)');
|
11330 | 11411 | visibleLabels.forEach(function (d, i) {
|
@@ -11766,17 +11847,18 @@
|
11766 | 11847 | };
|
11767 | 11848 | }
|
11768 | 11849 | }, {
|
11769 |
| - key: "logarithmicScale", |
11770 |
| - value: function logarithmicScale(yMin, yMax, base) { |
| 11850 | + key: "logarithmicScaleNice", |
| 11851 | + value: function logarithmicScaleNice(yMin, yMax, base) { |
| 11852 | + // Basic validation to avoid for loop starting at -inf. |
| 11853 | + if (yMax <= 0) yMax = Math.max(yMin, base); |
| 11854 | + if (yMin <= 0) yMin = Math.min(yMax, base); |
11771 | 11855 | var logs = [];
|
11772 |
| - var ticks = Math.ceil(Math.log(yMax) / Math.log(base)) + 1; // Get powers of base up to our max, and then one more |
| 11856 | + var logMax = Math.ceil(Math.log(yMax) / Math.log(base) + 1); // Get powers of base for our max and min |
11773 | 11857 |
|
11774 |
| - for (var i = 0; i < ticks; i++) { |
11775 |
| - logs.push(Math.pow(base, i)); |
11776 |
| - } |
| 11858 | + var logMin = Math.floor(Math.log(yMin) / Math.log(base)); |
11777 | 11859 |
|
11778 |
| - if (yMin === 0) { |
11779 |
| - logs.unshift(yMin); |
| 11860 | + for (var i = logMin; i < logMax; i++) { |
| 11861 | + logs.push(Math.pow(base, i)); |
11780 | 11862 | }
|
11781 | 11863 |
|
11782 | 11864 | return {
|
|
11785 | 11867 | niceMax: logs[logs.length - 1]
|
11786 | 11868 | };
|
11787 | 11869 | }
|
| 11870 | + }, { |
| 11871 | + key: "logarithmicScale", |
| 11872 | + value: function logarithmicScale(yMin, yMax, base) { |
| 11873 | + // Basic validation to avoid for loop starting at -inf. |
| 11874 | + if (yMax <= 0) yMax = Math.max(yMin, base); |
| 11875 | + if (yMin <= 0) yMin = Math.min(yMax, base); |
| 11876 | + var logs = []; // Get the logarithmic range. |
| 11877 | + |
| 11878 | + var logMax = Math.log(yMax) / Math.log(base); |
| 11879 | + var logMin = Math.log(yMin) / Math.log(base); // Get the exact logarithmic range. |
| 11880 | + // (This is the exact number of multiples of the base there are between yMin and yMax). |
| 11881 | + |
| 11882 | + var logRange = logMax - logMin; // Round the logarithmic range to get the number of ticks we will create. |
| 11883 | + // If the chosen min/max values are multiples of each other WRT the base, this will be neat. |
| 11884 | + // If the chosen min/max aren't, we will at least still provide USEFUL ticks. |
| 11885 | + |
| 11886 | + var ticks = Math.round(logRange); // Get the logarithmic spacing between ticks. |
| 11887 | + |
| 11888 | + var logTickSpacing = logRange / ticks; // Create as many ticks as there is range in the logs. |
| 11889 | + |
| 11890 | + for (var i = 0, logTick = logMin; i < ticks; i++, logTick += logTickSpacing) { |
| 11891 | + logs.push(Math.pow(base, logTick)); |
| 11892 | + } // Add a final tick at the yMax. |
| 11893 | + |
| 11894 | + |
| 11895 | + logs.push(Math.pow(base, logMax)); |
| 11896 | + return { |
| 11897 | + result: logs, |
| 11898 | + niceMin: yMin, |
| 11899 | + niceMax: yMax |
| 11900 | + }; |
| 11901 | + } |
11788 | 11902 | }, {
|
11789 | 11903 | key: "_adjustTicksForSmallRange",
|
11790 | 11904 | value: function _adjustTicksForSmallRange(ticks, index, range) {
|
|
11820 | 11934 | if (y.logarithmic && diff > 5) {
|
11821 | 11935 | gl.allSeriesCollapsed = false;
|
11822 | 11936 | gl.yAxisScale[index] = this.logarithmicScale(minY, maxY, y.logBase);
|
| 11937 | + gl.yAxisScale[index] = y.forceNiceScale ? this.logarithmicScaleNice(minY, maxY, y.logBase) : this.logarithmicScale(minY, maxY, y.logBase); |
11823 | 11938 | } else {
|
11824 | 11939 | if (maxY === -Number.MAX_VALUE || !Utils$1.isNumber(maxY)) {
|
11825 | 11940 | // no data in the chart. Either all series collapsed or user passed a blank array
|
|
12725 | 12840 | fontSize: yaxisFontSize,
|
12726 | 12841 | fontFamily: yaxisFontFamily,
|
12727 | 12842 | fontWeight: yaxisFontWeight,
|
| 12843 | + maxWidth: w.config.yaxis[realIndex].labels.maxWidth, |
12728 | 12844 | foreColor: getForeColor(),
|
12729 | 12845 | isPlainText: false,
|
12730 | 12846 | cssClass: 'apexcharts-yaxis-label ' + yaxisStyle.cssClass
|
|
16797 | 16913 | var markersWraps = this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers-wrap');
|
16798 | 16914 | markersWraps = _toConsumableArray(markersWraps);
|
16799 | 16915 | markersWraps.sort(function (a, b) {
|
16800 |
| - return Number(b.getAttribute('data:realIndex')) < Number(a.getAttribute('data:realIndex')) ? 0 : -1; |
| 16916 | + var indexA = Number(a.getAttribute('data:realIndex')); |
| 16917 | + var indexB = Number(b.getAttribute('data:realIndex')); |
| 16918 | + return indexB < indexA ? 1 : indexB > indexA ? -1 : 0; |
16801 | 16919 | });
|
16802 | 16920 | var markers = [];
|
16803 | 16921 | markersWraps.forEach(function (m) {
|
@@ -22541,11 +22659,18 @@
|
22541 | 22659 | var lineFill = null;
|
22542 | 22660 |
|
22543 | 22661 | if (type === 'line') {
|
22544 |
| - // fillable lines only for lineChart |
22545 | 22662 | lineFill = fill.fillPath({
|
22546 | 22663 | seriesNumber: realIndex,
|
22547 | 22664 | i: i
|
22548 | 22665 | });
|
| 22666 | + } else if (w.config.stroke.fill) { |
| 22667 | + var prevFill = w.config.fill; |
| 22668 | + w.config.fill = w.config.stroke.fill; |
| 22669 | + lineFill = fill.fillPath({ |
| 22670 | + seriesNumber: realIndex, |
| 22671 | + i: i |
| 22672 | + }); |
| 22673 | + w.config.fill = prevFill; |
22549 | 22674 | } else {
|
22550 | 22675 | lineFill = w.globals.stroke.colors[realIndex];
|
22551 | 22676 | }
|
|
24668 | 24793 |
|
24669 | 24794 | if (gl.dom.elLegendForeign) {
|
24670 | 24795 | gl.dom.elLegendForeign.setAttribute('height', newHeight);
|
24671 |
| - } |
| 24796 | + } // fix apexcharts/apexcharts.js/issues/3105 (when % is provided in height, it keeps increasing) |
| 24797 | + |
24672 | 24798 |
|
| 24799 | + if (w.config.chart.height && String(w.config.chart.height).indexOf('%') > 0) return; |
24673 | 24800 | gl.dom.elWrap.style.height = newHeight + 'px';
|
24674 | 24801 | Graphics.setAttrs(gl.dom.Paper.node, {
|
24675 | 24802 | height: newHeight
|
|
0 commit comments