pace-chart-lib 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +76 -38
  2. package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.d.ts +4 -2
  3. package/dist/{components → Components}/Charts/Core/CommonFunctions.d.ts +3 -1
  4. package/dist/{components → Components}/Charts/Core/DefaultProperties.types.d.ts +2 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/pace-chart-lib.es.js +54619 -0
  7. package/dist/pace-chart-lib.umd.js +54622 -0
  8. package/dist/vite.svg +1 -0
  9. package/package.json +1 -1
  10. package/dist/Services/ErrorLog.js +0 -3
  11. package/dist/components/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +0 -496
  12. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.d.ts +0 -4
  13. package/dist/components/Charts/ChartsWithAxis/AreaFamily/LineChart.js +0 -491
  14. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +0 -517
  15. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.d.ts +0 -4
  16. package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackLineChart.js +0 -553
  17. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +0 -517
  18. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.d.ts +0 -4
  19. package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackLineChart.js +0 -553
  20. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +0 -12
  21. package/dist/components/Charts/ChartsWithAxis/BarFamily/BarChart.js +0 -9
  22. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +0 -4909
  23. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -0
  24. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -0
  25. package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.js +0 -49
  26. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.d.ts +0 -4
  27. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart copy.js +0 -486
  28. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +0 -497
  29. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +0 -418
  30. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +0 -1013
  31. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +0 -478
  32. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.d.ts +0 -4
  33. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LineChart.js +0 -451
  34. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +0 -533
  35. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackLineChart.js +0 -512
  36. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +0 -530
  37. package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackLineChart.js +0 -512
  38. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.d.ts +0 -12
  39. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/BarChart.js +0 -9
  40. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +0 -497
  41. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +0 -497
  42. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.d.ts +0 -4
  43. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredColumnChart.js +0 -479
  44. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +0 -478
  45. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +0 -473
  46. package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +0 -465
  47. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.d.ts +0 -0
  48. package/dist/components/Charts/ChartsWithAxis/LineFamily/100%StackLineChart.js +0 -0
  49. package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +0 -451
  50. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.d.ts +0 -4
  51. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalisedStackLineChart.js +0 -554
  52. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.d.ts +0 -4
  53. package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +0 -510
  54. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.d.ts +0 -4
  55. package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +0 -507
  56. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +0 -393
  57. package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +0 -606
  58. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.d.ts +0 -0
  59. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxis.types.js +0 -0
  60. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -815
  61. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
  62. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
  63. package/dist/components/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.types.js +0 -32
  64. package/dist/components/Charts/ChartsWithoutAxis/Maps/Cordinates.js +0 -15021
  65. package/dist/components/Charts/ChartsWithoutAxis/Maps/Maps.js +0 -391
  66. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.js +0 -367
  67. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +0 -570
  68. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.js +0 -212
  69. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.js +0 -401
  70. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.js +0 -313
  71. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.js +0 -719
  72. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.js +0 -807
  73. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.js +0 -514
  74. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/VennChart.js +0 -282
  75. package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.js +0 -207
  76. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/DonutChart.js +0 -476
  77. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieChart.js +0 -420
  78. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.js +0 -106
  79. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.js +0 -507
  80. package/dist/components/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.js +0 -246
  81. package/dist/components/Charts/Core/Common.type.d.ts +0 -0
  82. package/dist/components/Charts/Core/Common.type.js +0 -0
  83. package/dist/components/Charts/Core/Common.types.js +0 -133
  84. package/dist/components/Charts/Core/CommonFunctions.js +0 -1782
  85. package/dist/components/Charts/Core/DefaultChartDataProperties.js +0 -64
  86. package/dist/components/Charts/Core/DefaultProperties.d.ts +0 -0
  87. package/dist/components/Charts/Core/DefaultProperties.js +0 -0
  88. package/dist/components/Charts/Core/DefaultProperties.type.d.ts +0 -586
  89. package/dist/components/Charts/Core/DefaultProperties.type.js +0 -585
  90. package/dist/components/Charts/Core/DefaultProperties.types.js +0 -592
  91. package/dist/index.js +0 -40
  92. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/AreaChart.d.ts +0 -0
  93. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.d.ts +0 -0
  94. /package/dist/{components → Components}/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.d.ts +0 -0
  95. /package/dist/{components → Components}/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +0 -0
  96. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.d.ts +0 -0
  97. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.d.ts +0 -0
  98. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.d.ts +0 -0
  99. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.d.ts +0 -0
  100. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.d.ts +0 -0
  101. /package/dist/{components → Components}/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.d.ts +0 -0
  102. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.d.ts +0 -0
  103. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.d.ts +0 -0
  104. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.d.ts +0 -0
  105. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.d.ts +0 -0
  106. /package/dist/{components → Components}/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.d.ts +0 -0
  107. /package/dist/{components → Components}/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +0 -0
  108. /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/NormalizedStackLineChart.d.ts +0 -0
  109. /package/dist/{components/Charts/ChartsWithAxis/ColumnFamily → Components/Charts/ChartsWithAxis/LineFamily}/StackLineChart.d.ts +0 -0
  110. /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.d.ts +0 -0
  111. /package/dist/{components → Components}/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.d.ts +0 -0
  112. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
  113. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Cordinates.d.ts +0 -0
  114. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/Maps/Maps.d.ts +0 -0
  115. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/BubbleChart.d.ts +0 -0
  116. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.d.ts +0 -0
  117. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ProgressChart.d.ts +0 -0
  118. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/PyramidChart.d.ts +0 -0
  119. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/RadialBarChart.d.ts +0 -0
  120. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/SankeyChart.d.ts +0 -0
  121. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/ScatterChart.d.ts +0 -0
  122. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/Speedometer.d.ts +0 -0
  123. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/VennChart.d.ts +0 -0
  124. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/OtherCharts/WordCloud.d.ts +0 -0
  125. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/DonutChart.d.ts +0 -0
  126. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieChart.d.ts +0 -0
  127. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieFamilyCommonFunctions.d.ts +0 -0
  128. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/PieofPieChart.d.ts +0 -0
  129. /package/dist/{components → Components}/Charts/ChartsWithoutAxis/PieFamily/TreemapChart.d.ts +0 -0
  130. /package/dist/{components → Components}/Charts/Core/Common.types.d.ts +0 -0
  131. /package/dist/{components → Components}/Charts/Core/DefaultChartDataProperties.d.ts +0 -0
@@ -1,554 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import { type TChartProps } from "../ChartsWithAxisTypes.types";
3
- declare const NormalisedStackLineChart: React.FC<TChartProps>;
4
- export default NormalisedStackLineChart;