pace-chart-lib 0.0.7 → 0.0.9

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.
Files changed (150) hide show
  1. package/README.md +10 -10
  2. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +46 -0
  3. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +2285 -0
  4. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +169 -0
  5. package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +47 -0
  6. package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +4 -0
  7. package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.js +403 -0
  8. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
  9. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -0
  10. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  11. package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  12. package/dist/Components1/Charts/Core/Common.type.d.ts +8 -0
  13. package/dist/Components1/Charts/Core/Common.type.js +9 -0
  14. package/dist/Components1/Charts/Core/CommonFunctions.d.ts +12 -0
  15. package/dist/Components1/Charts/Core/CommonFunctions.js +512 -0
  16. package/dist/Components1/Charts/Core/DefaultProperties.d.ts +586 -0
  17. package/dist/Components1/Charts/Core/DefaultProperties.js +585 -0
  18. package/dist/Services/ErrorLog.d.ts +1 -0
  19. package/dist/Services/ErrorLog.js +3 -0
  20. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +4 -0
  21. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +497 -0
  22. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +4 -0
  23. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +491 -0
  24. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +4 -0
  25. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +520 -0
  26. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +4 -0
  27. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +553 -0
  28. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +4 -0
  29. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +519 -0
  30. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +4 -0
  31. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +553 -0
  32. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +12 -0
  33. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +9 -0
  34. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +623 -0
  35. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +4897 -0
  36. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
  37. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
  38. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +173 -0
  39. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +49 -0
  40. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +4 -0
  41. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +486 -0
  42. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +4 -0
  43. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +498 -0
  44. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +4 -0
  45. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +417 -0
  46. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +4 -0
  47. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +1014 -0
  48. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +4 -0
  49. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +479 -0
  50. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +4 -0
  51. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +451 -0
  52. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +4 -0
  53. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +535 -0
  54. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.d.ts +4 -0
  55. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +512 -0
  56. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +4 -0
  57. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +532 -0
  58. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.d.ts +4 -0
  59. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +512 -0
  60. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +12 -0
  61. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +9 -0
  62. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +4 -0
  63. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +498 -0
  64. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +4 -0
  65. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +498 -0
  66. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +4 -0
  67. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +479 -0
  68. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +4 -0
  69. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +479 -0
  70. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +4 -0
  71. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +474 -0
  72. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +4 -0
  73. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +464 -0
  74. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
  75. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
  76. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +4 -0
  77. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +452 -0
  78. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +4 -0
  79. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +554 -0
  80. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +4 -0
  81. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +513 -0
  82. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +4 -0
  83. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +508 -0
  84. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +4 -0
  85. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +395 -0
  86. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +4 -0
  87. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +608 -0
  88. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
  89. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
  90. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +92 -0
  91. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +815 -0
  92. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  93. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  94. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +108 -0
  95. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +32 -0
  96. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +26 -0
  97. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +15021 -0
  98. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +4 -0
  99. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +391 -0
  100. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +4 -0
  101. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +367 -0
  102. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +4 -0
  103. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +569 -0
  104. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +3 -0
  105. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +212 -0
  106. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +3 -0
  107. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +401 -0
  108. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +4 -0
  109. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +313 -0
  110. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +4 -0
  111. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +719 -0
  112. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +4 -0
  113. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +807 -0
  114. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +3 -0
  115. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +514 -0
  116. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +4 -0
  117. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +282 -0
  118. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +4 -0
  119. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +207 -0
  120. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +4 -0
  121. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +476 -0
  122. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +4 -0
  123. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +420 -0
  124. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +10 -0
  125. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +106 -0
  126. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +3 -0
  127. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +507 -0
  128. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +3 -0
  129. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +246 -0
  130. package/dist/components/Charts/Core/Common.type.d.ts +0 -0
  131. package/dist/components/Charts/Core/Common.type.js +0 -0
  132. package/dist/components/Charts/Core/Common.types.d.ts +369 -0
  133. package/dist/components/Charts/Core/Common.types.js +133 -0
  134. package/dist/components/Charts/Core/CommonFunctions.d.ts +236 -0
  135. package/dist/components/Charts/Core/CommonFunctions.js +1778 -0
  136. package/dist/components/Charts/Core/DefaultChartDataProperties.d.ts +65 -0
  137. package/dist/components/Charts/Core/DefaultChartDataProperties.js +64 -0
  138. package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
  139. package/dist/components/Charts/Core/DefaultProperties.js +0 -0
  140. package/dist/components/Charts/Core/DefaultProperties.type.d.ts +586 -0
  141. package/dist/components/Charts/Core/DefaultProperties.type.js +585 -0
  142. package/dist/components/Charts/Core/DefaultProperties.types.d.ts +592 -0
  143. package/dist/components/Charts/Core/DefaultProperties.types.js +592 -0
  144. package/dist/index.d.ts +34 -2
  145. package/dist/index.js +40 -2
  146. package/package.json +40 -29
  147. package/dist/components/charts/linechart/LineChart.d.ts +0 -12
  148. package/dist/components/charts/linechart/LineChart.js +0 -5
  149. /package/dist/{components/charts/barchart → Components1/Charts/ChartsWithAxis/BarFamily}/BarChart.d.ts +0 -0
  150. /package/dist/{components/charts/barchart → Components1/Charts/ChartsWithAxis/BarFamily}/BarChart.js +0 -0
