logitude-dashboard-library 1.4.24 → 1.4.25

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.
@@ -436,6 +436,11 @@ $dark-grey: #717585;
436
436
  height: calc(100% - 5px);
437
437
  }
438
438
 
439
+ .db-fc-parent-container {
440
+ width: 100%;
441
+ height: calc(100% - 5px);
442
+ }
443
+
439
444
  .db-fc-container text {
440
445
  font-family: 'Manrope' !important;
441
446
  font-size: 10px !important;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { DashboardDataBinding } from "../../../../types/DashboardDataBinding";
3
3
  import { DataPointSelection } from "../../../../types/SeriesMeasure";
4
4
  import { ReactWidgetPM } from "../../../../types/widget";
@@ -8,5 +8,5 @@ export declare type FusionChartProps = {
8
8
  dataBinding: DashboardDataBinding;
9
9
  onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
10
10
  };
11
- declare const FusionChart: (props: FusionChartProps) => JSX.Element;
11
+ declare const FusionChart: React.ForwardRefExoticComponent<FusionChartProps & React.RefAttributes<unknown>>;
12
12
  export default FusionChart;
@@ -6,6 +6,7 @@ export declare class FusionChartHelper {
6
6
  private widget;
7
7
  constructor(widget: ReactWidgetPM, chart: ChartObject);
8
8
  trimChartLabels(chartWidth: number, chartHeight: number): void;
9
+ private IsInStep;
9
10
  private getTrimedLabelText;
10
11
  private trimString;
11
12
  private numberBetween;
@@ -37,6 +37,11 @@ export interface ChartInfo {
37
37
  canvasBottomPadding: string;
38
38
  labelDisplay: string;
39
39
  slantLabel: string;
40
+ manageLabelOverflow: string;
41
+ useEllipsesWhenOverflow: string;
42
+ enableSmartLabels: string;
43
+ pieRadius: string;
44
+ doughnutRadius: string;
40
45
  }
41
46
  export declare function getSeriesPositionColor(position: number): string | null;
42
47
  export declare function getSeriesHoverPositionColor(position: number): string | null;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from "react";
2
2
  import { DataPointSelection } from "../../types/SeriesMeasure";
3
3
  import { ReactWidgetPM } from "../../types/widget";
4
4
  import { DashboardDataBinding } from '../../types/DashboardDataBinding';
@@ -13,5 +13,5 @@ declare type WidgetCardProps = {
13
13
  isInEditMode: boolean;
14
14
  onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
15
15
  };
16
- declare const WidgetCard: (props: WidgetCardProps, state: any) => JSX.Element;
16
+ declare const WidgetCard: React.ForwardRefExoticComponent<WidgetCardProps & React.RefAttributes<unknown>>;
17
17
  export default WidgetCard;
package/dist/index.js CHANGED
@@ -710,6 +710,10 @@ function getDonutObject(seriesMeasures, widget) {
710
710
  chartInfo.legendCaptionFont = defautFont;
711
711
  chartInfo.labelFontSize = defautFontSize;
712
712
  chartInfo.labelFont = defautFont;
713
+ chartInfo.manageLabelOverflow = "1";
714
+ chartInfo.useEllipsesWhenOverflow = "1";
715
+ chartInfo.enableSmartLabels = "1";
716
+ chartInfo.pieRadius = "70%";
713
717
  chart.dataSource = getSimpleDataSource(chartInfo, seriesMeasures, widget);
714
718
  return chart;
715
719
  }
@@ -725,6 +729,10 @@ function getPieObject(seriesMeasures, widget) {
725
729
  chartInfo.legendCaptionFont = defautFont;
726
730
  chartInfo.labelFontSize = defautFontSize;
727
731
  chartInfo.labelFont = defautFont;
732
+ chartInfo.manageLabelOverflow = "1";
733
+ chartInfo.useEllipsesWhenOverflow = "1";
734
+ chartInfo.enableSmartLabels = "1";
735
+ chartInfo.pieRadius = "70%";
728
736
  chart.dataSource = getSimpleDataSource(chartInfo, seriesMeasures, widget);
729
737
  return chart;
730
738
  }
@@ -803,29 +811,27 @@ var FusionChartHelper = /*#__PURE__*/function () {
803
811
  var _proto = FusionChartHelper.prototype;
804
812
 
805
813
  _proto.trimChartLabels = function trimChartLabels(chartWidth, chartHeight) {
806
- var _this = this;
814
+ var _this$chart;
807
815
 
808
816
  if (!this.widget || this.widget.TypeCode != "pie" && this.widget.TypeCode != "donut") return;
809
817
  if (!this.chart || !this.dataSource) return;
810
- var copyDataSource = deepClone(this.dataSource);
811
- var data = copyDataSource === null || copyDataSource === void 0 ? void 0 : copyDataSource.data;
812
- if (!data || data.length == 0) return;
813
- data.forEach(function (dataItem) {
814
- dataItem.label = _this.getTrimedLabelText(dataItem.label, chartWidth, chartHeight);
815
- });
816
- this.chart.dataSource = copyDataSource;
818
+ var chartMinumunHeight = 236;
819
+ var startPercantage = 80;
820
+ var stepHeight = 60;
821
+ var chartInfo = (_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.dataSource.chart;
822
+ var step = Math.floor((chartHeight - chartMinumunHeight) / stepHeight);
823
+ if (step < 0) step = 0;
824
+ var pieRadius = startPercantage - step * 10;
825
+ if (pieRadius < 60) pieRadius = 60;
826
+ chartInfo.pieRadius = pieRadius + "%";
817
827
  };
818
828
 
819
- _proto.getTrimedLabelText = function getTrimedLabelText(label, chartWidth, chartHeight) {
820
- if (!label) return label;
821
- var charCount = chartWidth / 35;
822
- var widthHeight = chartWidth / chartHeight;
823
-
824
- if (WidthGreaterThanHeigh(widthHeight)) {
825
- charCount = charCount + widthHeight * 3.5;
826
- }
829
+ _proto.IsInStep = function IsInStep(chartHeight, chartMinumunHeight, stepHeight, staySafeValue, step) {
830
+ return chartHeight < chartMinumunHeight + stepHeight * step - staySafeValue;
831
+ };
827
832
 
828
- return this.trimString(label, charCount);
833
+ _proto.getTrimedLabelText = function getTrimedLabelText(label, chartWidth, chartHeight) {
834
+ return label;
829
835
  };
830
836
 
831
837
  _proto.trimString = function trimString(label, charCount) {
@@ -841,17 +847,12 @@ var FusionChartHelper = /*#__PURE__*/function () {
841
847
  return FusionChartHelper;
842
848
  }();
843
849
 
844
- function WidthGreaterThanHeigh(widthHeight) {
845
- return widthHeight > 2.5;
846
- }
847
-
848
850
  ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);
849
851
  FusionCharts.options['license']({
850
852
  key: 'prD4C-8eiA7A3A3C7E6G4B4A3J4C7B2D3D2nyqE1C3fd1npaE4D4tlA-21D7E4F4F1F1E1F4F1A10A8C2C5F5E2F2D1hwqD1B5D1aG4A19A32twbC6D3G4lhJ-7A9C11A5B-13ddA2I3A1B9B3D7A2B4G2H3H1F-7smC8B2XB4cetB8A7A5mxD3SG4F2tvgB2A3B2E4C3I3C7B3A4A3A2D3D2G4J-7==',
851
853
  creditLabel: false
852
854
  });
853
-
854
- var FusionChart = function FusionChart(props) {
855
+ var FusionChart = React.forwardRef(function (props, comRef) {
855
856
  var _useState = React.useState(false),
856
857
  dataLoaded = _useState[0],
857
858
  setDataLoaded = _useState[1];
@@ -866,13 +867,14 @@ var FusionChart = function FusionChart(props) {
866
867
  args = _useState3[0],
867
868
  setArgs = _useState3[1];
868
869
 
869
- var _useState4 = React.useState({}),
870
+ var _useState4 = React.useState(),
870
871
  fChart = _useState4[0],
871
872
  setFchart = _useState4[1];
872
873
 
873
874
  var id = (Math.random() + 1).toString(36).substring(7);
874
875
  var entered = React.useRef(false);
875
876
  var progressRef = React.useRef(null);
877
+ var fusionRef = React.useRef(null);
876
878
  var fusionChartHelper = React.useRef();
877
879
  React.useEffect(function () {
878
880
  widget.current = props.widget;
@@ -880,6 +882,21 @@ var FusionChart = function FusionChart(props) {
880
882
  RefreshData();
881
883
  }, 500);
882
884
  }, []);
885
+ React.useImperativeHandle(comRef, function () {
886
+ return {
887
+ onResizeFinish: function onResizeFinish() {
888
+ setTimeout(function () {
889
+ var _fusionChartHelper$cu, _fusionRef$current, _fusionRef$current2;
890
+
891
+ 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);
892
+ setDataLoaded(false);
893
+ setTimeout(function () {
894
+ setDataLoaded(true);
895
+ }, 100);
896
+ }, 100);
897
+ }
898
+ };
899
+ });
883
900
 
884
901
  var RefreshData = function RefreshData() {
885
902
  var dashboardAnalyticsService = new DashboardAnalyticsService();
@@ -921,21 +938,13 @@ var FusionChart = function FusionChart(props) {
921
938
  setFchart(chart);
922
939
  };
923
940
 
941
+ var drawComplete = function drawComplete(event) {};
942
+
924
943
  var _useResizeObserver = useResizeObserver({
925
944
  onResize: function onResize(_ref) {
926
- var _fusionChartHelper$cu;
927
-
928
945
  var width = _ref.width,
929
946
  height = _ref.height;
930
- fChart.resizeTo(width, height);
931
-
932
- if (entered.current == false) {
933
- entered.current = true;
934
- return;
935
- }
936
-
937
- fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu = fusionChartHelper.current) === null || _fusionChartHelper$cu === void 0 ? void 0 : _fusionChartHelper$cu.trimChartLabels(width, height);
938
- setArgs(args);
947
+ fChart === null || fChart === void 0 ? void 0 : fChart.resizeTo(width, height);
939
948
  }
940
949
  }),
941
950
  ref = _useResizeObserver.ref;
@@ -951,13 +960,17 @@ var FusionChart = function FusionChart(props) {
951
960
  strokeWidth: "4",
952
961
  animationDuration: "2s"
953
962
  })) : !error ? React__default.createElement("div", {
963
+ className: 'db-fc-parent-container',
964
+ ref: fusionRef
965
+ }, " ", React__default.createElement("div", {
954
966
  className: 'db-fc-container',
955
967
  ref: ref,
956
968
  id: id
957
969
  }, React__default.createElement(ReactFC, Object.assign({}, args, {
958
970
  "fcEvent-dataplotClick": dataplotClick,
959
- onRender: renderComplete
960
- }))) : React__default.createElement("div", {
971
+ onRender: renderComplete,
972
+ "fcEvent-drawComplete": drawComplete
973
+ }))), " ") : React__default.createElement("div", {
961
974
  className: "dl-flex-content-center dl-full-hight",
962
975
  style: {
963
976
  width: '100%'
@@ -970,9 +983,9 @@ var FusionChart = function FusionChart(props) {
970
983
  }), React__default.createElement("span", {
971
984
  className: "dl-tooltiptext"
972
985
  }, error)));
973
- };
986
+ });
974
987
 
