logitude-dashboard-library 1.4.49 → 1.4.50

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.
@@ -0,0 +1,3 @@
1
+ import { ReactWidgetPM } from "../types/widget";
2
+ declare const getLabelFormatByDateGroupType: (label: string, widget: ReactWidgetPM, isSecondGrouping?: boolean) => any;
3
+ export { getLabelFormatByDateGroupType };
@@ -7,7 +7,7 @@
7
7
 
8
8
  <g transform="translate(0.000000,134.000000) scale(0.100000,-0.100000)"
9
9
  fill="#ff0000" stroke="none">
10
- <path d="M705 1329 c-17 -4 -42 -21 -57 -36 -41 -44 -638 -1087 -644 -1124 -8
10
+ <path fill='#CF2528' d="M705 1329 c-17 -4 -42 -21 -57 -36 -41 -44 -638 -1087 -644 -1124 -8
11
11
  -53 31 -119 86 -146 l44 -23 616 0 616 0 44 23 c83 42 110 118 70 196 -59 117
12
12
  -605 1050 -628 1074 -14 15 -42 32 -61 37 -41 11 -45 11 -86 -1z m116 -378
13
13
  c36 -36 38 -86 10 -199 -11 -43 -27 -115 -36 -162 -26 -138 -23 -132 -48 -128
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ /// <reference types="react" />
2
2
  import { ReactWidgetPM } from "../../../types/widget";
3
3
  import { DataPointSelection } from '../../../types/SeriesMeasure';
4
4
  import { ApexOptions } from "apexcharts";
@@ -9,7 +9,7 @@ declare type ApexChartProps = {
9
9
  dataBinding: DashboardDataBinding;
10
10
  onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
11
11
  };
12
- declare const ApexChart: (props: ApexChartProps) => React.JSX.Element;
12
+ declare const ApexChart: (props: ApexChartProps) => JSX.Element;
13
13
  export declare type ApexChartArgs = {
14
14
  options: ApexOptions;
15
15
  series: ApexAxisChartSeries | ApexNonAxisChartSeries;
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ /// <reference types="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 CustomChartProps = {
8
8
  dataBinding: DashboardDataBinding;
9
9
  onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
10
10
  };
11
- declare const CustomChart: (props: CustomChartProps) => React.JSX.Element;
11
+ declare const CustomChart: (props: CustomChartProps) => JSX.Element;
12
12
  export default CustomChart;
@@ -1,7 +1,7 @@
1
- import React from "react";
1
+ /// <reference types="react" />
2
2
  import { CustomChartProps } from "./CustomChart";
3
3
  declare type KpiChartProps = {
4
4
  customChartProps: CustomChartProps;
5
5
  };
6
- declare const KpiChart: (props: KpiChartProps) => React.JSX.Element;
6
+ declare const KpiChart: (props: KpiChartProps) => JSX.Element;
7
7
  export default KpiChart;
@@ -1,3 +1,3 @@
1
- import React from 'react';
2
- declare function FusionChartTest(): React.JSX.Element;
1
+ /// <reference types="react" />
2
+ declare function FusionChartTest(): JSX.Element;
3
3
  export default FusionChartTest;
@@ -1,5 +1,5 @@
1
+ /// <reference types="react" />
1
2
  import { Layouts } from "react-grid-layout";
2
- import React from "react";
3
3
  import { ReactWidgetPM } from "../../types/widget";
4
4
  import { DataPointSelection } from "../../types/SeriesMeasure";
5
5
  import { DashboardDataBinding } from "../../types/DashboardDataBinding";
@@ -13,7 +13,7 @@ declare type DashboardDesignerProps = {
13
13
  dataBinding: DashboardDataBinding;
14
14
  onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
15
15
  };
