@websy/websy-designs 1.7.19 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/websy-designs-es6.debug.js +145 -70
- package/dist/websy-designs-es6.js +150 -67
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +576 -70
- package/dist/websy-designs.js +616 -67
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
package/dist/websy-designs.js
CHANGED
|
@@ -39,6 +39,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
39
39
|
WebsyIcons
|
|
40
40
|
WebsyChart
|
|
41
41
|
WebsyChartTooltip
|
|
42
|
+
WebsyPie
|
|
42
43
|
WebsyLegend
|
|
43
44
|
WebsyMap
|
|
44
45
|
WebsyKPI
|
|
@@ -2454,8 +2455,8 @@ var WebsyDragDrop = /*#__PURE__*/function () {
|
|
|
2454
2455
|
el.innerHTML = html;
|
|
2455
2456
|
this.options.items.forEach(function (item, i) {
|
|
2456
2457
|
if (item.component) {
|
|
2457
|
-
if (item.isQlikPlugin && WebsyDesigns.
|
|
2458
|
-
item.instance = new WebsyDesigns.
|
|
2458
|
+
if (item.isQlikPlugin && WebsyDesigns.QlikPlugins[item.component]) {
|
|
2459
|
+
item.instance = new WebsyDesigns.QlikPlugins[item.component]("".concat(item.id, "_component"), item.options);
|
|
2459
2460
|
} else if (WebsyDesigns[item.component]) {
|
|
2460
2461
|
item.instance = new WebsyDesigns[item.component]("".concat(item.id, "_component"), item.options);
|
|
2461
2462
|
} else {
|
|
@@ -5638,13 +5639,25 @@ var Switch = /*#__PURE__*/function () {
|
|
|
5638
5639
|
key: "disable",
|
|
5639
5640
|
value: function disable() {
|
|
5640
5641
|
this.options.enabled = false;
|
|
5641
|
-
this.
|
|
5642
|
+
var method = this.options.enabled === true ? 'add' : 'remove';
|
|
5643
|
+
var el = document.getElementById("".concat(this.elementId, "_switch"));
|
|
5644
|
+
el.classList[method]('enabled');
|
|
5645
|
+
|
|
5646
|
+
if (this.options.onToggle) {
|
|
5647
|
+
this.options.onToggle(this.options.enabled);
|
|
5648
|
+
}
|
|
5642
5649
|
}
|
|
5643
5650
|
}, {
|
|
5644
5651
|
key: "enable",
|
|
5645
5652
|
value: function enable() {
|
|
5646
5653
|
this.options.enabled = true;
|
|
5647
|
-
this.
|
|
5654
|
+
var method = this.options.enabled === true ? 'add' : 'remove';
|
|
5655
|
+
var el = document.getElementById("".concat(this.elementId, "_switch"));
|
|
5656
|
+
el.classList[method]('enabled');
|
|
5657
|
+
|
|
5658
|
+
if (this.options.onToggle) {
|
|
5659
|
+
this.options.onToggle(this.options.enabled);
|
|
5660
|
+
}
|
|
5648
5661
|
}
|
|
5649
5662
|
}, {
|
|
5650
5663
|
key: "handleClick",
|
|
@@ -7118,7 +7131,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7118
7131
|
var el = document.getElementById(this.elementId);
|
|
7119
7132
|
|
|
7120
7133
|
if (el) {
|
|
7121
|
-
var html = "\n <div id='".concat(this.elementId, "_tableContainer' class='websy-vis-table-3 ").concat(this.options.paging === 'pages' ? 'with-paging' : '', " ").concat(this.options.virtualScroll === true ? 'with-virtual-scroll' : '', "'>\n <!--<div class=\"download-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M16 11h5l-9 10-9-10h5v-11h8v11zm1 11h-10v2h10v-2z\"/></svg>\n </div>-->\n <div id=\"").concat(this.elementId, "_tableInner\" class=\"websy-table-inner-container\">\n <table id=\"").concat(this.elementId, "_tableHeader\" class=\"websy-table-header\"></table>\n <table id=\"").concat(this.elementId, "_tableBody\" class=\"websy-table-body\"></table>\n <table id=\"").concat(this.elementId, "_tableFooter\" class=\"websy-table-footer\"></table>\n <div id=\"").concat(this.elementId, "_vScrollContainer\" class=\"websy-v-scroll-container\">\n <div id=\"").concat(this.elementId, "_vScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-y\"></div>\n </div>\n <div id=\"").concat(this.elementId, "_hScrollContainer\" class=\"websy-h-scroll-container\">\n <div id=\"").concat(this.elementId, "_hScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-x\"></div>\n </div>\n ");
|
|
7134
|
+
var html = "\n <div id='".concat(this.elementId, "_tableContainer' class='websy-vis-table-3 ").concat(this.options.paging === 'pages' ? 'with-paging' : '', " ").concat(this.options.virtualScroll === true ? 'with-virtual-scroll' : '', " ").concat(this.isTouchDevice === true && this.options.virtualScroll === true ? 'touch-device' : '', "'>\n <!--<div class=\"download-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M16 11h5l-9 10-9-10h5v-11h8v11zm1 11h-10v2h10v-2z\"/></svg>\n </div>-->\n <div id=\"").concat(this.elementId, "_tableInner\" class=\"websy-table-inner-container\">\n <table id=\"").concat(this.elementId, "_tableHeader\" class=\"websy-table-header\"></table>\n <table id=\"").concat(this.elementId, "_tableBody\" class=\"websy-table-body\"></table>\n <table id=\"").concat(this.elementId, "_tableFooter\" class=\"websy-table-footer\"></table>\n <div id=\"").concat(this.elementId, "_vScrollContainer\" class=\"websy-v-scroll-container\">\n <div id=\"").concat(this.elementId, "_vScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-y\"></div>\n </div>\n <div id=\"").concat(this.elementId, "_hScrollContainer\" class=\"websy-h-scroll-container\">\n <div id=\"").concat(this.elementId, "_hScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-x\"></div>\n </div>\n ");
|
|
7122
7135
|
|
|
7123
7136
|
if (this.isTouchDevice === true && this.options.virtualScroll === true) {
|
|
7124
7137
|
html += "\n <div id=\"".concat(this.elementId, "_touchScroller\" class=\"websy-table-touch-scroller\"></div>\n ");
|
|
@@ -7542,9 +7555,9 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7542
7555
|
}
|
|
7543
7556
|
|
|
7544
7557
|
this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight);
|
|
7545
|
-
this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight;
|
|
7546
|
-
|
|
7547
|
-
this.endRow = this.sizes.rowsToRender;
|
|
7558
|
+
this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight; // this.startRow = 0
|
|
7559
|
+
|
|
7560
|
+
this.endRow = this.startRow + this.sizes.rowsToRender;
|
|
7548
7561
|
this.startCol = 0;
|
|
7549
7562
|
this.endCol = this.options.columns[this.options.columns.length - 1].length;
|
|
7550
7563
|
|
|
@@ -7646,7 +7659,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7646
7659
|
}, {
|
|
7647
7660
|
key: "handleMouseDown",
|
|
7648
7661
|
value: function handleMouseDown(event) {
|
|
7649
|
-
if (this.isTouchDevice
|
|
7662
|
+
if (this.isTouchDevice) {
|
|
7650
7663
|
return;
|
|
7651
7664
|
}
|
|
7652
7665
|
|
|
@@ -7659,6 +7672,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7659
7672
|
this.mouseYStart = event.pageY; // console.log('mouse down', this.handleYStart, this.mouseYStart)
|
|
7660
7673
|
// console.log(scrollHandleEl.offsetTop)
|
|
7661
7674
|
} else if (event.target.classList.contains('websy-scroll-handle-x')) {
|
|
7675
|
+
if (this.isTouchDevice) {
|
|
7676
|
+
event.preventDefault();
|
|
7677
|
+
}
|
|
7678
|
+
|
|
7662
7679
|
this.scrollDragging = true;
|
|
7663
7680
|
this.scrollDirection = 'x';
|
|
7664
7681
|
|
|
@@ -7673,6 +7690,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7673
7690
|
value: function handleMouseMove(event) {
|
|
7674
7691
|
// event.preventDefault()
|
|
7675
7692
|
if (this.scrollDragging === true) {
|
|
7693
|
+
if (this.isTouchDevice) {
|
|
7694
|
+
event.preventDefault();
|
|
7695
|
+
}
|
|
7696
|
+
|
|
7676
7697
|
if (this.scrollDirection === 'y') {
|
|
7677
7698
|
var diff = event.pageY - this.mouseYStart;
|
|
7678
7699
|
this.scrollY(diff);
|
|
@@ -7744,12 +7765,19 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7744
7765
|
key: "handleTouchEnd",
|
|
7745
7766
|
value: function handleTouchEnd(event) {
|
|
7746
7767
|
// console.log('touch end fired')
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7768
|
+
this.scrollDragging = false;
|
|
7769
|
+
this.cellDragging = false;
|
|
7770
|
+
this.handleYStart = null;
|
|
7771
|
+
this.mouseYStart = null;
|
|
7772
|
+
this.handleXStart = null;
|
|
7773
|
+
this.mouseXStart = null;
|
|
7751
7774
|
|
|
7752
|
-
|
|
7775
|
+
if (typeof event.targetTouches !== 'undefined') {
|
|
7776
|
+
this.isTouchScrolling = false; // this.touchEndTime = (new Date()).getTime()
|
|
7777
|
+
// this.isPerpetual = true
|
|
7778
|
+
// this.perpetualScroll()
|
|
7779
|
+
// this.touchStartTime = null
|
|
7780
|
+
// const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
|
|
7753
7781
|
// touchScrollEl.classList.add('hidden')
|
|
7754
7782
|
}
|
|
7755
7783
|
}
|
|
@@ -7762,46 +7790,70 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7762
7790
|
event.stopPropagation();
|
|
7763
7791
|
|
|
7764
7792
|
if (typeof event.targetTouches !== 'undefined' && event.targetTouches.length > 0) {
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
//
|
|
7777
|
-
// }
|
|
7778
|
-
//
|
|
7779
|
-
//
|
|
7780
|
-
//
|
|
7781
|
-
//
|
|
7782
|
-
//
|
|
7783
|
-
//
|
|
7784
|
-
//
|
|
7785
|
-
//
|
|
7786
|
-
//
|
|
7787
|
-
//
|
|
7788
|
-
//
|
|
7793
|
+
event.deltaX = this.touchXStart - event.targetTouches[0].pageX;
|
|
7794
|
+
event.deltaY = this.touchYStart - event.targetTouches[0].pageY;
|
|
7795
|
+
|
|
7796
|
+
if (Math.abs(event.deltaY) > 50) {
|
|
7797
|
+
event.deltaX = 0;
|
|
7798
|
+
this.handleScrollWheel(event);
|
|
7799
|
+
} else if (Math.abs(event.deltaX) > 50) {
|
|
7800
|
+
event.deltaY = 0;
|
|
7801
|
+
this.handleScrollWheel(event);
|
|
7802
|
+
} // let deltaX = (this.mouseXStart - event.targetTouches[0].pageX)
|
|
7803
|
+
// let deltaY = (this.mouseYStart - event.targetTouches[0].pageY)
|
|
7804
|
+
// const hScrollContainerEl = document.getElementById(`${this.elementId}_hScrollContainer`)
|
|
7805
|
+
// const vScrollContainerEl = document.getElementById(`${this.elementId}_vScrollContainer`)
|
|
7806
|
+
// const hScrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
7807
|
+
// const vScrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
7808
|
+
// let translatedDeltaX = deltaX * (hScrollHandleEl.getBoundingClientRect().width / vScrollContainerEl.getBoundingClientRect().width)
|
|
7809
|
+
// let translatedDeltaY = deltaY * (vScrollHandleEl.getBoundingClientRect().height / vScrollContainerEl.getBoundingClientRect().height)
|
|
7810
|
+
// // need to adjust the delta so that it scrolls at a reasonable speed/distance
|
|
7811
|
+
// const scrollHandleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
7812
|
+
// const scrollHandleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
7813
|
+
// // if (Math.abs(deltaY) > this.sizes.cellHeight) {
|
|
7814
|
+
// // this.isTouchScrolling = true
|
|
7815
|
+
// // }
|
|
7816
|
+
// // else {
|
|
7817
|
+
// // this.isTouchScrolling = false
|
|
7818
|
+
// // }
|
|
7819
|
+
// // console.log('delta', this.mouseYStart, event.targetTouches[0].pageY, deltaY)
|
|
7820
|
+
// // deltaX = deltaX * (scrollHandleXEl.offsetWidth / this.sizes.scrollableWidth)
|
|
7821
|
+
// // deltaY = deltaY * (scrollHandleYEl.offsetHeight / this.sizes.bodyHeight)
|
|
7822
|
+
// // console.log('delta', deltaY)
|
|
7823
|
+
// // NW
|
|
7824
|
+
// // else if (Math.abs(deltaX) > 50) {
|
|
7825
|
+
// // this.isTouchScrolling = false
|
|
7826
|
+
// // }
|
|
7827
|
+
// this.currentClientY = event.targetTouches[0].pageY
|
|
7828
|
+
// this.currentTouchtime = (new Date()).getTime()
|
|
7829
|
+
// // end
|
|
7830
|
+
// // delta = Math.min(10, delta)
|
|
7831
|
+
// // delta = Math.max(-10, delta)
|
|
7832
|
+
// if (this.isTouchScrolling === true) {
|
|
7833
|
+
// // this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
|
|
7834
|
+
// if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 20) {
|
|
7835
|
+
// // this.scrollX(Math.max(-5, Math.min(5, translatedDeltaX)))
|
|
7836
|
+
// this.scrollX(translatedDeltaX)
|
|
7837
|
+
// }
|
|
7838
|
+
// else if (deltaY > 20) {
|
|
7839
|
+
// // this.scrollY(Math.max(-5, Math.min(5, translatedDeltaY)))
|
|
7840
|
+
// this.scrollY(translatedDeltaY)
|
|
7841
|
+
// }
|
|
7842
|
+
// }
|
|
7789
7843
|
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
}
|
|
7804
|
-
}
|
|
7844
|
+
}
|
|
7845
|
+
}
|
|
7846
|
+
|
|
7847
|
+
if (this.scrollDragging === true) {
|
|
7848
|
+
event.preventDefault();
|
|
7849
|
+
|
|
7850
|
+
if (this.scrollDirection === 'y') {
|
|
7851
|
+
var diff = event.targetTouches[0].pageY - this.mouseYStart;
|
|
7852
|
+
this.scrollY(diff);
|
|
7853
|
+
} else if (this.scrollDirection === 'x') {
|
|
7854
|
+
var _diff2 = event.targetTouches[0].pageX - this.mouseXStart;
|
|
7855
|
+
|
|
7856
|
+
this.scrollX(_diff2);
|
|
7805
7857
|
}
|
|
7806
7858
|
}
|
|
7807
7859
|
}
|
|
@@ -7817,19 +7869,44 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7817
7869
|
} // console.log(event.target.classList)
|
|
7818
7870
|
|
|
7819
7871
|
|
|
7820
|
-
if (
|
|
7821
|
-
this.
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
this.mouseYStart = event.targetTouches[0].pageY;
|
|
7825
|
-
this.mouseXStart = event.targetTouches[0].pageX; // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
|
|
7826
|
-
// touchScrollEl.classList.remove('hidden')
|
|
7872
|
+
if (event.target.classList.contains('websy-table-touch-scroller')) {
|
|
7873
|
+
if (this.options.virtualScroll === true) {
|
|
7874
|
+
// this.touchStartTime = (new Date()).getTime()
|
|
7875
|
+
this.isTouchScrolling = true; // this.isPerpetual = false
|
|
7827
7876
|
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
this.handleXStart = handleXEl.offsetLeft;
|
|
7877
|
+
this.touchYStart = event.targetTouches[0].pageY;
|
|
7878
|
+
this.touchXStart = event.targetTouches[0].pageX;
|
|
7879
|
+
}
|
|
7832
7880
|
}
|
|
7881
|
+
|
|
7882
|
+
if (event.target.classList.contains('websy-scroll-handle-y')) {
|
|
7883
|
+
// set up the scroll start values
|
|
7884
|
+
this.scrollDragging = true;
|
|
7885
|
+
this.scrollDirection = 'y';
|
|
7886
|
+
var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
|
|
7887
|
+
this.handleYStart = scrollHandleEl.offsetTop;
|
|
7888
|
+
this.mouseYStart = event.targetTouches[0].pageY; // console.log('mouse down', this.handleYStart, this.mouseYStart)
|
|
7889
|
+
// console.log(scrollHandleEl.offsetTop)
|
|
7890
|
+
} else if (event.target.classList.contains('websy-scroll-handle-x')) {
|
|
7891
|
+
if (this.isTouchDevice) {
|
|
7892
|
+
event.preventDefault();
|
|
7893
|
+
}
|
|
7894
|
+
|
|
7895
|
+
this.scrollDragging = true;
|
|
7896
|
+
this.scrollDirection = 'x';
|
|
7897
|
+
|
|
7898
|
+
var _scrollHandleEl3 = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
|
|
7899
|
+
|
|
7900
|
+
this.handleXStart = _scrollHandleEl3.offsetLeft;
|
|
7901
|
+
this.mouseXStart = event.targetTouches[0].pageX;
|
|
7902
|
+
} // // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
|
|
7903
|
+
// // touchScrollEl.classList.remove('hidden')
|
|
7904
|
+
// const handleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
7905
|
+
// this.handleYStart = handleYEl.offsetTop
|
|
7906
|
+
// const handleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
7907
|
+
// this.handleXStart = handleXEl.offsetLeft
|
|
7908
|
+
// }
|
|
7909
|
+
|
|
7833
7910
|
}
|
|
7834
7911
|
}, {
|
|
7835
7912
|
key: "hideError",
|
|
@@ -7965,6 +8042,11 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7965
8042
|
vScrollEl.style.top = "".concat(this.sizes.header.height + this.sizes.total.height, "px");
|
|
7966
8043
|
vScrollEl.style.height = "".concat(this.sizes.bodyHeight, "px");
|
|
7967
8044
|
vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px';
|
|
8045
|
+
|
|
8046
|
+
if (this.startRow !== 0) {
|
|
8047
|
+
var scrollableSpace = vScrollEl.getBoundingClientRect().height - vHandleEl.getBoundingClientRect().height;
|
|
8048
|
+
vHandleEl.style.top = Math.round(this.startRow / (this.totalRowCount - this.sizes.rowsToRender) * scrollableSpace) + 'px';
|
|
8049
|
+
}
|
|
7968
8050
|
} else {
|
|
7969
8051
|
vHandleEl.style.height = '0px';
|
|
7970
8052
|
}
|
|
@@ -7974,7 +8056,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7974
8056
|
|
|
7975
8057
|
if (this.hScrollRequired === true) {
|
|
7976
8058
|
hScrollEl.style.left = "".concat(this.sizes.table.width - this.sizes.scrollableWidth, "px");
|
|
7977
|
-
hScrollEl.style.width = "".concat(this.sizes.scrollableWidth - 20, "px");
|
|
8059
|
+
hScrollEl.style.width = "".concat(this.sizes.scrollableWidth - (this.isTouchDevice ? 30 : 20), "px");
|
|
7978
8060
|
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalNonPinnedWidth)) + 'px';
|
|
7979
8061
|
} else {
|
|
7980
8062
|
hHandleEl.style.width = '0px';
|
|
@@ -8163,7 +8245,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
8163
8245
|
this.startRow += 1;
|
|
8164
8246
|
}
|
|
8165
8247
|
|
|
8166
|
-
this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns);
|
|
8248
|
+
this.options.onScroll('y', this.startRow, this.endRow, Math.max(0, this.startCol - this.pinnedColumns), this.endCol - this.pinnedColumns);
|
|
8167
8249
|
}
|
|
8168
8250
|
}
|
|
8169
8251
|
}, {
|
|
@@ -9950,7 +10032,9 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
9950
10032
|
key: "removebar",
|
|
9951
10033
|
value: function removebar(key) {
|
|
9952
10034
|
/* global key d3 */
|
|
9953
|
-
|
|
10035
|
+
this.barLayer.selectAll(".bar_".concat(key)).transition(this.transition).style('fill-opacity', 1e-6).remove(); // remove from the brush as well
|
|
10036
|
+
|
|
10037
|
+
this.brushArea.selectAll(".bar_".concat(key)).transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
9954
10038
|
}
|
|
9955
10039
|
}, {
|
|
9956
10040
|
key: "renderLabels",
|
|
@@ -10504,6 +10588,469 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
10504
10588
|
|
|
10505
10589
|
return WebsyChart;
|
|
10506
10590
|
}();
|
|
10591
|
+
/* global include */
|
|
10592
|
+
|
|
10593
|
+
|
|
10594
|
+
var WebsyPie = /*#__PURE__*/function () {
|
|
10595
|
+
function WebsyPie(elementId, options) {
|
|
10596
|
+
_classCallCheck(this, WebsyPie);
|
|
10597
|
+
|
|
10598
|
+
this.elementId = elementId;
|
|
10599
|
+
var DEFAULTS = {
|
|
10600
|
+
labelMode: 'auto',
|
|
10601
|
+
labelLocs: [],
|
|
10602
|
+
showLabels: false,
|
|
10603
|
+
segments: ['#9dbca6', '#e3c080', '#fd7336', '#b12737', '#50424b'],
|
|
10604
|
+
label: {
|
|
10605
|
+
value: {
|
|
10606
|
+
size: '12px',
|
|
10607
|
+
colour: '#BBB',
|
|
10608
|
+
family: 'arial',
|
|
10609
|
+
weight: 'normal'
|
|
10610
|
+
},
|
|
10611
|
+
label: {
|
|
10612
|
+
size: '10px',
|
|
10613
|
+
colour: '#888',
|
|
10614
|
+
family: 'arial',
|
|
10615
|
+
weight: 'normal'
|
|
10616
|
+
}
|
|
10617
|
+
},
|
|
10618
|
+
kpi: {
|
|
10619
|
+
background: '#555',
|
|
10620
|
+
value: {
|
|
10621
|
+
size: '60px',
|
|
10622
|
+
colour: '#CCC',
|
|
10623
|
+
family: 'arial',
|
|
10624
|
+
weight: 'bold'
|
|
10625
|
+
},
|
|
10626
|
+
label: {
|
|
10627
|
+
size: '20px',
|
|
10628
|
+
colour: '#FFF',
|
|
10629
|
+
family: 'arial',
|
|
10630
|
+
weight: 'normal'
|
|
10631
|
+
}
|
|
10632
|
+
}
|
|
10633
|
+
};
|
|
10634
|
+
this.options = _extends({}, DEFAULTS, options);
|
|
10635
|
+
this.listening = true;
|
|
10636
|
+
|
|
10637
|
+
if (!elementId) {
|
|
10638
|
+
console.log('No element Id provided for Websy Chart');
|
|
10639
|
+
return;
|
|
10640
|
+
}
|
|
10641
|
+
|
|
10642
|
+
var el = document.getElementById(this.elementId);
|
|
10643
|
+
|
|
10644
|
+
if (el) {
|
|
10645
|
+
el.classList.add('websy-pie');
|
|
10646
|
+
} else {
|
|
10647
|
+
console.error("No element found with ID ".concat(this.elementId));
|
|
10648
|
+
}
|
|
10649
|
+
}
|
|
10650
|
+
|
|
10651
|
+
_createClass(WebsyPie, [{
|
|
10652
|
+
key: "calculateArcAngle",
|
|
10653
|
+
value: function calculateArcAngle(arcLength, radius) {
|
|
10654
|
+
return this.convertRadiansToDegrees(arcLength / (Math.PI * (2 * radius)));
|
|
10655
|
+
}
|
|
10656
|
+
}, {
|
|
10657
|
+
key: "calculateCircumference",
|
|
10658
|
+
value: function calculateCircumference(perc) {
|
|
10659
|
+
return Math.PI * 2 * perc;
|
|
10660
|
+
}
|
|
10661
|
+
}, {
|
|
10662
|
+
key: "close",
|
|
10663
|
+
value: function close() {}
|
|
10664
|
+
}, {
|
|
10665
|
+
key: "convertDegreesToRadians",
|
|
10666
|
+
value: function convertDegreesToRadians(degrees) {
|
|
10667
|
+
return degrees * (Math.PI / 180);
|
|
10668
|
+
}
|
|
10669
|
+
}, {
|
|
10670
|
+
key: "convertRadiansToDegrees",
|
|
10671
|
+
value: function convertRadiansToDegrees(radians) {
|
|
10672
|
+
return radians * (180 / Math.PI);
|
|
10673
|
+
}
|
|
10674
|
+
}, {
|
|
10675
|
+
key: "createCanvases",
|
|
10676
|
+
value: function createCanvases(element) {
|
|
10677
|
+
/* global element */
|
|
10678
|
+
if (element && !element.target) {
|
|
10679
|
+
if (!this.listening) {
|
|
10680
|
+
// add event listeners to help with responsiveness
|
|
10681
|
+
element.addEventListener('resize', this.render.bind(this), false);
|
|
10682
|
+
window.addEventListener('resize', this.render.bind(this), false);
|
|
10683
|
+
this.listening = true;
|
|
10684
|
+
}
|
|
10685
|
+
|
|
10686
|
+
var height = element.clientHeight;
|
|
10687
|
+
var width = element.clientWidth;
|
|
10688
|
+
this.width = width;
|
|
10689
|
+
this.height = height;
|
|
10690
|
+
this.center = {
|
|
10691
|
+
x: width / 2,
|
|
10692
|
+
y: height / 2
|
|
10693
|
+
};
|
|
10694
|
+
this.outerRadius = Math.min(this.height, this.width) / 2 - 20;
|
|
10695
|
+
console.log('radius is ' + this.outerRadius); // segment canvas
|
|
10696
|
+
|
|
10697
|
+
var segmentCanvas = document.createElement('canvas');
|
|
10698
|
+
this.segmentPaper = {
|
|
10699
|
+
canvas: segmentCanvas,
|
|
10700
|
+
pen: segmentCanvas.getContext('2d')
|
|
10701
|
+
};
|
|
10702
|
+
this.segmentPaper.canvas.style.position = 'absolute';
|
|
10703
|
+
this.segmentPaper.canvas.style.top = '0px';
|
|
10704
|
+
this.segmentPaper.canvas.style.left = '0px';
|
|
10705
|
+
this.segmentPaper.canvas.style.zIndex = '5';
|
|
10706
|
+
this.segmentPaper.canvas.style.width = width + 'px';
|
|
10707
|
+
this.segmentPaper.canvas.style.height = height + 'px'; // make the canvase size double to accommodate for retina displays
|
|
10708
|
+
|
|
10709
|
+
this.segmentPaper.canvas.width = width * 2;
|
|
10710
|
+
this.segmentPaper.canvas.height = height * 2;
|
|
10711
|
+
this.segmentPaper.pen.scale(2, 2);
|
|
10712
|
+
element.appendChild(this.segmentPaper.canvas); // label canvas
|
|
10713
|
+
|
|
10714
|
+
var labelCanvas = document.createElement('canvas');
|
|
10715
|
+
this.labelPaper = {
|
|
10716
|
+
canvas: labelCanvas,
|
|
10717
|
+
pen: labelCanvas.getContext('2d')
|
|
10718
|
+
};
|
|
10719
|
+
this.labelPaper.canvas.style.position = 'absolute';
|
|
10720
|
+
this.labelPaper.canvas.style.top = '0px';
|
|
10721
|
+
this.labelPaper.canvas.style.left = '0px';
|
|
10722
|
+
this.labelPaper.canvas.style.zIndex = '5';
|
|
10723
|
+
this.labelPaper.canvas.style.width = width + 'px';
|
|
10724
|
+
this.labelPaper.canvas.style.height = height + 'px'; // make the canvase size double to accommodate for retina displays
|
|
10725
|
+
|
|
10726
|
+
this.labelPaper.canvas.width = width * 2;
|
|
10727
|
+
this.labelPaper.canvas.height = height * 2;
|
|
10728
|
+
this.labelPaper.pen.scale(2, 2);
|
|
10729
|
+
element.appendChild(this.labelPaper.canvas); // kpi canvas
|
|
10730
|
+
|
|
10731
|
+
var kpiCanvas = document.createElement('canvas');
|
|
10732
|
+
this.kpiPaper = {
|
|
10733
|
+
canvas: kpiCanvas,
|
|
10734
|
+
pen: kpiCanvas.getContext('2d')
|
|
10735
|
+
};
|
|
10736
|
+
this.kpiPaper.canvas.style.position = 'absolute';
|
|
10737
|
+
this.kpiPaper.canvas.style.top = '0px';
|
|
10738
|
+
this.kpiPaper.canvas.style.left = '0px';
|
|
10739
|
+
this.kpiPaper.canvas.style.zIndex = '5';
|
|
10740
|
+
this.kpiPaper.canvas.style.width = width + 'px';
|
|
10741
|
+
this.kpiPaper.canvas.style.height = height + 'px'; // make the canvase size double to accommodate for retina displays
|
|
10742
|
+
|
|
10743
|
+
this.kpiPaper.canvas.width = width * 2;
|
|
10744
|
+
this.kpiPaper.canvas.height = height * 2;
|
|
10745
|
+
this.kpiPaper.pen.scale(2, 2);
|
|
10746
|
+
element.appendChild(this.kpiPaper.canvas);
|
|
10747
|
+
} else {
|
|
10748
|
+
// clear the canvases
|
|
10749
|
+
this.segmentPaper.canvas.width = this.width * 2;
|
|
10750
|
+
this.labelPaper.canvas.width = this.width * 2;
|
|
10751
|
+
this.kpiPaper.canvas.width = this.width * 2;
|
|
10752
|
+
}
|
|
10753
|
+
}
|
|
10754
|
+
}, {
|
|
10755
|
+
key: "drawKPI",
|
|
10756
|
+
value: function drawKPI() {
|
|
10757
|
+
var kpiStyleDefaults = this.options.kpi;
|
|
10758
|
+
|
|
10759
|
+
if (this.kpi) {
|
|
10760
|
+
// draw the circle for the background colour if one has been specified
|
|
10761
|
+
if (!this.kpi.background || this.kpi.background !== 'transparent') {
|
|
10762
|
+
this.kpiPaper.pen.beginPath();
|
|
10763
|
+
this.kpiPaper.pen.fillStyle = this.kpi.background || kpiStyleDefaults.background;
|
|
10764
|
+
this.kpiPaper.pen.moveTo(this.center.x, this.center.y);
|
|
10765
|
+
this.kpiPaper.pen.arc(this.center.x, this.center.y, this.innerRadiusPixels + 5 * !this.addShading + 1, 0, Math.PI * 2);
|
|
10766
|
+
this.kpiPaper.pen.fill();
|
|
10767
|
+
this.kpiPaper.pen.closePath();
|
|
10768
|
+
} // draw the kpi value
|
|
10769
|
+
|
|
10770
|
+
|
|
10771
|
+
if (this.kpi.value) {
|
|
10772
|
+
this.kpiPaper.pen.save();
|
|
10773
|
+
this.kpiPaper.pen.beginPath();
|
|
10774
|
+
this.kpiPaper.pen.moveTo(this.center.x, this.center.y);
|
|
10775
|
+
this.kpiPaper.pen.font = (this.kpi.value.weight || kpiStyleDefaults.value.weight) + ' ' + (this.kpi.value.size || kpiStyleDefaults.value.size) + ' ' + (this.kpi.value.family || kpiStyleDefaults.value.family);
|
|
10776
|
+
this.kpiPaper.pen.textAlign = 'center';
|
|
10777
|
+
|
|
10778
|
+
if (this.kpi.label) {
|
|
10779
|
+
this.kpiPaper.pen.textBaseline = 'text-bottom';
|
|
10780
|
+
} else {
|
|
10781
|
+
this.kpiPaper.pen.textBaseline = 'middle';
|
|
10782
|
+
}
|
|
10783
|
+
|
|
10784
|
+
this.kpiPaper.pen.fillStyle = this.kpi.value.colour || kpiStyleDefaults.value.colour;
|
|
10785
|
+
this.kpiPaper.pen.fillText(this.kpi.value.text, this.center.x, this.center.y);
|
|
10786
|
+
this.kpiPaper.pen.closePath();
|
|
10787
|
+
this.kpiPaper.pen.restore();
|
|
10788
|
+
} // draw the kpi label
|
|
10789
|
+
|
|
10790
|
+
|
|
10791
|
+
if (this.kpi.label) {
|
|
10792
|
+
this.kpiPaper.pen.save();
|
|
10793
|
+
this.kpiPaper.pen.beginPath();
|
|
10794
|
+
this.kpiPaper.pen.moveTo(this.center.x, this.center.y);
|
|
10795
|
+
this.kpiPaper.pen.font = (this.kpi.label.weight || kpiStyleDefaults.label.weight) + ' ' + (this.kpi.label.size || kpiStyleDefaults.label.size) + ' ' + (this.kpi.label.family || kpiStyleDefaults.label.family);
|
|
10796
|
+
this.kpiPaper.pen.textAlign = 'center';
|
|
10797
|
+
|
|
10798
|
+
if (this.kpi.value) {
|
|
10799
|
+
this.kpiPaper.pen.textBaseline = 'top';
|
|
10800
|
+
} else {
|
|
10801
|
+
this.kpiPaper.pen.textBaseline = 'middle';
|
|
10802
|
+
}
|
|
10803
|
+
|
|
10804
|
+
this.kpiPaper.pen.fillStyle = this.kpi.label.colour || kpiStyleDefaults.label.colour;
|
|
10805
|
+
this.kpiPaper.pen.fillText(this.kpi.label.text, this.center.x, this.center.y + 10);
|
|
10806
|
+
this.kpiPaper.pen.closePath();
|
|
10807
|
+
this.kpiPaper.pen.restore();
|
|
10808
|
+
}
|
|
10809
|
+
}
|
|
10810
|
+
}
|
|
10811
|
+
}, {
|
|
10812
|
+
key: "drawLabels",
|
|
10813
|
+
value: function drawLabels() {
|
|
10814
|
+
// this.labelPaper.pen.translate(this.center.x, this.center.y)
|
|
10815
|
+
if (this.options.showLabels) {
|
|
10816
|
+
for (var s in this.data.segments) {
|
|
10817
|
+
this.labelPaper.pen.beginPath();
|
|
10818
|
+
this.labelPaper.pen.font = '20px arial';
|
|
10819
|
+
this.labelPaper.pen.textAlign = 'center';
|
|
10820
|
+
this.labelPaper.pen.textBaseline = 'text-bottom';
|
|
10821
|
+
this.labelPaper.pen.fillStyle = 'black'; // calculate the nearest 90 degrees to the mid point and reduce to within 360 degrees
|
|
10822
|
+
|
|
10823
|
+
var midAngleDeg = this.data.segments[s].midAngleDeg % 360;
|
|
10824
|
+
var nearest90Deg = Math.round(midAngleDeg / 90) * 90 % 360;
|
|
10825
|
+
console.log(Math.abs(nearest90Deg - midAngleDeg));
|
|
10826
|
+
var missingAngleDeg = 270 - Math.abs(nearest90Deg - midAngleDeg);
|
|
10827
|
+
console.log(nearest90Deg);
|
|
10828
|
+
var oppLength = this.outerRadius * Math.sin(this.convertDegreesToRadians(Math.abs(nearest90Deg - midAngleDeg))) / Math.sin(this.convertDegreesToRadians(missingAngleDeg));
|
|
10829
|
+
oppLength = Math.abs(oppLength);
|
|
10830
|
+
var moveLength = this.outerRadius + 5;
|
|
10831
|
+
var slopeMultiplier = 1.2;
|
|
10832
|
+
var flatMultiplier = 1.3;
|
|
10833
|
+
|
|
10834
|
+
if (midAngleDeg > 0 && midAngleDeg <= 45) {
|
|
10835
|
+
this.labelPaper.pen.moveTo(this.center.x + moveLength, this.center.y + oppLength);
|
|
10836
|
+
this.labelPaper.pen.lineTo(this.center.x + moveLength * slopeMultiplier, this.center.y + oppLength * slopeMultiplier);
|
|
10837
|
+
this.labelPaper.pen.lineTo(this.center.x + moveLength * flatMultiplier, this.center.y + oppLength * slopeMultiplier);
|
|
10838
|
+
} else if (midAngleDeg > 45 && midAngleDeg <= 90) {
|
|
10839
|
+
this.labelPaper.pen.moveTo(this.center.x + oppLength, this.center.y + moveLength);
|
|
10840
|
+
this.labelPaper.pen.lineTo(this.center.x + oppLength * slopeMultiplier, this.center.y + moveLength * slopeMultiplier);
|
|
10841
|
+
this.labelPaper.pen.lineTo(this.center.x + oppLength * flatMultiplier, this.center.y + moveLength * slopeMultiplier);
|
|
10842
|
+
} else if (midAngleDeg > 90 && midAngleDeg <= 135) {
|
|
10843
|
+
this.labelPaper.pen.moveTo(this.center.x - oppLength, this.center.y + moveLength);
|
|
10844
|
+
this.labelPaper.pen.lineTo(this.center.x - oppLength * slopeMultiplier, this.center.y + moveLength * slopeMultiplier);
|
|
10845
|
+
this.labelPaper.pen.lineTo(this.center.x - oppLength * flatMultiplier, this.center.y + moveLength * slopeMultiplier);
|
|
10846
|
+
} else if (midAngleDeg > 135 && midAngleDeg <= 180) {
|
|
10847
|
+
this.labelPaper.pen.moveTo(this.center.x - moveLength, this.center.y + oppLength);
|
|
10848
|
+
this.labelPaper.pen.lineTo(this.center.x - moveLength * slopeMultiplier, this.center.y + oppLength * slopeMultiplier);
|
|
10849
|
+
this.labelPaper.pen.lineTo(this.center.x - moveLength * flatMultiplier, this.center.y + oppLength * slopeMultiplier);
|
|
10850
|
+
} else if (midAngleDeg > 180 && midAngleDeg <= 225) {
|
|
10851
|
+
this.labelPaper.pen.moveTo(this.center.x - moveLength, this.center.y - oppLength);
|
|
10852
|
+
this.labelPaper.pen.lineTo(this.center.x - moveLength * slopeMultiplier, this.center.y - oppLength * slopeMultiplier);
|
|
10853
|
+
this.labelPaper.pen.lineTo(this.center.x - moveLength * flatMultiplier, this.center.y - oppLength * slopeMultiplier);
|
|
10854
|
+
} else if (midAngleDeg > 225 && midAngleDeg <= 270) {
|
|
10855
|
+
this.labelPaper.pen.moveTo(this.center.x - oppLength, this.center.y - moveLength);
|
|
10856
|
+
this.labelPaper.pen.lineTo(this.center.x - oppLength * slopeMultiplier, this.center.y - moveLength * slopeMultiplier);
|
|
10857
|
+
this.labelPaper.pen.lineTo(this.center.x - oppLength * flatMultiplier, this.center.y - moveLength * slopeMultiplier);
|
|
10858
|
+
} else if (midAngleDeg > 270 && midAngleDeg <= 315) {
|
|
10859
|
+
this.labelPaper.pen.moveTo(this.center.x + oppLength, this.center.y - moveLength);
|
|
10860
|
+
this.labelPaper.pen.lineTo(this.center.x + oppLength * slopeMultiplier, this.center.y - moveLength * slopeMultiplier);
|
|
10861
|
+
this.labelPaper.pen.lineTo(this.center.x + oppLength * flatMultiplier, this.center.y - moveLength * slopeMultiplier);
|
|
10862
|
+
} else {
|
|
10863
|
+
this.labelPaper.pen.moveTo(this.center.x + moveLength, this.center.y - oppLength);
|
|
10864
|
+
this.labelPaper.pen.lineTo(this.center.x + moveLength * slopeMultiplier, this.center.y - oppLength * slopeMultiplier);
|
|
10865
|
+
this.labelPaper.pen.lineTo(this.center.x + moveLength * flatMultiplier, this.center.y - oppLength * slopeMultiplier);
|
|
10866
|
+
}
|
|
10867
|
+
|
|
10868
|
+
this.labelPaper.pen.strokeStyle = '#cccccc';
|
|
10869
|
+
this.labelPaper.pen.stroke();
|
|
10870
|
+
this.labelPaper.pen.fillText(this.center.x + this.data.segments[s].label.x, this.center.y + this.data.segments[s].label.y, s);
|
|
10871
|
+
this.labelPaper.pen.closePath();
|
|
10872
|
+
}
|
|
10873
|
+
}
|
|
10874
|
+
}
|
|
10875
|
+
}, {
|
|
10876
|
+
key: "drawSegments",
|
|
10877
|
+
value: function drawSegments() {
|
|
10878
|
+
var originalStartPoint = this.convertDegreesToRadians(270);
|
|
10879
|
+
var startPoint = originalStartPoint;
|
|
10880
|
+
var colourIndex = 0;
|
|
10881
|
+
|
|
10882
|
+
for (var s in this.data.segments) {
|
|
10883
|
+
if (colourIndex >= this.options.colors.length) {
|
|
10884
|
+
colourIndex = 0;
|
|
10885
|
+
}
|
|
10886
|
+
|
|
10887
|
+
var segmentColour = this.options.colors[colourIndex];
|
|
10888
|
+
var endPoint = startPoint + this.data.segments[s].circumference;
|
|
10889
|
+
var midAngle = (startPoint + endPoint) / 2;
|
|
10890
|
+
this.data.segments[s].labelCanvasRotation = startPoint;
|
|
10891
|
+
this.data.segments[s].startAngle = startPoint;
|
|
10892
|
+
this.data.segments[s].midAngle = midAngle;
|
|
10893
|
+
this.data.segments[s].endAngle = endPoint;
|
|
10894
|
+
this.data.segments[s].startAngleDeg = this.convertRadiansToDegrees(startPoint);
|
|
10895
|
+
this.data.segments[s].midAngleDeg = this.convertRadiansToDegrees(midAngle);
|
|
10896
|
+
this.data.segments[s].endAngleDeg = this.convertRadiansToDegrees(endPoint);
|
|
10897
|
+
this.segmentPaper.pen.beginPath();
|
|
10898
|
+
this.segmentPaper.pen.moveTo(this.center.x, this.center.y);
|
|
10899
|
+
this.segmentPaper.pen.fillStyle = segmentColour;
|
|
10900
|
+
this.segmentPaper.pen.arc(this.center.x, this.center.y, this.outerRadius, startPoint, endPoint);
|
|
10901
|
+
console.log(this.segmentPaper.pen);
|
|
10902
|
+
this.segmentPaper.pen.fill();
|
|
10903
|
+
this.segmentPaper.pen.closePath();
|
|
10904
|
+
startPoint = endPoint;
|
|
10905
|
+
colourIndex++;
|
|
10906
|
+
} // cut out the center of the pie if an inner radius has been set
|
|
10907
|
+
|
|
10908
|
+
|
|
10909
|
+
if (this.innerRadius && this.innerRadius !== 0) {
|
|
10910
|
+
// inner radius is a percentage so we compare it against outerRadius (px) to calculate the pixel value
|
|
10911
|
+
this.innerRadiusPixels = Math.round(this.outerRadius * (this.innerRadius / 100));
|
|
10912
|
+
this.segmentPaper.pen.save();
|
|
10913
|
+
this.segmentPaper.pen.beginPath();
|
|
10914
|
+
this.segmentPaper.pen.moveTo(this.center.x, this.center.y);
|
|
10915
|
+
this.segmentPaper.pen.arc(this.center.x, this.center.y, this.innerRadiusPixels + 5, 0, Math.PI * 2);
|
|
10916
|
+
this.segmentPaper.pen.clip();
|
|
10917
|
+
this.segmentPaper.pen.clearRect(0, 0, this.width * 2, this.height * 2);
|
|
10918
|
+
this.segmentPaper.pen.closePath();
|
|
10919
|
+
this.segmentPaper.pen.restore(); // add shading if required
|
|
10920
|
+
|
|
10921
|
+
if (this.addShading === true) {
|
|
10922
|
+
startPoint = originalStartPoint;
|
|
10923
|
+
colourIndex = 0;
|
|
10924
|
+
|
|
10925
|
+
for (var _s in this.data.segments) {
|
|
10926
|
+
if (colourIndex >= this.options.colors.length) {
|
|
10927
|
+
colourIndex = 0;
|
|
10928
|
+
}
|
|
10929
|
+
|
|
10930
|
+
var _segmentColour = this.hexToRGBA(this.options.colors[colourIndex], 0.8);
|
|
10931
|
+
|
|
10932
|
+
var _endPoint = startPoint + this.data.segments[_s].circumference;
|
|
10933
|
+
|
|
10934
|
+
this.segmentPaper.pen.beginPath();
|
|
10935
|
+
this.segmentPaper.pen.moveTo(this.center.x, this.center.y);
|
|
10936
|
+
this.segmentPaper.pen.fillStyle = _segmentColour;
|
|
10937
|
+
this.segmentPaper.pen.arc(this.center.x, this.center.y, this.innerRadiusPixels + 6, startPoint, _endPoint);
|
|
10938
|
+
this.segmentPaper.pen.fill();
|
|
10939
|
+
this.segmentPaper.pen.closePath();
|
|
10940
|
+
startPoint = _endPoint;
|
|
10941
|
+
colourIndex++;
|
|
10942
|
+
} // cut out the center again
|
|
10943
|
+
|
|
10944
|
+
|
|
10945
|
+
this.segmentPaper.pen.save();
|
|
10946
|
+
this.segmentPaper.pen.beginPath();
|
|
10947
|
+
this.segmentPaper.pen.moveTo(this.center.x, this.center.y);
|
|
10948
|
+
this.segmentPaper.pen.arc(this.center.x, this.center.y, this.innerRadiusPixels, 0, Math.PI * 2);
|
|
10949
|
+
this.segmentPaper.pen.clip();
|
|
10950
|
+
this.segmentPaper.pen.clearRect(0, 0, this.width * 2, this.height * 2);
|
|
10951
|
+
this.segmentPaper.pen.closePath();
|
|
10952
|
+
this.segmentPaper.pen.restore();
|
|
10953
|
+
}
|
|
10954
|
+
}
|
|
10955
|
+
|
|
10956
|
+
console.log(this.data);
|
|
10957
|
+
}
|
|
10958
|
+
}, {
|
|
10959
|
+
key: "hexToRGBA",
|
|
10960
|
+
value: function hexToRGBA(hex, opacity) {
|
|
10961
|
+
if (!opacity) {
|
|
10962
|
+
opacity = 1;
|
|
10963
|
+
}
|
|
10964
|
+
|
|
10965
|
+
var c;
|
|
10966
|
+
|
|
10967
|
+
if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)) {
|
|
10968
|
+
c = hex.substring(1).split('');
|
|
10969
|
+
|
|
10970
|
+
if (c.length === 3) {
|
|
10971
|
+
c = [c[0], c[0], c[1], c[1], c[2], c[2]];
|
|
10972
|
+
}
|
|
10973
|
+
|
|
10974
|
+
c = '0x' + c.join('');
|
|
10975
|
+
return 'rgba(' + [c >> 16 & 255, c >> 8 & 255, c & 255, opacity].join(',') + ')';
|
|
10976
|
+
}
|
|
10977
|
+
|
|
10978
|
+
console.error("Unable to convert hex (".concat(hex, ") to RGBA"));
|
|
10979
|
+
return 'rgba(0, 0, 0, 1)';
|
|
10980
|
+
}
|
|
10981
|
+
}, {
|
|
10982
|
+
key: "render",
|
|
10983
|
+
value: function render(data) {
|
|
10984
|
+
/* global data */
|
|
10985
|
+
var el = document.getElementById(this.elementId);
|
|
10986
|
+
|
|
10987
|
+
if (el && !el.target) {
|
|
10988
|
+
this.createCanvases(el);
|
|
10989
|
+
}
|
|
10990
|
+
|
|
10991
|
+
if (data && !data.target) {
|
|
10992
|
+
this.originalData = _toConsumableArray(data);
|
|
10993
|
+
}
|
|
10994
|
+
|
|
10995
|
+
this.processData(data);
|
|
10996
|
+
this.drawSegments();
|
|
10997
|
+
this.drawLabels();
|
|
10998
|
+
this.drawKPI();
|
|
10999
|
+
}
|
|
11000
|
+
}, {
|
|
11001
|
+
key: "resize",
|
|
11002
|
+
value: function resize() {}
|
|
11003
|
+
}, {
|
|
11004
|
+
key: "processData",
|
|
11005
|
+
value: function processData(data) {
|
|
11006
|
+
/* global data */
|
|
11007
|
+
var tempData = {};
|
|
11008
|
+
var tempTotal = 0;
|
|
11009
|
+
|
|
11010
|
+
for (var i = 0; i < data.length; i++) {
|
|
11011
|
+
// if the dimension does not exists as a property on tempData, add it
|
|
11012
|
+
if (!tempData[data[i][0].label]) {
|
|
11013
|
+
tempData[data[i][0].label] = {
|
|
11014
|
+
segmentValue: 0,
|
|
11015
|
+
drill: []
|
|
11016
|
+
};
|
|
11017
|
+
} // add the value to the relevent segmentValue
|
|
11018
|
+
|
|
11019
|
+
|
|
11020
|
+
tempData[data[i][0].label].segmentValue += data[i][1].value; // add the value to the total
|
|
11021
|
+
|
|
11022
|
+
tempTotal += data[i][1].value; // if a drill has been specified add the data to the drill property
|
|
11023
|
+
|
|
11024
|
+
if (this.drill && this.drill !== '') {
|
|
11025
|
+
tempData[data[i][0].label].drill.push({
|
|
11026
|
+
label: data[i][0].label,
|
|
11027
|
+
value: data[i][1].value
|
|
11028
|
+
});
|
|
11029
|
+
}
|
|
11030
|
+
} // loop through the full data set to calculate the percentages
|
|
11031
|
+
|
|
11032
|
+
|
|
11033
|
+
for (var s in tempData) {
|
|
11034
|
+
tempData[s].percValue = tempData[s].segmentValue / tempTotal;
|
|
11035
|
+
tempData[s].circumference = this.calculateCircumference(tempData[s].percValue);
|
|
11036
|
+
tempData[s].labelAngle = 360 * (tempData[s].percValue / 2); // calculate where the label should be for that segment
|
|
11037
|
+
|
|
11038
|
+
tempData[s].label = {
|
|
11039
|
+
x: (this.outerRadius + 5) / Math.sin(this.convertDegreesToRadians(90)) * Math.sin(this.convertDegreesToRadians(180 - 90 - tempData[s].labelAngle))
|
|
11040
|
+
};
|
|
11041
|
+
tempData[s].label.y = (this.outerRadius + 5) / Math.sin(this.convertDegreesToRadians(90)) * Math.sin(this.convertDegreesToRadians(tempData[s].labelAngle));
|
|
11042
|
+
}
|
|
11043
|
+
|
|
11044
|
+
this.data = {
|
|
11045
|
+
segments: tempData,
|
|
11046
|
+
total: tempTotal
|
|
11047
|
+
};
|
|
11048
|
+
console.log(this.data);
|
|
11049
|
+
}
|
|
11050
|
+
}]);
|
|
11051
|
+
|
|
11052
|
+
return WebsyPie;
|
|
11053
|
+
}();
|
|
10507
11054
|
|
|
10508
11055
|
var WebsyLegend = /*#__PURE__*/function () {
|
|
10509
11056
|
function WebsyLegend(elementId, options) {
|
|
@@ -11033,6 +11580,8 @@ var WebsyDesigns = {
|
|
|
11033
11580
|
Chart: WebsyChart,
|
|
11034
11581
|
WebsyChartTooltip: WebsyChartTooltip,
|
|
11035
11582
|
ChartTooltip: WebsyChartTooltip,
|
|
11583
|
+
Pie: WebsyPie,
|
|
11584
|
+
WebsyPie: WebsyPie,
|
|
11036
11585
|
Legend: WebsyLegend,
|
|
11037
11586
|
WebsyMap: WebsyMap,
|
|
11038
11587
|
Map: WebsyMap,
|