975
- var WidgetCard = function WidgetCard(props, state) {
988
+ var WidgetCard = React.forwardRef(function (props, comRef) {
976
989
  var _widget$current2, _widget$current3;
977
990
 
978
991
  var moreBtnToggle = React.useRef(null);
@@ -985,6 +998,8 @@ var WidgetCard = function WidgetCard(props, state) {
985
998
  var _useState2 = React.useState(false),
986
999
  showTooltip = _useState2[1];
987
1000
 
1001
+ var fusionChartRef = React.useRef(null);
1002
+
988
1003
  var editWidget = function editWidget() {
989
1004
  var _moreBtnToggle$curren;
990
1005
 
@@ -1005,6 +1020,15 @@ var WidgetCard = function WidgetCard(props, state) {
1005
1020
  setIsLoading(false);
1006
1021
  });
1007
1022
  }, []);
1023
+ React.useImperativeHandle(comRef, function () {
1024
+ return {
1025
+ onResizeFinish: function onResizeFinish() {
1026
+ var _fusionChartRef$curre;
1027
+
1028
+ fusionChartRef === null || fusionChartRef === void 0 ? void 0 : (_fusionChartRef$curre = fusionChartRef.current) === null || _fusionChartRef$curre === void 0 ? void 0 : _fusionChartRef$curre.onResizeFinish();
1029
+ }
1030
+ };
1031
+ });
1008
1032
  return React__default.createElement("div", {
1009
1033
  className: "dl-panel",
1010
1034
  key: props.el.i,
@@ -1076,13 +1100,14 @@ var WidgetCard = function WidgetCard(props, state) {
1076
1100
  onSelectDataPoint: props.onSelectDataPoint
1077
1101
  });
1078
1102
  return React__default.createElement(FusionChart, {
1103
+ ref: fusionChartRef,
1079
1104
  dataBinding: props.dataBinding,
1080
1105
  widget: widget.current,
1081
1106
  widgetRef: props.widgetRef,
1082
1107
  onSelectDataPoint: props.onSelectDataPoint
1083
1108
  });
1084
1109
  }
1085
- };
1110
+ });
1086
1111
 
