logitude-dashboard-library 1.4.37 → 1.4.39

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.
@@ -1,10 +1,15 @@
1
1
  import { ChartObject } from "fusioncharts";
2
2
  import { ReactWidgetPM } from "../../../../types/widget";
3
+ import { ChartInfo } from "./FusionChartObjectHelper";
3
4
  export declare class FusionChartHelper {
4
5
  private chart;
5
6
  private widget;
6
7
  private pieRadius;
8
+ private legendWidth;
7
9
  constructor(widget: ReactWidgetPM, chart: ChartObject);
8
10
  getPieRadius(): number;
11
+ getLegendWidth(): string;
9
12
  trimChartLabels(chartWidth: number, chartHeight: number): void;
13
+ handlePieRadius(chartHeight: number, chartInfo: ChartInfo): void;
14
+ handleLegendWidth(chartWidth: number, chartHeight: number, chartInfo: ChartInfo): void;
10
15
  }
@@ -35,6 +35,7 @@ export interface ChartInfo {
35
35
  plottooltext: string;
36
36
  anchorradius: string;
37
37
  canvasBottomPadding: string;
38
+ canvasTopPadding: string;
38
39
  labelDisplay: string;
39
40
  slantLabel: string;
40
41
  manageLabelOverflow: string;
@@ -45,6 +46,16 @@ export interface ChartInfo {
45
46
  baseFontColor: string;
46
47
  legendCaptionFontColor: string;
47
48
  labelFontColor: string;
49
+ plotColorinTooltip: string;
50
+ showLabels: string;
51
+ legendPosition: string;
52
+ legendScrollBgColor: string;
53
+ legendIconScale: number;
54
+ scrollShowButtons: string;
55
+ legendCaptionAlignment: string;
56
+ legendWidth: string;
57
+ alignLegendWithCanvas: string;
58
+ centerLabelBold: string;
48
59
  }
49
60
  export declare function getSeriesPositionColor(position: number): string | null;
50
61
  export declare function getSeriesHoverPositionColor(position: number): string | null;
@@ -1,2 +1,2 @@
1
1
  import { ReactWidgetPM } from "../../../../types/widget";
2
- export declare function buildToolTip(widget: ReactWidgetPM, value: any, seriesName: string, label: any): string;
2
+ export declare function buildToolTip(widget: ReactWidgetPM, value: any, seriesName: string, label: any, index: number): string;
package/dist/index.js CHANGED
@@ -426,8 +426,9 @@ function getSeriesPositionColor(position) {
426
426
  }
427
427
  }
428
428
 
