|
1 | 1 | /*!
|
2 |
| - * ApexCharts v3.26.1 |
| 2 | + * ApexCharts v3.26.2 |
3 | 3 | * (c) 2018-2021 Juned Chhipa
|
4 | 4 | * Released under the MIT License.
|
5 | 5 | */
|
|
3849 | 3849 | max: undefined,
|
3850 | 3850 | range: undefined,
|
3851 | 3851 | floating: false,
|
| 3852 | + decimalsInFloat: undefined, |
3852 | 3853 | position: 'bottom',
|
3853 | 3854 | title: {
|
3854 | 3855 | text: undefined,
|
|
5080 | 5081 | y = correctedLabels.y;
|
5081 | 5082 | }
|
5082 | 5083 |
|
5083 |
| - if (correctedLabels.textRects) ; |
| 5084 | + if (correctedLabels.textRects) { |
| 5085 | + // fixes #2264 |
| 5086 | + if (x < -10 - correctedLabels.textRects.width || x > w.globals.gridWidth + correctedLabels.textRects.width + 10) { |
| 5087 | + // datalabels fall outside drawing area, so draw a blank label |
| 5088 | + text = ''; |
| 5089 | + } |
| 5090 | + } |
5084 | 5091 |
|
5085 | 5092 | var dataLabelColor = w.globals.dataLabels.style.colors[i];
|
5086 | 5093 |
|
|
9655 | 9662 |
|
9656 | 9663 | var w = this.w;
|
9657 | 9664 |
|
9658 |
| - w.globals.xLabelFormatter = function (val) { |
9659 |
| - return _this.defaultGeneralFormatter(val); |
9660 |
| - }; |
9661 |
| - |
9662 | 9665 | w.globals.xaxisTooltipFormatter = function (val) {
|
9663 | 9666 | return _this.defaultGeneralFormatter(val);
|
9664 | 9667 | };
|
|
9681 | 9684 | } else {
|
9682 | 9685 | w.globals.xLabelFormatter = function (val) {
|
9683 | 9686 | if (Utils.isNumber(val)) {
|
9684 |
| - // numeric xaxis may have smaller range, so defaulting to 1 decimal |
9685 |
| - if (!w.config.xaxis.convertedCatToNumeric && w.config.xaxis.type === 'numeric' && w.globals.dataPoints < 50) { |
9686 |
| - return val.toFixed(1); |
| 9687 | + if (!w.config.xaxis.convertedCatToNumeric && w.config.xaxis.type === 'numeric') { |
| 9688 | + if (Utils.isNumber(w.config.xaxis.decimalsInFloat)) { |
| 9689 | + return val.toFixed(w.config.xaxis.decimalsInFloat); |
| 9690 | + } else { |
| 9691 | + var diff = w.globals.maxX - w.globals.minX; |
| 9692 | + |
| 9693 | + if (diff > 0 && diff < 100) { |
| 9694 | + return val.toFixed(1); |
| 9695 | + } |
| 9696 | + |
| 9697 | + return val.toFixed(0); |
| 9698 | + } |
9687 | 9699 | }
|
9688 | 9700 |
|
9689 | 9701 | if (w.globals.isBarHorizontal) {
|
@@ -13583,18 +13595,15 @@
|
13583 | 13595 | // for timeline labels, we take the last label and check if it exceeds gridWidth
|
13584 | 13596 | var firstimescaleLabel = _this.dCtx.timescaleLabels[0];
|
13585 | 13597 | var lastTimescaleLabel = _this.dCtx.timescaleLabels[_this.dCtx.timescaleLabels.length - 1];
|
13586 |
| - var lastLabelPosition = lastTimescaleLabel.position + lbWidth / 1.75 - // replace + with - ; |
13587 |
| - // allow the last label to intersect with the right y axis |
13588 |
| - _this.dCtx.yAxisWidthRight; |
13589 |
| - var firstLabelPosition = firstimescaleLabel.position - lbWidth / 1.75 + // remove conditional since the first label is always at the very left |
13590 |
| - // allow the first label to intersect with the left y axes |
13591 |
| - _this.dCtx.yAxisWidthLeft; |
13592 |
| - |
13593 |
| - if (lastLabelPosition > gl.svgWidth - gl.translateX) { |
| 13598 | + var lastLabelPosition = lastTimescaleLabel.position + lbWidth / 1.75 - _this.dCtx.yAxisWidthRight; |
| 13599 | + var firstLabelPosition = firstimescaleLabel.position - lbWidth / 1.75 + _this.dCtx.yAxisWidthLeft; |
| 13600 | + var lgRightRectWidth = w.config.legend.position === 'right' && _this.dCtx.lgRect.width > 0 ? _this.dCtx.lgRect.width : 0; |
| 13601 | + |
| 13602 | + if (lastLabelPosition > gl.svgWidth - gl.translateX - lgRightRectWidth) { |
13594 | 13603 | gl.skipLastTimelinelabel = true;
|
13595 | 13604 | }
|
13596 | 13605 |
|
13597 |
| - if (firstLabelPosition < -((!yaxe.show || yaxe.floating) && (cnf.chart.type === 'bar' || cnf.chart.type === 'candlestick' || cnf.chart.type === 'rangeBar' || cnf.chart.type === 'boxPlot') ? lbWidth / 1.75 : 0)) { |
| 13606 | + if (firstLabelPosition < -((!yaxe.show || yaxe.floating) && (cnf.chart.type === 'bar' || cnf.chart.type === 'candlestick' || cnf.chart.type === 'rangeBar' || cnf.chart.type === 'boxPlot') ? lbWidth / 1.75 : 10)) { |
13598 | 13607 | gl.skipFirstTimelinelabel = true;
|
13599 | 13608 | }
|
13600 | 13609 | } else if (xtype === 'datetime') {
|
|
13672 | 13681 |
|
13673 | 13682 | if (!axesUtils.isYAxisHidden(index) && yaxe.labels.show && yS.result.length) {
|
13674 | 13683 | var lbFormatter = w.globals.yLabelFormatters[index];
|
13675 |
| - var longestStr = String(yS.niceMin).length > String(yS.niceMax).length ? yS.niceMin : yS.niceMax; // the second parameter -1 is the index of tick which user can use in the formatter |
| 13684 | + var minV = yS.niceMin === Number.MIN_VALUE ? 0 : yS.niceMin; |
| 13685 | + var longestStr = String(minV).length > String(yS.niceMax).length ? minV : yS.niceMax; // the second parameter -1 is the index of tick which user can use in the formatter |
13676 | 13686 |
|
13677 | 13687 | var val = lbFormatter(longestStr, {
|
13678 | 13688 | seriesIndex: index,
|
|
23105 | 23115 | unit = 'month';
|
23106 | 23116 | date = firstVal.minDate;
|
23107 | 23117 | numberOfDays++;
|
| 23118 | + } else if (firstVal.minDate !== 1 && firstVal.minHour === 0 && firstVal.minMinute === 0) { |
| 23119 | + // fixes apexcharts/apexcharts.js/issues/1730 |
| 23120 | + firstTickPosition = 0; |
| 23121 | + firstTickValue = firstVal.minDate; |
| 23122 | + date = firstTickValue; |
| 23123 | + val = firstTickValue; // in case it's the last date of month, we need to check it |
| 23124 | + |
| 23125 | + month = changeMonth(date, currentMonth, currentYear); |
23108 | 23126 | } // push the first tick in the array
|
23109 | 23127 |
|
23110 | 23128 |
|
|
0 commit comments