pace-chart-lib 1.0.1 → 1.0.3

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,282 +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 * as venn from "venn.js";
5
- import { useEffect, useRef } from "react";
6
- import { fontStyleOptions, staticLegendShape, staticLegendPosition, } from "../../Core/Common.types";
7
- import { convertStringToNumber, drawChartTitle, firstFunctionBeforeRender, generalizedChartData, getNumberWithFormatFunction, hideTooltipOnMouseOut, initChartArea, initSvg, legendsWithScroll, marginCalculationsForChartsWithoutAxis, preCalculateTextDimensions, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
8
- import { chartMargins } from "../../Core/DefaultProperties.types";
9
- import { logError } from "../../../../Services/ErrorLog";
10
- //#endregion
11
- const VennChart = ({ data, formatOptions, chartId, }) => {
12
- //#region Variables
13
- const svgRef = useRef(); // Reference to the SVG element
14
- let seriesData = generalizedChartData(data); // Data for the word cloud, expected to be an array of objects with properties
15
- let chartFormatOptions; // Format options for the chart
16
- let width; // svg total width
17
- let height; // svg total height
18
- let chartTitleHeight = 40; // Height of the chart title
19
- let margins = chartMargins; // Margins for the chart
20
- let innerHeight; // Height of the chart excluding margins
21
- let innerWidth; // Width of the chart excluding margins
22
- let legendListWidth;
23
- let maxLegendDimensions = [0, 0]; // to calculate margins [width, height]
24
- let chartAreaTagG; // Group element for the chart area
25
- let svg; // SVG element for the chart
26
- //#endregion
27
- useEffect(() => {
28
- drawChart();
29
- }, [formatOptions]);
30
- const drawChart = () => {
31
- ({ chartFormatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
32
- maxLegendDimensions = calculateLegendsMaxPossibleWidth();
33
- ({ margins, innerHeight, innerWidth, legendListWidth, chartTitleHeight } =
34
- marginCalculationsForChartsWithoutAxis(chartFormatOptions, width, height, maxLegendDimensions, margins, true));
35
- initSvg(svgRef, width, height, chartFormatOptions); // Initialize SVG with width, height and background color
36
- chartAreaTagG = initChartArea(svg, margins);
37
- drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
38
- drawVennDiagramChart();
39
- initLegendListWithTotalValueAllowance();
40
- };
41
- const drawVennDiagramChart = () => {
42
- try {
43
- let fontStyleName = chartFormatOptions.plotArea.dataLabelNameFontStyle;
44
- let fontStyleValue = chartFormatOptions.plotArea.dataLabelValueFontStyle;
45
- // draw venn diagram
46
- let vennContainer = chartAreaTagG.attr("class", "vennContainer");
47
- vennContainer &&
48
- vennContainer
49
- .datum(data)
50
- .call(venn.VennDiagram().width(innerWidth).height(innerHeight));
51
- //Adding hoverId to paths
52
- // vennContainer &&
53
- // vennContainer
54
- // .selectAll(".venn-area.venn-circle")
55
- // .attr("hoverId", (d: any) =>
56
- // `${d.legendDisplay} : ${d.size}`.replace(/ /g, "-")
57
- // );
58
- // vennContainer &&
59
- // vennContainer
60
- // .selectAll(".venn-area.venn-intersection")
61
- // .attr("hoverId", (d: any) =>
62
- // `${d.legendDisplay} : ${d.size}`.replace(/ /g, "-")
63
- // );
64
- // vennContainer &&
65
- // vennContainer
66
- // .selectAll(".path")
67
- // .attr("hoverId", (d: any) =>
68
- // `${d.legendDisplay} : ${d.size}`.replace(/ /g, "-")
69
- // );
70
- vennContainer &&
71
- vennContainer
72
- .selectAll(".venn-circle path")
73
- .style("fill-opacity", chartFormatOptions.plotArea.opacity);
74
- if (chartFormatOptions.plotArea.dataLabelName) {
75
- vennContainer && vennContainer.selectAll(".venn-circle text").html("");
76
- vennContainer &&
77
- vennContainer
78
- .selectAll(".venn-circle text")
79
- .append("tspan")
80
- .style("font-family", chartFormatOptions.plotArea.dataLabelNameFontFamily)
81
- .style("fill", chartFormatOptions.plotArea.dataLabelNameColor)
82
- .style("font-size", chartFormatOptions.plotArea.dataLabelNameFontSize + "px")
83
- .style("font-style", fontStyleName.includes(fontStyleOptions.italic)
84
- ? fontStyleOptions.italic
85
- : "")
86
- .attr("text-decoration", fontStyleName.includes(fontStyleOptions.underline)
87
- ? fontStyleOptions.underline
88
- : "")
89
- .style("font-weight", fontStyleName.includes(fontStyleOptions.bold)
90
- ? fontStyleOptions.bold
91
- : "")
92
- .html((d) => d.label)
93
- .attr("visibility", chartFormatOptions.plotArea.dataLabelName ? "visible" : "hidden");
94
- }
95
- else {
96
- vennContainer &&
97
- vennContainer
98
- .selectAll(".venn-circle text")
99
- .style("visibility", "hidden");
100
- vennContainer && vennContainer.selectAll(".venn-circle text").html("");
101
- }
102
- //text formatting options
103
- if (chartFormatOptions.plotArea.dataLabelValue) {
104
- vennContainer &&
105
- vennContainer
106
- .selectAll(".venn-circle text")
107
- .append("tspan")
108
- .attr("font-size", chartFormatOptions.plotArea.dataLabelValueFontSize)
109
- .attr("fill", chartFormatOptions.plotArea.dataLabelValueColor !== "#ffffff"
110
- ? chartFormatOptions.plotArea.dataLabelValueColor
111
- : "none")
112
- .style("font-style", fontStyleValue.includes(fontStyleOptions.italic)
113
- ? fontStyleOptions.italic
114
- : "normal")
115
- .attr("text-decoration", fontStyleValue.includes(fontStyleOptions.underline)
116
- ? fontStyleOptions.underline
117
- : "none")
118
- .style("font-weight", fontStyleValue.includes(fontStyleOptions.bold)
119
- ? fontStyleOptions.bold
120
- : "normal")
121
- .attr("font-family", chartFormatOptions.plotArea.dataLabelValueFontFamily)
122
- .attr("fill-opacity", 0.5)
123
- .html((d) => d.actualValue !== undefined
124
- ? (chartFormatOptions.plotArea.dataLabelName ? " : " : "") +
125
- d3.format(chartFormatOptions.plotArea.dataLabelNumberFormat)(d.actualValue)
126
- : "")
127
- .attr("visibility", chartFormatOptions.plotArea.dataLabelValue ? "visible" : "hidden");
128
- }
129
- if (chartFormatOptions.plotArea.intersectionLabelVisibility) {
130
- vennContainer &&
131
- vennContainer.selectAll(".venn-intersection text").html("");
132
- vennContainer &&
133
- vennContainer
134
- .selectAll(".venn-intersection text")
135
- .append("tspan")
136
- .style("font-family", chartFormatOptions.plotArea.dataLabelNameFontFamily)
137
- .style("fill", chartFormatOptions.plotArea.dataLabelNameColor)
138
- .style("font-size", chartFormatOptions.plotArea.dataLabelNameFontSize + "px")
139
- .style("font-style", fontStyleName.includes(fontStyleOptions.italic)
140
- ? fontStyleOptions.italic
141
- : "")
142
- .attr("text-decoration", fontStyleName.includes(fontStyleOptions.underline)
143
- ? fontStyleOptions.underline
144
- : "")
145
- .style("font-weight", fontStyleName.includes(fontStyleOptions.bold)
146
- ? fontStyleOptions.bold
147
- : "")
148
- .html((d) => d.label)
149
- .attr("visibility", chartFormatOptions.plotArea.intersectionLabelVisibility
150
- ? "visible"
151
- : "hidden");
152
- }
153
- else {
154
- vennContainer &&
155
- vennContainer
156
- .selectAll(".venn-intersection text")
157
- .style("visibility", "hidden");
158
- vennContainer &&
159
- vennContainer.selectAll(".venn-intersection text").html("");
160
- }
161
- //text formatting options
162
- if (chartFormatOptions.plotArea.intersectionValueVisibility) {
163
- vennContainer &&
164
- vennContainer
165
- .selectAll(".venn-intersection text")
166
- .append("tspan")
167
- .attr("font-size", chartFormatOptions.plotArea.dataLabelValueFontSize)
168
- .attr("fill", chartFormatOptions.plotArea.dataLabelValueColor !== "#ffffff"
169
- ? chartFormatOptions.plotArea.dataLabelValueColor
170
- : "none")
171
- .style("font-style", fontStyleValue.includes(fontStyleOptions.italic)
172
- ? fontStyleOptions.italic
173
- : "normal")
174
- .attr("text-decoration", fontStyleValue.includes(fontStyleOptions.underline)
175
- ? fontStyleOptions.underline
176
- : "none")
177
- .style("font-weight", fontStyleValue.includes(fontStyleOptions.bold)
178
- ? fontStyleOptions.bold
179
- : "normal")
180
- .attr("font-family", chartFormatOptions.plotArea.dataLabelValueFontFamily)
181
- .attr("font-weight", 300)
182
- .attr("fill-opacity", 0.5)
183
- .html((d) => d.actualValue !== undefined
184
- ? (chartFormatOptions.plotArea.dataLabelName ? " : " : "") +
185
- d3.format(chartFormatOptions.plotArea.dataLabelNumberFormat)(d.actualValue)
186
- : "")
187
- .attr("visibility", chartFormatOptions.plotArea.intersectionValueVisibility
188
- ? "visible"
189
- : "hidden");
190
- }
191
- // to get the color of legendEntries to the venn dia
192
- vennContainer &&
193
- vennContainer
194
- .selectAll(".venn-circle path")
195
- .style("fill", (d) => d.properties ? d.properties.color : null);
196
- vennContainer &&
197
- vennContainer
198
- .selectAll("g")
199
- .on("mousemove", function (event, d) {
200
- showTooltipOnMouseMove([
201
- {
202
- key: d.label,
203
- value: getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.size),
204
- },
205
- ], chartFormatOptions);
206
- // highlight the current path
207
- let selection = d3.select(this).transition("tooltip").duration(10);
208
- selection
209
- .selectAll("path")
210
- .style("stroke-dasharray", "5,5")
211
- .style("stroke-opacity", 1)
212
- .style("stroke", "black");
213
- })
214
- .on("mouseout", function (d, i) {
215
- hideTooltipOnMouseOut();
216
- var selection = d3.select(this).transition("tooltip").duration(400);
217
- selection
218
- .select("path")
219
- .style("stroke-width", 0)
220
- .style("stroke-opacity", 0);
221
- });
222
- }
223
- catch (error) {
224
- logError("VennChart.tsx", "drawVennDiagramChart", error);
225
- }
226
- };
227
- const calculateLegendsMaxPossibleWidth = () => {
228
- try {
229
- let maxWidth = 0;
230
- let maxHeight = 0;
231
- seriesData.forEach((series) => {
232
- if (series.legendDisplay) {
233
- let textDimensions = preCalculateTextDimensions(series.legendDisplay + " : " + series.actualValue, convertStringToNumber(chartFormatOptions.legends.legendFontSize), chartFormatOptions.legends.legendFontFamily);
234
- maxWidth = Math.max(maxWidth, textDimensions.width);
235
- maxHeight = Math.max(maxHeight, textDimensions.height);
236
- }
237
- });
238
- return [maxWidth, maxHeight];
239
- }
240
- catch (error) {
241
- logError("VennChart.tsx", "calculateLegendsMaxPossibleWidth", error);
242
- return [0, 0];
243
- }
244
- };
245
- const initLegendListWithTotalValueAllowance = () => {
246
- try {
247
- let position = chartFormatOptions.legends.legendPosition;
248
- let horizontalLegendAlignment = chartFormatOptions.legends.legendAlignmentTopBottom;
249
- let verticalLegendAlignment = chartFormatOptions.legends.legendAlignment;
250
- switch (position) {
251
- case staticLegendPosition.none:
252
- break;
253
- case staticLegendPosition.right:
254
- legendsWithScroll(svg, seriesData, width - legendListWidth - 25, chartTitleHeight + 5, legendListWidth + 15, height - chartTitleHeight - 10, position, verticalLegendAlignment, staticLegendShape.none, chartFormatOptions, chartId, true);
255
- break;
256
- case staticLegendPosition.top:
257
- legendsWithScroll(svg, seriesData, 5, chartTitleHeight + 5, width - 10, 30, position, horizontalLegendAlignment, staticLegendShape.none, chartFormatOptions, chartId, true);
258
- break;
259
- case staticLegendPosition.left:
260
- legendsWithScroll(svg, seriesData, 5, margins.top, legendListWidth + 15, height - chartTitleHeight - 10, position, verticalLegendAlignment, staticLegendShape.none, chartFormatOptions, chartId, true);
261
- break;
262
- case staticLegendPosition.bottom:
263
- legendsWithScroll(svg, seriesData, 5, height - 35, width - 10, 30, position, horizontalLegendAlignment, staticLegendShape.none, chartFormatOptions, chartId, true);
264
- break;
265
- }
266
- }
267
- catch (error) {
268
- logError("VennChart.tsx", "initLegendListWithTotalValueAllowance", error);
269
- }
270
- };
271
- // return (
272
- // <div style={{ width: "100%", height: "100%" }}>
273
- // <svg
274
- // className="chartSVG"
275
- // style={{ width: "100%", height: "100%" }}
276
- // ref={svgRef}
277
- // ></svg>
278
- // </div>
279
- // );
280
- return (_jsxs("div", { style: { width: "100%", height: "100%" }, children: [_jsx("div", { id: "chartTooltipDiv" }), _jsx("svg", { className: "chartSVG", ref: svgRef, id: chartId, style: { width: "100%", height: "100%" } })] }));
281
- };
282
- export default VennChart;
@@ -1,207 +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 cloud from "d3-cloud";
5
- import { useEffect, useRef } from "react";
6
- import { drawChartTitle, firstFunctionBeforeRender, generalizedChartData, getNumberWithFormatFunction, hideTooltipOnMouseOut, initChartArea, initSvg, marginCalculationsForChartsWithoutLegends, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
7
- import { chartMargins } from "../../Core/DefaultProperties.types";
8
- import { logError } from "../../../../Services/ErrorLog";
9
- //#endregion
10
- const fileName = "WordCloud.tsx";
11
- const WordCloud = ({ data, formatOptions, chartId }) => {
12
- //#region Variables
13
- const svgRef = useRef(); // Reference to the SVG element
14
- let seriesData = generalizedChartData(data); // Data for the word cloud, expected to be an array of objects with properties
15
- let chartFormatOptions; // Format options for the chart
16
- let width; // svg total width
17
- let height; // svg total height
18
- let min = Number.MAX_VALUE; // svg total height
19
- let max = Number.MIN_VALUE; // svg total height
20
- let chartTitleHeight = 40; // Height of the chart title
21
- let margins = chartMargins; // Margins for the chart
22
- let innerHeight; // Height of the chart excluding margins
23
- let innerWidth; // Width of the chart excluding margins
24
- let chartAreaTagG; // Group element for the chart area
25
- let svg; // SVG element for the chart
26
- let scale; // Scale for the font size based on data values
27
- let totalMeasureValue = 0;
28
- //#endregion
29
- useEffect(() => {
30
- drawChart();
31
- }, [formatOptions]);
32
- const drawChart = () => {
33
- ({ chartFormatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
34
- ({ margins, chartTitleHeight, innerHeight, innerWidth } =
35
- marginCalculationsForChartsWithoutLegends(chartFormatOptions, height, width));
36
- initSvg(svgRef, width, height, chartFormatOptions); // Initialize SVG with width, height and background color
37
- chartAreaTagG = initChartArea(svg, margins);
38
- drawChartTitle(svgRef, chartTitleHeight, width, chartFormatOptions);
39
- calculateWordCloudData(seriesData);
40
- drawWordCloudChart();
41
- };
42
- const calculateWordCloudData = (seriesData) => {
43
- try {
44
- totalMeasureValue = 0;
45
- seriesData = seriesData.map((item) => {
46
- let value = item.data[0].value;
47
- totalMeasureValue += value;
48
- if (value < min) {
49
- min = value;
50
- }
51
- if (value > max) {
52
- max = value;
53
- }
54
- if (chartFormatOptions.plotArea.hideZeroValues && item[0].value != 0) {
55
- return null; // Filter out zero values if hideZeroValues is true
56
- }
57
- else {
58
- return item;
59
- }
60
- });
61
- seriesData = seriesData.filter((item) => item !== null); // Remove null values
62
- scale = d3.scaleLinear().domain([min, max]).range([12, 70]);
63
- }
64
- catch (error) {
65
- logError(fileName, "calculateWordCloudData", error);
66
- }
67
- };
68
- const drawWordCloudChart = () => {
69
- try {
70
- let spacing = chartFormatOptions.text.textSpacing;
71
- let rotation = chartFormatOptions.text.textRotation;
72
- let layout = cloud()
73
- .size([innerWidth, innerHeight])
74
- .words(seriesData)
75
- .padding(spacing)
76
- .rotate(function () {
77
- try {
78
- return Math.round(Math.random()) * rotation;
79
- }
80
- catch (error) {
81
- logError(fileName, "rotate", error);
82
- return 0;
83
- }
84
- })
85
- .random(() => 0.5)
86
- .font(chartFormatOptions.text.textFontFamily)
87
- .fontWeight("bolder")
88
- .fontSize(function (d) {
89
- try {
90
- return scale(d.data[0].value);
91
- }
92
- catch (error) {
93
- logError(fileName, "fontSize", error);
94
- return 12;
95
- }
96
- })
97
- .text(function (d) {
98
- try {
99
- return d.properties.alias;
100
- }
101
- catch (error) {
102
- logError(fileName, "text", error);
103
- return "";
104
- }
105
- })
106
- .on("end", draw);
107
- layout.start();
108
- function draw(words) {
109
- try {
110
- chartAreaTagG
111
- .append("g")
112
- .attr("transform", "translate(" +
113
- layout.size()[0] / 2 +
114
- "," +
115
- layout.size()[1] / 2 +
116
- ")")
117
- .selectAll("text")
118
- .data(words)
119
- .enter()
120
- .append("text")
121
- .attr("font-size", function (d) {
122
- try {
123
- return scale(d.data[0].value) + "px";
124
- }
125
- catch (error) {
126
- logError(fileName, "draw-font-size", error);
127
- return "12px";
128
- }
129
- })
130
- .attr("text-anchor", "middle")
131
- .style("font-family", chartFormatOptions.text.textFontFamily)
132
- .attr("fill", function (d) {
133
- try {
134
- return d.properties.color !== "#ffffff"
135
- ? d.properties.color
136
- : "none";
137
- }
138
- catch (error) {
139
- logError(fileName, "draw-fill", error);
140
- return "none";
141
- }
142
- })
143
- .attr("transform", function (d) {
144
- try {
145
- return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
146
- }
147
- catch (error) {
148
- logError(fileName, "draw-transform", error);
149
- return "";
150
- }
151
- })
152
- .text(function (d) {
153
- try {
154
- return d.properties.alias;
155
- }
156
- catch (error) {
157
- logError(fileName, "draw-text", error);
158
- return "";
159
- }
160
- })
161
- .on("mousemove.text", (mouseEvent, d) => {
162
- try {
163
- showTooltipOnMouseMove([
164
- {
165
- key: d.properties.alias,
166
- value: getNumberWithFormatFunction("None", chartFormatOptions.toolTip.toolTipNumberFormat, chartFormatOptions.toolTip.toolTipDecimalPrecision)(d.data[0].value),
167
- },
168
- {
169
- key: d.properties.measureUniqueId,
170
- value: totalMeasureValue,
171
- },
172
- ], chartFormatOptions);
173
- }
174
- catch (error) {
175
- logError(fileName, "draw-mousemove", error);
176
- }
177
- })
178
- .on("mouseout.text", () => {
179
- try {
180
- hideTooltipOnMouseOut();
181
- }
182
- catch (error) {
183
- logError(fileName, "draw-mouseout", error);
184
- }
185
- });
186
- }
187
- catch (error) {
188
- logError(fileName, "draw", error);
189
- }
190
- }
191
- }
192
- catch (e) {
193
- logError(fileName, "drawWordCloudChart", e);
194
- }
195
- };
196
- // return (
197
- // <div style={{ width: "100%", height: "100%" }}>
198
- // <svg
199
- // className="chartSVG"
200
- // style={{ width: "100%", height: "100%" }}
201
- // ref={svgRef}
202
- // ></svg>
203
- // </div>
204
- // );
205
- return (_jsxs("div", { style: { width: "100%", height: "100%" }, children: [_jsx("div", { id: "chartTooltipDiv" }), _jsx("svg", { className: "chartSVG", ref: svgRef, id: chartId, style: { width: "100%", height: "100%" } })] }));
206
- };
207
- export default WordCloud;