pace-chart-lib 0.0.7 → 0.0.8

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,451 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ //#region Imports
3
+ import * as d3 from "d3";
4
+ import * as d3Annotation from "d3-svg-annotation";
5
+ import { useEffect, useRef } from "react";
6
+ import { logError } from "../../../../Services/ErrorLog";
7
+ import { staticLineStyle } from "../../Core/Common.types";
8
+ import { drawLegends, lineMarkers } from "../../Core/CommonFunctions";
9
+ import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, drawSeriesLabels, firstFunctionBeforeRender, getCurveType, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, initYaxisRight, lineAnnotations, marginCalculation, prepareDataForSeriesLabel, responsiveSecondaryYaxisLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight, } from "../ChartsWithAxisFunctions";
10
+ import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
11
+ const ColumnChart = ({ title, width, height, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
12
+ // adding variables as per requirement
13
+ const barWidth = 0; // coz line chart
14
+ const chartType = actualChartTypes.line;
15
+ const svgRef = useRef();
16
+ const seriesData = data;
17
+ const barChart = false;
18
+ let isSecondaryAxisDrawn = false;
19
+ const isNormalizedChart = false;
20
+ let isPrimaryAxisDrawn = true;
21
+ let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
22
+ let customYaxisMaxValue = parseFloat(formatOptions.yAxisLabel.yAxisMaxText);
23
+ let secondaryCustomYaxisMinValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMinText);
24
+ let secondaryCustomYaxisMaxValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMaxText);
25
+ let margin;
26
+ let yLabel;
27
+ let xLabel;
28
+ let yTitle;
29
+ let xTitle;
30
+ let dimensionHeightWidthArray;
31
+ let chartTitleHeight;
32
+ let secondaryAxisTitleWidth;
33
+ let legendMargin;
34
+ let secondaryYLabel;
35
+ let maxNumberForPrimaryAxis;
36
+ let maxNumberForSecondaryAxis;
37
+ let innerWidth;
38
+ let innerHeight;
39
+ let dataTable;
40
+ let dataTableHeight;
41
+ let svg;
42
+ let gTag;
43
+ let yScaleLeft;
44
+ let yScaleRight;
45
+ let xScale;
46
+ let seriesLabels;
47
+ let calculatedRange;
48
+ let seriesLabelWidth;
49
+ let yAxisLeft;
50
+ let xAxis;
51
+ let yAxisRight;
52
+ let filteredDimension;
53
+ let filteredData;
54
+ let scrollPosition = 0;
55
+ const visibleBars = 2;
56
+ let chartJSON = {
57
+ dimensionList: [],
58
+ chartType: chartType,
59
+ chartData: [],
60
+ formatOptions: formatOptions,
61
+ legendList: [],
62
+ secondaryAxisDrawn: false,
63
+ yMaxLeft: 0,
64
+ yMaxRight: 0,
65
+ yMinLeft: 0,
66
+ yMinRight: 0,
67
+ hideZeroValues: false,
68
+ formattedDimensionListMap: new Map(),
69
+ };
70
+ //#region UseEffect
71
+ useEffect(() => {
72
+ try {
73
+ createLineChart();
74
+ }
75
+ catch (error) {
76
+ logError("Linechart", "createLineChart", error);
77
+ }
78
+ }, []);
79
+ //#endregion
80
+ const createLineChart = () => {
81
+ ({ formatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
82
+ preProcessChartData(); // preaparing data related to chart creation
83
+ // Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
84
+ ({ maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } = customYscaleLabelFormatting(
85
+ // for calculating primary/secondary axis max number so that we can calculate margin accordinglt
86
+ formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight));
87
+ ({
88
+ margin,
89
+ yLabel,
90
+ xLabel,
91
+ yTitle,
92
+ xTitle,
93
+ dimensionHeightWidthArray,
94
+ chartTitleHeight,
95
+ secondaryAxisTitleWidth,
96
+ legendMargin,
97
+ secondaryYLabel,
98
+ } = marginCalculation(
99
+ // for all margin related calculations
100
+ width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart));
101
+ setSVGContainer(margin); // for innerWidth/height static width/height
102
+ ({ dataTable, dataTableHeight } = dataTablePreCalculation(
103
+ // calculations for data tables
104
+ formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
105
+ initSvg(
106
+ // for svg creation
107
+ svg, width, height, formatOptions);
108
+ gTag = initChartArea(svg, margin); // creating chart area
109
+ initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
110
+ initScale();
111
+ initAxis();
112
+ initYaxis(gTag, formatOptions, dataTableHeight, yLabel, yAxisLeft, innerHeight);
113
+ initYaxisRight(gTag, formatOptions, dataTableHeight, secondaryYLabel, yAxisRight, innerHeight, innerWidth);
114
+ horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
115
+ if (formatOptions.dataTableProperties &&
116
+ formatOptions.dataTableProperties.dataTable) {
117
+ if (formatOptions.xAxisLabel.xAxisPosition != 1)
118
+ formatOptions.xAxisLabel.xAxisLabelVisibility = false;
119
+ addDataTable(formatOptions.plotArea.fitChart, svg, gTag, dataTable, barWidth, yScaleLeft, xScale, undefined, undefined, undefined, dataTableHeight, "Line", formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, innerHeight);
120
+ }
121
+ setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
122
+ yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
123
+ yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
124
+ setChartTitle(svg, formatOptions, width, chartTitleHeight);
125
+ drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId);
126
+ };
127
+ const preProcessChartData = () => {
128
+ const allChartData = [];
129
+ const legendList = [];
130
+ const dimensionSet = new Set();
131
+ let formatedDimesionList = [];
132
+ let yMaxLeft = -Infinity;
133
+ let yMinLeft = Infinity;
134
+ let yMaxRight = -Infinity;
135
+ let yMinRight = Infinity;
136
+ seriesData.forEach((series) => {
137
+ legendList.push(series.legend);
138
+ series.data.forEach((point) => {
139
+ allChartData.push(point);
140
+ dimensionSet.add(point.dimension);
141
+ if (series.properties.axis === "Secondary") {
142
+ isSecondaryAxisDrawn = true;
143
+ yMaxRight = Math.max(yMaxRight, point.value);
144
+ yMinRight = Math.min(yMinRight, point.value);
145
+ }
146
+ else {
147
+ yMaxLeft = Math.max(yMaxLeft, point.value);
148
+ yMinLeft = Math.min(yMinLeft, point.value);
149
+ }
150
+ });
151
+ });
152
+ chartJSON.chartData = allChartData;
153
+ chartJSON.legendList = legendList;
154
+ chartJSON.dimensionList = Array.from(dimensionSet);
155
+ chartJSON.yMaxLeft = yMaxLeft;
156
+ chartJSON.yMinLeft = yMinLeft;
157
+ chartJSON.yMaxRight = yMaxRight;
158
+ chartJSON.yMinRight = yMinRight;
159
+ // Apply formatted dimensions
160
+ let xAxisObject = xAxisObj[0];
161
+ formatedDimesionList =
162
+ (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
163
+ xAxisObject.dataType === "DATE"
164
+ ? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d[0])
165
+ : chartJSON.dimensionList;
166
+ chartJSON.dimensionList.forEach((dim, i) => {
167
+ chartJSON.formattedDimensionListMap.set(dim, formatedDimesionList[i]);
168
+ });
169
+ filteredData = JSON.parse(JSON.stringify(seriesData));
170
+ // if (formatOptions.scrollChart.scrollX) {
171
+ if (false) {
172
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
173
+ }
174
+ else {
175
+ filteredDimension = chartJSON.dimensionList;
176
+ }
177
+ if (formatOptions.plotArea.hideZeroValues) {
178
+ chartJSON.hideZeroValues = true;
179
+ }
180
+ };
181
+ const initScale = () => {
182
+ // rounding the ymin & ymax
183
+ let yAxisLabelArray = responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray;
184
+ chartJSON.yMaxLeft = yAxisLabelArray[yAxisLabelArray.length - 1];
185
+ chartJSON.yMinLeft = yAxisLabelArray[0];
186
+ if (isPrimaryAxisDrawn) {
187
+ yScaleLeft = d3
188
+ .scaleLinear()
189
+ .domain([
190
+ customYaxisMinValue !== undefined &&
191
+ !Number.isNaN(customYaxisMinValue)
192
+ ? customYaxisMinValue
193
+ : chartJSON.yMinLeft < 0
194
+ ? chartJSON.yMinLeft * 1.1
195
+ : chartJSON.yMinLeft * 0.9,
196
+ chartJSON.yMaxLeft <= 0
197
+ ? 0
198
+ : customYaxisMaxValue !== undefined &&
199
+ !Number.isNaN(customYaxisMaxValue)
200
+ ? customYaxisMaxValue
201
+ : chartJSON.yMaxLeft * 1.1,
202
+ ])
203
+ .range([
204
+ dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
205
+ 0,
206
+ ]);
207
+ }
208
+ if (isSecondaryAxisDrawn) {
209
+ yScaleRight = d3
210
+ .scaleLinear()
211
+ .domain([
212
+ chartJSON.yMinRight >= 0
213
+ ? (secondaryCustomYaxisMinValue ||
214
+ secondaryCustomYaxisMinValue == 0) &&
215
+ !Number.isNaN(secondaryCustomYaxisMinValue)
216
+ ? secondaryCustomYaxisMinValue
217
+ : 0
218
+ : (secondaryCustomYaxisMinValue ||
219
+ secondaryCustomYaxisMinValue == 0) &&
220
+ !Number.isNaN(secondaryCustomYaxisMinValue)
221
+ ? secondaryCustomYaxisMinValue
222
+ : chartJSON.yMinRight * 1.1,
223
+ chartJSON.yMaxRight <= 0
224
+ ? secondaryCustomYaxisMaxValue
225
+ ? secondaryCustomYaxisMaxValue
226
+ : 0
227
+ : secondaryCustomYaxisMaxValue
228
+ ? secondaryCustomYaxisMaxValue
229
+ : chartJSON.yMaxRight * 1.1,
230
+ ])
231
+ .range([
232
+ dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
233
+ 0,
234
+ ]);
235
+ }
236
+ calculatedRange = [0, innerWidth];
237
+ if (formatOptions.seriesLabel.seriesLabelVisibility) {
238
+ let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn);
239
+ seriesLabels = labelObj.labelArray;
240
+ formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
241
+ (seriesLabelWidth = labelObj.heightWidth[0]);
242
+ formatOptions.seriesLabel.seriesLabelPosition == "Right"
243
+ ? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
244
+ : (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
245
+ }
246
+ getXScale();
247
+ };
248
+ const getXScale = () => {
249
+ xScale = d3
250
+ .scalePoint()
251
+ .domain(filteredDimension)
252
+ .range(calculatedRange)
253
+ .padding(0.5);
254
+ };
255
+ const initAxis = () => {
256
+ getXAxis();
257
+ if (isPrimaryAxisDrawn) {
258
+ yAxisLeft = d3
259
+ .axisLeft(yScaleLeft)
260
+ .tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
261
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
262
+ ? formatOptions.plotArea.gridLinesHorizontal
263
+ ? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
264
+ : 0
265
+ : 0)
266
+ .tickValues(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray)
267
+ .ticks(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).customTickValue ??
268
+ (dataTableHeight > 0
269
+ ? (innerHeight - dataTableHeight) / 30
270
+ : innerHeight / 30))
271
+ .tickSizeOuter(0);
272
+ }
273
+ if (isSecondaryAxisDrawn) {
274
+ yAxisRight = d3
275
+ .axisRight(yScaleRight)
276
+ .tickFormat((d) => getNumberWithFormat(d, formatOptions.secondaryYAxisLabel.secondaryYAxisDisplayUnits, formatOptions.secondaryYAxisLabel.secondaryYAxisNumberFormat, formatOptions.secondaryYAxisLabel
277
+ .secondaryYAxisLabelDecimalPrecision))
278
+ .tickValues(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
279
+ ? secondaryCustomYaxisMaxValue
280
+ : chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryYAxisLabelArray)
281
+ .ticks(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
282
+ ? secondaryCustomYaxisMaxValue
283
+ : chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryCustomTickValue ?? innerHeight / 30)
284
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
285
+ ? formatOptions.plotArea.gridLinesHorizontal
286
+ ? -innerWidth
287
+ : 0
288
+ : 0)
289
+ .tickSizeOuter(0);
290
+ }
291
+ };
292
+ const getXAxis = () => {
293
+ xAxis = d3
294
+ .axisBottom(xScale)
295
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
296
+ ? formatOptions.plotArea.gridLinesVeritcal
297
+ ? formatOptions.plotArea.gridLinesVeritcal
298
+ ? -(dataTableHeight > 0
299
+ ? innerHeight - dataTableHeight
300
+ : innerHeight)
301
+ : formatOptions.plotArea.ticksHeight *
302
+ ((dataTableHeight > 0
303
+ ? innerHeight - dataTableHeight
304
+ : innerHeight) /
305
+ 100) *
306
+ (formatOptions.xAxisLabel.xAxisPosition == 1 ? 1 : -1)
307
+ : 0
308
+ : 0)
309
+ .tickSizeOuter(0)
310
+ .tickValues(responsiveXaxisLabel(filteredDimension, innerWidth));
311
+ };
312
+ const getChartType = (lineData) => {
313
+ lineData.forEach((lData) => {
314
+ lData.data.forEach((cData) => {
315
+ cData.hideZero = lData.properties.hideZeroValues;
316
+ cData.axis = lData.properties.axis;
317
+ });
318
+ });
319
+ const lineGenerator = d3
320
+ .line()
321
+ .x((d) => xScale(d.dimension)
322
+ ? xScale(d.dimension)
323
+ : null)
324
+ .y((d) => d.axis == "Primary"
325
+ ? yScaleLeft(d.value)
326
+ : yScaleRight(d.value))
327
+ .defined((d) => (d.hideZero ? Boolean(d.value) : true))
328
+ .curve(getCurveType(formatOptions));
329
+ // Bind dummy data to ensure a single group is created
330
+ let lines = gTag.selectAll(".parentGroup").data([lineData]);
331
+ lines = lines
332
+ .enter()
333
+ .append("g")
334
+ .attr("class", "lines parentGroup")
335
+ .merge(lines);
336
+ // JOIN: one group per line
337
+ let lineGroups = lines.selectAll(".line-group").data((d) => d);
338
+ // ENTER: create group for each new line
339
+ let lineGroupsEnter = lineGroups
340
+ .enter()
341
+ .append("g")
342
+ .attr("class", "line-group");
343
+ // Append path to new groups
344
+ lineGroupsEnter
345
+ .attr("hoverId", (d) => d.legend.replace(/ /g, "-"))
346
+ .append("path")
347
+ .attr("class", "line")
348
+ .attr("fill", "none");
349
+ // ENTER + UPDATE
350
+ lineGroupsEnter
351
+ .merge(lineGroups)
352
+ .select("path")
353
+ .attr("d", (d) => lineGenerator(d.data))
354
+ .attr("stroke", (d) => d.properties.color !== "#ffffff" ? d.properties.color : "none")
355
+ .attr("stroke-dasharray", (d) => {
356
+ switch (d.properties.lineStyle) {
357
+ case staticLineStyle.dotted:
358
+ return "0,3";
359
+ case staticLineStyle.dashed:
360
+ return "20,10,5,5,5,10";
361
+ default:
362
+ return "";
363
+ }
364
+ })
365
+ .attr("stroke-linecap", (d) => d.properties.lineStyle === staticLineStyle.dotted ? "round" : "")
366
+ .attr("stroke-width", (d) => d.properties.lineStyle !== "None" ? d.properties.lineWidth : "0");
367
+ // EXIT: remove old groups
368
+ lineGroups.exit().remove();
369
+ //Markers
370
+ lineMarkers(lines, lineData, "None", xScale, yScaleLeft, yScaleRight, null, formatOptions, chartJSON, secondaryCustomYaxisMaxValue, secondaryCustomYaxisMinValue, customYaxisMinValue, customYaxisMaxValue);
371
+ };
372
+ const setSVGContainer = (margin) => {
373
+ innerWidth = width - margin.left - margin.right;
374
+ innerHeight = height - margin.bottom - margin.top;
375
+ };
376
+ const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
377
+ // if (formatOptions.scrollChart.scrollX) {
378
+ if (false) {
379
+ // Scrollbar parameters
380
+ const scrollMax = seriesData[0].data.length - visibleBars;
381
+ // Scrollbar track & handle
382
+ const scrollbarY = height - 20;
383
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
384
+ getXScale();
385
+ filteredData = JSON.parse(JSON.stringify(seriesData));
386
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
387
+ getXAxis();
388
+ svg
389
+ .append("rect")
390
+ .attr("x", margin.left)
391
+ .attr("y", scrollbarY)
392
+ .attr("width", innerWidth)
393
+ .attr("height", 8)
394
+ .attr("fill", "#ddd")
395
+ .attr("rx", 4);
396
+ const handleWidth = (innerWidth * visibleBars) / seriesData.length;
397
+ const handle = svg
398
+ .append("rect")
399
+ .attr("x", margin.left)
400
+ .attr("y", scrollbarY)
401
+ .attr("width", handleWidth)
402
+ .attr("height", 8)
403
+ .attr("fill", "#999")
404
+ .attr("rx", 4)
405
+ .style("cursor", "ew-resize")
406
+ .call(d3.drag().on("drag", (event) => {
407
+ let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
408
+ handle.attr("x", x);
409
+ scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
410
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
411
+ getXScale();
412
+ filteredData = JSON.parse(JSON.stringify(seriesData));
413
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
414
+ getXAxis();
415
+ drawLineChart();
416
+ }));
417
+ svg.on("wheel", (event) => {
418
+ event.preventDefault();
419
+ const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
420
+ ? event.deltaX
421
+ : event.deltaY;
422
+ scrollPosition += scrollDelta > 0 ? 1 : -1;
423
+ scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
424
+ const x = margin.left +
425
+ ((innerWidth - handleWidth) * scrollPosition) / scrollMax;
426
+ handle.attr("x", x);
427
+ getXScale();
428
+ filteredData = JSON.parse(JSON.stringify(seriesData));
429
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
430
+ getXAxis();
431
+ drawLineChart();
432
+ });
433
+ }
434
+ drawLineChart();
435
+ };
436
+ const drawLineChart = () => {
437
+ // filteredData.forEach((data) => getChartType([data]));
438
+ getChartType(filteredData);
439
+ initXaxis(gTag, chartJSON, xLabel, formatOptions, xAxisObj[0], dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, xAxisObj[0].dataType, innerWidth, innerHeight, filteredDimension);
440
+ lineAnnotations(seriesData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
441
+ margin, d3Annotation, [], //this.labelExcludeList,
442
+ [], //this.individualLabelColor,
443
+ [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
444
+ formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg);
445
+ let newSeriesLabelArray = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn).labelArray;
446
+ // adding series labels ( appending legends at the end of line : by default) in plot area
447
+ drawSeriesLabels(formatOptions, gTag, newSeriesLabelArray);
448
+ };
449
+ return (_jsxs("div", { children: [_jsx("div", { id: "chartTooltipDiv" }), _jsx("svg", { className: "chartSVG", ref: svgRef, id: chartId, width: width, height: height })] }));
450
+ };
451
+ export default ColumnChart;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { type TChartProps } from "../ChartsWithAxisTypes.types";
3
+ declare const NormalizedStackColumnChart: React.FC<TChartProps>;
4
+ export default NormalizedStackColumnChart;