pace-chart-lib 1.0.2 → 1.0.4

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