@@ -0,0 +1,2285 @@
1
+ import * as d3 from "d3";
2
+ import { actualChartTypes } from "./ChartsWithAxisTypes.type";
3
+ import { calculateMaxLegendWidth } from "../Core/CommonFunctions";
4
+ const chartsWithDataTableArray = [
5
+ actualChartTypes.bar,
6
+ actualChartTypes.stackColumn,
7
+ actualChartTypes.stackColumn100,
8
+ actualChartTypes.line,
9
+ actualChartTypes.stackLine,
10
+ actualChartTypes.stackLine100,
11
+ actualChartTypes.area,
12
+ actualChartTypes.stackArea,
13
+ actualChartTypes.stackArea100,
14
+ ];
15
+ const chartsWithoutPlotArea = [
16
+ actualChartTypes.pie,
17
+ actualChartTypes.pieOfPie,
18
+ actualChartTypes.sunburst,
19
+ actualChartTypes.pyramidChart,
20
+ actualChartTypes.organizationalChart,
21
+ actualChartTypes.vennDiagramChart,
22
+ actualChartTypes.progressChart,
23
+ actualChartTypes.maps,
24
+ actualChartTypes.wordCloud,
25
+ actualChartTypes.sankey,
26
+ actualChartTypes.speedometerChart,
27
+ actualChartTypes.radialBarChart,
28
+ ];
29
+ export function getRandomColor() {
30
+ let letters = "0123456789ABCDEF";
31
+ let color = "#";
32
+ for (let i = 0; i < 6; i++) {
33
+ color += letters[Math.floor(Math.random() * 16)];
34
+ }
35
+ return { color };
36
+ }
37
+ export function calculateWidthHeightDynamically(content, fontSize, fontFamily, rotationDegree, fixedWidth) {
38
+ // Create a hidden div element
39
+ var div = document.createElement("div");
40
+ // Apply necessary styles to ensure accurate measurement
41
+ div.style.visibility = "hidden";
42
+ div.style.position = "absolute";
43
+ div.style.top = "-9999px";
44
+ div.style.left = "-9999px";
45
+ div.style.fontSize = fontSize == undefined ? "" : fontSize + "px";
46
+ div.style.fontFamily = fontFamily == undefined ? "" : fontFamily;
47
+ div.style.margin = "0";
48
+ // div.style.padding = '1px';
49
+ div.style.border = "none";
50
+ if (fixedWidth) {
51
+ div.style.width = fixedWidth + "px";
52
+ div.style.whiteSpace = "normal";
53
+ div.style.overflowWrap = "break-word";
54
+ }
55
+ else {
56
+ div.style.whiteSpace = "nowrap";
57
+ }
58
+ div.innerHTML = content;
59
+ document.body.appendChild(div);
60
+ var boundingRect = div.getBoundingClientRect();
61
+ var width = boundingRect.width;
62
+ var height = boundingRect.height;
63
+ if (rotationDegree) {
64
+ div.style.transform = `rotate(${rotationDegree}deg)`;
65
+ boundingRect = div.getBoundingClientRect();
66
+ div.remove();
67
+ return [width, height, boundingRect.width, boundingRect.height];
68
+ }
69
+ else {
70
+ div.remove();
71
+ return [boundingRect.width, boundingRect.height];
72
+ }
73
+ }
74
+ export function getYAxisLabel(formatOptions, maxLegendLength) {
75
+ let dataTableCondition = formatOptions.dataTableProperties &&
76
+ formatOptions.dataTableProperties.dataTable;
77
+ // &&
78
+ // chartsWithDataTableArray.includes(chartType);
79
+ let yAxisLabelLength = dataTableCondition
80
+ ? maxLegendLength * 7 < 50
81
+ ? 50
82
+ : maxLegendLength * 7 > 100
83
+ ? 100
84
+ : maxLegendLength * 7
85
+ : 0;
86
+ if (dataTableCondition && yAxisLabelLength < 30) {
87
+ yAxisLabelLength = 30;
88
+ }
89
+ return yAxisLabelLength;
90
+ }
91
+ export function marginCalculation(width, height, maxNumberForPrimaryAxis, YmaxLeft, formatOptions, legendList, dimensionList) {
92
+ try {
93
+ // min svg height/width final values are yet to decide.
94
+ let isDataTableDrawnWithAxis = formatOptions.dataTableProperties &&
95
+ formatOptions.dataTableProperties.dataTable &&
96
+ formatOptions.xAxisLabel.xAxisPosition == 0;
97
+ // &&
98
+ // chartsWithDataTableArray.includes(chartType);
99
+ let Width = width < 200 ? 200 : width;
100
+ let Height = height < 200 ? 200 : height;
101
+ let Margin = { top: 0, left: 0, right: 0, bottom: 0 };
102
+ let width15Percent = Width * 0.15 * 0.8;
103
+ let maxLegendWidth = calculateMaxLegendWidth(legendList, formatOptions);
104
+ let legendMargin = width15Percent < maxLegendWidth[0] + 10
105
+ ? width15Percent
106
+ : maxLegendWidth[0] + 10;
107
+ let maxLegend = d3.max(legendList, (legend) => legend.includes("~$~")
108
+ ? legend.split("~$~")[1].length
109
+ : legend.includes("-")
110
+ ? legend.slice(legend.indexOf("-") + 1).length
111
+ : legend.length);
112
+ // (xAxisObject.GroupBy == "NA" || xAxisObject.GroupBy == undefined) ? parentReference.dataModifierService.setDateFormats(xAxisObject.Name.name, basestyle.xAxisLabel.xAxisNumberFormat,chartData.dimensionList.map(d=>[d]),xAxisObject.Name.dataSourceId).map(d=> d[0]): chartData.dimensionList;
113
+ let formatedDimesionList = dimensionList;
114
+ let maxDimension = formatedDimesionList
115
+ ? formatedDimesionList[0] + ""
116
+ : "";
117
+ let maxDimensionLength = maxDimension.length;
118
+ formatedDimesionList &&
119
+ formatedDimesionList.forEach((dim) => {
120
+ dim = dim + "";
121
+ let length = dim.trim()?.length || 0;
122
+ if (length > maxDimensionLength) {
123
+ maxDimensionLength = length;
124
+ maxDimension = dim.trim();
125
+ }
126
+ });
127
+ let dimensionHeightWidthArray = calculateWidthHeightDynamically(maxDimension, formatOptions.xAxisLabel.xAxisLabelFontSize, formatOptions.xAxisLabel.xAxisLabelFontFamily, formatOptions.xAxisLabel.xAxisLabelRotation);
128
+ let actualDimesionWidth = dimensionHeightWidthArray[0] + 5;
129
+ let maxDimensionWidth = dimensionHeightWidthArray[3] + 10;
130
+ let Xtitle = formatOptions.xAxisTitle.xAxisTitleVisibility
131
+ ? formatOptions.xAxisTitle.xAxisDynamicTitleText.length !== 0
132
+ ? calculateWidthHeightDynamically(formatOptions.xAxisTitle.xAxisTitleHTML, undefined, undefined)[1]
133
+ : calculateWidthHeightDynamically(formatOptions.xAxisTitle.xAxisTitleText, 13, "Helvetica")[1]
134
+ : isDataTableDrawnWithAxis
135
+ ? 5
136
+ : 0;
137
+ Xtitle = Xtitle > Height * 0.1 ? Height * 0.1 : Xtitle;
138
+ let Xlabel = isDataTableDrawnWithAxis
139
+ ? 0
140
+ : formatOptions.xAxisLabel.xAxisLabelVisibility
141
+ ? // bubbleChart
142
+ // ? responsiveXaxisMarginForBubbleChart() * 1.2
143
+ // :
144
+ formatOptions.xAxisLabel.labelTextWrap
145
+ ? maxDimensionWidth < Height * 0.15
146
+ ? maxDimensionWidth
147
+ : Height * 0.15
148
+ : maxDimensionWidth
149
+ : 0;
150
+ let Ytitle = formatOptions.yAxisTitle.yAxisTitleVisibility
151
+ ? formatOptions.yAxisTitle.yAxisDynamicTitleText.length !== 0
152
+ ? calculateWidthHeightDynamically(formatOptions.yAxisTitle.yAxisTitleHTML, undefined, undefined)[1]
153
+ : calculateWidthHeightDynamically(formatOptions.yAxisTitle.yAxisTitleText, 13, "Helvetica")[1]
154
+ : 0;
155
+ Ytitle = Ytitle > Width * 0.1 ? Width * 0.1 : Ytitle;
156
+ let Ylabel = formatOptions.yAxisLabel.yAxisLabelVisibility
157
+ ? responsiveYaxisMargin(maxNumberForPrimaryAxis, YmaxLeft, formatOptions)
158
+ : getYAxisLabel(formatOptions, maxLegend);
159
+ let chartTitleHeight = formatOptions.chartTitle.chartTitleVisibility
160
+ ? formatOptions.chartTitle.dynamicTitleText.length !== 0
161
+ ? calculateWidthHeightDynamically(formatOptions.chartTitle.chartTitleHTML, undefined, undefined)[1]
162
+ : calculateWidthHeightDynamically(formatOptions.chartTitle.chartTitleText, 16, "Helvetica")[1]
163
+ : 0;
164
+ chartTitleHeight =
165
+ chartTitleHeight > Height * 0.1 ? Height * 0.1 : chartTitleHeight;
166
+ let legendPosition = formatOptions.legends.legendPosition;
167
+ let legendVisibility = formatOptions.legends.legendVisibility;
168
+ let stackDataForTotals = false;
169
+ let normalizedChart = false;
170
+ if (!legendVisibility)
171
+ legendPosition = "None";
172
+ // if (chartType == "Waterfall" && !stackDataForTotals)
173
+ // legendPosition = "None";
174
+ switch (legendPosition) {
175
+ case "None":
176
+ // Margin.top = (formatOptions.type == "Waterfall") ? Ctitle + 10 : Ctitle + (normalizedChart ? 12 : 0);
177
+ Margin.top = chartTitleHeight + 5 + (normalizedChart ? 12 : 0);
178
+ Margin.bottom = Xtitle + Xlabel + 5;
179
+ Margin.right = 15;
180
+ Margin.left = Ytitle + Ylabel + 5;
181
+ break;
182
+ case "Top":
183
+ Margin.top = 40 + chartTitleHeight + (normalizedChart ? 12 : 0);
184
+ Margin.bottom = Xtitle + Xlabel + 5;
185
+ Margin.right = 15;
186
+ Margin.left = Ytitle + Ylabel + 5;
187
+ break;
188
+ case "Right":
189
+ Margin.right = legendMargin + 35;
190
+ Margin.top = chartTitleHeight + 5 + (normalizedChart ? 12 : 0);
191
+ Margin.bottom = Xtitle + Xlabel + 5;
192
+ Margin.left = Ytitle + Ylabel + 5;
193
+ break;
194
+ case "Bottom":
195
+ Margin.bottom = 40 + Xlabel + Xtitle;
196
+ Margin.top = chartTitleHeight + 5 + (normalizedChart ? 12 : 0);
197
+ Margin.right = 15;
198
+ Margin.left = Ytitle + Ylabel + 5;
199
+ break;
200
+ case "Left":
201
+ Margin.left = legendMargin + Ytitle + Ylabel + 33;
202
+ Margin.top = chartTitleHeight + 5 + (normalizedChart ? 12 : 0);
203
+ Margin.bottom = Xtitle + Xlabel + 5;
204
+ Margin.right = 15;
205
+ }
206
+ // Margin.top = Margin.top > 25 ? Margin.top : 25;
207
+ // Margin.bottom = Margin.bottom > 25 ? Margin.bottom : 25;
208
+ // formatOptions.footerNote &&
209
+ // formatOptions.footerNote.footerNoteVisibility &&
210
+ // (formatOptions.type == "StackColumn" || formatOptions.type == "Waterfall")
211
+ // ? (Margin.bottom = Margin.bottom + 25)
212
+ // : Margin.bottom;
213
+ if (formatOptions.xAxisLabel.xAxisPosition &&
214
+ formatOptions.xAxisLabel.xAxisPosition == 1) {
215
+ Margin.bottom = Margin.bottom - Xlabel;
216
+ Margin.top = Margin.top + Xlabel;
217
+ }
218
+ //Final Margin Adjustments for scrolling chart
219
+ if (!formatOptions.plotArea.fitChart) {
220
+ Margin.bottom += 10;
221
+ // Margin.right += 15;
222
+ }
223
+ let manualMarginArray = formatOptions.chartPadding.paddingArrayLTRB;
224
+ if (manualMarginArray) {
225
+ Margin.top += manualMarginArray[1];
226
+ Margin.bottom += manualMarginArray[3];
227
+ Margin.right += manualMarginArray[2];
228
+ Margin.left += manualMarginArray[0];
229
+ }
230
+ // if(formatOptions.dataTableProperties && formatOptions.dataTableProperties.dataTable && normalizedChart){
231
+ // Margin.left = Margin.left + 35;
232
+ // }
233
+ let staticSvgInnerWidth = Width - Margin.left - Margin.right;
234
+ return {
235
+ Margin,
236
+ Ylabel,
237
+ Xlabel,
238
+ Ytitle,
239
+ Xtitle,
240
+ dimensionHeightWidthArray,
241
+ staticSvgInnerWidth,
242
+ chartTitleHeight,
243
+ legendMargin,
244
+ };
245
+ }
246
+ catch (error) {
247
+ // loggerService.logError(error, {
248
+ // componentName: constructor.name,
249
+ // functionName: "marginCalculation",
250
+ // });
251
+ }
252
+ }
253
+ export function initSvg(svgRef, width, height) {
254
+ // initNewAddedPropertiesForOldReports();
255
+ return d3.select(svgRef).attr("viewBox", "0 0 " + width + " " + height);
256
+ // if ((!formatOptions.plotArea.fitChart) && (chartsWithXScrollFlag || chartsWithYScrollFlag)) {
257
+ // svg = d3
258
+ // .select("#scaling-svg" + svgIndex)
259
+ // .attr("viewBox", "0 0 " + Width + " " + Height)
260
+ // .style("pointer-events", "none")
261
+ // .style("position", "absolute")
262
+ // let staticSvg = d3
263
+ // .select("#scaling-svg" + svgIndex) // a.node().parentElement.id
264
+ // staticSvg.node().parentNode.id = "checkForNoDataImage" + svgIndex;
265
+ // let parent = d3.select("#checkForNoDataImage" + svgIndex);
266
+ // const body = parent
267
+ // .append("div")
268
+ // .attr("class", "floating-div" + svgIndex + " scrollbar-div")
269
+ // .style("width", "100%")
270
+ // .style("height", "100%")
271
+ // .style("overflow-x", chartsWithYScrollFlag ? "hidden" : "scroll")
272
+ // .style("overflow-y", chartsWithYScrollFlag ? "scroll" : "hidden")
273
+ // .style("-webkit-overflow-scrolling", "touch");
274
+ // if (chartsWithXScrollFlag) {
275
+ // floatingSvg = body
276
+ // .append("svg")
277
+ // .attr("id", floatingSvgID + svgIndex)
278
+ // .attr("viewBox", "0 0 " + (totalWidth) + " " + totalHeight)
279
+ // .style("height", "calc(100% + 8px)")
280
+ // // .style("height","100%")
281
+ // .style("z-index", "11")
282
+ // .style("background-color", formatOptions.chartArea.chartAreaColor)
283
+ // } else if (chartsWithYScrollFlag) {
284
+ // floatingSvg = body
285
+ // .append("svg")
286
+ // .attr("id", floatingSvgID + svgIndex)
287
+ // .attr("viewBox", "0 0 " + (totalWidth + " " + totalHeight))
288
+ // .style("width", "calc(100% + 10px)")
289
+ // // .style("width", "100%" )
290
+ // .style("z-index", "11")
291
+ // .style("background-color", formatOptions.chartArea.chartAreaColor)
292
+ // }
293
+ // }
294
+ // else {
295
+ // svg
296
+ // .style("position", "")
297
+ // floatingSvg = svg;
298
+ // }
299
+ // chartType = formatOptions.type;
300
+ }
301
+ export function customYscaleLabelFormatting(formatOptions, YminLeft, YmaxLeft, YminRight, YmaxRight) {
302
+ //e.g
303
+ // yAxisMinText: "1000", // custom max
304
+ // yAxisAutoText: "0", // custom min
305
+ // yAxisIntervalText: "300", // custom interval
306
+ let customYaxisIntervalValue = parseFloat(formatOptions.yAxisLabel.yAxisIntervalText);
307
+ let customYaxisMaxValue;
308
+ let customYaxisMinValue;
309
+ // let secondaryCustomYaxisIntervalValue =
310
+ // formatOptions.SecondaryYAxisLabel.SecondaryYAxisIntervalText;
311
+ if (formatOptions.yAxisLabel.yAxisIntervalsVisibility) {
312
+ if (formatOptions.xAxisLabel.xAxisPosition == 2) {
313
+ formatOptions.xAxisLabel.xAxisPosition = 0;
314
+ }
315
+ customYaxisMinValue =
316
+ formatOptions.yAxisLabel.yAxisAutoText !== ""
317
+ ? parseFloat(formatOptions.yAxisLabel.yAxisAutoText)
318
+ : undefined;
319
+ let maxValue = formatOptions.yAxisLabel.yAxisMinText;
320
+ customYaxisMaxValue = maxValue.length > 0 ? parseFloat(maxValue) : YmaxLeft;
321
+ customYaxisMaxValue ? (YmaxLeft = customYaxisMaxValue) : null;
322
+ parseFloat(formatOptions.yAxisLabel.yAxisIntervalText) < YmaxLeft
323
+ ? (customYaxisIntervalValue = parseFloat(formatOptions.yAxisLabel.yAxisIntervalText))
324
+ : "";
325
+ }
326
+ else {
327
+ customYaxisMaxValue = undefined;
328
+ customYaxisMinValue = undefined;
329
+ customYaxisIntervalValue = undefined;
330
+ }
331
+ // if (formatOptions.SecondaryYAxisLabel.SecondaryYAxisIntervalsVisibility) {
332
+ // if (
333
+ // parseFloat(formatOptions.SecondaryYAxisLabel.SecondaryYAxisAutoText) <
334
+ // YmaxRight
335
+ // ) {
336
+ // secondaryCustomYaxisMinValue = parseFloat(
337
+ // formatOptions.SecondaryYAxisLabel.SecondaryYAxisAutoText
338
+ // );
339
+ // }
340
+ // secondaryCustomYaxisMaxValue =
341
+ // formatOptions.SecondaryYAxisLabel.SecondaryYAxisMinText &&
342
+ // formatOptions.SecondaryYAxisLabel.SecondaryYAxisMinText !== ""
343
+ // ? parseFloat(formatOptions.SecondaryYAxisLabel.SecondaryYAxisMinText)
344
+ // : YmaxRight;
345
+ // secondaryCustomYaxisIntervalValue =
346
+ // formatOptions.SecondaryYAxisLabel.SecondaryYAxisIntervalText !== ""
347
+ // ? parseFloat(formatOptions.SecondaryYAxisLabel.SecondaryYAxisIntervalText)
348
+ // : undefined;
349
+ // } else {
350
+ // secondaryCustomYaxisMaxValue = undefined;
351
+ // secondaryCustomYaxisMinValue = undefined;
352
+ // secondaryCustomYaxisIntervalValue = undefined;
353
+ // }
354
+ let yMinLength = YminLeft
355
+ ? getNumberWithFormat(formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision ?? 2)(YminLeft).toString().length
356
+ : 0;
357
+ let yMaxLength = YmaxLeft
358
+ ? getNumberWithFormat(formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision ?? 2)(YmaxLeft).toString().length
359
+ : 0;
360
+ // let secondaryYMinLength = YminRight
361
+ // ? getFormatedValueForSecondaryYAxis(YminRight).toString().length
362
+ // : 0;
363
+ // let secondaryYMaxLength = YmaxRight
364
+ // ? getFormatedValueForSecondaryYAxis(YmaxRight).toString().length
365
+ // : 0;
366
+ let customYaxisMaxValueLength = customYaxisMaxValue
367
+ ? getNumberWithFormat(formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision ?? 2)(customYaxisMaxValue).toString().length
368
+ : 0;
369
+ let customYaxisMinValueLength = customYaxisMinValue
370
+ ? getNumberWithFormat(formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision ?? 2)(customYaxisMinValue).toString().length
371
+ : 0;
372
+ // let secondaryCustomYaxisMaxValueLength = secondaryCustomYaxisMaxValue
373
+ // ? getFormatedValueFoissrSecondaryYAxis(
374
+ // secondaryCustomYaxisMaxValue
375
+ // ).toString().length
376
+ // : 0;
377
+ // let secondaryCustomYaxisMinValueLength = secondaryCustomYaxisMinValue
378
+ // ? getFormatedValueForSecondaryYAxis(
379
+ // secondaryCustomYaxisMinValue
380
+ // ).toString().length
381
+ // : 0;
382
+ // primary scale : Margin adjustments
383
+ let maxNumberForPrimaryAxis = yMinLength < yMaxLength ? YmaxLeft : YminLeft;
384
+ if (customYaxisMinValue) {
385
+ let tempLength = customYaxisMinValueLength < yMaxLength ? YmaxLeft : customYaxisMinValue;
386
+ maxNumberForPrimaryAxis =
387
+ maxNumberForPrimaryAxis < tempLength
388
+ ? tempLength
389
+ : maxNumberForPrimaryAxis;
390
+ }
391
+ if (customYaxisMaxValue) {
392
+ let tempLength = customYaxisMaxValueLength > yMinLength ? customYaxisMaxValue : YminLeft;
393
+ maxNumberForPrimaryAxis =
394
+ maxNumberForPrimaryAxis < tempLength
395
+ ? tempLength
396
+ : maxNumberForPrimaryAxis;
397
+ }
398
+ if (customYaxisMaxValue && customYaxisMinValue) {
399
+ maxNumberForPrimaryAxis =
400
+ customYaxisMaxValueLength > customYaxisMinValueLength
401
+ ? customYaxisMaxValue
402
+ : customYaxisMinValue;
403
+ }
404
+ let maxNumberForSecondaryAxis;
405
+ // secondary scale : Margin adjustments
406
+ // maxNumberForSecondaryAxis =
407
+ // secondaryYMinLength < secondaryYMaxLength ? YmaxRight : YminRight;
408
+ // if (secondaryCustomYaxisMinValue) {
409
+ // let tempLength =
410
+ // secondaryCustomYaxisMinValueLength < secondaryYMaxLength
411
+ // ? YmaxRight
412
+ // : secondaryCustomYaxisMinValue;
413
+ // maxNumberForSecondaryAxis =
414
+ // maxNumberForSecondaryAxis < tempLength
415
+ // ? tempLength
416
+ // : maxNumberForSecondaryAxis;
417
+ // }
418
+ // if (secondaryCustomYaxisMaxValue) {
419
+ // let tempLength =
420
+ // secondaryCustomYaxisMaxValueLength > secondaryYMaxLength
421
+ // ? secondaryCustomYaxisMaxValue
422
+ // : YmaxRight;
423
+ // maxNumberForSecondaryAxis =
424
+ // maxNumberForSecondaryAxis < tempLength
425
+ // ? tempLength
426
+ // : maxNumberForSecondaryAxis;
427
+ // }
428
+ // if (secondaryCustomYaxisMaxValue && secondaryCustomYaxisMinValue) {
429
+ // maxNumberForSecondaryAxis =
430
+ // secondaryCustomYaxisMaxValueLength > secondaryCustomYaxisMinValueLength
431
+ // ? secondaryCustomYaxisMaxValue
432
+ // : secondaryCustomYaxisMinValue;
433
+ // }
434
+ return {
435
+ maxNumberForPrimaryAxis,
436
+ maxNumberForSecondaryAxis,
437
+ };
438
+ }
439
+ export function getYaxisLabelList(dataMin, dataMax, axisLengthPx, labelWidthPx = 80) {
440
+ const dataRange = dataMax - dataMin;
441
+ if (dataRange === 0) {
442
+ return [dataMin];
443
+ }
444
+ const maxLabels = Math.max(2, Math.floor(axisLengthPx / labelWidthPx));
445
+ const rawInterval = dataRange / maxLabels;
446
+ const magnitude = Math.pow(10, Math.floor(Math.log10(rawInterval)));
447
+ const niceNumbers = [1, 1.5, 2, 2.5, 5, 10];
448
+ let interval = null;
449
+ for (const n of niceNumbers) {
450
+ const candidate = n * magnitude;
451
+ if (Math.ceil(dataRange / candidate) <= maxLabels) {
452
+ interval = candidate;
453
+ break;
454
+ }
455
+ }
456
+ if (interval === null) {
457
+ interval = niceNumbers[niceNumbers.length - 1] * magnitude;
458
+ }
459
+ const minLabel = Math.floor(dataMin / interval) * interval;
460
+ const maxLabel = Math.ceil(dataMax / interval) * interval;
461
+ const labels = [];
462
+ let current = minLabel;
463
+ while (current <= maxLabel + 1e-8) {
464
+ labels.push(parseFloat(current.toFixed(10)));
465
+ current += interval;
466
+ }
467
+ return labels;
468
+ }
469
+ export function getNumberWithFormat(displayUnits, numberFormat, decimalPrescision) {
470
+ try {
471
+ let Unit;
472
+ let displayUnitsPostFix = "";
473
+ let decimalValues = decimalPrescision;
474
+ let formatter;
475
+ return function (d) {
476
+ if (displayUnits != "None") {
477
+ displayUnits == "Thousands"
478
+ ? ((Unit = 1000), (displayUnitsPostFix = "K"))
479
+ : null;
480
+ displayUnits == "Millions"
481
+ ? ((Unit = 1000000), (displayUnitsPostFix = "M"))
482
+ : null;
483
+ displayUnits == "Billions"
484
+ ? ((Unit = 1000000000), (displayUnitsPostFix = "B"))
485
+ : null;
486
+ d = d / Unit;
487
+ }
488
+ // if (self.tornadoChart) {
489
+ // if (d < 0) d = -d;
490
+ // }
491
+ switch (numberFormat) {
492
+ case ",.0%":
493
+ formatter = `.${decimalValues}%`;
494
+ return d3.format(formatter)(d);
495
+ break;
496
+ case "":
497
+ formatter = `.${decimalValues}f`;
498
+ return d3.format(formatter)(d) + displayUnitsPostFix;
499
+ break;
500
+ case ".2n":
501
+ formatter = `.${decimalValues == 0 ? 1 : (parseFloat(decimalValues) + 1).toString()}n`;
502
+ return d3.format(formatter)(d) + displayUnitsPostFix;
503
+ break;
504
+ case ".2$":
505
+ formatter = `,.${decimalValues}f`;
506
+ return "$" + d3.format(formatter)(d) + displayUnitsPostFix;
507
+ break;
508
+ case ".2c":
509
+ formatter = `,.${decimalValues}f`;
510
+ return "C$" + d3.format(formatter)(d) + displayUnitsPostFix;
511
+ break;
512
+ case ".2ē":
513
+ formatter = `,.${decimalValues}f`;
514
+ return "€" + d3.format(formatter)(d) + displayUnitsPostFix;
515
+ break;
516
+ case ".2ch":
517
+ formatter = `,.${decimalValues}f`;
518
+ return "CHF" + d3.format(formatter)(d) + displayUnitsPostFix;
519
+ break;
520
+ case ".2£":
521
+ formatter = `,.${decimalValues}f`;
522
+ return "£" + d3.format(formatter)(d) + displayUnitsPostFix;
523
+ break;
524
+ case ".2₹":
525
+ formatter = `,.${decimalValues}f`;
526
+ return "₹" + d3.format(formatter)(d) + displayUnitsPostFix;
527
+ break;
528
+ case ",":
529
+ formatter = `,.${decimalValues}f`;
530
+ return d3.format(formatter)(d) + displayUnitsPostFix;
531
+ break;
532
+ default:
533
+ formatter = `.${2}f`;
534
+ return d3.format(formatter)(d) + displayUnitsPostFix;
535
+ }
536
+ };
537
+ }
538
+ catch (error) {
539
+ // loggerService.logError(error, {
540
+ // componentName: constructor.name,
541
+ // functionName: "getNumberWithFormat",
542
+ // });
543
+ }
544
+ }
545
+ export function responsiveYaxisMargin(maxNumberForPrimaryAxis, yMaxLeft, formatOptions) {
546
+ try {
547
+ // if (barChart) {
548
+ // let dimensionticklist = [];
549
+ // DimensionList.forEach((d) => dimensionticklist.push(d.length));
550
+ // xmaxticksize = d3.max(dimensionticklist);
551
+ // return xmaxticksize * formatOptions.yAxisLabel.yAxisLabelFontSize;
552
+ // } else
553
+ {
554
+ let YmaxNumber;
555
+ let normalizedChart = false;
556
+ let YmaxNumberWidth;
557
+ if (formatOptions.yAxisLabel.yAxisDisplayUnits != "None") {
558
+ YmaxNumber = getNumberWithFormat(formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision ?? 2)(Math.floor(maxNumberForPrimaryAxis) || Math.floor(yMaxLeft)).toString();
559
+ YmaxNumberWidth = calculateWidthHeightDynamically(YmaxNumber, formatOptions.yAxisLabel.yAxisLabelFontSize, formatOptions.yAxisLabel.yAxisLabelFontFamily)[0];
560
+ return YmaxNumberWidth < 30 ? 30 : YmaxNumberWidth + 5;
561
+ }
562
+ else {
563
+ try {
564
+ YmaxNumber = getNumberWithFormat(formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision ?? 2)(Math.floor(maxNumberForPrimaryAxis) || Math.floor(yMaxLeft)).toString();
565
+ normalizedChart ? (YmaxNumber = "-100%") : "";
566
+ YmaxNumberWidth = calculateWidthHeightDynamically(YmaxNumber, formatOptions.yAxisLabel.yAxisLabelFontSize, formatOptions.yAxisLabel.yAxisLabelFontFamily)[0];
567
+ return YmaxNumberWidth < 30 ? 30 : YmaxNumberWidth + 5;
568
+ }
569
+ catch (e) {
570
+ // loggerService.logError(e, {
571
+ // componentName: constructor.name,
572
+ // functionName: "responsiveYaxisMargin(Innerloop)",
573
+ // });
574
+ }
575
+ }
576
+ }
577
+ }
578
+ catch (error) {
579
+ // loggerService.logError(error, {
580
+ // componentName: constructor.name,
581
+ // functionName: "responsiveYaxisMargin",
582
+ // });
583
+ }
584
+ }
585
+ export function InitChartArea(svg, margin) {
586
+ try {
587
+ return svg
588
+ .append("g")
589
+ .attr("transform", `translate(${margin.left},${margin.top})`)
590
+ .attr("font-color", "#ccc");
591
+ }
592
+ catch (error) {
593
+ // this.loggerService.logError(error, {
594
+ // componentName: this.constructor.name,
595
+ // functionName: "InitChartArea",
596
+ // });
597
+ }
598
+ }
599
+ export function InitChartFloatingArea(formatOptions, margin, floatingSvg, gTag, chartsWithXScrollFlag, chartsWithYScrollFlag) {
600
+ try {
601
+ if (!formatOptions.plotArea.fitChart &&
602
+ (chartsWithXScrollFlag || chartsWithYScrollFlag)) {
603
+ return floatingSvg
604
+ .append("g")
605
+ .attr("transform", `translate(${margin.left},${margin.top})`)
606
+ .attr("font-color", "#ccc");
607
+ }
608
+ else {
609
+ return gTag;
610
+ }
611
+ }
612
+ catch (error) {
613
+ // this.loggerService.logError(error,{componentName :this.constructor.name,functionName :"InitChartFloatingArea"});
614
+ }
615
+ }
616
+ export function initBlackBox(g, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType) {
617
+ try {
618
+ let uniqueID = crypto.randomUUID().toUpperCase();
619
+ g.append("defs")
620
+ .append("clipPath")
621
+ .attr("id", uniqueID)
622
+ .append("rect")
623
+ .attr("width", innerWidth)
624
+ .attr("height", dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight);
625
+ g.append("rect")
626
+ .attr("width", innerWidth)
627
+ .attr("height", dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight)
628
+ .attr("stroke", formatOptions.plotArea.plotAreaBorder &&
629
+ !chartsWithoutPlotArea.includes(chartType)
630
+ ? formatOptions.plotArea.plotAreaBorderColor
631
+ : "none")
632
+ .attr("stroke-width", formatOptions.plotArea.plotAreaBorderThickness)
633
+ .attr("fill", formatOptions.plotArea.plotAreaColor !== "#ffffff" &&
634
+ !chartsWithoutPlotArea.includes(chartType)
635
+ ? formatOptions.plotArea.plotAreaColor
636
+ : "none");
637
+ // this.setTextAnnotation();
638
+ }
639
+ catch (error) {
640
+ // this.loggerService.logError(error, {
641
+ // componentName: this.constructor.name,
642
+ // functionName: "initBlackBox",
643
+ // });
644
+ }
645
+ }
646
+ export function isVerticallyOverlapping(obj1, obj2) {
647
+ // Calculate the vertical bounds of the first object
648
+ const obj1Top = obj1.yPosition;
649
+ const obj1Bottom = obj1.yPosition + obj1.height;
650
+ // Calculate the vertical bounds of the second object
651
+ const obj2Top = obj2.yPosition;
652
+ const obj2Bottom = obj2.yPosition + obj2.height;
653
+ // Check for vertical overlap
654
+ const verticalOverlap = obj1Top < obj2Bottom && obj1Bottom > obj2Top;
655
+ return verticalOverlap;
656
+ }
657
+ // to get exact value of interval user enter, here we return the array of the intervals to be shown on y-axis scale
658
+ export function responsiveYaxisLabel(Ymax, Ymin, innerWidth, innerHeight, formatOptions, chartJSON) {
659
+ try {
660
+ let customYaxisIntervalValue = parseFloat(formatOptions.yAxisLabel.yAxisIntervalText);
661
+ let customTickValue;
662
+ if (customYaxisIntervalValue &&
663
+ customYaxisIntervalValue !== 0 &&
664
+ customYaxisIntervalValue !== undefined) {
665
+ let minValue = chartJSON.customYaxisMinValue || chartJSON.customYaxisMinValue == 0
666
+ ? chartJSON.customYaxisMinValue
667
+ : Ymin;
668
+ let maxValue = chartJSON.customYaxisMaxValue || chartJSON.customYaxisMaxValue == 0
669
+ ? chartJSON.customYaxisMaxValue
670
+ : Ymax;
671
+ if (minValue < 0) {
672
+ customTickValue = Math.floor((maxValue - minValue) / customYaxisIntervalValue);
673
+ }
674
+ else {
675
+ customTickValue = Math.floor(maxValue / customYaxisIntervalValue);
676
+ }
677
+ let minRequiredTicks = 18;
678
+ chartJSON.customYaxisMaxValue || chartJSON.customYaxisMaxValue == 0
679
+ ? (Ymax = chartJSON.customYaxisMaxValue)
680
+ : "";
681
+ let yAxisLabelArray = [];
682
+ let tickvalue = chartJSON.customYaxisMinValue || chartJSON.customYaxisMinValue == 0
683
+ ? chartJSON.customYaxisMinValue
684
+ : Ymin < 0
685
+ ? Math.round(Ymin)
686
+ : 0;
687
+ yAxisLabelArray.push(tickvalue);
688
+ if (customTickValue > 100) {
689
+ let message = "Tick count cannot exceed more than 100.";
690
+ // openWarningBox(message); // we will add warning pop up later on
691
+ if (minValue < 0) {
692
+ customYaxisIntervalValue = (maxValue - tickvalue) / 100;
693
+ }
694
+ else {
695
+ customYaxisIntervalValue = maxValue / 100;
696
+ }
697
+ }
698
+ customTickValue = customTickValue < 100 ? customTickValue : 100;
699
+ if (customTickValue > minRequiredTicks) {
700
+ for (let interval = 0; interval < parseInt(customTickValue); interval++) {
701
+ tickvalue += customYaxisIntervalValue;
702
+ if (tickvalue.toFixed(5) <= Ymax) {
703
+ yAxisLabelArray.push(tickvalue);
704
+ }
705
+ else
706
+ break;
707
+ }
708
+ }
709
+ else {
710
+ for (let interval = 0; interval < minRequiredTicks; interval++) {
711
+ tickvalue += customYaxisIntervalValue;
712
+ if (tickvalue <= Ymax) {
713
+ yAxisLabelArray.push(tickvalue);
714
+ }
715
+ else
716
+ break;
717
+ }
718
+ }
719
+ return yAxisLabelArray;
720
+ }
721
+ else {
722
+ // Algorithm from aishwarya
723
+ let labelWidthPx = calculateWidthHeightDynamically(chartJSON.customYaxisMaxValue || chartJSON.yMaxLeft, formatOptions.yAxisLabel.yAxisLabelFontSize, formatOptions.yAxisLabel.yAxisLabelFontFamily, "0");
724
+ let labelList = getLabelsFromAlgo(chartJSON.customYaxisMinValue || chartJSON.yMinLeft, chartJSON.customYaxisMaxValue || chartJSON.yMaxLeft, innerHeight, labelWidthPx[0]);
725
+ return labelList;
726
+ // customTickValue = barChart
727
+ // ? innerWidth / 50
728
+ // : innerHeight / 30;
729
+ }
730
+ }
731
+ catch (e) {
732
+ // this.loggerService.logError(e, {
733
+ // componentName: this.constructor.name,
734
+ // functionName: "responsiveYaxisLabel",
735
+ // });
736
+ }
737
+ }
738
+ export function getLabelsFromAlgo(
739
+ // ){
740
+ // function getOptimalAxisLabels(
741
+ dataMin, dataMax, axisLengthPx, labelWidthPx = 80) {
742
+ const dataRange = dataMax - dataMin;
743
+ if (dataRange === 0) {
744
+ return [dataMin];
745
+ }
746
+ const maxLabels = Math.max(2, Math.floor(axisLengthPx / labelWidthPx));
747
+ const rawInterval = dataRange / maxLabels;
748
+ const magnitude = Math.pow(10, Math.floor(Math.log10(rawInterval)));
749
+ const niceNumbers = [1, 1.5, 2, 2.5, 5, 10];
750
+ let interval = null;
751
+ for (const n of niceNumbers) {
752
+ const candidate = n * magnitude;
753
+ if (Math.ceil(dataRange / candidate) <= maxLabels) {
754
+ interval = candidate;
755
+ break;
756
+ }
757
+ }
758
+ if (interval === null) {
759
+ interval = niceNumbers[niceNumbers.length - 1] * magnitude;
760
+ }
761
+ const minLabel = Math.floor(dataMin / interval) * interval;
762
+ const maxLabel = Math.ceil(dataMax / interval) * interval;
763
+ const labels = [];
764
+ let current = minLabel;
765
+ while (current <= maxLabel + 1e-8) {
766
+ labels.push(parseFloat(current.toFixed(10))); // rounding like Python's round
767
+ current += interval;
768
+ }
769
+ return labels;
770
+ }
771
+ export function initYaxis(gTag, formatOptions, dataTableHeight, Ylabel, YaxisLeft, innerHeight) {
772
+ try {
773
+ let fontStyle = formatOptions.yAxisLabel.yAxisLabelFontStyle;
774
+ gTag
775
+ .append("rect")
776
+ .attr("transform", `translate(${-Ylabel},0)`)
777
+ .attr("height", dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight)
778
+ .attr("width", Ylabel)
779
+ .attr("fill", formatOptions.yAxisLabel.yAxisLabelVisibility
780
+ ? formatOptions.yAxisLabel.yAxisBackgroundColor
781
+ ? formatOptions.yAxisLabel.yAxisBackgroundColor !== "#ffffff"
782
+ ? formatOptions.yAxisLabel.yAxisBackgroundColor
783
+ : "none"
784
+ : formatOptions.chartArea.chartAreaColor
785
+ : formatOptions.chartArea.chartAreaColor);
786
+ const YaxisG = gTag.append("g").call(YaxisLeft);
787
+ YaxisG.selectAll("line")
788
+ .style("shape-rendering", "crispEdges")
789
+ .attr("stroke", formatOptions.plotArea.gridLinesColor)
790
+ .attr("stroke-width", "0.05em")
791
+ .attr("stroke-opacity", formatOptions.plotArea.fitChart ? "1" : "0");
792
+ YaxisG.selectAll("text")
793
+ .style("fill", formatOptions.yAxisLabel.yAxisLabelColor !== "#ffffff"
794
+ ? formatOptions.yAxisLabel.yAxisLabelColor
795
+ : "none")
796
+ .style("user-select", "none")
797
+ .style("font-size", formatOptions.yAxisLabel.yAxisLabelFontSize)
798
+ .style("font-family", formatOptions.yAxisLabel.yAxisLabelFontFamily)
799
+ .style("font-style", formatOptions.yAxisLabel.yAxisLabelFontStyle)
800
+ .style("font-style", fontStyle.includes("Italic") ? "Italic" : "")
801
+ .style("text-decoration", fontStyle.includes("Underline") ? "Underline" : "")
802
+ .style("font-weight", fontStyle.includes("Bold") ? "Bold" : "")
803
+ .attr("visibility", formatOptions.yAxisLabel.yAxisLabelVisibility ? "visible" : "hidden");
804
+ YaxisG.select(".domain")
805
+ .style("shape-rendering", "crispEdges")
806
+ .style("stroke", formatOptions.yAxisLabel.yAxisColor)
807
+ .attr("stroke-width", formatOptions.yAxisLabel.yAxisWidth
808
+ ? formatOptions.yAxisLabel.yAxisWidth
809
+ : formatOptions.plotArea.plotAreaBorderThickness);
810
+ // if (
811
+ // !formatOptions.plotArea.fitChart &&
812
+ // (chartsWithXScrollFlag || chartsWithYScrollFlag)
813
+ // ) {
814
+ // const YaxisG2 = floatinggTag.append("g").call(YaxisLeft);
815
+ // YaxisG2.select(".domain").remove();
816
+ // YaxisG2.selectAll("line")
817
+ // .style("shape-rendering", "crispEdges")
818
+ // .attr("stroke", formatOptions.plotArea.gridLinesColor)
819
+ // .attr("stroke-width", "0.05em");
820
+ // YaxisG2.selectAll("text").remove();
821
+ // }
822
+ return gTag;
823
+ }
824
+ catch (error) {
825
+ // loggerService.logError(error, {
826
+ // componentName: this.constructor.name,
827
+ // functionName: "initYaxis",
828
+ // });
829
+ }
830
+ }
831
+ export function responsiveXaxisLabel(dimenstionList, innerWidth) {
832
+ try {
833
+ let filteredDimensionList = [];
834
+ let tickCount =
835
+ // this.barChart
836
+ // ? this.innerHeight / 30 < this.DimenstionListLength
837
+ // ? Math.round(this.innerHeight / 30)
838
+ // : this.DimenstionListLength
839
+ // :
840
+ innerWidth / 30 < dimenstionList.length
841
+ ? Math.round(innerWidth / 30)
842
+ : dimenstionList.length;
843
+ if (tickCount >= dimenstionList.length) {
844
+ filteredDimensionList = dimenstionList;
845
+ return filteredDimensionList;
846
+ }
847
+ let Scale = Math.round(dimenstionList.length / tickCount);
848
+ if (!((dimenstionList.length - 1) % Scale == 0)) {
849
+ if ((dimenstionList.length - 1) % (Scale + 1) == 0) {
850
+ Scale = Scale + 1;
851
+ }
852
+ }
853
+ filteredDimensionList.push(dimenstionList[0]);
854
+ let lastIndex;
855
+ for (let i = 1; i < dimenstionList.length - 1; i++) {
856
+ const index = i * Scale;
857
+ if (index > dimenstionList.length)
858
+ break;
859
+ else
860
+ filteredDimensionList.push(dimenstionList[index]);
861
+ lastIndex = index;
862
+ }
863
+ // to ensure that last dimension gets added in the list
864
+ if (!filteredDimensionList.includes(dimenstionList[dimenstionList.length - 1])) {
865
+ let last1Percent = lastIndex >=
866
+ Math.round(dimenstionList.length - dimenstionList.length * 0.02);
867
+ // if (last1Percent && barChart) {
868
+ // filteredDimensionList.pop();
869
+ // }
870
+ filteredDimensionList.push(dimenstionList[dimenstionList.length - 1]);
871
+ }
872
+ return (filteredDimensionList = filteredDimensionList.filter((val) => val));
873
+ }
874
+ catch (error) {
875
+ // this.loggerService.logError(error, {
876
+ // componentName: this.constructor.name,
877
+ // functionName: "responsiveXaxisLabel",
878
+ // });
879
+ }
880
+ }
881
+ export function initXaxis(gTag, chartJSON, Xlabel, formatOptions, xAxisObj, dataTableHeight, YscaleLeft, Xaxis, dimensionHeightWidthArray, height, barWidth, dataType, innerWidth, innerHeight) {
882
+ try {
883
+ let responsiveDimList = responsiveXaxisLabel(chartJSON.dimensionList, innerWidth);
884
+ let xAxisObject = xAxisObj;
885
+ let formatedResponsiveDimList = [];
886
+ let actualDimesionWidth = dimensionHeightWidthArray[0] + 5;
887
+ let maxDimensionWidth = dimensionHeightWidthArray[3] + 10;
888
+ if (chartJSON.chartType != "Waterfall") {
889
+ formatedResponsiveDimList =
890
+ (xAxisObject.GroupBy == "NA" || xAxisObject.GroupBy == undefined) &&
891
+ dataType === "DATE"
892
+ ? setDateFormats(xAxisObject.Name.name, formatOptions.xAxisLabel.xAxisNumberFormat, responsiveDimList.map((d) => [d]), xAxisObject.dataSourceId).map((d) => d[0])
893
+ : responsiveDimList;
894
+ }
895
+ else {
896
+ responsiveDimList.forEach((item) => {
897
+ formatedResponsiveDimList.push(chartJSON.formatedDimensionMap.get(item));
898
+ });
899
+ }
900
+ let isAreaTypeChartAndNotFitChart = !formatOptions.plotArea.fitChart &&
901
+ (chartJSON.chartType == "Area" ||
902
+ chartJSON.chartType == "StackArea" ||
903
+ chartJSON.chartType == "100StackArea");
904
+ gTag ? "" : (gTag = gTag);
905
+ let fontStyle = formatOptions.xAxisLabel.xAxisLabelFontStyle;
906
+ let Rotation = "rotate(" + -formatOptions.xAxisLabel.xAxisLabelRotation + ")";
907
+ if (formatOptions.dataTableProperties &&
908
+ formatOptions.dataTableProperties.dataTable &&
909
+ chartsWithDataTableArray.includes(chartJSON.chartType)) {
910
+ if (formatOptions.xAxisLabel.xAxisPosition != 1)
911
+ formatOptions.xAxisLabel.xAxisLabelVisibility = false;
912
+ }
913
+ let xaxisLabelPosition = formatOptions.xAxisLabel.xAxisPosition;
914
+ gTag
915
+ .append("rect")
916
+ .attr("transform", `translate(1,${xaxisLabelPosition === 0
917
+ ? dataTableHeight > 0
918
+ ? innerHeight - dataTableHeight
919
+ : innerHeight
920
+ : xaxisLabelPosition === 1
921
+ ? -Xlabel
922
+ : YscaleLeft(0)})`)
923
+ .attr("height", Xlabel)
924
+ .attr("width", innerWidth)
925
+ .attr("fill", formatOptions.xAxisLabel.xAxisLabelVisibility
926
+ ? formatOptions.xAxisLabel.xAxisBackgroundColor
927
+ ? formatOptions.xAxisLabel.xAxisBackgroundColor !== "#ffffff"
928
+ ? formatOptions.xAxisLabel.xAxisBackgroundColor
929
+ : "none"
930
+ : formatOptions.chartArea.chartAreaColor
931
+ : formatOptions.chartArea.chartAreaColor);
932
+ const XaxisG = gTag
933
+ .append("g")
934
+ .attr("transform", `translate(0,${xaxisLabelPosition === 0
935
+ ? dataTableHeight > 0
936
+ ? innerHeight - dataTableHeight
937
+ : innerHeight
938
+ : xaxisLabelPosition === 1
939
+ ? 0
940
+ : YscaleLeft(0)})`)
941
+ .call(Xaxis);
942
+ let dx = xaxisLabelPosition === 1 ? "5" : "0";
943
+ let width = formatOptions.xAxisLabel.labelTextWrap
944
+ ? maxDimensionWidth < height * 0.125
945
+ ? maxDimensionWidth
946
+ : height * 0.125
947
+ : formatOptions.xAxisLabel.xAxisLabelRotation == 0
948
+ ? barWidth
949
+ : actualDimesionWidth;
950
+ let foreignObject = XaxisG.selectAll("g")
951
+ .append("foreignObject")
952
+ .attr("class", "testingoverflowing")
953
+ .style("width", Math.round(width))
954
+ .style("height", "20px")
955
+ .attr("transform", (d, i) => `rotate(${xaxisLabelPosition === 1
956
+ ? -formatOptions.xAxisLabel.xAxisLabelRotation
957
+ : formatOptions.xAxisLabel.xAxisLabelRotation != 0
958
+ ? 180 - formatOptions.xAxisLabel.xAxisLabelRotation
959
+ : 0}) translate (${formatOptions.xAxisLabel.xAxisLabelRotation != 0
960
+ ? dx + `, -${i == 0 && isAreaTypeChartAndNotFitChart ? 15 : 5}`
961
+ : -width / 2 + " , " + (xaxisLabelPosition === 1 ? "-15" : "8")})`);
962
+ if (detectBrowserName() === "safari") {
963
+ foreignObject
964
+ .attr("width", formatOptions.xAxisLabel.labelTextWrap
965
+ ? maxDimensionWidth < height * 0.125
966
+ ? maxDimensionWidth
967
+ : height * 0.125
968
+ : Xlabel)
969
+ .attr("height", "20px");
970
+ }
971
+ foreignObject
972
+ .append("xhtml:h3")
973
+ .style("transform", detectBrowserName() === "safari"
974
+ ? ""
975
+ : xaxisLabelPosition === 1
976
+ ? ""
977
+ : formatOptions.xAxisLabel.xAxisLabelRotation != 0
978
+ ? "rotate(180deg)"
979
+ : "0")
980
+ .style("white-space", "pre")
981
+ .style("text-overflow", "ellipsis")
982
+ .style("text-align", formatOptions.xAxisLabel.xAxisLabelRotation != 0 ? "start" : "center")
983
+ .style("user-select", "none")
984
+ .style("margin", 0)
985
+ .style("padding", 0)
986
+ .style("overflow", "hidden")
987
+ .style("font-family", formatOptions.xAxisLabel.xAxisLabelFontFamily)
988
+ // .style("font-style", formatOptions.xAxisLabel.xAxisLabelFontStyle)
989
+ .style("color", formatOptions.xAxisLabel.xAxisLabelColor)
990
+ .style("font-size", formatOptions.xAxisLabel.xAxisLabelFontSize + "px")
991
+ .style("font-style", fontStyle.includes("Italic") ? "Italic" : "")
992
+ .style("text-decoration", fontStyle.includes("Underline") ? "Underline" : "")
993
+ .style("font-weight", fontStyle.includes("Bold") ? "Bold" : "")
994
+ .style("visibility", formatOptions.xAxisLabel.xAxisLabelVisibility ? "visible" : "hidden")
995
+ .attr("title", (d, i) => ("" + formatedResponsiveDimList[i]).trim())
996
+ .html((d, i) => ("" + formatedResponsiveDimList[i]).trim());
997
+ //default text elements are set to hidden
998
+ XaxisG.selectAll("text").style("visibility", formatOptions.xAxisLabel.xAxisLabelVisibility ? "hidden" : "hidden");
999
+ XaxisG.selectAll("line")
1000
+ .style("stroke", formatOptions.plotArea.gridLinesColor)
1001
+ .style("shape-rendering", "crispEdges")
1002
+ .attr("visibility", formatOptions.xAxisLabel.xAxisLabelVisibility
1003
+ ? "visible"
1004
+ : formatOptions.plotArea.gridLinesVeritcal
1005
+ ? "visible"
1006
+ : "hidden");
1007
+ XaxisG.select(".domain")
1008
+ .style("stroke", formatOptions.xAxisLabel.xAxisColor)
1009
+ .attr("stroke-width", formatOptions.xAxisLabel.xAxisWidth
1010
+ ? formatOptions.xAxisLabel.xAxisWidth
1011
+ : formatOptions.plotArea.plotAreaBorderThickness)
1012
+ .style("shape-rendering", "crispEdges");
1013
+ return gTag;
1014
+ }
1015
+ catch (error) {
1016
+ // loggerService.logError(error, {
1017
+ // componentName: this.constructor.name,
1018
+ // functionName: "initXaxis",
1019
+ // });
1020
+ }
1021
+ }
1022
+ export function detectBrowserName() {
1023
+ let browserName = "";
1024
+ try {
1025
+ const agent = window.navigator.userAgent.toLowerCase();
1026
+ switch (true) {
1027
+ case agent.indexOf("edge") > -1:
1028
+ browserName = "edge";
1029
+ break;
1030
+ case agent.indexOf("opr") > -1 && !!window.opr:
1031
+ browserName = "opera";
1032
+ break;
1033
+ case agent.indexOf("chrome") > -1 && !!window.chrome:
1034
+ browserName = "chrome";
1035
+ break;
1036
+ case agent.indexOf("trident") > -1:
1037
+ browserName = "ie";
1038
+ break;
1039
+ case agent.indexOf("firefox") > -1:
1040
+ browserName = "firefox";
1041
+ break;
1042
+ case agent.indexOf("safari") > -1 || agent.indexOf("applewebkit") > -1:
1043
+ browserName = "safari";
1044
+ break;
1045
+ default:
1046
+ browserName = "other";
1047
+ break;
1048
+ }
1049
+ }
1050
+ catch (error) {
1051
+ // Optionally log error if loggerService is available
1052
+ // console.error(error);
1053
+ }
1054
+ finally {
1055
+ return browserName;
1056
+ }
1057
+ }
1058
+ export function setDateFormats(name, format, dimensionmarks, datasourceId) {
1059
+ try {
1060
+ let formatdim = [];
1061
+ let daysArray = [
1062
+ "01",
1063
+ "02",
1064
+ "03",
1065
+ "04",
1066
+ "05",
1067
+ "06",
1068
+ "07",
1069
+ "08",
1070
+ "09",
1071
+ "10",
1072
+ "11",
1073
+ "12",
1074
+ "13",
1075
+ "14",
1076
+ "15",
1077
+ "16",
1078
+ "17",
1079
+ "18",
1080
+ "19",
1081
+ "20",
1082
+ "21",
1083
+ "22",
1084
+ "23",
1085
+ "24",
1086
+ "25",
1087
+ "26",
1088
+ "27",
1089
+ "28",
1090
+ "29",
1091
+ "30",
1092
+ "31",
1093
+ ];
1094
+ if (this.ObjService.dateKeyMap[datasourceId] &&
1095
+ this.ObjService.dateKeyMap[datasourceId].indexOf(name) != -1) {
1096
+ if (format == "Month") {
1097
+ var fix = [
1098
+ "January",
1099
+ "February",
1100
+ "March",
1101
+ "April",
1102
+ "May",
1103
+ "June",
1104
+ "July",
1105
+ "August",
1106
+ "September",
1107
+ "October",
1108
+ "November",
1109
+ "December",
1110
+ ];
1111
+ dimensionmarks.forEach((e) => {
1112
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1113
+ if (fix[month]) {
1114
+ formatdim.push(fix[month]);
1115
+ }
1116
+ else {
1117
+ formatdim.push(e);
1118
+ }
1119
+ });
1120
+ }
1121
+ else if (format == "Quarter") {
1122
+ var fix = [
1123
+ "Quarter1",
1124
+ "Quarter1",
1125
+ "Quarter1",
1126
+ "Quarter2",
1127
+ "Quarter2",
1128
+ "Quarter2",
1129
+ "Quarter3",
1130
+ "Quarter3",
1131
+ "Quarter3",
1132
+ "Quarter4",
1133
+ "Quarter4",
1134
+ "Quarter4",
1135
+ ];
1136
+ dimensionmarks.forEach((e) => {
1137
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1138
+ if (fix[month]) {
1139
+ formatdim.push(fix[month] + "-" + year);
1140
+ }
1141
+ else {
1142
+ formatdim.push(e);
1143
+ }
1144
+ });
1145
+ }
1146
+ else if (format == "Year") {
1147
+ dimensionmarks.forEach((e) => {
1148
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1149
+ if (year) {
1150
+ formatdim.push(year);
1151
+ }
1152
+ else {
1153
+ formatdim.push(e);
1154
+ }
1155
+ });
1156
+ }
1157
+ else if (format == "Default") {
1158
+ var fix = [
1159
+ "Jan",
1160
+ "Feb",
1161
+ "Mar",
1162
+ "Apr",
1163
+ "May",
1164
+ "June",
1165
+ "July",
1166
+ "Aug",
1167
+ "Sept",
1168
+ "Oct",
1169
+ "Nov",
1170
+ "Dec",
1171
+ ];
1172
+ dimensionmarks.forEach((e) => {
1173
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1174
+ if (daysArray[day] && fix[month] && year) {
1175
+ formatdim.push([daysArray[day] + "-" + fix[month] + "-" + year]);
1176
+ }
1177
+ else {
1178
+ formatdim.push(e);
1179
+ }
1180
+ });
1181
+ }
1182
+ else if (format == "DD-MM-YYYY") {
1183
+ var fix = [
1184
+ "01",
1185
+ "02",
1186
+ "03",
1187
+ "04",
1188
+ "05",
1189
+ "06",
1190
+ "07",
1191
+ "08",
1192
+ "09",
1193
+ "10",
1194
+ "11",
1195
+ "12",
1196
+ ];
1197
+ dimensionmarks.forEach((e) => {
1198
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1199
+ if (daysArray[day] && fix[month] && year) {
1200
+ formatdim.push([daysArray[day] + "-" + fix[month] + "-" + year]);
1201
+ }
1202
+ else {
1203
+ formatdim.push(e);
1204
+ }
1205
+ });
1206
+ }
1207
+ else if (format == "MM-DD-YYYY") {
1208
+ var fix = [
1209
+ "01",
1210
+ "02",
1211
+ "03",
1212
+ "04",
1213
+ "05",
1214
+ "06",
1215
+ "07",
1216
+ "08",
1217
+ "09",
1218
+ "10",
1219
+ "11",
1220
+ "12",
1221
+ ];
1222
+ dimensionmarks.forEach((e) => {
1223
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1224
+ if (daysArray[day] && fix[month] && year) {
1225
+ formatdim.push([fix[month] + "-" + daysArray[day] + "-" + year]);
1226
+ }
1227
+ else {
1228
+ formatdim.push(e);
1229
+ }
1230
+ });
1231
+ }
1232
+ else if (format == "DD-MM") {
1233
+ var fix = [
1234
+ "01",
1235
+ "02",
1236
+ "03",
1237
+ "04",
1238
+ "05",
1239
+ "06",
1240
+ "07",
1241
+ "08",
1242
+ "09",
1243
+ "10",
1244
+ "11",
1245
+ "12",
1246
+ ];
1247
+ dimensionmarks.forEach((e) => {
1248
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1249
+ if (daysArray[day] && fix[month]) {
1250
+ formatdim.push([daysArray[day] + "-" + fix[month]]);
1251
+ }
1252
+ else {
1253
+ formatdim.push(e);
1254
+ }
1255
+ });
1256
+ }
1257
+ else if (format == "YYYY-MM-DD") {
1258
+ var fix = [
1259
+ "01",
1260
+ "02",
1261
+ "03",
1262
+ "04",
1263
+ "05",
1264
+ "06",
1265
+ "07",
1266
+ "08",
1267
+ "09",
1268
+ "10",
1269
+ "11",
1270
+ "12",
1271
+ ];
1272
+ dimensionmarks.forEach((e) => {
1273
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1274
+ if (daysArray[day] && fix[month] && year) {
1275
+ formatdim.push([year + "-" + fix[month] + "-" + daysArray[day]]);
1276
+ }
1277
+ else {
1278
+ formatdim.push(e);
1279
+ }
1280
+ });
1281
+ }
1282
+ else if (format == "YYYY-MM") {
1283
+ var fix = [
1284
+ "01",
1285
+ "02",
1286
+ "03",
1287
+ "04",
1288
+ "05",
1289
+ "06",
1290
+ "07",
1291
+ "08",
1292
+ "09",
1293
+ "10",
1294
+ "11",
1295
+ "12",
1296
+ ];
1297
+ dimensionmarks.forEach((e) => {
1298
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1299
+ if (fix[month] && year) {
1300
+ formatdim.push([year + "-" + fix[month]]);
1301
+ }
1302
+ else {
1303
+ formatdim.push(e);
1304
+ }
1305
+ });
1306
+ }
1307
+ else if (format == "YYYY") {
1308
+ var fix = [
1309
+ "01",
1310
+ "02",
1311
+ "03",
1312
+ "04",
1313
+ "05",
1314
+ "06",
1315
+ "07",
1316
+ "08",
1317
+ "09",
1318
+ "10",
1319
+ "11",
1320
+ "12",
1321
+ ];
1322
+ dimensionmarks.forEach((e) => {
1323
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1324
+ if (year) {
1325
+ formatdim.push([year]);
1326
+ }
1327
+ else {
1328
+ formatdim.push(e);
1329
+ }
1330
+ });
1331
+ }
1332
+ else if (format == "MM-YYYY") {
1333
+ var fix = [
1334
+ "01",
1335
+ "02",
1336
+ "03",
1337
+ "04",
1338
+ "05",
1339
+ "06",
1340
+ "07",
1341
+ "08",
1342
+ "09",
1343
+ "10",
1344
+ "11",
1345
+ "12",
1346
+ ];
1347
+ dimensionmarks.forEach((e) => {
1348
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1349
+ if (fix[month] && year) {
1350
+ formatdim.push([fix[month] + "-" + year]);
1351
+ }
1352
+ else {
1353
+ formatdim.push(e);
1354
+ }
1355
+ });
1356
+ }
1357
+ else if (format == "MMM-YY") {
1358
+ var fix = [
1359
+ "Jan",
1360
+ "Feb",
1361
+ "Mar",
1362
+ "Apr",
1363
+ "May",
1364
+ "Jun",
1365
+ "Jul",
1366
+ "Aug",
1367
+ "Sep",
1368
+ "Oct",
1369
+ "Nov",
1370
+ "Dec",
1371
+ ];
1372
+ dimensionmarks.forEach((e) => {
1373
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1374
+ let modifiedyear = this.getYearInCorrectFormat(year);
1375
+ if (fix[month] && modifiedyear) {
1376
+ formatdim.push([fix[month] + "-" + modifiedyear]);
1377
+ }
1378
+ else {
1379
+ formatdim.push(e);
1380
+ }
1381
+ });
1382
+ }
1383
+ else if (format == "YY-MMM") {
1384
+ var fix = [
1385
+ "Jan",
1386
+ "Feb",
1387
+ "Mar",
1388
+ "Apr",
1389
+ "May",
1390
+ "Jun",
1391
+ "Jul",
1392
+ "Aug",
1393
+ "Sep",
1394
+ "Oct",
1395
+ "Nov",
1396
+ "Dec",
1397
+ ];
1398
+ dimensionmarks.forEach((e) => {
1399
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1400
+ let modifiedyear = this.getYearInCorrectFormat(year);
1401
+ if (fix[month] && modifiedyear) {
1402
+ formatdim.push([modifiedyear + "-" + fix[month]]);
1403
+ }
1404
+ else {
1405
+ formatdim.push(e);
1406
+ }
1407
+ });
1408
+ }
1409
+ else if (format == "MMMM-YY") {
1410
+ var fix = [
1411
+ "January",
1412
+ "February",
1413
+ "March",
1414
+ "April",
1415
+ "May",
1416
+ "June",
1417
+ "July",
1418
+ "August",
1419
+ "September",
1420
+ "October",
1421
+ "November",
1422
+ "December",
1423
+ ];
1424
+ dimensionmarks.forEach((e) => {
1425
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1426
+ let modifiedyear = this.getYearInCorrectFormat(year);
1427
+ if (fix[month] && modifiedyear) {
1428
+ formatdim.push([fix[month] + "-" + modifiedyear]);
1429
+ }
1430
+ else {
1431
+ formatdim.push(e);
1432
+ }
1433
+ });
1434
+ }
1435
+ else if (format == "MMMM-YYYY") {
1436
+ var fix = [
1437
+ "January",
1438
+ "February",
1439
+ "March",
1440
+ "April",
1441
+ "May",
1442
+ "June",
1443
+ "July",
1444
+ "August",
1445
+ "September",
1446
+ "October",
1447
+ "November",
1448
+ "December",
1449
+ ];
1450
+ dimensionmarks.forEach((e) => {
1451
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1452
+ if (fix[month] && year) {
1453
+ formatdim.push([fix[month] + "-" + year]);
1454
+ }
1455
+ else {
1456
+ formatdim.push(e);
1457
+ }
1458
+ });
1459
+ }
1460
+ else if (format == "DD-MMM") {
1461
+ var fix = [
1462
+ "Jan",
1463
+ "Feb",
1464
+ "Mar",
1465
+ "Apr",
1466
+ "May",
1467
+ "Jun",
1468
+ "Jul",
1469
+ "Aug",
1470
+ "Sep",
1471
+ "Oct",
1472
+ "Nov",
1473
+ "Dec",
1474
+ ];
1475
+ dimensionmarks.forEach((e) => {
1476
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1477
+ if (fix[month] && daysArray[day]) {
1478
+ formatdim.push([daysArray[day] + "-" + fix[month]]);
1479
+ }
1480
+ else {
1481
+ formatdim.push(e);
1482
+ }
1483
+ });
1484
+ }
1485
+ else if (format == "DD-MMM-YY") {
1486
+ var fix = [
1487
+ "Jan",
1488
+ "Feb",
1489
+ "Mar",
1490
+ "Apr",
1491
+ "May",
1492
+ "Jun",
1493
+ "Jul",
1494
+ "Aug",
1495
+ "Sep",
1496
+ "Oct",
1497
+ "Nov",
1498
+ "Dec",
1499
+ ];
1500
+ dimensionmarks.forEach((e) => {
1501
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1502
+ let modifiedyear = this.getYearInCorrectFormat(year);
1503
+ if (fix[month] && daysArray[day] && modifiedyear) {
1504
+ formatdim.push([
1505
+ daysArray[day] + "-" + fix[month] + "-" + modifiedyear,
1506
+ ]);
1507
+ }
1508
+ else {
1509
+ formatdim.push(e);
1510
+ }
1511
+ });
1512
+ }
1513
+ else if (format == "DD-MMM-YYYY") {
1514
+ var fix = [
1515
+ "Jan",
1516
+ "Feb",
1517
+ "Mar",
1518
+ "Apr",
1519
+ "May",
1520
+ "Jun",
1521
+ "Jul",
1522
+ "Aug",
1523
+ "Sep",
1524
+ "Oct",
1525
+ "Nov",
1526
+ "Dec",
1527
+ ];
1528
+ dimensionmarks.forEach((e) => {
1529
+ let { day, month, year } = this.getDateFromDimension(e[0]);
1530
+ if (fix[month] && daysArray[day] && year) {
1531
+ formatdim.push([daysArray[day] + "-" + fix[month] + "-" + year]);
1532
+ }
1533
+ else {
1534
+ formatdim.push(e);
1535
+ }
1536
+ });
1537
+ }
1538
+ else
1539
+ return dimensionmarks;
1540
+ return formatdim;
1541
+ }
1542
+ else {
1543
+ return dimensionmarks;
1544
+ }
1545
+ }
1546
+ catch (error) {
1547
+ // this.loggerService.logError(error, {
1548
+ // componentName: this.constructor.name,
1549
+ // functionName: "setDateFormats",
1550
+ // });
1551
+ }
1552
+ }
1553
+ export function initScrollingSvgClippath(formatOptions, Margin, width) {
1554
+ // if (!formatOptions.plotArea.fitChart) {
1555
+ // document.getElementById(`defs${svgIndex}`)?.remove();
1556
+ // g.append("defs")
1557
+ // .attr("id", `defs${svgIndex}`)
1558
+ // .append("clipPath")
1559
+ // .attr("id", `clipPath${svgIndex}`)
1560
+ // .append("rect")
1561
+ // .attr(
1562
+ // "width",
1563
+ // Width -
1564
+ // Margin.left -
1565
+ // Margin.right -
1566
+ // (!parentReference.fromPreviewWindow &&
1567
+ // !formatOptions.plotArea.fitChart
1568
+ // ? 4
1569
+ // : 0)
1570
+ // )
1571
+ // .attr(
1572
+ // "height",
1573
+ // Height -
1574
+ // Margin.top +
1575
+ // (formatOptions.legends.legendPosition == "Right" ? Xlabel : 0)
1576
+ // )
1577
+ // .attr(
1578
+ // "transform",
1579
+ // `translate(${Margin.left},${
1580
+ // formatOptions.xAxisLabel.xAxisPosition == 1 ||
1581
+ // formatOptions.xAxisLabel.xAxisPosition == 2
1582
+ // ? Margin.top - Xlabel
1583
+ // : Margin.top
1584
+ // })`
1585
+ // ); // Adjust these values as needed
1586
+ // // Position the clipPath relative to the SVG container
1587
+ // document
1588
+ // .querySelector(".floating-div" + svgIndex)
1589
+ // .addEventListener("scroll", updateClipPathPosition);
1590
+ // floatingSvg.attr("clip-path", `url(#clipPath${svgIndex})`);
1591
+ // }
1592
+ }
1593
+ export function drawSeriesLabels(formatOptions, floatingTagG, seriesLabels) {
1594
+ if (formatOptions.seriesLabel.seriesLabelVisibility) {
1595
+ let fontStyle = formatOptions.seriesLabel.seriesLabelFontStyle;
1596
+ const groups = floatingTagG
1597
+ .selectAll(".seriesLabels")
1598
+ .data(seriesLabels)
1599
+ .enter()
1600
+ .filter((d) => d.isVisible)
1601
+ .append("g")
1602
+ .attr("class", "seriesLabels")
1603
+ .attr("transform", (d) => `translate(${d.xPosition}, ${d.yPosition})`);
1604
+ groups
1605
+ .append("foreignObject")
1606
+ .attr("width", (d) => d.width)
1607
+ .attr("height", (d) => d.height)
1608
+ .append("xhtml:div")
1609
+ .style("display", "flex")
1610
+ .style("align-items", "center")
1611
+ .style("justify-content", "center")
1612
+ .style("width", "100%")
1613
+ .style("height", "100%")
1614
+ .append("xhtml:div")
1615
+ .style("width", "fit-content")
1616
+ .style("height", "100%")
1617
+ .style("padding-left", "5px")
1618
+ .style("padding-right", "5px")
1619
+ .style("border-radius", "4px")
1620
+ .style("background-color", formatOptions.seriesLabel.seriesLabelBackgroundColor)
1621
+ .style("font-size", formatOptions.seriesLabel.seriesLabelFontSize + "px")
1622
+ .style("font-family", formatOptions.seriesLabel.seriesLabelFontFamily)
1623
+ .style("font-style", fontStyle.includes("Italic") ? "italic" : "")
1624
+ .style("text-decoration", fontStyle.includes("Underline") ? "underline" : "")
1625
+ .style("font-weight", fontStyle.includes("Bold") ? "bold" : "")
1626
+ .style("color", "black")
1627
+ .text((d) => d.seriesValue);
1628
+ }
1629
+ }
1630
+ export function setXaxistitle(formatOptions, barChart, svg, Margin, Xlabel, height, Xtitle, chartType, Ylabel, staticSvgInnerWidth, innerHeight) {
1631
+ try {
1632
+ let xAxisLabelPosition = formatOptions.xAxisLabel.xAxisPosition;
1633
+ let chartsWithXScrollFlag = true;
1634
+ let chartsWithYScrollFlag = false;
1635
+ let object = svg
1636
+ .append("foreignObject")
1637
+ .attr("visibility", barChart
1638
+ ? formatOptions.yAxisTitle.yAxisTitleVisibility
1639
+ ? "visible"
1640
+ : "hidden"
1641
+ : formatOptions.xAxisTitle.xAxisTitleVisibility
1642
+ ? "visible"
1643
+ : "hidden")
1644
+ .attr("transform", !formatOptions.plotArea.fitChart && chartsWithXScrollFlag
1645
+ ? `translate(${Margin.left},${Margin.top +
1646
+ innerHeight +
1647
+ (formatOptions?.xAxisLabel?.xAxisPosition == 1 ? 0 : Xlabel)})`
1648
+ : !formatOptions.plotArea.fitChart && chartsWithYScrollFlag
1649
+ ? `translate(${Margin.left},${height - Xtitle - 5})`
1650
+ : `translate(${Margin.left},${Margin.top +
1651
+ innerHeight +
1652
+ (chartsWithXScrollFlag
1653
+ ? formatOptions?.xAxisLabel?.xAxisPosition == 1
1654
+ ? 0
1655
+ : Xlabel
1656
+ : chartType == actualChartTypes.tornadoChart
1657
+ ? Xlabel + 5
1658
+ : Ylabel + 5)})`
1659
+ // `translate(${Margin.left},${Margin.top + innerHeight + (chartsWithXScrollFlag ? (formatOptions?.xAxisLabel?.xAxisPosition == "1" ? 0 : Xlabel) : (attributes.type == ActualChartTypes.TornadoChart) ? Xlabel + 5 : Ylabel + 5) })`
1660
+ )
1661
+ .attr("class", "xAxisTitle")
1662
+ .attr("width", staticSvgInnerWidth)
1663
+ .attr("height", Xtitle + "px")
1664
+ .style("z-index", "9999");
1665
+ if (formatOptions.xAxisTitle.xAxisDynamicTitleText.length !== 0) {
1666
+ object
1667
+ .append("xhtml:div")
1668
+ .style("color", "rgba(119,119,119)")
1669
+ .attr("title", formatOptions.xAxisTitle.xAxisTitleText)
1670
+ .style("white-space", "pre")
1671
+ .style("text-overflow", "ellipsis")
1672
+ .html(formatOptions.xAxisTitle.xAxisTitleHTML
1673
+ ? formatOptions.xAxisTitle.xAxisTitleHTML
1674
+ : formatOptions.xAxisTitle.xAxisTitleText);
1675
+ }
1676
+ else {
1677
+ object
1678
+ .append("xhtml:h3")
1679
+ .style("white-space", "pre")
1680
+ .style("text-overflow", "ellipsis")
1681
+ .style("user-select", "none")
1682
+ .style("margin", 0)
1683
+ .style("padding", 0)
1684
+ .style("text-align", "center")
1685
+ .style("overflow", "hidden")
1686
+ .attr("class", "xAxisTitle")
1687
+ .style("padding-top", "5px")
1688
+ .style("text-anchor", "middle")
1689
+ .style("color", "rgba(119,119,119)")
1690
+ .style("font-size", "12px")
1691
+ .style("font-size", formatOptions.xAxisTitle.xAxisTitleFontSize)
1692
+ .style("font-family", formatOptions.xAxisTitle.xAxisTitleFontFamily)
1693
+ .style("font-style", formatOptions.xAxisTitle.xAxisTitleFontStyle)
1694
+ .attr("title", formatOptions.xAxisTitle.xAxisTitleText !== "~$~Dimension"
1695
+ ? formatOptions.xAxisTitle.xAxisTitleText
1696
+ : "")
1697
+ .html(formatOptions.xAxisTitle.xAxisTitleText !== "~$~Dimension"
1698
+ ? formatOptions.xAxisTitle.xAxisTitleText
1699
+ : "");
1700
+ }
1701
+ return svg;
1702
+ }
1703
+ catch (error) {
1704
+ // loggerService.logError(error, {
1705
+ // componentName: constructor.name,
1706
+ // functionName: "setXaxistitle",
1707
+ // });
1708
+ }
1709
+ }
1710
+ export function Yaxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, Margin, Ytitle, Ylabel) {
1711
+ try {
1712
+ let currentInnerHeight = dataTableHeight > 0
1713
+ ? innerHeight - dataTableHeight
1714
+ : innerHeight
1715
+ ? innerHeight
1716
+ : innerHeight;
1717
+ let object = svg
1718
+ .append("foreignObject")
1719
+ .attr("visibility", barChart
1720
+ ? formatOptions.xAxisTitle.xAxisTitleVisibility
1721
+ ? "visible"
1722
+ : "hidden"
1723
+ : formatOptions.yAxisTitle.yAxisTitleVisibility
1724
+ ? "visible"
1725
+ : "hidden")
1726
+ .attr("x", `-${Margin.top + currentInnerHeight}`)
1727
+ .attr("y", Margin.left - Ytitle - Ylabel + 5)
1728
+ .attr("class", "yAxisTitle")
1729
+ .attr("transform", "rotate(-90)")
1730
+ .attr("width", currentInnerHeight)
1731
+ .attr("height", Ytitle + "px");
1732
+ if (formatOptions.yAxisTitle.yAxisDynamicTitleText.length !== 0) {
1733
+ object
1734
+ .append("xhtml:div")
1735
+ .style("color", "rgba(119,119,119)")
1736
+ .attr("title", formatOptions.yAxisTitle.yAxisTitleText)
1737
+ .style("white-space", "pre")
1738
+ .style("text-overflow", "ellipsis")
1739
+ .html(formatOptions.yAxisTitle.yAxisTitleHTML
1740
+ ? formatOptions.yAxisTitle.yAxisTitleHTML
1741
+ : formatOptions.yAxisTitle.yAxisTitleText);
1742
+ }
1743
+ else {
1744
+ object
1745
+ .append("xhtml:h3")
1746
+ .style("white-space", "pre")
1747
+ .style("text-overflow", "ellipsis")
1748
+ .style("user-select", "none")
1749
+ .style("margin", 0)
1750
+ .style("padding", 0)
1751
+ .style("text-align", "center")
1752
+ .style("overflow", "hidden")
1753
+ .attr("class", "xAxisTitle")
1754
+ // .style("padding-top", "5px")
1755
+ .style("text-anchor", "middle")
1756
+ .style("color", "rgba(119,119,119)")
1757
+ .style("font-size", "12px")
1758
+ .style("font-size", formatOptions.yAxisTitle.yAxisTitleFontSize)
1759
+ .style("font-family", formatOptions.yAxisTitle.yAxisTitleFontFamily)
1760
+ .style("font-style", formatOptions.yAxisTitle.yAxisTitleFontStyle)
1761
+ .attr("title", formatOptions.yAxisTitle.yAxisTitleText)
1762
+ .html(formatOptions.yAxisTitle.yAxisTitleText);
1763
+ }
1764
+ return svg;
1765
+ }
1766
+ catch (error) {
1767
+ // loggerService.logError(error, {
1768
+ // componentName: constructor.name,
1769
+ // functionName: "Yaxistitle",
1770
+ // });
1771
+ }
1772
+ }
1773
+ export function setChartTitle(svg, formatOptions, width, chartTitleHeight) {
1774
+ let object = svg
1775
+ .append("foreignObject")
1776
+ .attr("visibility", formatOptions.chartTitle.chartTitleVisibility ? "visible" : "hidden")
1777
+ .attr("transform", `translate(2,2)`)
1778
+ .attr("class", "chartTitle")
1779
+ .attr("width", width)
1780
+ .attr("height", chartTitleHeight + "px");
1781
+ // if (formatOptions.chartTitle.chartTitleVisibility) {
1782
+ // let chartTitleStyle = formatOptions.chartTitle;
1783
+ if (formatOptions.chartTitle.dynamicTitleText.length !== 0) {
1784
+ object
1785
+ .append("xhtml:div")
1786
+ .style("color", "rgba(119,119,119)")
1787
+ .attr("title", formatOptions.chartTitle.chartTitleText)
1788
+ .style("white-space", "pre")
1789
+ .style("text-overflow", "ellipsis")
1790
+ .html(formatOptions.chartTitle.chartTitleHTML
1791
+ ? formatOptions.chartTitle.chartTitleHTML
1792
+ : formatOptions.chartTitle.chartTitleText);
1793
+ }
1794
+ else {
1795
+ object
1796
+ .append("xhtml:div")
1797
+ .style("white-space", "pre")
1798
+ .style("user-select", "none")
1799
+ .style("text-overflow", "ellipsis")
1800
+ .style("overflow", "hidden")
1801
+ .attr("class", "chartTiltle")
1802
+ .attr("id", "chartTitleId")
1803
+ .style("text-anchor", "start")
1804
+ .style("color", "rgba(119,119,119)")
1805
+ .style("font-size", "16px")
1806
+ .style("font-family", formatOptions.chartTitle.chartTitleFontFamily)
1807
+ .attr("title", formatOptions.chartTitle.chartTitleText)
1808
+ .html(formatOptions.chartTitle.chartTitleText);
1809
+ }
1810
+ }
1811
+ //This function is to set the Chart Area Background Color and Chart Bordor.
1812
+ export function initSvgBox(svg, formatOptions, widgetId, chartsWithXScrollFlag, chartsWithYScrollFlag) {
1813
+ try {
1814
+ let fixedSVG = document.getElementById(widgetId);
1815
+ let floatingDiv = document.getElementById(`checkForNoDataImage${widgetId}`);
1816
+ let svgDomBunny;
1817
+ if (!formatOptions.plotArea.fitChart &&
1818
+ (chartsWithXScrollFlag || chartsWithYScrollFlag)) {
1819
+ svgDomBunny = floatingDiv;
1820
+ //removing properties of fixed svg
1821
+ fixedSVG ? (fixedSVG.style.backgroundColor = "") : "";
1822
+ fixedSVG ? (fixedSVG.style.border = "") : "";
1823
+ }
1824
+ else {
1825
+ svgDomBunny = fixedSVG;
1826
+ floatingDiv ? (floatingDiv.style.backgroundColor = "") : "";
1827
+ floatingDiv ? (floatingDiv.style.border = "") : "";
1828
+ }
1829
+ let style = formatOptions.chartArea.chartAreaBorderStyle;
1830
+ let isBorderEnable = formatOptions.chartArea.chartAreaBorder;
1831
+ let borderColor = formatOptions.chartArea.chartAreaBorderColor;
1832
+ let borderWidth = formatOptions.chartArea.chartAreaBorderThickness + "px";
1833
+ let borderStyle = style == 1 ? "solid" : style == 2 ? "dashed" : "dotted";
1834
+ if (svgDomBunny) {
1835
+ if (formatOptions) {
1836
+ svgDomBunny.style.backgroundColor =
1837
+ formatOptions.chartArea.chartAreaColor;
1838
+ svgDomBunny.style.border =
1839
+ svgDomBunny && isBorderEnable
1840
+ ? `${borderWidth} ${borderStyle} ${borderColor}`
1841
+ : "";
1842
+ }
1843
+ else {
1844
+ svgDomBunny.style.backgroundColor = "#F7F7F7";
1845
+ }
1846
+ }
1847
+ return svg;
1848
+ // this.setTextAnnotation(); // to be added later
1849
+ }
1850
+ catch (error) {
1851
+ // this.loggerService.logError(error, {
1852
+ // componentName: this.constructor.name,
1853
+ // functionName: "initSvgBox",
1854
+ // });
1855
+ }
1856
+ }
1857
+ export function lineAnnotations(chartData, Xscale, YscaleLeft, YscaleRight, Margin, d3Annotation, labelExcludeList, individualLabelColor, oldAnnotationList, formatOptions, chartType) {
1858
+ try {
1859
+ let annotationType = formatOptions.annotation.annotationType ?? "1";
1860
+ if (formatOptions.annotation.annotationVisibility) {
1861
+ let Disable = [annotationType == "1" ? "connector" : ""];
1862
+ const self = this;
1863
+ let labelData = [];
1864
+ let makeAnnotations = d3Annotation.annotation();
1865
+ let connector = formatOptions.annotation.connectorType;
1866
+ let labelType = formatOptions.annotation.annotationVisibility;
1867
+ let fontStyle = formatOptions.annotation.annotationFontStyle;
1868
+ let connectorType = formatOptions.annotation.connectorType
1869
+ ? formatOptions.annotation.connectorType.toLowerCase()
1870
+ : "None";
1871
+ oldAnnotationList = conditionallyResetOldAnnotations(oldAnnotationList, formatOptions, chartType);
1872
+ let AnnotationsList = [];
1873
+ let finalAnnotationList = [];
1874
+ if (oldAnnotationList.length != 0) {
1875
+ oldAnnotationList.forEach((d) => {
1876
+ d.dx = (d.dx * this.Width) / d.width;
1877
+ d.dy = (d.dy * this.Height) / d.height;
1878
+ d.width = this.Width;
1879
+ d.height = this.Height;
1880
+ });
1881
+ }
1882
+ switch (labelType) {
1883
+ case 2:
1884
+ chartData.forEach((d) => labelData.push({
1885
+ Dimension: d.data[0].dimension,
1886
+ Measure: d.data[0].value,
1887
+ Legend: d.data[0].legend,
1888
+ LabelPosition: d.properties.dataLabelPosition,
1889
+ Labelcolor: d.properties.labelColor,
1890
+ Axis: d.properties.axis,
1891
+ }));
1892
+ break;
1893
+ case 3:
1894
+ chartData.forEach((d) => labelData.push({
1895
+ Dimension: d.data[d.data.length - 1].dimension,
1896
+ Measure: d.data[d.data.length - 1].value,
1897
+ Legend: d.data[d.data.length - 1].legend,
1898
+ LabelPosition: d.properties.dataLabelPosition,
1899
+ Labelcolor: d.properties.labelColor,
1900
+ Axis: d.properties.axis,
1901
+ }));
1902
+ break;
1903
+ case 4:
1904
+ chartData.forEach((d) => labelData.push({
1905
+ Dimension: d.data[0].dimension,
1906
+ Measure: d.data[0].value,
1907
+ Legend: d.data[0].legend,
1908
+ LabelPosition: d.properties.dataLabelPosition,
1909
+ Labelcolor: d.properties.labelColor,
1910
+ Axis: d.properties.axis,
1911
+ }));
1912
+ chartData.forEach((d) => labelData.push({
1913
+ Dimension: d.data[d.data.length - 1].dimension,
1914
+ Measure: d.data[d.data.length - 1].value,
1915
+ Legend: d.data[d.data.length - 1].legend,
1916
+ LabelPosition: d.properties.dataLabelPosition,
1917
+ Labelcolor: d.properties.labelColor,
1918
+ Axis: d.properties.axis,
1919
+ }));
1920
+ break;
1921
+ case 1:
1922
+ for (let i = 0; i < chartData[0].data.length; i++) {
1923
+ chartData.forEach((d) => labelData.push({
1924
+ Dimension: d.data[i].dimension,
1925
+ Measure: d.data[i].value,
1926
+ Legend: d.data[i].legend,
1927
+ LabelPosition: d.properties.dataLabelPosition,
1928
+ Labelcolor: d.properties.labelColor,
1929
+ Axis: d.properties.axis,
1930
+ }));
1931
+ }
1932
+ break;
1933
+ case 5:
1934
+ labelData;
1935
+ break;
1936
+ case 6:
1937
+ chartData.forEach((d) => {
1938
+ let annotationVisibility = d.properties.individualAnnotationVisibility;
1939
+ switch (annotationVisibility) {
1940
+ case 1:
1941
+ for (let i = 0; i < chartData[0].data.length; i++) {
1942
+ // labelData.push(d.Data[i]);
1943
+ labelData.push({
1944
+ Dimension: d.data[i].dimension,
1945
+ Measure: d.data[i].value,
1946
+ Legend: d.data[i].legend,
1947
+ LabelPosition: d.properties.dataLabelPosition,
1948
+ Labelcolor: d.properties.labelColor,
1949
+ Axis: d.properties.axis,
1950
+ });
1951
+ }
1952
+ break;
1953
+ case 2:
1954
+ labelData;
1955
+ break;
1956
+ case 3:
1957
+ // labelData.push(d.Data[0]);
1958
+ labelData.push({
1959
+ Dimension: d.data[0].dimension,
1960
+ Measure: d.data[0].value,
1961
+ Legend: d.data[0].legend,
1962
+ LabelPosition: d.properties.dataLabelPosition,
1963
+ Labelcolor: d.properties.labelColor,
1964
+ Axis: d.properties.axis,
1965
+ });
1966
+ break;
1967
+ case 4:
1968
+ // labelData.push(d.Data[chartData[0].Data.length - 1]);
1969
+ labelData.push({
1970
+ Dimension: d.data[d.data.length - 1].dimension,
1971
+ Measure: d.data[d.data.length - 1].value,
1972
+ Legend: d.data[d.data.length - 1].legend,
1973
+ LabelPosition: d.properties.dataLabelPosition,
1974
+ Labelcolor: d.properties.labelColor,
1975
+ Axis: d.properties.axis,
1976
+ });
1977
+ break;
1978
+ case 5:
1979
+ // labelData.push(d.Data[0]);
1980
+ // labelData.push(d.Data[chartData[0].Data.length - 1]);
1981
+ labelData.push({
1982
+ Dimension: d.data[0].dimension,
1983
+ Measure: d.data[0].value,
1984
+ Legend: d.data[0].legend,
1985
+ LabelPosition: d.properties.dataLabelPosition,
1986
+ Labelcolor: d.properties.labelColor,
1987
+ Axis: d.properties.axis,
1988
+ });
1989
+ labelData.push({
1990
+ Dimension: d.data[d.data.length - 1].dimension,
1991
+ Measure: d.data[d.data.length - 1].value,
1992
+ Legend: d.data[d.data.length - 1].legend,
1993
+ LabelPosition: d.properties.dataLabelPosition,
1994
+ Labelcolor: d.properties.labelColor,
1995
+ Axis: d.properties.axis,
1996
+ });
1997
+ break;
1998
+ }
1999
+ });
2000
+ break;
2001
+ }
2002
+ let maxValue = 0;
2003
+ labelData.forEach((d, i) => {
2004
+ if (maxValue < d.Measure) {
2005
+ maxValue = d.Measure;
2006
+ }
2007
+ });
2008
+ let minValue = maxValue * 0.1;
2009
+ labelData.forEach((d, i) => {
2010
+ let singleAnnotation = {
2011
+ note: {
2012
+ label: d.Measure >= 1000000000 &&
2013
+ formatOptions.annotation.annotationNumberFormat === ".2s"
2014
+ ? Math.round(d.Measure / 1000000000) + "B"
2015
+ : this.tooltipNumberFormat(d.Measure, formatOptions.annotation.annotationDecimalPrecision, formatOptions.annotation.annotationNumberFormat, formatOptions.annotation.annotationDisplayUnits ||
2016
+ formatOptions.plotArea.plotAreaDisplayUnits),
2017
+ align: "middle",
2018
+ },
2019
+ data: {
2020
+ x: d.Dimension,
2021
+ y: { measure: d.Measure, axis: d.Axis },
2022
+ position: parseInt(d.LabelPosition),
2023
+ currentLegend: d.Legend.replaceAll(" ", "-"),
2024
+ isVisible: true,
2025
+ },
2026
+ dx: 0,
2027
+ dy: 0,
2028
+ connector: {
2029
+ end: connectorType,
2030
+ curve: this.connecterCurve[formatOptions.annotation.ConnectorCurve],
2031
+ },
2032
+ disable: Disable,
2033
+ subject: {
2034
+ height: 15,
2035
+ width: 15,
2036
+ },
2037
+ color: d.Labelcolor,
2038
+ type: this.annotationTypeforCharts(d3Annotation, annotationType),
2039
+ height: this.Height,
2040
+ width: this.Width,
2041
+ };
2042
+ this.finalLegendseries.includes(d.Legend) &&
2043
+ this.responsiveXaxisLabel().includes(d.Dimension) &&
2044
+ !labelExcludeList.includes(d.Legend) &&
2045
+ (d.Axis == "Primary"
2046
+ ? YscaleLeft(d.Measure) <= this.innerHeight &&
2047
+ YscaleLeft(d.Measure) >= 0
2048
+ : YscaleRight(d.Measure) <= this.innerHeight &&
2049
+ YscaleRight(d.Measure) >= 0)
2050
+ ? AnnotationsList.push(singleAnnotation)
2051
+ : null;
2052
+ });
2053
+ AnnotationsList = AnnotationsList.filter((d) => d.data.y.measure != 0);
2054
+ oldAnnotationList =
2055
+ oldAnnotationList.length == 0 ? AnnotationsList : oldAnnotationList;
2056
+ AnnotationsList.forEach((newAnnotation) => {
2057
+ let newLegend = newAnnotation.data.x + "-" + newAnnotation.data.y.measure;
2058
+ if (oldAnnotationList.length != 0) {
2059
+ oldAnnotationList.forEach((oldAnnotation) => {
2060
+ let oldLegend = oldAnnotation.data.x + "-" + oldAnnotation.data.y.measure;
2061
+ if (newLegend == oldLegend) {
2062
+ newAnnotation.dx = oldAnnotation.dx;
2063
+ newAnnotation.dy = oldAnnotation.dy;
2064
+ newAnnotation.data.isVisible =
2065
+ oldAnnotation.data.isVisible ?? true;
2066
+ newAnnotation.connector.points = oldAnnotation.connector.points;
2067
+ if (formatOptions.annotation.annotationType == 5 &&
2068
+ newAnnotation.dx == 0 &&
2069
+ newAnnotation.dy == 0) {
2070
+ newAnnotation.connector["points"] = [
2071
+ [0, 0],
2072
+ [0, 0],
2073
+ ];
2074
+ }
2075
+ }
2076
+ });
2077
+ }
2078
+ finalAnnotationList.push(newAnnotation);
2079
+ });
2080
+ makeAnnotations
2081
+ .editMode(formatOptions.annotation.annotationDraggable &&
2082
+ !(self.attributes.fromReportBuilder == undefined &&
2083
+ this.svgIndex != undefined))
2084
+ .accessors({
2085
+ x: function (d) {
2086
+ return Xscale(d.x);
2087
+ },
2088
+ y: function (d) {
2089
+ if (d.y.axis == "Primary") {
2090
+ return self.dataLabelsPosition(d.y.measure, d.position, YscaleLeft, minValue, d.prevValue, "Line");
2091
+ }
2092
+ else {
2093
+ return self.dataLabelsPosition(d.y.measure, d.position, YscaleRight, minValue, d.prevValue, "Line");
2094
+ }
2095
+ // return YscaleLeft(d.y) + Margin.top;
2096
+ },
2097
+ })
2098
+ .on("dragend", function (annotation) {
2099
+ if (!annotation.data.isVisible) {
2100
+ annotation.data.isVisible = true;
2101
+ oldAnnotationList.forEach((d) => {
2102
+ if (d.data.x == annotation.data.x &&
2103
+ d.data.y.measure == annotation.data.y.measure) {
2104
+ annotations
2105
+ .selectAll(".annotation-note-label")
2106
+ .filter((d) => d.data.x == annotation.data.x &&
2107
+ d.data.y.measure == annotation.data.y.measure)
2108
+ .attr("display", "block");
2109
+ d.data.isVisible = true;
2110
+ }
2111
+ });
2112
+ }
2113
+ oldAnnotationList.forEach((d) => {
2114
+ if (d.data.x == annotation.data.x &&
2115
+ d.data.y.measure == annotation.data.y.measure) {
2116
+ d.dx = (annotation._dx * self.Width) / d.width;
2117
+ d.dy = (annotation._dy * self.Height) / d.height;
2118
+ d.connector["points"] = annotation.connector.points;
2119
+ }
2120
+ });
2121
+ if (self.attributes.Id) {
2122
+ let index = self.parentReference.objService.Charts.findIndex((d) => d.Id == self.attributes.Id);
2123
+ self.parentReference.objService.Charts[index].SourceData.ChartStyle.Style.plotArea.dataLabelsCoordinates =
2124
+ oldAnnotationList;
2125
+ }
2126
+ else {
2127
+ self.parentReference.objService.tempAnnotationArray =
2128
+ oldAnnotationList;
2129
+ }
2130
+ annotations
2131
+ .selectAll(".connector")
2132
+ .attr("hoverId", (d) => d.data.currentLegend)
2133
+ .style("stroke", self.basestyle.annotation.connectorColor || "#ccc")
2134
+ .attr("stroke-dasharray", self.connectedStyle[self.basestyle.annotation.connectorStyle]);
2135
+ annotations
2136
+ .selectAll(`.connector-${connectorType}`)
2137
+ .attr("fill", self.basestyle.annotation.connectorColor || "#ccc")
2138
+ .style("stroke", self.basestyle.annotation.connectorColor || "#ccc");
2139
+ annotations
2140
+ .selectAll(".note-line")
2141
+ .attr("hoverId", (d) => d.data.currentLegend)
2142
+ .style("stroke", self.basestyle.annotation.connectorColor || "#ccc")
2143
+ .attr("stroke-dasharray", self.connectedStyle[self.basestyle.annotation.connectorStyle])
2144
+ .filter((d) => d._dx == 0 && d._dy == 0)
2145
+ .remove();
2146
+ annotations
2147
+ .selectAll(".annotation-note-label")
2148
+ .filter((d) => d.data && d.data.isVisible)
2149
+ .style("display", "block");
2150
+ })
2151
+ .on("noteclick", function (annotation) {
2152
+ if (self.basestyle.annotation.annotationDraggable &&
2153
+ !(self.attributes.fromReportBuilder == undefined &&
2154
+ self.svgIndex != undefined)) {
2155
+ annotation.data.isVisible = false;
2156
+ oldAnnotationList.forEach((d) => {
2157
+ if (d.data.x == annotation.data.x &&
2158
+ d.data.y.measure == annotation.data.y.measure) {
2159
+ annotations
2160
+ .selectAll(".annotation-note-label")
2161
+ .filter((d) => d.data.x == annotation.data.x &&
2162
+ d.data.y.measure == annotation.data.y.measure)
2163
+ .attr("display", "none");
2164
+ d.data.isVisible = false;
2165
+ }
2166
+ });
2167
+ if (self.attributes.Id) {
2168
+ let index = self.parentReference.objService.Charts.findIndex((d) => d.Id == self.attributes.Id);
2169
+ self.parentReference.objService.Charts[index].SourceData.ChartStyle.Style.plotArea.dataLabelsCoordinates =
2170
+ oldAnnotationList;
2171
+ }
2172
+ else {
2173
+ self.parentReference.objService.tempAnnotationArray =
2174
+ oldAnnotationList;
2175
+ }
2176
+ annotations
2177
+ .selectAll(".annotation-note-label")
2178
+ .filter((d) => d.data && !d.data.isVisible)
2179
+ .style("display", "none");
2180
+ }
2181
+ })
2182
+ .accessorsInverse({
2183
+ x: (d) => Xscale.invert(d.x),
2184
+ y: (d) => YscaleLeft.invert(d.y),
2185
+ })
2186
+ .notePadding(0)
2187
+ .annotations(finalAnnotationList);
2188
+ let annotations = this.floatingSvg
2189
+ .append("g")
2190
+ .attr("class", "annotation-group parentGroup")
2191
+ .attr("transform", `translate(${this.Margin.left},${this.Margin.top})`)
2192
+ .style("fill", formatOptions.annotation.annotationColor)
2193
+ .style("font-family", formatOptions.annotation.annotationFontFamily)
2194
+ .style("font-size", formatOptions.annotation.annotationFontSize)
2195
+ .style("font-style", fontStyle.includes("Italic") ? "Italic" : "")
2196
+ .style("text-decoration", fontStyle.includes("Underline") ? "Underline" : "")
2197
+ .style("font-weight", fontStyle.includes("Bold") ? "Bold" : "")
2198
+ .call(makeAnnotations);
2199
+ annotations.selectAll("rect").style("visibility", "hidden");
2200
+ annotations.selectAll(".annotation-subject").remove();
2201
+ annotations
2202
+ .selectAll(".connector")
2203
+ .style("stroke", formatOptions.annotation.connectorColor || "#ccc")
2204
+ .attr("stroke-dasharray", this.connectedStyle[formatOptions.annotation.connectorStyle]);
2205
+ annotations
2206
+ .selectAll(`.connector-${connectorType}`)
2207
+ .attr("fill", formatOptions.annotation.connectorColor || "#ccc")
2208
+ .style("stroke", formatOptions.annotation.connectorColor || "#ccc");
2209
+ annotations
2210
+ .selectAll(".note-line")
2211
+ .style("stroke", formatOptions.annotation.connectorColor || "#ccc")
2212
+ .attr("stroke-dasharray", this.connectedStyle[formatOptions.annotation.connectorStyle])
2213
+ .filter((d) => d._dx == 0 && d._dy == 0)
2214
+ .remove();
2215
+ annotations
2216
+ .selectAll(".connector-end")
2217
+ .filter((d) => d.connector.end == "dot" && d._dx == 0 && d._dy == 0)
2218
+ .remove();
2219
+ annotations
2220
+ .selectAll(".annotation-note-label")
2221
+ .filter((d) => d.data && !d.data.isVisible)
2222
+ .style("display", "none");
2223
+ formatOptions.annotation.annotationType == 1 &&
2224
+ annotations
2225
+ .selectAll(".annotation-note-content")
2226
+ .attr("transform", function () {
2227
+ const transform = d3.select(this).attr("transform");
2228
+ const translateValues = transform.match(/translate\(([^,]+),([^,]+)\)/);
2229
+ if (translateValues) {
2230
+ const currentX = parseFloat(translateValues[1]);
2231
+ return `translate(${currentX}, 0)`;
2232
+ }
2233
+ });
2234
+ annotations
2235
+ .selectAll("text")
2236
+ .append("text")
2237
+ .style("fill", formatOptions.annotation.annotationColor !== "#ffffff"
2238
+ ? formatOptions.annotation.annotationColor
2239
+ : "none");
2240
+ annotations
2241
+ .selectAll("tspan")
2242
+ .attr("hoverId", (d) => d.data.currentLegend)
2243
+ .style("visibility", (d) => parseFloat(d.data.y.measure) == 0 &&
2244
+ formatOptions.annotation.annotationHideZeroValues
2245
+ ? "hidden"
2246
+ : "visible");
2247
+ if (this.parentReference.objService &&
2248
+ this.parentReference.objService.tempAnnotationArray) {
2249
+ this.parentReference.objService.tempAnnotationArray =
2250
+ finalAnnotationList;
2251
+ }
2252
+ }
2253
+ }
2254
+ catch (error) {
2255
+ // this.loggerService.logError(error, {
2256
+ // componentName: this.constructor.name,
2257
+ // functionName: "lineAnnotations",
2258
+ // });
2259
+ }
2260
+ }
2261
+ const conditionallyResetOldAnnotations = (oldAnnotationList, formatOptions, chartType) => {
2262
+ try {
2263
+ let path = [
2264
+ actualChartTypes.pie,
2265
+ actualChartTypes.sunburst,
2266
+ ].includes(chartType)
2267
+ ? "plotArea"
2268
+ : "annotation";
2269
+ const isDraggable = formatOptions[path].annotationDraggable;
2270
+ // const measureInfo =
2271
+ // this.parentReference.objService.dataSourceDimensionUniqueValueMap?.[
2272
+ // "PublicFields"
2273
+ // ]?.["[Measure Names]"]?.[0];
2274
+ const isMeasureReplaced = false; //measureInfo?.isMeasureReplaced;
2275
+ oldAnnotationList =
2276
+ isDraggable && !isMeasureReplaced ? oldAnnotationList ?? [] : [];
2277
+ return oldAnnotationList;
2278
+ }
2279
+ catch (error) {
2280
+ // this.loggerService.logError(error, {
2281
+ // componentName: this.constructor.name,
2282
+ // functionName: "conditionallyResetOldAnnotations",
2283
+ // });
2284
+ }
2285
+ };