pace-chart-lib 1.0.2 → 1.0.4

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 (131) hide show
  1. package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +76 -38
  2. package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +4 -2
  3. package/dist/{components → Components}/Charts/Core/CommonFunctions.d.ts +3 -1
  4. package/dist/{components → Components}/Charts/Core/DefaultProperties.types.d.ts +2 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/pace-chart-lib.es.js +54619 -0
  7. package/dist/pace-chart-lib.umd.js +54622 -0
  8. package/dist/vite.svg +1 -0
  9. package/package.json +1 -1
  10. package/dist/Services/ErrorLog.js +0 -3
  11. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +0 -496
  12. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +0 -4
  13. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +0 -491
  14. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +0 -517
  15. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +0 -4
  16. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +0 -553
  17. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +0 -517
  18. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +0 -4
  19. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +0 -553
  20. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +0 -12
  21. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +0 -9
  22. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +0 -4909
  23. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
  24. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
  25. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +0 -49
  26. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +0 -4
  27. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +0 -486
  28. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +0 -497
  29. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +0 -418
  30. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +0 -1013
  31. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +0 -478
  32. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +0 -4
  33. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +0 -451
  34. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +0 -533
  35. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +0 -512
  36. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +0 -530
  37. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +0 -512
  38. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +0 -12
  39. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +0 -9
  40. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +0 -497
  41. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +0 -497
  42. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +0 -4
  43. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +0 -479
  44. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +0 -478
  45. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +0 -473
  46. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +0 -465
  47. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
  48. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
  49. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +0 -451
  50. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +0 -4
  51. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +0 -554
  52. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +0 -4
  53. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +0 -510
  54. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +0 -4
  55. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +0 -507
  56. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +0 -393
  57. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +0 -606
  58. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
  59. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
  60. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -815
  61. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  62. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  63. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +0 -32
  64. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +0 -15021
  65. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +0 -391
  66. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +0 -367
  67. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +0 -570
  68. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +0 -212
  69. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +0 -401
  70. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +0 -313
  71. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +0 -719
  72. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +0 -807
  73. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +0 -514
  74. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +0 -282
  75. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +0 -207
  76. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +0 -476
  77. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +0 -420
  78. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +0 -106
  79. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +0 -507
  80. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +0 -246
  81. package/dist/components/Charts/Core/Common.type.d.ts +0 -0
  82. package/dist/components/Charts/Core/Common.type.js +0 -0
  83. package/dist/components/Charts/Core/Common.types.js +0 -133
  84. package/dist/components/Charts/Core/CommonFunctions.js +0 -1782
  85. package/dist/components/Charts/Core/DefaultChartDataProperties.js +0 -64
  86. package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
  87. package/dist/components/Charts/Core/DefaultProperties.js +0 -0
  88. package/dist/components/Charts/Core/DefaultProperties.type.d.ts +0 -586
  89. package/dist/components/Charts/Core/DefaultProperties.type.js +0 -585
  90. package/dist/components/Charts/Core/DefaultProperties.types.js +0 -592
  91. package/dist/index.js +0 -40
  92. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +0 -0
  93. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +0 -0
  94. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +0 -0
  95. /package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +0 -0
  96. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +0 -0
  97. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +0 -0
  98. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +0 -0
  99. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +0 -0
  100. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +0 -0
  101. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +0 -0
  102. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +0 -0
  103. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +0 -0
  104. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +0 -0
  105. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +0 -0
  106. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +0 -0
  107. /package/dist/{components → Components}/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +0 -0
  108. /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/NormalizedStackLineChart.d.ts +0 -0
  109. /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/StackLineChart.d.ts +0 -0
  110. /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +0 -0
  111. /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +0 -0
  112. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
  113. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +0 -0
  114. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +0 -0
  115. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +0 -0
  116. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +0 -0
  117. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +0 -0
  118. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +0 -0
  119. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +0 -0
  120. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +0 -0
  121. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +0 -0
  122. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +0 -0
  123. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +0 -0
  124. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +0 -0
  125. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +0 -0
  126. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +0 -0
  127. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +0 -0
  128. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +0 -0
  129. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +0 -0
  130. /package/dist/{components → Components}/Charts/Core/Common.types.d.ts +0 -0
  131. /package/dist/{components → Components}/Charts/Core/DefaultChartDataProperties.d.ts +0 -0