429
- function buildToolTip(widget, value, seriesName, label) {
430
- return "\n <div style=\"min-width: 108px;\">\n <div style=\"display: flex;align-items: center;margin-bottom: 6px;\">\n <span style=\"margin: 0; height: 10px; width: 10px; background-color: #A4A4A4; border-radius: 50%; display: inline-block;\"></span>\n <p style=\" margin: 0; margin-left: 4px;font-family: 'Manrope'; font-style: normal;font-weight: 400; font-size: 11px; line-height: 100%; color: #323232; flex: none; order: 1;flex-grow: 0;\"> " + getTooltiplabel(label) + "</p>\n </div>\n <hr style=\"margin: 0;border-top: 1px solid #F0F0F0;\">\n <div style=\"display: flex;align-items: center;margin:0;margin-top: 6px;\">\n <p style=\"margin: 0;font-family: 'Manrope';font-style: normal;font-weight: 400; font-size: 11px;line-height: 100%;color: #A4A4A4;flex: none;order: 0;flex-grow: 0;\"> " + getMeasureType(seriesName) + "</p>\n <p style=\"margin: 0;margin-left: 6px;font-family: 'Manrope';font-style: normal;font-weight: 500;font-size: 11px;line-height: 100%; color: #323232;flex: none; order: 1;flex-grow: 0;\">" + getTooltipValue(value) + "</p>\n " + getTooltipPercentage(widget) + " </div>\n </div>\n ";
429
+ function buildToolTip(widget, value, seriesName, label, index) {
430
+ var padding = widget.TypeCode == 'line' && index > 0 ? 'padding-top: 3px' : '';
431
+ return "\n <div style=\"min-width: 108px;" + padding + "\">\n <div style=\"display: flex;align-items: center;margin-bottom: 6px;\">\n <span style=\"margin: 0; height: 10px; width: 10px; background-color: #A4A4A4; border-radius: 50%; display: inline-block;\"></span>\n <p style=\" margin: 0; margin-left: 4px;font-family: 'Manrope'; font-style: normal;font-weight: 400; font-size: 11px; line-height: 100%; color: #323232; flex: none; order: 1;flex-grow: 0;\"> " + getTooltiplabel(label) + "</p>\n </div>\n <hr style=\"margin: 0;border-top: 1px solid #F0F0F0;\">\n <div style=\"display: flex;align-items: center;margin:0;margin-top: 6px;\">\n <p style=\"margin: 0;font-family: 'Manrope';font-style: normal;font-weight: 400; font-size: 11px;line-height: 100%;color: #A4A4A4;flex: none;order: 0;flex-grow: 0;\"> " + getMeasureType(seriesName) + "</p>\n <p style=\"margin: 0;margin-left: 6px;font-family: 'Manrope';font-style: normal;font-weight: 500;font-size: 11px;line-height: 100%; color: #323232;flex: none; order: 1;flex-grow: 0;\">" + getTooltipValue(value) + "</p>\n " + getTooltipPercentage(widget) + " </div>\n </div>\n ";
431
432
  }
432
433
 
433
434
  function getTooltipPercentage(widget) {
@@ -506,7 +507,7 @@ function buildDataSource(values, widget) {
506
507
  GroupById: e.GroupById,
507
508
  MeasureFieldId: series.MeasureFieldId
508
509
  },
509
- tooltext: buildToolTip(widget, null, series.Name, e.Label),
510
+ tooltext: buildToolTip(widget, null, series.Name, e.Label, 0),
510
511
  color: getSeriesPositionColor(index + 1)
511
512
  };
512
513
  return item;
@@ -518,14 +519,14 @@ function buildDataSet(seriesMeasures, widget) {
518
519
  var dataSet = [];
519
520
  var seriesPosition = 1;
520
521
  seriesMeasures.forEach(function (seriesMeasure) {
521
- var datas = seriesMeasure.Values.map(function (e) {
522
+ var datas = seriesMeasure.Values.map(function (e, index) {
522
523
  return {
523
524
  value: e.Value,
524
525
  id: {
525
526
  GroupById: e.GroupById,
526
527
  MeasureFieldId: seriesMeasure.MeasureFieldId
527
528
  },
528
- tooltext: buildToolTip(widget, e.Value, seriesMeasure.Name, null)
529
+ tooltext: buildToolTip(widget, e.Value, seriesMeasure.Name, null, index)
529
530
  };
530
531
  });
531
532
  var color = getSeriesPositionColor(seriesPosition);
@@ -584,7 +585,7 @@ function buildStackedGroupData(secGroup, series, widget) {
584
585
  MeasureFieldId: series.MeasureFieldId,
585
586
  GroupByIdSec: secGroup.code
586
587
  },
587
- tooltext: buildToolTip(widget, null, series.Name, group.label + " - " + secGroup.label)
588
+ tooltext: buildToolTip(widget, null, series.Name, group.label + " - " + secGroup.label, 0)
588
589
  });
589
590
  });
590
591
  return data;
@@ -664,8 +665,6 @@ function getBarObject(seriesMeasures, widget) {
664
665
  chartInfo.flatScrollBars = "1";
665
666
  chartInfo.showPercentValues = "1";
666
667
  chartInfo.showLegend = (seriesMeasures === null || seriesMeasures === void 0 ? void 0 : seriesMeasures.length) > 1 ? "1" : "0";
667
- chartInfo.legendItemFont = defautFont;
668
- chartInfo.legendItemFontSize = defautFontSize;
669
668
  setLineDash(chartInfo);
670
669
  chartInfo.chartTopMargin = "10";
671
670
  chartInfo.chartBottomMargin = "10";
@@ -681,8 +680,6 @@ function getStackedBarObject(seriesMeasures, widget) {
681
680
  chartInfo.flatScrollBars = "1";
682
681
  chartInfo.showPercentValues = "1";
683
682
  chartInfo.showLegend = (seriesMeasures === null || seriesMeasures === void 0 ? void 0 : seriesMeasures.length) > 1 ? "1" : "0";
684
- chartInfo.legendItemFont = defautFont;
685
- chartInfo.legendItemFontSize = defautFontSize;
686
683
  setLineDash(chartInfo);
687
684
  chartInfo.chartTopMargin = "10";
688
685
  chartInfo.chartBottomMargin = "10";
@@ -699,8 +696,6 @@ function getLineObject(seriesMeasures, widget) {
699
696
  chartInfo.flatScrollBars = "1";
700
697
  chartInfo.showPercentValues = "1";
701
698
  chartInfo.showLegend = (seriesMeasures === null || seriesMeasures === void 0 ? void 0 : seriesMeasures.length) > 1 ? "1" : "0";
702
- chartInfo.legendItemFont = defautFont;
703
- chartInfo.legendItemFontSize = defautFontSize;
704
699
  setLineDash(chartInfo);
705
700
  chartInfo.chartTopMargin = "20";
706
701
  chartInfo.chartBottomMargin = "10";
@@ -708,6 +703,7 @@ function getLineObject(seriesMeasures, widget) {
708
703
  chartInfo.chartRightMargin = "50";
709
704
  chartInfo.anchorradius = "5";
710
705
  chartInfo.canvasBottomPadding = "10";
706
+ chartInfo.canvasTopPadding = "10";
711
707
  chart.dataSource = getCategoriesBasedDataSource(chartInfo, seriesMeasures, widget);
712
708
  return chart;
713
709
  }
@@ -716,17 +712,12 @@ function getDonutObject(seriesMeasures, widget) {
716
712
  var chart = getDefaultChartobject();
717
713
  chart.type = "doughnut2d";
718
714
  var chartInfo = getDefaultChartInfo();
719
- chartInfo.showPercentValues = "0";
720
- chartInfo.showValues = "0";
721
- chartInfo.showLegend = "0";
722
- chartInfo.legendCaptionFontSize = defautFontSize;
723
- chartInfo.legendCaptionFont = defautFont;
724
715
  chartInfo.labelFontSize = defautFontSize;
725
716
  chartInfo.labelFont = defautFont;
726
717
  chartInfo.manageLabelOverflow = "1";
727
718
  chartInfo.useEllipsesWhenOverflow = "1";
728
719
  chartInfo.enableSmartLabels = "1";
729
- chartInfo.pieRadius = "70%";
720
+ setPieDonutLegends(chartInfo, widget);
730
721
  chart.dataSource = getSimpleDataSource(chartInfo, seriesMeasures, widget);
731
722
  return chart;
732
723
  }
@@ -735,17 +726,12 @@ function getPieObject(seriesMeasures, widget) {
735
726
  var chart = getDefaultChartobject();
736
727
  chart.type = "pie2d";
737
728
  var chartInfo = getDefaultChartInfo();
738
- chartInfo.showPercentValues = "0";
739
- chartInfo.showValues = "0";
740
- chartInfo.showLegend = "0";
741
- chartInfo.legendCaptionFontSize = defautFontSize;
742
- chartInfo.legendCaptionFont = defautFont;
743
729
  chartInfo.labelFontSize = defautFontSize;
744
730
  chartInfo.labelFont = defautFont;
745
731
  chartInfo.manageLabelOverflow = "1";
746
732
  chartInfo.useEllipsesWhenOverflow = "1";
747
733
  chartInfo.enableSmartLabels = "1";
748
- chartInfo.pieRadius = "70%";
734
+ setPieDonutLegends(chartInfo, widget);
749
735
  chart.dataSource = getSimpleDataSource(chartInfo, seriesMeasures, widget);
750
736
  return chart;
751
737
  }
@@ -758,8 +744,6 @@ function getColumnObject(seriesMeasures, widget) {
758
744
  chartInfo.flatScrollBars = "1";
759
745
  chartInfo.showPercentValues = "1";
760
746
  chartInfo.showLegend = (seriesMeasures === null || seriesMeasures === void 0 ? void 0 : seriesMeasures.length) > 1 ? "1" : "0";
761
- chartInfo.legendItemFont = defautFont;
762
- chartInfo.legendItemFontSize = defautFontSize;
763
747
  setLineDash(chartInfo);
764
748
  chartInfo.chartTopMargin = "20";
765
749
  chartInfo.chartBottomMargin = "10";
@@ -800,6 +784,8 @@ function getDefaultChartInfo(widget) {
800
784
  chart.labelFontSize = defautFontSize;
801
785
  chart.labelFontColor = defautColor;
802
786
  chart.labelFont = defautFont;
787
+ chart.legendItemFont = defautFont;
788
+ chart.legendItemFontSize = defautFontSize;
803
789
  chart.enableSlicing = "0";
804
790
  chart.enableRotation = "0";
805
791
  chart.chartTopMargin = "10";
@@ -810,9 +796,36 @@ function getDefaultChartInfo(widget) {
810
796
  chart.showToolTipShadow = "1";
811
797
  chart.scrollHeight = "6";
812
798
  chart.scrollWidth = "6";
799
+ chart.plotColorinTooltip = "0";
813
800
  return chart;
814
801
  }
815
802
 
803
+ function setPieDonutLegends(chart, widget) {
804
+ chart.showValues = "0";
805
+ chart.showLabels = widget.LabelsPosition == 'InLegend' ? '0' : '1';
806
+ chart.showLegend = widget.LabelsPosition == 'InLegend' ? '1' : '0';
807
+ setOnChartLegend(chart, widget);
808
+ setChartInLegend(chart, widget);
809
+ }
810
+
811
+ function setOnChartLegend(chart, widget) {
812
+ if (widget.LabelsPosition != 'InLegend') return;
813
+ chart.legendPosition = "right";
814
+ chart.legendScrollBgColor = "#ffffff";
815
+ chart.legendIconScale = 0.75;
816
+ chart.scrollShowButtons = "0";
817
+ chart.scrollShowButtons = "0";
818
+ chart.legendCaptionAlignment = "right";
819
+ chart.alignLegendWithCanvas = "1";
820
+ chart.showPercentValues = "0";
821
+ chart.chartRightMargin = "20";
822
+ }
823
+
824
+ function setChartInLegend(chart, widget) {
825
+ if (widget.LabelsPosition == 'InLegend') return;
826
+ chart.pieRadius = "70%";
827
+ }
828
+
816
829
  var FusionChartHelper = /*#__PURE__*/function () {
817
830
  function FusionChartHelper(widget, chart) {
818
831
  this.chart = chart;
@@ -825,17 +838,25 @@ var FusionChartHelper = /*#__PURE__*/function () {
825
838
  return this.pieRadius;
826
839
  };
827
840
 
841
+ _proto.getLegendWidth = function getLegendWidth() {
842
+ return this.legendWidth;
843
+ };
844
+
828
845
  _proto.trimChartLabels = function trimChartLabels(chartWidth, chartHeight) {
829
846
  var _this$chart;
830
847
 
831
848
  if (!this.widget || this.widget.TypeCode != "pie" && this.widget.TypeCode != "donut") return;
832
849
  if (!this.chart) return;
833
- var chartMinumunHeight = 236;
834
- var startPercantage = 70;
835
- var stepHeight = 60;
836
850
  var dataSource = (_this$chart = this.chart) === null || _this$chart === void 0 ? void 0 : _this$chart.dataSource;
837
851
  if (!dataSource) return;
838
852
  var chartInfo = dataSource.chart;
853
+ if (this.widget.LabelsPosition == 'InLegend') this.handleLegendWidth(chartWidth, chartHeight, chartInfo);else this.handlePieRadius(chartHeight, chartInfo);
854
+ };
855
+
856
+ _proto.handlePieRadius = function handlePieRadius(chartHeight, chartInfo) {
857
+ var chartMinumunHeight = 236;
858
+ var startPercantage = 70;
859
+ var stepHeight = 60;
839
860
  var step = Math.floor((chartHeight - chartMinumunHeight) / stepHeight);
840
861
  if (step < 0) step = 0;
841
862
  var pieRadius = startPercantage - step * 10;
@@ -854,6 +875,13 @@ var FusionChartHelper = /*#__PURE__*/function () {
854
875
  chartInfo.pieRadius = pieRadius + "%";
855
876
  };
856
877
 
878
+ _proto.handleLegendWidth = function handleLegendWidth(chartWidth, chartHeight, chartInfo) {
879
+ if (chartWidth < 730) chartInfo.legendWidth = "200";
880
+ if (chartWidth >= 730) chartInfo.legendWidth = "400";
881
+ if (chartWidth >= 1000) chartInfo.legendWidth = "500";
882
+ this.legendWidth = chartInfo.legendWidth;
883
+ };
884
+
857
885
  return FusionChartHelper;
858
886
  }();
859
887
 
@@ -919,11 +947,13 @@ var FusionChart = React.forwardRef(function (props, comRef) {
919
947
 
920
948
  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;
921
949
  setTimeout(function () {
922
- var _fusionChartHelper$cu, _fusionChartHelper$cu2, _fusionRef$current, _fusionRef$current2, _fusionChartHelper$cu3;
950
+ var _fusionChartHelper$cu, _fusionChartHelper$cu2, _fusionChartHelper$cu3, _fusionRef$current, _fusionRef$current2, _widget$current3, _fusionChartHelper$cu4, _widget$current4, _fusionChartHelper$cu5;
923
951
 
924
952
  var oldPieRadius = fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu = fusionChartHelper.current) === null || _fusionChartHelper$cu === void 0 ? void 0 : _fusionChartHelper$cu.getPieRadius();
925
- 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);
926
- if (oldPieRadius == (fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu3 = fusionChartHelper.current) === null || _fusionChartHelper$cu3 === void 0 ? void 0 : _fusionChartHelper$cu3.getPieRadius())) return;
953
+ var oldLegendWidth = fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu2 = fusionChartHelper.current) === null || _fusionChartHelper$cu2 === void 0 ? void 0 : _fusionChartHelper$cu2.getLegendWidth();
954
+ fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu3 = fusionChartHelper.current) === null || _fusionChartHelper$cu3 === void 0 ? void 0 : _fusionChartHelper$cu3.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);
955
+ if (((_widget$current3 = widget.current) === null || _widget$current3 === void 0 ? void 0 : _widget$current3.LabelsPosition) != 'InLegend' && oldPieRadius == (fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu4 = fusionChartHelper.current) === null || _fusionChartHelper$cu4 === void 0 ? void 0 : _fusionChartHelper$cu4.getPieRadius())) return;
956
+ if (((_widget$current4 = widget.current) === null || _widget$current4 === void 0 ? void 0 : _widget$current4.LabelsPosition) == 'InLegend' && oldLegendWidth == (fusionChartHelper === null || fusionChartHelper === void 0 ? void 0 : (_fusionChartHelper$cu5 = fusionChartHelper.current) === null || _fusionChartHelper$cu5 === void 0 ? void 0 : _fusionChartHelper$cu5.getLegendWidth())) return;
927
957
  setDataLoaded(false);
928
958
  setTimeout(function () {
929
959
  setDataLoaded(true);