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