|
1 | 1 | /*!
|
2 |
| - * ApexCharts v3.26.2 |
| 2 | + * ApexCharts v3.26.3 |
3 | 3 | * (c) 2018-2021 Juned Chhipa
|
4 | 4 | * Released under the MIT License.
|
5 | 5 | */
|
|
3797 | 3797 | // internal property which should not be altered outside
|
3798 | 3798 | offsetX: 0,
|
3799 | 3799 | offsetY: 0,
|
| 3800 | + overwriteCategories: undefined, |
3800 | 3801 | labels: {
|
3801 | 3802 | show: true,
|
3802 | 3803 | rotate: -45,
|
|
5555 | 5556 | });
|
5556 | 5557 | }
|
5557 | 5558 |
|
5558 |
| - if (val === 0 && w.config.chart.stacked) { |
5559 |
| - // in a stacked bar/column chart, 0 value should be neglected as it will overlap on the next element |
5560 |
| - text = ''; |
5561 |
| - } |
5562 |
| - |
5563 |
| - var valIsNegative = w.globals.series[i][j] <= 0; |
| 5559 | + var valIsNegative = w.globals.series[i][j] < 0; |
5564 | 5560 | var position = w.config.plotOptions.bar.dataLabels.position;
|
5565 | 5561 |
|
5566 | 5562 | if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') {
|
|
9980 | 9976 | function Exports(ctx) {
|
9981 | 9977 | _classCallCheck(this, Exports);
|
9982 | 9978 |
|
| 9979 | + _defineProperty(this, "scaleSvgNode", function (svg, scale) { |
| 9980 | + // get current both width and height of the svg |
| 9981 | + var svgWidth = parseFloat(svg.getAttributeNS(null, 'width')); |
| 9982 | + var svgHeight = parseFloat(svg.getAttributeNS(null, 'height')); // set new width and height based on the scale |
| 9983 | + |
| 9984 | + svg.setAttributeNS(null, 'width', svgWidth * scale); |
| 9985 | + svg.setAttributeNS(null, 'height', svgHeight * scale); |
| 9986 | + svg.setAttributeNS(null, 'viewBox', '0 0 ' + svgWidth + ' ' + svgHeight); |
| 9987 | + }); |
| 9988 | + |
9983 | 9989 | this.ctx = ctx;
|
9984 | 9990 | this.w = ctx.w;
|
9985 | 9991 | }
|
|
10007 | 10013 | }
|
10008 | 10014 | }, {
|
10009 | 10015 | key: "getSvgString",
|
10010 |
| - value: function getSvgString() { |
10011 |
| - var svgString = this.w.globals.dom.Paper.svg(); |
| 10016 | + value: function getSvgString(scale) { |
| 10017 | + var svgString = this.w.globals.dom.Paper.svg(); // in case the scale is different than 1, the svg needs to be rescaled |
| 10018 | + |
| 10019 | + if (scale !== 1) { |
| 10020 | + // clone the svg node so it remains intact in the UI |
| 10021 | + var svgNode = this.w.globals.dom.Paper.node.cloneNode(true); // scale the image |
| 10022 | + |
| 10023 | + this.scaleSvgNode(svgNode, scale); // get the string representation of the svgNode |
| 10024 | + |
| 10025 | + svgString = new XMLSerializer().serializeToString(svgNode); |
| 10026 | + } |
| 10027 | + |
10012 | 10028 | return this.fixSvgStringForIe11(svgString);
|
10013 | 10029 | }
|
10014 | 10030 | }, {
|
@@ -10047,24 +10063,25 @@
|
10047 | 10063 | }
|
10048 | 10064 | }, {
|
10049 | 10065 | key: "dataURI",
|
10050 |
| - value: function dataURI() { |
| 10066 | + value: function dataURI(options) { |
10051 | 10067 | var _this = this;
|
10052 | 10068 |
|
10053 | 10069 | return new Promise(function (resolve) {
|
10054 | 10070 | var w = _this.w;
|
| 10071 | + var scale = options ? options.scale || options.width / w.globals.svgWidth : 1; |
10055 | 10072 |
|
10056 | 10073 | _this.cleanup();
|
10057 | 10074 |
|
10058 | 10075 | var canvas = document.createElement('canvas');
|
10059 |
| - canvas.width = w.globals.svgWidth; |
10060 |
| - canvas.height = parseInt(w.globals.dom.elWrap.style.height, 10); // because of resizeNonAxisCharts |
| 10076 | + canvas.width = w.globals.svgWidth * scale; |
| 10077 | + canvas.height = parseInt(w.globals.dom.elWrap.style.height, 10) * scale; // because of resizeNonAxisCharts |
10061 | 10078 |
|
10062 | 10079 | var canvasBg = w.config.chart.background === 'transparent' ? '#fff' : w.config.chart.background;
|
10063 | 10080 | var ctx = canvas.getContext('2d');
|
10064 | 10081 | ctx.fillStyle = canvasBg;
|
10065 |
| - ctx.fillRect(0, 0, canvas.width, canvas.height); |
| 10082 | + ctx.fillRect(0, 0, canvas.width * scale, canvas.height * scale); |
10066 | 10083 |
|
10067 |
| - var svgData = _this.getSvgString(); |
| 10084 | + var svgData = _this.getSvgString(scale); |
10068 | 10085 |
|
10069 | 10086 | if (window.canvg && Utils.isIE11()) {
|
10070 | 10087 | // use canvg as a polyfill to workaround ie11 considering a canvas with loaded svg 'unsafe'
|
|
10309 | 10326 | this.xaxisLabels = w.globals.timescaleLabels.slice();
|
10310 | 10327 | }
|
10311 | 10328 |
|
| 10329 | + if (w.config.xaxis.overwriteCategories) { |
| 10330 | + this.xaxisLabels = w.config.xaxis.overwriteCategories; |
| 10331 | + } |
| 10332 | + |
10312 | 10333 | this.drawnLabels = [];
|
10313 | 10334 | this.drawnLabelsRects = [];
|
10314 | 10335 |
|
|
12285 | 12306 | if (w.config.yaxis[realIndex].labels.show) {
|
12286 | 12307 | var _loop = function _loop(i) {
|
12287 | 12308 | var val = labels[i];
|
12288 |
| - val = lbFormatter(val, i); |
| 12309 | + val = lbFormatter(val, i, w); |
12289 | 12310 | var xPad = w.config.yaxis[realIndex].labels.padding;
|
12290 | 12311 |
|
12291 | 12312 | if (w.config.yaxis[realIndex].opposite && w.config.yaxis.length !== 0) {
|
|
12409 | 12430 | if (w.config.xaxis.labels.show) {
|
12410 | 12431 | for (var i = tl ? 0 : tickAmount; tl ? i < tl : i >= 0; tl ? i++ : i--) {
|
12411 | 12432 | var val = labels[i];
|
12412 |
| - val = lbFormatter(val, i); |
| 12433 | + val = lbFormatter(val, i, w); |
12413 | 12434 | var x = w.globals.gridWidth + w.globals.padHorizontal - (l - labelsDivider + w.config.xaxis.labels.offsetX);
|
12414 | 12435 |
|
12415 | 12436 | if (timescaleLabels.length) {
|
|
30871 | 30892 | }
|
30872 | 30893 | }, {
|
30873 | 30894 | key: "dataURI",
|
30874 |
| - value: function dataURI() { |
| 30895 | + value: function dataURI(options) { |
30875 | 30896 | var exp = new Exports(this.ctx);
|
30876 |
| - return exp.dataURI(); |
| 30897 | + return exp.dataURI(options); |
30877 | 30898 | }
|
30878 | 30899 | }, {
|
30879 | 30900 | key: "paper",
|
|
0 commit comments