16
- declare const DashboardDesigner: (props: DashboardDesignerProps) => React.JSX.Element;
16
+ declare const DashboardDesigner: (props: DashboardDesignerProps) => JSX.Element;
17
17
  export declare const layoutGridProps: {
18
18
  rowHeight: number;
19
19
  className: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ /// <reference types="react" />
2
2
  import "./styles.module.css";
3
3
  import { ReactWidgetPM } from './types/widget';
4
4
  import { DashboardDataBinding } from './types/DashboardDataBinding';
@@ -16,5 +16,5 @@ declare type DashboardProps = {
16
16
  openEditWidget: (Widget: ReactWidgetPM) => void;
17
17
  onSelectDataPoint: (dataPointSelection: DataPointSelection) => void;
18
18
  };
19
- declare const Dashboard: (props: DashboardProps) => React.JSX.Element;
19
+ declare const Dashboard: (props: DashboardProps) => JSX.Element;
20
20
  export default Dashboard;
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ var ReactFC = _interopDefault(require('react-fusioncharts'));
12
12
  var FusionCharts = _interopDefault(require('fusioncharts'));
13
13
  var Charts = _interopDefault(require('fusioncharts/fusioncharts.charts'));
14
14
  var FusionTheme = _interopDefault(require('fusioncharts/themes/fusioncharts.theme.fusion'));
15
+ var moment = _interopDefault(require('moment'));
15
16
  var useResizeObserver = _interopDefault(require('use-resize-observer'));
16
17
 
17
18
  function _extends() {
@@ -229,8 +230,8 @@ function SvgRedWarning(props) {
229
230
  height: 25,
230
231
  viewBox: "0 0 150 134"
231
232
  }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
232
- d: "M70.5 1.1c-1.7.4-4.2 2.1-5.7 3.6C60.7 9.1 1 113.4.4 117.1c-.8 5.3 3.1 11.9 8.6 14.6l4.4 2.3h123.2l4.4-2.3c8.3-4.2 11-11.8 7-19.6-5.9-11.7-60.5-105-62.8-107.4C83.8 3.2 81 1.5 79.1 1c-4.1-1.1-4.5-1.1-8.6.1zm11.6 37.8c3.6 3.6 3.8 8.6 1 19.9-1.1 4.3-2.7 11.5-3.6 16.2-2.6 13.8-2.3 13.2-4.8 12.8-1.8-.2-2.3-1.2-3-5.3-.4-2.8-2.1-11.3-3.9-19-4-18.2-4-21 .1-24.7 4.4-4 10.1-3.9 14.2.1zM80 95.7c3.9 2.7 4.9 4.5 5 8.6 0 8.8-10.8 13.1-17.1 6.8-8.2-8.2 2.6-22 12.1-15.4z",
233
- fill: "red"
233
+ fill: "#CF2528",
234
+ d: "M70.5 1.1c-1.7.4-4.2 2.1-5.7 3.6C60.7 9.1 1 113.4.4 117.1c-.8 5.3 3.1 11.9 8.6 14.6l4.4 2.3h123.2l4.4-2.3c8.3-4.2 11-11.8 7-19.6-5.9-11.7-60.5-105-62.8-107.4C83.8 3.2 81 1.5 79.1 1c-4.1-1.1-4.5-1.1-8.6.1zm11.6 37.8c3.6 3.6 3.8 8.6 1 19.9-1.1 4.3-2.7 11.5-3.6 16.2-2.6 13.8-2.3 13.2-4.8 12.8-1.8-.2-2.3-1.2-3-5.3-.4-2.8-2.1-11.3-3.9-19-4-18.2-4-21 .1-24.7 4.4-4 10.1-3.9 14.2.1zM80 95.7c3.9 2.7 4.9 4.5 5 8.6 0 8.8-10.8 13.1-17.1 6.8-8.2-8.2 2.6-22 12.1-15.4z"
234
235
  })));
235
236
  }
236
237
 
@@ -420,6 +421,70 @@ var CustomChart = function CustomChart(props) {
420
421
  }, project());
421
422
  };
422
423
 