1087
1112
  var ResponsiveReactGridLayout = reactGridLayout.WidthProvider(reactGridLayout.Responsive);
1088
1113
 
@@ -1121,6 +1146,7 @@ var DashboardDesigner = function DashboardDesigner(props) {
1121
1146
 
1122
1147
  var gridLayoutComponent = React.useRef(null);
1123
1148
  var entered = React.useRef(false);
1149
+ var widgetCardRef = React.useRef([]);
1124
1150
  React.useEffect(function () {
1125
1151
  FillLayout(props.Widgetlayouts);
1126
1152
  }, [props.Widgetlayouts]);
@@ -1170,6 +1196,14 @@ var DashboardDesigner = function DashboardDesigner(props) {
1170
1196
  props.onLayoutChange(changedLayouts);
1171
1197
  }
1172
1198
 
1199
+ function onResizeStop(event, oldItem) {
1200
+ var _widgetCardRef$curren, _widgetCardRef$curren2;
1201
+
1202
+ widgetCardRef === null || widgetCardRef === void 0 ? void 0 : (_widgetCardRef$curren = widgetCardRef.current) === null || _widgetCardRef$curren === void 0 ? void 0 : (_widgetCardRef$curren2 = _widgetCardRef$curren.find(function (x) {
1203
+ return x.i == oldItem.i;
1204
+ })) === null || _widgetCardRef$curren2 === void 0 ? void 0 : _widgetCardRef$curren2.ref.onResizeFinish(widgetsDictionaryRef.current[oldItem.i].key);
1205
+ }
1206
+
1173
1207
  function UpdateWidget(changedLayouts) {
1174
1208
  for (var _iterator2 = _createForOfIteratorHelperLoose(changedLayouts.lg), _step2; !(_step2 = _iterator2()).done;) {
1175
1209
  var item = _step2.value;
@@ -1245,8 +1279,9 @@ var DashboardDesigner = function DashboardDesigner(props) {
1245
1279
  isDraggable: isInEditMode,
1246
1280
  isResizable: isInEditMode,
1247
1281
  onWidthChange: function onWidthChange() {},
1282
+ onResizeStop: onResizeStop,
1248
1283
  onLayoutChange: onLayoutChange
1249
- }), widgets.lg.map(function (widget) {
1284
+ }), widgets.lg.map(function (widget, i) {
1250
1285
  var _widget$Layout, _widget$Layout2;
1251
1286
 
1252
1287
  return React__default.createElement("div", {
@@ -1261,7 +1296,15 @@ var DashboardDesigner = function DashboardDesigner(props) {
1261
1296
  dateFilter: dateFilter,
1262
1297
  editBtnClicked: editWidget,
1263
1298
  deleteBtnClicked: deletePanel,
1264
- onSelectDataPoint: props.onSelectDataPoint
1299
+ onSelectDataPoint: props.onSelectDataPoint,
1300
+ ref: function ref(el) {
1301
+ var _widget$Layout3;
1302
+
1303
+ widgetCardRef.current[i] = {
1304
+ ref: el,
1305
+ i: (_widget$Layout3 = widget.Layout) === null || _widget$Layout3 === void 0 ? void 0 : _widget$Layout3.i
1306
+ };
1307
+ }
1265
1308
  }));
1266
1309
  }))))));
1267
1310
  };