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,554 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ //#region Imports
3
+ import { useEffect, useRef } from "react";
4
+ import * as d3 from "d3";
5
+ import * as d3Annotation from "d3-svg-annotation";
6
+ import { marginCalculation, initSvg, initChartArea, getNumberWithFormat, initYaxis, responsiveXaxisLabel, initXaxis, setDateFormats,
7
+ // initScrollingSvgClippath,
8
+ drawSeriesLabels, setXaxistitle, yAxistitle, setChartTitle,
9
+ // responsiveSecondaryYaxisLabel,
10
+ dataTablePreCalculation, setChartFloatingSVGContainer, addDataTable, initPlotArea, yAxistitleRight, getCurveType, getStackedData, prepareDataForSeriesLabel, stacklineAnnotations, } from "../ChartsWithAxisFunctions";
11
+ import { legendsWithScroll, lineMarkers, } from "../../Core/CommonFunctions";
12
+ import { legendShape } from "../../Core/Common.types";
13
+ import { logError } from "../../../../Services/ErrorLog";
14
+ const NormalisedStackLineChart = ({ title, width, height, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
15
+ // adding variables as per requirement
16
+ const barWidth = 0; // coz line chart
17
+ const chartType = "NormalizedStackLine";
18
+ const svgRef = useRef();
19
+ const seriesData = data;
20
+ const barChart = false;
21
+ const chartsWithXScrollFlag = true;
22
+ const chartsWithYScrollFlag = false;
23
+ const isSecondaryAxisDrawn = false;
24
+ let isPrimaryAxisDrawn = true;
25
+ let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
26
+ let customYaxisMaxValue = parseFloat(formatOptions.yAxisLabel.yAxisMaxText);
27
+ let secondaryCustomYaxisMinValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMinText);
28
+ let secondaryCustomYaxisMaxValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMaxText);
29
+ let margin;
30
+ let yLabel;
31
+ let xLabel;
32
+ let yTitle;
33
+ let xTitle;
34
+ let dimensionHeightWidthArray;
35
+ let chartTitleHeight;
36
+ let secondaryAxisTitleWidth;
37
+ let legendMargin;
38
+ let secondaryYLabel;
39
+ let maxNumberForPrimaryAxis;
40
+ let maxNumberForSecondaryAxis;
41
+ let innerWidth;
42
+ let innerHeight;
43
+ let staticSvgInnerWidth;
44
+ let staticSvgInnerHeight;
45
+ let totalHeight;
46
+ let totalWidth;
47
+ let dataTable;
48
+ let dataTableHeight;
49
+ let floatingSvg;
50
+ let svg;
51
+ let gTag;
52
+ let floatingTagG;
53
+ let yScaleLeft;
54
+ let yScaleRight;
55
+ let xScale;
56
+ let seriesLabels;
57
+ let calculatedRange;
58
+ let seriesLabelWidth;
59
+ let yAxisLeft;
60
+ let xAxis;
61
+ let yAxisRight;
62
+ let filteredDimension;
63
+ let filteredData;
64
+ let scrollPosition = 0;
65
+ const visibleBars = 2;
66
+ let stackLineData = [];
67
+ let stackChartData = [];
68
+ const isNormalizedChart = true;
69
+ let chartJSON = {
70
+ dimensionList: [],
71
+ chartType: chartType,
72
+ chartData: [],
73
+ formatOptions: formatOptions,
74
+ legendList: [],
75
+ secondaryAxisDrawn: false,
76
+ yMaxLeft: 0,
77
+ yMaxRight: 0,
78
+ yMinLeft: 0,
79
+ yMinRight: 0,
80
+ hideZeroValues: false,
81
+ formattedDimensionListMap: new Map(),
82
+ };
83
+ //#region UseEffect
84
+ useEffect(() => {
85
+ try {
86
+ createLineChart();
87
+ }
88
+ catch (error) {
89
+ logError("StackLinechart", "createLineChart", error);
90
+ }
91
+ }, []);
92
+ //#endregion
93
+ const createLineChart = () => {
94
+ // firstFunctionForDrawChart(); // not required in library
95
+ preProcessChartData(); // preaparing data related to chart creation
96
+ // Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
97
+ // const resultCustomYscaleLabelFormatting = customYscaleLabelFormatting(
98
+ // // for calculating primary/secondary axis max number so that we can calculate margin accordinglt
99
+ // formatOptions,
100
+ // chartJSON.yMinLeft,
101
+ // chartJSON.yMaxLeft,
102
+ // chartJSON.yMinRight,
103
+ // chartJSON.yMaxRight
104
+ // );
105
+ // maxNumberForPrimaryAxis =
106
+ // resultCustomYscaleLabelFormatting.maxNumberForPrimaryAxis;
107
+ // maxNumberForSecondaryAxis =
108
+ // resultCustomYscaleLabelFormatting.maxNumberForSecondaryAxis;
109
+ const marginResult = marginCalculation(
110
+ // for all margin related calculations
111
+ width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart);
112
+ margin = marginResult.margin;
113
+ yLabel = marginResult.yLabel;
114
+ xLabel = marginResult.xLabel;
115
+ yTitle = marginResult.yTitle;
116
+ xTitle = marginResult.xTitle;
117
+ dimensionHeightWidthArray = marginResult.dimensionHeightWidthArray;
118
+ chartTitleHeight = marginResult.chartTitleHeight;
119
+ secondaryAxisTitleWidth = marginResult.secondaryAxisTitleWidth;
120
+ legendMargin = marginResult.legendMargin;
121
+ secondaryYLabel = marginResult.secondaryYLabel;
122
+ setSVGContainer(margin); // for innerWidth/height static width/height
123
+ const resultDataTablePreCalculation = dataTablePreCalculation(
124
+ // calculations for data tables
125
+ formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList);
126
+ dataTable = resultDataTablePreCalculation.dataTable;
127
+ dataTableHeight = resultDataTablePreCalculation.dataTableHeight;
128
+ svg = initSvg(
129
+ // for svg creation
130
+ svg, svgRef.current, width, height, formatOptions, chartsWithXScrollFlag, chartsWithYScrollFlag, chartId, totalWidth, totalHeight);
131
+ //d3.select(svgRef.current, width, height);
132
+ gTag = initChartArea(svg, margin); // creating chart area
133
+ floatingTagG = setChartFloatingSVGContainer(
134
+ // might not needed after dynamic scrolling effect // marked for review for final
135
+ gTag, formatOptions, floatingSvg, margin, chartsWithXScrollFlag, chartsWithYScrollFlag);
136
+ initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
137
+ initScale();
138
+ initAxis();
139
+ initYaxis(gTag, formatOptions, dataTableHeight, yLabel, yAxisLeft, innerHeight, floatingTagG, chartsWithXScrollFlag, chartsWithYScrollFlag);
140
+ // initYaxisRight(
141
+ // gTag,
142
+ // formatOptions,
143
+ // dataTableHeight,
144
+ // secondaryYLabel,
145
+ // yAxisRight,
146
+ // innerHeight,
147
+ // staticSvgInnerWidth,
148
+ // floatingTagG
149
+ // );
150
+ horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
151
+ setDataTable(gTag, floatingTagG, dataTable, barWidth, yScaleLeft, xScale, dataTableHeight, yLabel, yTitle, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, svg, innerWidth, innerHeight); // data tables to be added later
152
+ setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, staticSvgInnerWidth, innerHeight);
153
+ yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
154
+ yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, staticSvgInnerHeight, staticSvgInnerWidth, secondaryYLabel, secondaryAxisTitleWidth, innerHeight); // to be added later
155
+ setChartTitle(svg, formatOptions, width, chartTitleHeight);
156
+ drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin);
157
+ //
158
+ };
159
+ const preProcessChartData = () => {
160
+ chartJSON.chartData = seriesData.flatMap((s) => s.data); // Flattening the data from all series
161
+ for (let k = 0; k < seriesData.length; k++) {
162
+ seriesData[k].properties.legend =
163
+ k + "~$~" + seriesData[k].properties.legend;
164
+ }
165
+ chartJSON.dimensionList = Array.from(new Set(chartJSON.chartData.map((data) => data.dimension))); // getting unique x values as dimension list
166
+ filteredData = JSON.parse(JSON.stringify(seriesData));
167
+ // if (formatOptions.scrollChart.scrollX) {
168
+ if (false) {
169
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
170
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
171
+ }
172
+ else {
173
+ filteredDimension = chartJSON.dimensionList;
174
+ }
175
+ if (formatOptions.plotArea.hideZeroValues) {
176
+ chartJSON.hideZeroValues = true;
177
+ }
178
+ chartJSON.legendList = seriesData.map((data) => data.properties.legend); // getting legend list from series data
179
+ let tempStackLineData = getStackedData(chartJSON.dimensionList, seriesData, isNormalizedChart);
180
+ let allStackDataChart = d3
181
+ .stack()
182
+ .keys(chartJSON.legendList)
183
+ .offset(d3.stackOffsetDiverging)(tempStackLineData);
184
+ createStackLineData();
185
+ function stackMin(series) {
186
+ return d3.min(series, function (d) {
187
+ return d[0];
188
+ });
189
+ }
190
+ function stackMax(series) {
191
+ return d3.max(series, function (d) {
192
+ return d[1];
193
+ });
194
+ }
195
+ chartJSON.yMaxLeft = 1; // max value from chart Data
196
+ chartJSON.yMinLeft = parseFloat(d3.min(allStackDataChart, stackMin)); // min value from chart Data
197
+ let xAxisObject = xAxisObj[0];
198
+ let formatedDimesionList = (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
199
+ xAxisObject.dataType === "DATE"
200
+ ? setDateFormats(xAxisObject.name.name, formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList, xAxisObject.name.dataSourceId).map((d) => d[0])
201
+ : chartJSON.dimensionList;
202
+ chartJSON.dimensionList.forEach((d, i) => {
203
+ chartJSON.formattedDimensionListMap.set(d, formatedDimesionList[i]);
204
+ });
205
+ let secondaryAxisMinValue = 0;
206
+ let secondaryAxisMaxValue = 0;
207
+ if (isSecondaryAxisDrawn) {
208
+ seriesData?.forEach((data) => {
209
+ if (data.properties.axis == "Secondary") {
210
+ // isSecondaryAxisDrawn = true;
211
+ if (secondaryAxisMinValue >
212
+ d3.min(data.data, (d) => d.value)) {
213
+ secondaryAxisMinValue = d3.min(data.data, (d) => d.value);
214
+ }
215
+ if (secondaryAxisMaxValue <
216
+ d3.max(data.data, (d) => d.value)) {
217
+ secondaryAxisMaxValue = d3.max(data.data, (d) => d.value);
218
+ }
219
+ }
220
+ });
221
+ chartJSON.yMinRight = secondaryAxisMinValue;
222
+ chartJSON.yMaxRight = secondaryAxisMaxValue;
223
+ }
224
+ };
225
+ const initScale = () => {
226
+ if (isPrimaryAxisDrawn) {
227
+ yScaleLeft = d3
228
+ .scaleLinear()
229
+ .domain([chartJSON.yMinLeft < 0 ? -1 : 0, 1])
230
+ .range([
231
+ dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
232
+ 0,
233
+ ]);
234
+ }
235
+ if (isSecondaryAxisDrawn) {
236
+ yScaleRight = d3
237
+ .scaleLinear()
238
+ .domain([
239
+ chartJSON.yMinRight >= 0
240
+ ? (secondaryCustomYaxisMinValue ||
241
+ secondaryCustomYaxisMinValue == 0) &&
242
+ !Number.isNaN(secondaryCustomYaxisMinValue)
243
+ ? secondaryCustomYaxisMinValue
244
+ : 0
245
+ : (secondaryCustomYaxisMinValue ||
246
+ secondaryCustomYaxisMinValue == 0) &&
247
+ !Number.isNaN(secondaryCustomYaxisMinValue)
248
+ ? secondaryCustomYaxisMinValue
249
+ : chartJSON.yMinRight * 1.1,
250
+ chartJSON.yMaxRight <= 0
251
+ ? secondaryCustomYaxisMaxValue
252
+ ? secondaryCustomYaxisMaxValue
253
+ : 0
254
+ : secondaryCustomYaxisMaxValue
255
+ ? secondaryCustomYaxisMaxValue
256
+ : chartJSON.yMaxRight * 1.1,
257
+ ])
258
+ .range([
259
+ dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
260
+ 0,
261
+ ]);
262
+ }
263
+ calculatedRange = [0, innerWidth];
264
+ if (formatOptions.seriesLabel.seriesLabelVisibility) {
265
+ let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, undefined, isSecondaryAxisDrawn, true);
266
+ seriesLabels = labelObj.labelArray;
267
+ formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
268
+ (seriesLabelWidth = labelObj.heightWidth[0]);
269
+ formatOptions.seriesLabel.seriesLabelPosition == "Right"
270
+ ? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
271
+ : (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
272
+ }
273
+ getXScale();
274
+ };
275
+ const getXScale = () => {
276
+ xScale = d3
277
+ .scalePoint()
278
+ .domain(filteredDimension)
279
+ .range(calculatedRange)
280
+ .padding(0.5);
281
+ };
282
+ const initAxis = () => {
283
+ getXAxis();
284
+ if (isPrimaryAxisDrawn) {
285
+ yAxisLeft = d3
286
+ .axisLeft(yScaleLeft)
287
+ .tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
288
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
289
+ ? formatOptions.plotArea.gridLinesHorizontal
290
+ ? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
291
+ : 0
292
+ : 0)
293
+ .ticks(dataTableHeight > 0
294
+ ? (innerHeight - dataTableHeight) / 30
295
+ : innerHeight / 30)
296
+ .tickSizeOuter(0);
297
+ }
298
+ };
299
+ const getXAxis = () => {
300
+ xAxis = d3
301
+ .axisBottom(xScale)
302
+ .tickSize(formatOptions.plotArea.gridLinesVisibility
303
+ ? formatOptions.plotArea.gridLinesVeritcal
304
+ ? formatOptions.plotArea.gridLinesVeritcal
305
+ ? -(dataTableHeight > 0
306
+ ? innerHeight - dataTableHeight
307
+ : innerHeight)
308
+ : formatOptions.plotArea.ticksHeight *
309
+ ((dataTableHeight > 0
310
+ ? innerHeight - dataTableHeight
311
+ : innerHeight) /
312
+ 100) *
313
+ (formatOptions.xAxisLabel.xAxisPosition == 1 ? 1 : -1)
314
+ : 0
315
+ : 0)
316
+ .tickSizeOuter(0)
317
+ .tickValues(responsiveXaxisLabel(filteredDimension, innerWidth));
318
+ };
319
+ const getChartType = (lineData) => {
320
+ stackChartData.forEach((data, i) => data.forEach((item, position) => {
321
+ lineData[i].data[position][0] = item[0] =
322
+ item.data.Total === 0 ? 0 : item[0] / item.data.Total;
323
+ lineData[i].data[position][1] = item[1] =
324
+ item.data.Total === 0 ? 0 : item[1] / item.data.Total;
325
+ }));
326
+ lineData.forEach((lData) => {
327
+ lData.data.forEach((cData) => {
328
+ cData.hideZero = lData.properties.hideZeroValues;
329
+ cData.axis = lData.properties.axis;
330
+ });
331
+ });
332
+ const lineGenerator = d3
333
+ .line()
334
+ .x((d) => xScale(d.data.dimension)
335
+ ? xScale(d.data.dimension)
336
+ : null)
337
+ .y((d) => (d[1] > 0 ? yScaleLeft(d[1]) : yScaleLeft(d[0])))
338
+ // .defined((d) => (d.hideZero ? Boolean(d.value) : true))
339
+ .curve(getCurveType(formatOptions));
340
+ //Lines
341
+ // Bind dummy data to ensure a single group is created
342
+ let lines = gTag.selectAll(".parentGroup").data([stackChartData]);
343
+ lines = lines
344
+ .enter()
345
+ .append("g")
346
+ .attr("class", "lines parentGroup")
347
+ .merge(lines);
348
+ // JOIN: one group per line
349
+ let lineGroups = lines.selectAll(".line-group").data((d) => d);
350
+ // ENTER: create group for each new line
351
+ let lineGroupsEnter = lineGroups
352
+ .enter()
353
+ .append("g")
354
+ .attr("class", (d) => "line-group " + d.key.replace(/ /g, "-"));
355
+ // .attr("class", (d) => d.key.replace(/ /g, "-"));
356
+ lineGroupsEnter
357
+ .attr("hoverId", (d) => d.key.includes("~$~")
358
+ ? d.key.split("~$~")[1].replace(/ /g, "-")
359
+ : d.key.replace(/ /g, "-"))
360
+ .append("path")
361
+ .attr("class", "line")
362
+ .attr("fill", "none");
363
+ // ENTER + UPDATE
364
+ lineGroupsEnter
365
+ .merge(lineGroups)
366
+ .select("path")
367
+ .attr("d", (d, i) => lineGenerator(d))
368
+ .attr("stroke", (d) => (d.color !== "#ffffff" ? d.color : "none"))
369
+ // .style("visibility", (d,i) => (this.individualLegendStyle[i].hideZero && d[i].data[d.key] === 0) ? "hidden" : "visible")
370
+ .attr("stroke-dasharray", (d, i) => seriesData[i].properties.lineStyle === "dotted"
371
+ ? "0,3"
372
+ : seriesData[i].properties.lineStyle === "dashed"
373
+ ? "20,10,5,5,5,10"
374
+ : "")
375
+ .attr("stroke-linecap", (d, i) => seriesData[i].properties.lineStyle === "dotted" ? "round" : "")
376
+ .attr("stroke-width", (d, i) => seriesData[i].properties.lineStyle !== "None"
377
+ ? seriesData[i].properties.lineWidth
378
+ : "0");
379
+ // EXIT: remove old groups
380
+ lineGroups.exit().remove();
381
+ //Markers
382
+ lineMarkers(lines, lineData, chartType, xScale, yScaleLeft, yScaleRight, null, formatOptions, chartJSON, secondaryCustomYaxisMaxValue, secondaryCustomYaxisMinValue, customYaxisMinValue, customYaxisMaxValue);
383
+ };
384
+ const drawLegends = (height, svg, maxLegendDimensions, chartTitleHeight, width, legendMargin) => {
385
+ try {
386
+ let position = formatOptions.legends.legendPosition;
387
+ let horizontalLegendAlignment = formatOptions.legends.legendAlignmentTopBottom;
388
+ let verticalLegendAlignment = formatOptions.legends.legendAlignment;
389
+ switch (position) {
390
+ case "None":
391
+ break;
392
+ case "Right":
393
+ let heightRight = !formatOptions.plotArea.fitChart
394
+ ? height - chartTitleHeight - 20
395
+ : height - chartTitleHeight - 10;
396
+ legendsWithScroll(svg, seriesData, width - maxLegendDimensions[0] - 30, chartTitleHeight + 5, legendMargin + 25, heightRight, position, verticalLegendAlignment, legendShape.line, formatOptions, chartId);
397
+ break;
398
+ case "Top":
399
+ legendsWithScroll(svg, seriesData, 7, chartTitleHeight + 5, width - 10, 30, position, horizontalLegendAlignment, legendShape.line, formatOptions, chartId);
400
+ break;
401
+ case "Left":
402
+ let heightLeft = !formatOptions.plotArea.fitChart
403
+ ? height - chartTitleHeight - 20
404
+ : height - chartTitleHeight - 10;
405
+ legendsWithScroll(svg, seriesData, 7, chartTitleHeight + 5, legendMargin + 25, heightLeft, position, verticalLegendAlignment, legendShape.line, formatOptions, chartId);
406
+ break;
407
+ case "Bottom":
408
+ legendsWithScroll(svg, seriesData, 7, height - 25, width - 10, 30, position, horizontalLegendAlignment, legendShape.line, formatOptions, chartId);
409
+ break;
410
+ }
411
+ }
412
+ catch (error) {
413
+ console.log(error);
414
+ }
415
+ };
416
+ const setSVGContainer = (margin) => {
417
+ totalHeight = height;
418
+ totalWidth = width;
419
+ if (chartsWithXScrollFlag) {
420
+ totalWidth = formatOptions.plotArea.scaleFactor * width;
421
+ }
422
+ if (chartsWithYScrollFlag) {
423
+ totalHeight = formatOptions.plotArea.scaleFactor * height;
424
+ }
425
+ innerWidth =
426
+ (!formatOptions.plotArea.fitChart ? totalWidth : width) -
427
+ margin.left -
428
+ margin.right;
429
+ innerHeight =
430
+ (!formatOptions.plotArea.fitChart && chartsWithYScrollFlag
431
+ ? totalHeight
432
+ : height) -
433
+ margin.bottom -
434
+ margin.top;
435
+ staticSvgInnerWidth = width - margin.left - margin.right;
436
+ staticSvgInnerHeight = height - margin.top - margin.bottom;
437
+ };
438
+ const setDataTable = (gTag, floatingTagG, dataTable, barWidth, yScaleLeft, xScale, dataTableHeight, yLabel, yTitle, calculatedRange, formatedDimensionMap, chartId, margin, svg, innerWidth, innerHeight) => {
439
+ try {
440
+ if (formatOptions.dataTableProperties &&
441
+ formatOptions.dataTableProperties.dataTable) {
442
+ if (formatOptions.xAxisLabel.xAxisPosition != 1)
443
+ formatOptions.xAxisLabel.xAxisLabelVisibility = false;
444
+ let requiredTag = formatOptions.plotArea.fitChart ? gTag : floatingTagG;
445
+ addDataTable(formatOptions.plotArea.fitChart, svg, requiredTag, dataTable, barWidth, yScaleLeft, xScale, undefined, undefined, undefined, dataTableHeight, "Line", formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, formatedDimensionMap, chartId, margin, innerHeight);
446
+ }
447
+ }
448
+ catch (error) {
449
+ // loggerService.logError(error,{componentName :constructor.name,functionName :"setDataTable"}); }
450
+ }
451
+ };
452
+ const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
453
+ // if (formatOptions.scrollChart.scrollX) {
454
+ if (false) {
455
+ // Scrollbar parameters
456
+ const scrollMax = seriesData[0].data.length - visibleBars;
457
+ // Scrollbar track & handle
458
+ const scrollbarY = height - 20;
459
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
460
+ getXScale();
461
+ filteredData = JSON.parse(JSON.stringify(seriesData));
462
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
463
+ createStackLineData();
464
+ getXAxis();
465
+ svg
466
+ .append("rect")
467
+ .attr("x", margin.left)
468
+ .attr("y", scrollbarY)
469
+ .attr("width", innerWidth)
470
+ .attr("height", 8)
471
+ .attr("fill", "#ddd")
472
+ .attr("rx", 4);
473
+ const handleWidth = (innerWidth * visibleBars) / seriesData.length;
474
+ const handle = svg
475
+ .append("rect")
476
+ .attr("x", margin.left)
477
+ .attr("y", scrollbarY)
478
+ .attr("width", handleWidth)
479
+ .attr("height", 8)
480
+ .attr("fill", "#999")
481
+ .attr("rx", 4)
482
+ .style("cursor", "ew-resize")
483
+ .call(d3.drag().on("drag", (event) => {
484
+ let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
485
+ handle.attr("x", x);
486
+ scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
487
+ filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
488
+ getXScale();
489
+ filteredData = JSON.parse(JSON.stringify(seriesData));
490
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
491
+ createStackLineData();
492
+ getXAxis();
493
+ drawLineChart();
494
+ }));
495
+ svg.on("wheel", (event) => {
496
+ event.preventDefault();
497
+ const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
498
+ ? event.deltaX
499
+ : event.deltaY;
500
+ scrollPosition += scrollDelta > 0 ? 1 : -1;
501
+ scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
502
+ const x = margin.left +
503
+ ((innerWidth - handleWidth) * scrollPosition) / scrollMax;
504
+ handle.attr("x", x);
505
+ getXScale();
506
+ filteredData = JSON.parse(JSON.stringify(seriesData));
507
+ filteredData.forEach((data, i) => (filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension))));
508
+ createStackLineData();
509
+ getXAxis();
510
+ drawLineChart();
511
+ });
512
+ }
513
+ drawLineChart();
514
+ };
515
+ const drawLineChart = () => {
516
+ // filteredData.forEach((data) => getChartType([data]));
517
+ getChartType(filteredData);
518
+ initXaxis(formatOptions.plotArea.fitChart ? gTag : floatingTagG, chartJSON, xLabel, formatOptions, xAxisObj[0], dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, xAxisObj[0].dataType, innerWidth, innerHeight, filteredDimension);
519
+ stacklineAnnotations(stackChartData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
520
+ margin, d3Annotation, [], //this.labelExcludeList,
521
+ [], //this.individualLabelColor,
522
+ [], //this.attributes.Id ? formatOptions.plotArea.dataLabelsCoordinates : this.parentReference.objService.tempAnnotationArray
523
+ formatOptions, chartType, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg, dataTableHeight);
524
+ let newSeriesLabelArray = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, undefined, isSecondaryAxisDrawn, true).labelArray;
525
+ // adding series labels ( appending legends at the end of line : by default) in plot area
526
+ drawSeriesLabels(formatOptions, floatingTagG, newSeriesLabelArray);
527
+ };
528
+ const createStackLineData = () => {
529
+ let stackLineData = getStackedData(filteredDimension, filteredData, isNormalizedChart);
530
+ // }
531
+ stackChartData = d3
532
+ .stack()
533
+ .keys(chartJSON.legendList)
534
+ .offset(d3.stackOffsetDiverging)(stackLineData);
535
+ filteredData.forEach((data, index) => data.data.forEach((axisData, position) => {
536
+ axisData["0"] = stackChartData[index][position][0];
537
+ axisData["1"] = stackChartData[index][position][1];
538
+ }));
539
+ //Appending Extra key for tooltip color
540
+ let seriesColor = formatOptions.annotation.annotationSetLabelColor;
541
+ stackChartData.forEach((K, j) => K.forEach((d) => {
542
+ d["key"] = K.key;
543
+ K["color"] = JSON.parse(JSON.stringify(seriesData[j].properties.color));
544
+ d.data.labelPosition = seriesData[j].properties.dataLabelPosition;
545
+ d.data["labelColor"] =
546
+ seriesColor == 2
547
+ ? JSON.parse(JSON.stringify(seriesData[j].properties.color))
548
+ : seriesData[j].properties.labelColor;
549
+ d["hideZero"] = JSON.parse(JSON.stringify(seriesData[j].properties.hideZeroValues));
550
+ }));
551
+ };
552
+ return (_jsxs("div", { children: [_jsx("div", { id: "chartTooltipDiv" }), _jsx("svg", { className: "chartSVG", ref: svgRef, id: chartId, width: width, height: height })] }));
553
+ };
554
+ export default NormalisedStackLineChart;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { type TChartProps } from "../ChartsWithAxisTypes.types";
3
+ declare const NormalisedStackLineChart: React.FC<TChartProps>;
4
+ export default NormalisedStackLineChart;