logitude-dashboard-library 1.4.26 → 1.4.27
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.
|
@@ -2,12 +2,9 @@ import { ChartObject } from "fusioncharts";
|
|
|
2
2
|
import { ReactWidgetPM } from "../../../../types/widget";
|
|
3
3
|
export declare class FusionChartHelper {
|
|
4
4
|
private chart;
|
|
5
|
-
private dataSource;
|
|
6
5
|
private widget;
|
|
6
|
+
private pieRadius;
|
|
7
7
|
constructor(widget: ReactWidgetPM, chart: ChartObject);
|
|
8
|
+
getPieRadius(): number;
|
|
8
9
|
trimChartLabels(chartWidth: number, chartHeight: number): void;
|
|
9
|
-
private IsInStep;
|
|
10
|
-
private getTrimedLabelText;
|
|
11
|
-
private trimString;
|
|
12
|
-
private numberBetween;
|
|
13
10
|
}
|
package/dist/index.js
CHANGED
|
@@ -797,51 +797,42 @@ function getDefaultChartInfo(widget) {
|
|
|
797
797
|
return chart;
|
|
798
798
|
}
|
|
799
799
|
|
|
800
|
-
function deepClone(obj) {
|
|
801
|
-
return JSON.parse(JSON.stringify(obj));
|
|
802
|
-
}
|
|
803
|
-
|
|
804
800
|
var FusionChartHelper = /*#__PURE__*/function () {
|
|
805
801
|
function FusionChartHelper(widget, chart) {
|
|
806
802
|
this.chart = chart;
|
|
807
803
|
this.widget = widget;
|
|
808
|
-
this.dataSource = deepClone(chart.dataSource);
|
|
809
804
|
}
|
|
810
805
|
|
|
811
806
|
var _proto = FusionChartHelper.prototype;
|
|
812
807
|
|
|
808
|
+
_proto.getPieRadius = function getPieRadius() {
|
|
809
|
+
return this.pieRadius;
|
|
810
|
+
};
|
|
811
|
+
|
|
813
812
|
_proto.trimChartLabels = function trimChartLabels(chartWidth, chartHeight) {
|
|
814
813
|
var _this$chart;
|
|
815
814
|
|
|
816
815
|
if (!this.widget || this.widget.TypeCode != "pie" && this.widget.TypeCode != "donut") return;
|
|
817
|
-
if (!this.chart
|
|
816
|
+
if (!this.chart) return;
|
|
818
817
|
var chartMinumunHeight = 236;
|
|
819
|
-
var startPercantage =
|
|
818
|
+
var startPercantage = 70;
|
|
820
819
|
var stepHeight = 60;
|
|
821
820
|
var chartInfo = (_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.dataSource.chart;
|
|
822
821
|
var step = Math.floor((chartHeight - chartMinumunHeight) / stepHeight);
|
|
823
822
|
if (step < 0) step = 0;
|
|
824
823
|
var pieRadius = startPercantage - step * 10;
|
|
825
824
|
if (pieRadius < 60) pieRadius = 60;
|
|
826
|
-
chartInfo.pieRadius = pieRadius + "%";
|
|
827
|
-
};
|
|
828
825
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
return label;
|
|
835
|
-
};
|
|
836
|
-
|
|
837
|
-
_proto.trimString = function trimString(label, charCount) {
|
|
838
|
-
if (label.length <= charCount) return label;
|
|
839
|
-
if (charCount > label.length) return label;
|
|
840
|
-
return label.substring(0, charCount - 2) + "..";
|
|
841
|
-
};
|
|
826
|
+
if (window.innerWidth > 1700) {
|
|
827
|
+
this.pieRadius = pieRadius;
|
|
828
|
+
chartInfo.pieRadius = pieRadius + "%";
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
842
831
|
|
|
843
|
-
|
|
844
|
-
|
|
832
|
+
var reducedValue = Math.floor((1700 - window.innerWidth) / 100) + 1;
|
|
833
|
+
pieRadius = pieRadius - reducedValue * 5;
|
|
834
|
+
this.pieRadius = pieRadius;
|
|
835
|
+
chartInfo.pieRadius = pieRadius + "%";
|
|
845
836
|
};
|
|
846
837
|
|
|
847
838
|
return FusionChartHelper;
|
|
@@ -872,7 +863,6 @@ var FusionChart = React.forwardRef(function (props, comRef) {
|
|
|
872
863
|
setFchart = _useState4[1];
|
|
873
864
|
|
|
874
865
|
var id = (Math.random() + 1).toString(36).substring(7);
|
|
875
|
-
var entered = React.useRef(false);
|
|
876
866
|
var progressRef = React.useRef(null);
|
|
877
867
|
var fusionRef = React.useRef(null);
|
|
878
868
|
var fusionChartHelper = React.useRef();
|
|
@@ -882,25 +872,46 @@ var FusionChart = React.forwardRef(function (props, comRef) {
|
|
|
882
872
|
RefreshData();
|
|
883
873
|
}, 500);
|
|
884
874
|
}, []);
|
|
875
|
+
React.useEffect(function () {
|
|
876
|
+
var timeout;
|
|
877
|
+
|
|
878
|
+
var handleResize = function handleResize() {
|
|
879
|
+
clearTimeout(timeout);
|
|
880
|
+
timeout = setTimeout(function () {
|
|
881
|
+
HandleSizeChange();
|
|
882
|
+
}, 200);
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
window.addEventListener("resize", handleResize);
|
|
886
|
+
return function () {
|
|
887
|
+
return window.removeEventListener("resize", handleResize);
|
|
888
|
+
};
|
|
889
|
+
}, []);
|
|
885
890
|
React.useImperativeHandle(comRef, function () {
|
|
886
891
|
return {
|
|
887
892
|
onResizeFinish: function onResizeFinish() {
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
if (!widget || ((_widget$current = widget.current) === null || _widget$current === void 0 ? void 0 : _widget$current.TypeCode) != "pie" && ((_widget$current2 = widget.current) === null || _widget$current2 === void 0 ? void 0 : _widget$current2.TypeCode) != "donut") return;
|
|
891
|
-
setTimeout(function () {
|
|
892
|
-
var _fusionChartHelper$cu, _fusionRef$current, _fusionRef$current2;
|
|
893
|
-
|
|
894
|
-
fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu = fusionChartHelper.current) === null || _fusionChartHelper$cu === void 0 ? void 0 : _fusionChartHelper$cu.trimChartLabels(fusionRef === null || fusionRef === void 0 ? void 0 : (_fusionRef$current = fusionRef.current) === null || _fusionRef$current === void 0 ? void 0 : _fusionRef$current.offsetWidth, fusionRef === null || fusionRef === void 0 ? void 0 : (_fusionRef$current2 = fusionRef.current) === null || _fusionRef$current2 === void 0 ? void 0 : _fusionRef$current2.offsetHeight);
|
|
895
|
-
setDataLoaded(false);
|
|
896
|
-
setTimeout(function () {
|
|
897
|
-
setDataLoaded(true);
|
|
898
|
-
}, 100);
|
|
899
|
-
}, 100);
|
|
893
|
+
HandleSizeChange();
|
|
900
894
|
}
|
|
901
895
|
};
|
|
902
896
|
});
|
|
903
897
|
|
|
898
|
+
var HandleSizeChange = function HandleSizeChange() {
|
|
899
|
+
var _widget$current, _widget$current2;
|
|
900
|
+
|
|
901
|
+
if (!widget || ((_widget$current = widget.current) === null || _widget$current === void 0 ? void 0 : _widget$current.TypeCode) != "pie" && ((_widget$current2 = widget.current) === null || _widget$current2 === void 0 ? void 0 : _widget$current2.TypeCode) != "donut") return;
|
|
902
|
+
setTimeout(function () {
|
|
903
|
+
var _fusionChartHelper$cu, _fusionChartHelper$cu2, _fusionRef$current, _fusionRef$current2, _fusionChartHelper$cu3;
|
|
904
|
+
|
|
905
|
+
var oldPieRadius = fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu = fusionChartHelper.current) === null || _fusionChartHelper$cu === void 0 ? void 0 : _fusionChartHelper$cu.getPieRadius();
|
|
906
|
+
fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu2 = fusionChartHelper.current) === null || _fusionChartHelper$cu2 === void 0 ? void 0 : _fusionChartHelper$cu2.trimChartLabels(fusionRef === null || fusionRef === void 0 ? void 0 : (_fusionRef$current = fusionRef.current) === null || _fusionRef$current === void 0 ? void 0 : _fusionRef$current.offsetWidth, fusionRef === null || fusionRef === void 0 ? void 0 : (_fusionRef$current2 = fusionRef.current) === null || _fusionRef$current2 === void 0 ? void 0 : _fusionRef$current2.offsetHeight);
|
|
907
|
+
if (oldPieRadius == (fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu3 = fusionChartHelper.current) === null || _fusionChartHelper$cu3 === void 0 ? void 0 : _fusionChartHelper$cu3.getPieRadius())) return;
|
|
908
|
+
setDataLoaded(false);
|
|
909
|
+
setTimeout(function () {
|
|
910
|
+
setDataLoaded(true);
|
|
911
|
+
}, 100);
|
|
912
|
+
}, 100);
|
|
913
|
+
};
|
|
914
|
+
|
|
904
915
|
var RefreshData = function RefreshData() {
|
|
905
916
|
var dashboardAnalyticsService = new DashboardAnalyticsService();
|
|
906
917
|
|
|
@@ -1112,6 +1123,10 @@ var WidgetCard = React.forwardRef(function (props, comRef) {
|
|
|
1112
1123
|
}
|
|
1113
1124
|
});
|
|
1114
1125
|
|
|
1126
|
+
function deepClone(obj) {
|
|
1127
|
+
return JSON.parse(JSON.stringify(obj));
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1115
1130
|
var ResponsiveReactGridLayout = reactGridLayout.WidthProvider(reactGridLayout.Responsive);
|
|
1116
1131
|
|
|
1117
1132
|
var DashboardDesigner = function DashboardDesigner(props) {
|