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,282 @@
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;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { IChartProps } from "../ChartsWithoutAxisTypes.types";
3
+ declare const WordCloud: React.FC<IChartProps>;
4
+ export default WordCloud;
@@ -0,0 +1,207 @@
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;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { IChartProps } from "../ChartsWithoutAxisTypes.types";
3
+ declare const DonutChart: React.FC<IChartProps>;
4
+ export default DonutChart;