@@ -1,570 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- //#region imports
3
- import * as d3 from "d3";
4
- import { OrgChart } from "d3-org-chart";
5
- import { useEffect, useRef } from "react";
6
- import { logError } from "../../../../Services/ErrorLog";
7
- import { fontStyleOptions, } from "../../Core/Common.types";
8
- import { convertStringToNumber, drawChartTitle, firstFunctionBeforeRender, getNumberWithFormatFunction, initSvg, marginCalculationsForChartsWithoutLegends } from "../../Core/CommonFunctions";
9
- import { chartMargins } from "../../Core/DefaultProperties.types";
10
- import { connectorStyle, orgChartDirection, orgChartLineType, orgChartNodeType, } from "../ChartsWithoutAxisTypes.types";
11
- //#endregion
12
- const fileName = "OrganizationChart.tsx";
13
- const OrganizationChart = ({ data, formatOptions, legendEntries, legendSequence, }) => {
14
- //#region Variables
15
- const chartId = crypto.randomUUID();
16
- const svgRef = useRef(); // Reference to the SVG element
17
- const floatingSvgRef = useRef(); // Reference to the SVG element
18
- let chartFormatOptions; // Format options for the chart
19
- let width; // svg total width
20
- let height; // svg total height
21
- let chartTitleHeight = 40; // Height of the chart title
22
- let margins = chartMargins; // Margins for the chart
23
- let svg; // SVG element for the chart
24
- let idIndexMap = new Map(); // Map to store the index of each id in the data
25
- let indexMapForStyleObject = new Map(); // Map to store the index and UID for styling purposes
26
- let chartDirection = orgChartDirection.left; // Direction of the chart layout, default is left
27
- let chartData = [];
28
- let scrollWidth = 0;
29
- let scrollHeight = 0;
30
- //#endregion
31
- useEffect(() => {
32
- drawChart();
33
- }, [chartId, data, formatOptions]);
34
- const drawChart = () => {
35
- ({ chartFormatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
36
- ({ margins, chartTitleHeight, innerHeight, innerWidth } =
37
- marginCalculationsForChartsWithoutLegends(chartFormatOptions, height, width));
38
- initSvg(svgRef, width, height, chartFormatOptions); // Initialize SVG with width, height and background color
39
- drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
40
- dataPreparation();
41
- scrollWidthHeightCalculation();
42
- drawOrganizationChart(chartData);
43
- };
44
- const dataPreparation = () => {
45
- try {
46
- chartDirection =
47
- chartFormatOptions.plotArea.chartDirection || orgChartDirection.left;
48
- var sum = 0;
49
- var absoluteSum = 0;
50
- data.forEach((item) => {
51
- sum = sum + item.value;
52
- absoluteSum = absoluteSum + item.absoluteValue;
53
- });
54
- var newObj = {
55
- id: 0,
56
- children: data,
57
- value: sum, // Total value of all children
58
- absoluteValue: absoluteSum,
59
- nodeLabel: "",
60
- UID: "",
61
- };
62
- let tempData = getFlattenedData(newObj).filter((data) => data.value !== null);
63
- createIdIndexMap(tempData); // Create a map of id to index for quick access
64
- generateUID(tempData); // Generate unique IDs for each node based on its parent
65
- chartData = addStyleObjectToChartData(tempData);
66
- }
67
- catch (error) {
68
- logError(fileName, "dataPreparation", error);
69
- }
70
- };
71
- const scrollWidthHeightCalculation = () => {
72
- try {
73
- if (chartFormatOptions.plotArea.fitChart) {
74
- scrollHeight = height;
75
- scrollWidth = width;
76
- floatingSvgRef.current.style.width = `calc(100% - 10px)`;
77
- floatingSvgRef.current.style.height = `calc(100% - 10px)`;
78
- }
79
- else {
80
- scrollWidth = 0;
81
- chartData.forEach((node) => {
82
- if (node.label == legendSequence[legendSequence.length - 1]) {
83
- scrollWidth += calculateNodeWidth(node, false);
84
- }
85
- });
86
- scrollHeight =
87
- (legendSequence.length + 1) *
88
- convertStringToNumber(chartFormatOptions.nodes.nodeHeight) *
89
- 10 +
90
- (legendSequence.length + 1) * 70;
91
- floatingSvgRef.current.style.width = `${scrollWidth}px`;
92
- floatingSvgRef.current.style.height = `${scrollHeight}px`;
93
- d3.select(floatingSvgRef.current)
94
- .append("defs")
95
- .attr("id", `defs${chartId}`)
96
- .append("clipPath")
97
- .attr("id", `clipPath${chartId}`)
98
- .append("rect")
99
- .attr("width", width - margins.left - margins.right)
100
- .attr("height", height - margins.top - margins.bottom - 15)
101
- .attr("transform", `translate(${margins.left},${margins.top})`); // Adjust these values as needed
102
- // Position the clipPath relative to the SVG container
103
- document
104
- .querySelector("#floating-div" + chartId)
105
- .addEventListener("scroll", updateClipPathPosition);
106
- d3.select(floatingSvgRef.current).attr("clip-path", `url(#clipPath${chartId})`);
107
- function updateClipPathPosition() {
108
- let self = this;
109
- var scrollLeft = self.scrollLeft;
110
- var scrollTop = self.scrollTop;
111
- d3.select(`#clipPath${chartId}`)
112
- .select("rect")
113
- .attr("x", scrollLeft)
114
- .attr("y", scrollTop);
115
- }
116
- }
117
- }
118
- catch (error) {
119
- logError(fileName, "scrollWidthHeightCalculation", error);
120
- }
121
- };
122
- const generateUID = (data) => {
123
- try {
124
- data.forEach((nodeObject, i) => {
125
- if (nodeObject.id != 0) {
126
- let parentUID = data[idIndexMap.get(nodeObject.parentId)].UID;
127
- parentUID === ""
128
- ? (nodeObject.UID = nodeObject.nodeLabel)
129
- : (nodeObject.UID = parentUID + "-" + nodeObject.nodeLabel);
130
- indexMapForStyleObject.set(nodeObject.UID, i); //Maintaining map of index and UID
131
- }
132
- });
133
- }
134
- catch (error) {
135
- logError(fileName, "generateUID", error);
136
- }
137
- };
138
- const addStyleObjectToChartData = (data) => {
139
- try {
140
- data[0] = { ...data[0], styleObject: legendEntries[0] };
141
- legendEntries.forEach((styleObject) => {
142
- if (styleObject === legendEntries[0])
143
- return;
144
- let dataIndex = indexMapForStyleObject.get(styleObject.name);
145
- let obj = data[dataIndex];
146
- data[dataIndex] = { ...obj, styleObject: styleObject };
147
- });
148
- return data;
149
- }
150
- catch (error) {
151
- logError(fileName, "addStyleObjectToChartData", error);
152
- }
153
- };
154
- const createIdIndexMap = (data) => {
155
- try {
156
- data.forEach((object, i) => {
157
- idIndexMap.set(object.id, i);
158
- });
159
- }
160
- catch (error) {
161
- logError(fileName, "createIdIndexMap", error);
162
- }
163
- };
164
- const getFlattenedData = (dataHierarchy) => {
165
- try {
166
- const descendants = d3.hierarchy(dataHierarchy).descendants();
167
- descendants.forEach((d, i) => {
168
- d.id = d.id || "id" + i;
169
- });
170
- return descendants.map((d, i) => {
171
- const copy = { ...d.data };
172
- delete copy.children;
173
- if (d.parent) {
174
- copy.parentValue = d.parent.data.value || 0;
175
- }
176
- return { ...copy, ...{ parentId: d.parent?.data?.id } };
177
- });
178
- }
179
- catch (error) {
180
- logError(fileName, "getFlattenedData", error);
181
- }
182
- };
183
- const drawOrganizationChart = (chartData) => {
184
- try {
185
- let lineType = chartFormatOptions.connector.lineType || "straight";
186
- let nodeType = chartFormatOptions.nodes.nodeType || orgChartNodeType.rectangle;
187
- let connectorVisibility = parseInt(chartFormatOptions.connector.connectorLineThickness);
188
- let organizationalChart = new OrgChart();
189
- organizationalChart
190
- .container(`#floating-${chartId}`)
191
- .svgWidth(scrollWidth)
192
- .svgHeight(scrollHeight)
193
- .nodeHeight((d) => calculateNodeHeight(d))
194
- .nodeWidth((d) => calculateNodeWidth(d, true))
195
- .layout(chartDirection)
196
- .diagonal((s, t, m, offsets = { sy: 0 }) => {
197
- if (chartDirection == "top" ||
198
- chartDirection == "bottom" ||
199
- !chartDirection) {
200
- switch (lineType) {
201
- case orgChartLineType.curve:
202
- return `M ${s.x} ${s.y} C ${(s.x + t.x) / 2} ${s.y}, ${(s.x + t.x) / 2} ${t.y}, ${t.x} ${t.y}`;
203
- case orgChartLineType.elbow:
204
- return `M ${s.x} ${s.y} H ${s.x} V ${t.y} H ${t.x}`;
205
- case orgChartLineType.diagonal:
206
- return `M ${s.x} ${s.y} L ${(s.x + t.x) / 2} ${s.y} L ${(s.x + t.x) / 2} ${t.y} L ${t.x} ${t.y}`;
207
- case orgChartLineType.s_curve:
208
- const midY = (s.y + t.y) / 2;
209
- return `M ${s.x},${s.y} C ${s.x},${midY} ${t.x},${midY} ${t.x},${t.y}`;
210
- case orgChartLineType.arc:
211
- const dx = t.x - s.x;
212
- const dy = t.y - s.y;
213
- const dr = Math.sqrt(dx * dx + dy * dy);
214
- return `M ${s.x},${s.y} A ${dr},${dr} 0 0,1 ${t.x},${t.y}`;
215
- case orgChartLineType.reverse_elbow:
216
- if (chartDirection == orgChartDirection.bottom)
217
- return `M ${s.x} ${s.y} V ${s.y - 20} H ${t.x} V ${t.y}`;
218
- else if (chartDirection == orgChartDirection.top)
219
- return `M ${s.x} ${s.y} V ${s.y + 20} H ${t.x} V ${t.y}`;
220
- case orgChartLineType.zigzag:
221
- if (chartDirection == orgChartDirection.top) {
222
- const mid = (s.y + t.y) / 2;
223
- return `M ${s.x},${s.y} L ${s.x},${mid - 10} L ${t.x},${mid + 10} L ${t.x},${t.y}`;
224
- }
225
- else if (chartDirection == orgChartDirection.bottom) {
226
- const midY = (s.y + t.y) / 2;
227
- return `
228
- M ${s.x},${s.y}
229
- L ${s.x},${midY + 10}
230
- L ${t.x},${midY - 10}
231
- L ${t.x},${t.y}
232
- `;
233
- }
234
- default:
235
- if (chartDirection == orgChartDirection.bottom) {
236
- return `M ${s.x} ${s.y} V ${s.y + 25} H ${t.x} V ${t.y}`;
237
- }
238
- else if (chartDirection == "top") {
239
- return `M ${s.x} ${s.y} V ${s.y - 25} H ${t.x} V ${t.y}`;
240
- }
241
- }
242
- }
243
- })
244
- .hdiagonal((s, t, m, offsets = { sx: 0 }) => {
245
- if (chartDirection === orgChartDirection.left ||
246
- chartDirection === orgChartDirection.right) {
247
- switch (lineType) {
248
- case orgChartLineType.curve:
249
- return `M ${s.x} ${s.y} C ${(s.x + t.x) / 2} ${s.y}, ${(s.x + t.x) / 2} ${t.y}, ${t.x} ${t.y}`;
250
- case orgChartLineType.elbow:
251
- if (chartDirection == orgChartDirection.left)
252
- return `M ${s.x} ${s.y} H ${s.x - 50} V ${t.y} H ${t.x}`;
253
- else if (chartDirection == orgChartDirection.right) {
254
- return `M ${s.x} ${s.y} H ${s.x + 50} V ${t.y} H ${t.x}`;
255
- }
256
- case orgChartLineType.diagonal:
257
- return `M ${s.x} ${s.y} L ${(s.x + t.x) / 2} ${s.y} L ${(s.x + t.x) / 2} ${t.y} L ${t.x} ${t.y}`;
258
- case orgChartLineType.s_curve:
259
- const midX = (s.x + t.x) / 2;
260
- return `M ${s.x},${s.y} C ${midX},${s.y} ${midX},${t.y} ${t.x},${t.y}`;
261
- case orgChartLineType.arc:
262
- if (chartDirection == orgChartDirection.left) {
263
- const dx = t.x - s.x;
264
- const dy = t.y - s.y;
265
- const dr = Math.sqrt(dx * dx + dy * dy);
266
- return `M ${s.x},${s.y} A ${dr},${dr} 0 0,1 ${t.x},${t.y}`;
267
- }
268
- else if (chartDirection == orgChartDirection.right) {
269
- const dxRight = s.x - t.x; // Inverse the dx for right orientation
270
- const dyRight = t.y - s.y;
271
- const drRight = Math.sqrt(dxRight * dxRight + dyRight * dyRight);
272
- return `M ${s.x},${s.y} A ${drRight},${drRight} 0 0,0 ${t.x},${t.y}`;
273
- }
274
- case "reverse-elbow":
275
- if (chartDirection == orgChartDirection.left)
276
- return `M ${s.x} ${s.y} H ${s.x + 60} V ${t.y} H ${t.x}`;
277
- else if (chartDirection == orgChartDirection.right)
278
- return `M ${s.x} ${s.y} H ${s.x - 60} V ${t.y} H ${t.x}`;
279
- case "zigzag":
280
- if (chartDirection == orgChartDirection.left) {
281
- const midX = (s.x + t.x) / 2;
282
- return `
283
- M ${s.x},${s.y}
284
- L ${midX - 10},${s.y}
285
- L ${midX + 10},${t.y}
286
- L ${t.x},${t.y}
287
- `;
288
- }
289
- else {
290
- const midX = (s.x + t.x) / 2;
291
- return `
292
- M ${s.x},${s.y}
293
- L ${midX + 10},${s.y}
294
- L ${midX - 10},${t.y}
295
- L ${t.x},${t.y}
296
- `;
297
- }
298
- default:
299
- if (chartDirection == orgChartDirection.left)
300
- return `M ${s.x} ${s.y} H ${s.x - 25} V ${t.y} H ${t.x}`;
301
- else
302
- return `M ${s.x} ${s.y} H ${s.x + 25} V ${t.y} H ${t.x}`;
303
- }
304
- }
305
- else {
306
- return `M ${s.x} ${s.y} L ${t.x} ${t.y}`; // fallback for vertical
307
- }
308
- })
309
- .linkUpdate(function (d) {
310
- try {
311
- if (connectorVisibility) {
312
- const markerType = chartFormatOptions.plotArea.connectorType || "arrow";
313
- const isValidMarker = ["arrow", "diamond", "dot"].includes(markerType) &&
314
- chartFormatOptions.connector.lineType !== "reverse-elbow";
315
- d3.select(this)
316
- .attr("stroke-width", chartFormatOptions.connector.connectorLineThickness)
317
- .attr("stroke-dasharray", chartFormatOptions.connector.connectorStyle ===
318
- connectorStyle.solid
319
- ? 0
320
- : chartFormatOptions.connector.connectorStyle ===
321
- connectorStyle.dotted
322
- ? 1
323
- : 4)
324
- .style("stroke", chartFormatOptions.connector.connectorLineColor)
325
- .attr("marker-start", isValidMarker ? `url(#${markerType})` : null)
326
- .attr("marker-end", null); // always null to avoid showing marker at parent
327
- }
328
- else {
329
- d3.select(this)
330
- .attr("stroke-width", 0)
331
- .attr("marker-start", null)
332
- .attr("marker-end", null);
333
- }
334
- }
335
- catch (error) {
336
- logError(fileName, "drawOrganizationChart.linkUpdate", error);
337
- }
338
- })
339
- .nodeContent((d, i) => {
340
- try {
341
- let borderRadius = `${d.data.styleObject.borderRadius}px`;
342
- let transform = "";
343
- let innerWrapperStart = "";
344
- let innerWrapperEnd = "";
345
- let clipPath = "";
346
- let shapeStyle = "";
347
- switch (nodeType) {
348
- case orgChartNodeType.rounded:
349
- borderRadius = "10px";
350
- break;
351
- case orgChartNodeType.pill:
352
- borderRadius = "999px";
353
- break;
354
- case orgChartNodeType.extra_rounded:
355
- borderRadius = "20px";
356
- break;
357
- case orgChartNodeType.squircle:
358
- borderRadius = "25%";
359
- break;
360
- default:
361
- borderRadius = "1px";
362
- break;
363
- }
364
- shapeStyle = `
365
- border-width: ${d.data.styleObject.borderWidth}px
366
- border-style:${chartFormatOptions.nodes.nodesBorderVisibility
367
- ? d.data.styleObject.borderStyle
368
- : "none"}
369
- border-color:${d.data.styleObject.borderColor};
370
- border-radius: ${borderRadius};
371
- `;
372
- return `<div hoverId="${d.data.label}" style="
373
- border-width: ${d.data.styleObject.borderWidth}px;
374
- border-style:${chartFormatOptions.nodes.nodesBorderVisibility
375
- ? d.data.styleObject.borderStyle
376
- : "none"} ;
377
- border-color:${d.data.styleObject.borderColor};
378
- border-radius: ${borderRadius};
379
- width: ${d.width}px;
380
- height: ${d.height}px;
381
- padding: 5px;
382
- display: flex;
383
- flex-direction: column;
384
- justify-content: center;
385
- align-items: center;
386
- text-align: center;
387
- background-color: ${d.data.styleObject.backgroundColor
388
- ? d.data.styleObject.backgroundColor
389
- : d.data.styleObject.Color};
390
- z-index: 99;
391
- transform: ${transform};
392
- transition: unset;">
393
-
394
- ${innerWrapperStart}
395
-
396
- <div style="font-family:${d.data.styleObject.labelFont};
397
- color:${d.data.styleObject.labelFontColor};
398
- font-size:${d.data.styleObject.labelFontSize}px;
399
- font-weight:${d.data.styleObject.labelFontStyle.includes(fontStyleOptions.bold)
400
- ? "Bolder"
401
- : "normal"};
402
- font-style:${d.data.styleObject.labelFontStyle.includes(fontStyleOptions.italic)
403
- ? fontStyleOptions.italic
404
- : "normal"};
405
- text-decoration:${d.data.styleObject.labelFontStyle.includes(fontStyleOptions.underline)
406
- ? fontStyleOptions.underline
407
- : "none"};
408
- text-overflow: ellipsis;
409
- overflow: hidden;
410
- white-space: nowrap;
411
- max-width: ${d.width}px;
412
- padding: 5px;">
413
- ${i === 0
414
- ? d.data.styleObject.alias
415
- : chartFormatOptions.nodes.nodesLabelVisibility
416
- ? `${d.data.label} : ${getLabelText(d.data.styleObject.alias)}`
417
- : `${getLabelText(d.data.styleObject.alias)}`}
418
- </div>
419
-
420
- <div style="font-family:${d.data.styleObject.valueFont};
421
- color:${d.data.styleObject.valueFontColor};
422
- font-weight:${d.data.styleObject.valueFontStyle.includes(fontStyleOptions.bold)
423
- ? "Bolder"
424
- : "normal"};
425
- font-style:${d.data.styleObject.valueFontStyle.includes(fontStyleOptions.italic)
426
- ? fontStyleOptions.italic
427
- : "normal"};
428
- text-decoration:${d.data.styleObject.valueFontStyle.includes(fontStyleOptions.underline)
429
- ? fontStyleOptions.underline
430
- : "none"};
431
- font-size:${d.data.styleObject.valueFontSize}px;">
432
- ${chartFormatOptions.nodes.dataLabelNumberFormat == ",.0%"
433
- ? d.data.parentValue
434
- ? Math.round((d.data.value / d.data.parentValue) * 100) + "%"
435
- : Math.round((d.data.value / d.data.value) * 100) +
436
- "%"
437
- : getNumberWithFormatFunction(chartFormatOptions.nodes.nodesDisplayUnits, chartFormatOptions.nodes.dataLabelNumberFormat, chartFormatOptions.nodes.dataLabelDecimalPrecision)(d.data.value)}
438
- <br>
439
- ${chartFormatOptions.nodes.percentageVisibility
440
- ? +d.data.parentValue
441
- ? Math.round((d.data.value / d.data.parentValue) * 100) + "%"
442
- : Math.round((d.data.value / d.data.value) * 100) +
443
- "%"
444
- : ""}
445
- </div>
446
-
447
- ${innerWrapperEnd}
448
- </div>`;
449
- }
450
- catch (error) {
451
- logError(fileName, "drawOrganizationChart.nodeContent", error);
452
- return "";
453
- }
454
- })
455
- .buttonContent(({ node, state }) => {
456
- try {
457
- if (connectorVisibility) {
458
- return `
459
- <div
460
- style="
461
- color: black;
462
- height: 10px;
463
- width: 10px;
464
- padding: 0;
465
- font-size: 10px;
466
- margin: auto;
467
- background-color: white;
468
- display: flex;
469
- justify-content: center;
470
- align-items: center;
471
- border-radius: 50%;
472
- border: 1px solid ${node.data.styleObject.borderColor};
473
- position: relative;
474
- ">
475
- <span style="font-size: 10px; position: relative; align-items: center; top:-0.15px">
476
- ${node.children ? `-` : `+`}
477
- </span>
478
- ${!node.children
479
- ? `<span style="
480
- position: absolute;
481
- bottom: -8px;
482
- font-size: 7px;
483
- font-weight: bold;
484
- ">${node.data._directSubordinates}</span>`
485
- : ""}
486
- </div>`;
487
- }
488
- }
489
- catch (error) {
490
- logError(fileName, "drawOrganizationChart.buttonContent", error);
491
- return "";
492
- }
493
- })
494
- .childrenMargin((d) => 50)
495
- .siblingsMargin((d) => 20)
496
- .neighbourMargin((n1, n2) => 20)
497
- .duration(0)
498
- .setActiveNodeCentered(false)
499
- .data(chartData)
500
- .compact(false)
501
- .expandAll()
502
- .fit(false)
503
- .render();
504
- }
505
- catch (error) {
506
- logError(fileName, "drawOrganizationChart", error);
507
- }
508
- };
509
- const calculateNodeHeight = (d) => {
510
- try {
511
- let height;
512
- if (d.data.styleObject) {
513
- chartFormatOptions.nodes.percentageVisibility
514
- ? (height = d.data.styleObject.nodeHeight * 10 + 10)
515
- : (height = d.data.styleObject.nodeHeight * 10);
516
- return height;
517
- }
518
- }
519
- catch (error) {
520
- logError(fileName, "calculateNodeHeight", error);
521
- }
522
- };
523
- const calculateNodeWidth = (d, throughOrgData) => {
524
- try {
525
- let data = {};
526
- throughOrgData ? (data = d.data) : (data = d);
527
- let width;
528
- let staticAddition;
529
- chartFormatOptions.nodes.nodesLabelVisibility
530
- ? (staticAddition = 50)
531
- : (staticAddition = 20);
532
- if (data.styleObject) {
533
- if (chartFormatOptions.nodes.nodesLabelOverflow) {
534
- data.id == 0
535
- ? (width = data.styleObject.nodeWidth * 10 + 50)
536
- : (width = data.styleObject.nodeWidth * 10);
537
- }
538
- else {
539
- width =
540
- staticAddition +
541
- getLabelText(data.styleObject.alias).length * 10 +
542
- data.styleObject.labelFontSize * 5;
543
- }
544
- return width;
545
- }
546
- }
547
- catch (error) {
548
- logError(fileName, "calculateNodeWidth", error);
549
- }
550
- };
551
- const getLabelText = (name) => {
552
- try {
553
- let parts = name.split("-");
554
- let lastValue = parts[parts.length - 1];
555
- return lastValue;
556
- }
557
- catch (error) {
558
- logError(fileName, "getLabelText", error);
559
- }
560
- };
561
- return (_jsxs("div", { style: { width: "100%", height: "100%", position: "relative" }, children: [_jsx("svg", { id: chartId, className: "chartSVG", style: { width: "100%", height: "100%" }, ref: svgRef }), _jsx("div", { id: `floating-div${chartId}`, className: "floatingDiv", style: {
562
- position: "absolute",
563
- left: 0,
564
- top: 0,
565
- width: "100%",
566
- height: "100%",
567
- overflow: "auto",
568
- }, children: _jsx("svg", { id: `floating-${chartId}`, className: "chartSVG", ref: floatingSvgRef }) })] }));
569
- };
570
- export default OrganizationChart;