424
+ var DateGroupCodes = {
425
+ Full_Date: 'Full Date',
426
+ Month: 'Month',
427
+ Quarter: 'Quarter',
428
+ Year: 'Year',
429
+ Month_Year: 'Month & Year',
430
+ Quarter_Year: 'Quarter & Year'
431
+ };
432
+
433
+ var getDateFormat = function getDateFormat(label, _format) {
434
+ if (!label) return label;
435
+
436
+ var _date = moment(label);
437
+
438
+ if (!_date || !_date.isValid()) return label;
439
+ return _date.format(_format);
440
+ };
441
+
442
+ var getQuarterYearFormat = function getQuarterYearFormat(label) {
443
+ if (!label) return label;
444
+
445
+ if (label.includes("/")) {
446
+ var result = label.split("/");
447
+ var quarterVal = result && result[1] ? result[1] : "";
448
+ var yearVal = result && result[0] ? result[0] : "";
449
+ return quarterVal + " " + yearVal;
450
+ }
451
+
452
+ return label;
453
+ };
454
+
455
+ var getLabelFormatByDateGroupType = function getLabelFormatByDateGroupType(label, widget, isSecondGrouping) {
456
+ if (isSecondGrouping === void 0) {
457
+ isSecondGrouping = false;
458
+ }
459
+
460
+ if (!widget) return label;
461
+ var groupFieldDataType = isSecondGrouping ? widget.SecondaryDateGroupCode : widget.DateGroupCode;
462
+ if (!groupFieldDataType) return label;
463
+
464
+ switch (groupFieldDataType) {
465
+ case DateGroupCodes.Full_Date:
466
+ return getDateFormat(label, "DD MMM YYYY");
467
+
468
+ case DateGroupCodes.Month:
469
+ return getDateFormat(label, "MMM");
470
+
471
+ case DateGroupCodes.Quarter:
472
+ return label;
473
+
474
+ case DateGroupCodes.Year:
475
+ return getDateFormat(label, "YYYY");
476
+
477
+ case DateGroupCodes.Month_Year:
478
+ return getDateFormat(label, "MMM YYYY");
479
+
480
+ case DateGroupCodes.Quarter_Year:
481
+ return getQuarterYearFormat(label);
482
+
483
+ default:
484
+ return label;
485
+ }
486
+ };
487
+
423
488
  var mainYellowColor = "#F6CF33";
424
489
  var mainRedColor = "#EE5F77";
425
490
  var mainGreenColor = "#4AC76F";
@@ -486,7 +551,7 @@ function getCategoriesBasedDataSource(chartInfo, seriesMeasures, widget) {
486
551
  handelNullLabels(seriesMeasures);
487
552
  return {
488
553
  chart: chartInfo,
489
- categories: buildCategories(seriesMeasures),
554
+ categories: buildCategories(seriesMeasures, widget),
490
555
  dataset: buildDataSet(seriesMeasures, widget)
491
556
  };
492
557
  }
@@ -495,7 +560,7 @@ function getStackedDataSource(chartInfo, seriesMeasures, widget) {
495
560
  handelNullLabels(seriesMeasures);
496
561
  return {
497
562
  chart: chartInfo,
498
- categories: buildStackedCategories(seriesMeasures),
563
+ categories: buildStackedCategories(seriesMeasures, widget),
499
564
  dataset: buildStackedDataSet(seriesMeasures, widget)
500
565
  };
501
566
  }
@@ -532,7 +597,7 @@ function buildDataSource(values, widget) {
532
597
  data = series.Values.map(function (e, index) {
533
598
  var item = {
534
599
  value: e.Value,
535
- label: e.Label,
600
+ label: getLabelFormatByDateGroupType(e.Label, widget, false),
536
601
  id: {
537
602
  GroupById: e.GroupById,
538
603
  MeasureFieldId: series.MeasureFieldId
@@ -585,7 +650,7 @@ function buildStackedDataSet(seriesMeasures, widget) {
585
650
  return x.code == element.GroupByIdSec;
586
651
  })) uniqueGroups.push({
587
652
  code: element.GroupByIdSec,
588
- label: element.LabelSec
653
+ label: getLabelFormatByDateGroupType(element.LabelSec, widget, true)
589
654
  });
590
655
  });
591
656
  uniqueGroups.forEach(function (group) {
@@ -621,10 +686,10 @@ function buildStackedGroupData(secGroup, series, widget) {
621
686
  return data;
622
687
  }
623
688
 
624
- function buildCategories(seriesMeasures) {
689
+ function buildCategories(seriesMeasures, widget) {
625
690
  var categories = seriesMeasures[0].Values.map(function (e) {
626
691
  return {
627
- label: e.Label
692
+ label: getLabelFormatByDateGroupType(e.Label, widget, false)
628
693
  };
629
694
  });
630
695
  var result = [];
@@ -638,7 +703,7 @@ function buildStackedCategories(seriesMeasures, widget) {
638
703
  var uniqueGroups = getUniqueGroupOrderdList(seriesMeasures[0]);
639
704
  var categories = uniqueGroups.map(function (e) {
640
705
  return {
641
- label: e.label
706
+ label: getLabelFormatByDateGroupType(e.label, widget, false)
642
707
  };
643
708
  });
644
709
  var result = [];