pace-chart-lib 1.0.2 → 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.
- 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,1013 +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 { staticLineStyle } from "../../Core/Common.types";
|
|
8
|
-
import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, lineMarkers, onHoverMarkerForAreaChartFamily, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
|
|
9
|
-
import { addDataTable, commonAnnotationsForCustomChart, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getCurveType, getNumberWithFormat, getStackedData, 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 CustomColumnChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
|
-
// adding variables as per requirement
|
|
13
|
-
const chartId = crypto.randomUUID();
|
|
14
|
-
let columnWidth = 0; // for column width calculation
|
|
15
|
-
let stackChartData = [];
|
|
16
|
-
const chartType = actualChartTypes.customColumnChart;
|
|
17
|
-
const svgRef = useRef();
|
|
18
|
-
const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
|
|
19
|
-
const dimensionList = data.DimensionList;
|
|
20
|
-
const barChart = false;
|
|
21
|
-
let isSecondaryAxisDrawn = false;
|
|
22
|
-
const isNormalizedChart = false;
|
|
23
|
-
let isPrimaryAxisDrawn = true;
|
|
24
|
-
let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
|
|
25
|
-
let customYaxisMaxValue = parseFloat(formatOptions.yAxisLabel.yAxisMaxText);
|
|
26
|
-
let secondaryCustomYaxisMinValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMinText);
|
|
27
|
-
let secondaryCustomYaxisMaxValue = parseFloat(formatOptions.secondaryYAxisLabel.secondaryYAxisMaxText);
|
|
28
|
-
let margin;
|
|
29
|
-
let yLabel;
|
|
30
|
-
let xLabel;
|
|
31
|
-
let yTitle;
|
|
32
|
-
let xTitle;
|
|
33
|
-
let dimensionHeightWidthArray;
|
|
34
|
-
let chartTitleHeight;
|
|
35
|
-
let secondaryAxisTitleWidth;
|
|
36
|
-
let legendMargin;
|
|
37
|
-
let secondaryYLabel;
|
|
38
|
-
let maxNumberForPrimaryAxis;
|
|
39
|
-
let maxNumberForSecondaryAxis;
|
|
40
|
-
let innerWidth;
|
|
41
|
-
let innerHeight;
|
|
42
|
-
let width;
|
|
43
|
-
let height;
|
|
44
|
-
let dataTable;
|
|
45
|
-
let dataTableHeight;
|
|
46
|
-
let svg;
|
|
47
|
-
let gTag;
|
|
48
|
-
let yScaleLeft;
|
|
49
|
-
let yScaleRight;
|
|
50
|
-
let xScale;
|
|
51
|
-
let xScaleForLegends;
|
|
52
|
-
let seriesLabels;
|
|
53
|
-
let calculatedRange;
|
|
54
|
-
let seriesLabelWidth;
|
|
55
|
-
let stackAreaChartDataForPrimaryAxis = [];
|
|
56
|
-
let stackAreaChartDataForSecondaryAxis = [];
|
|
57
|
-
let stackColumnChartDataForPrimaryAxis = [];
|
|
58
|
-
let stackColumnChartDataForSecondaryAxis = [];
|
|
59
|
-
let primaryStackAxisData = [];
|
|
60
|
-
let secondaryStackAxisData = [];
|
|
61
|
-
let primaryStackAreaAxisData = [];
|
|
62
|
-
let primaryStackColumnAxisData = [];
|
|
63
|
-
let secondaryStackAreaAxisData = [];
|
|
64
|
-
let secondaryStackColumnAxisData = [];
|
|
65
|
-
let stackColumnData = [];
|
|
66
|
-
let stackAreaData = [];
|
|
67
|
-
let yAxisLeft;
|
|
68
|
-
let xAxis;
|
|
69
|
-
let yAxisRight;
|
|
70
|
-
let filteredDimension;
|
|
71
|
-
let filteredData = [];
|
|
72
|
-
let requiredData = [];
|
|
73
|
-
let scrollPosition = 0;
|
|
74
|
-
const visibleBars = 2;
|
|
75
|
-
let chartJSON = {
|
|
76
|
-
dimensionList: dimensionList,
|
|
77
|
-
chartType: chartType,
|
|
78
|
-
chartData: [],
|
|
79
|
-
formatOptions: formatOptions,
|
|
80
|
-
legendList: [],
|
|
81
|
-
secondaryAxisDrawn: false,
|
|
82
|
-
yMaxLeft: 0,
|
|
83
|
-
yMaxRight: 0,
|
|
84
|
-
yMinLeft: 0,
|
|
85
|
-
yMinRight: 0,
|
|
86
|
-
hideZeroValues: false,
|
|
87
|
-
formattedDimensionListMap: new Map(),
|
|
88
|
-
};
|
|
89
|
-
//#region UseEffect
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
try {
|
|
92
|
-
createCustomColumnChart();
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
logError("CustomColumnchart", "createCustomColumnChart", error);
|
|
96
|
-
}
|
|
97
|
-
}, [formatOptions]);
|
|
98
|
-
//#endregion
|
|
99
|
-
const createCustomColumnChart = () => {
|
|
100
|
-
({ formatOptions, svg, width, height } = firstFunctionBeforeRender(svgRef, formatOptions));
|
|
101
|
-
preProcessChartData(); // preaparing data related to chart creation
|
|
102
|
-
// Applies custom Y-axis label formatting and calculates the necessary margin based on axis extremes.
|
|
103
|
-
({ maxNumberForPrimaryAxis, maxNumberForSecondaryAxis } =
|
|
104
|
-
customYscaleLabelFormatting(
|
|
105
|
-
// for calculating primary/secondary axis max number so that we can calculate margin accordinglt
|
|
106
|
-
formatOptions, chartJSON.yMinLeft, chartJSON.yMaxLeft, chartJSON.yMinRight, chartJSON.yMaxRight));
|
|
107
|
-
({
|
|
108
|
-
margin,
|
|
109
|
-
yLabel,
|
|
110
|
-
xLabel,
|
|
111
|
-
yTitle,
|
|
112
|
-
xTitle,
|
|
113
|
-
dimensionHeightWidthArray,
|
|
114
|
-
chartTitleHeight,
|
|
115
|
-
secondaryAxisTitleWidth,
|
|
116
|
-
legendMargin,
|
|
117
|
-
secondaryYLabel,
|
|
118
|
-
} = marginCalculation(
|
|
119
|
-
// for all margin related calculations
|
|
120
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
121
|
-
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
122
|
-
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
123
|
-
// calculations for data tables
|
|
124
|
-
formatOptions, yLabel, yTitle, seriesData, chartJSON.dimensionList));
|
|
125
|
-
initSvg(
|
|
126
|
-
// for svg creation
|
|
127
|
-
svg, width, height, formatOptions);
|
|
128
|
-
gTag = initChartArea(svg, margin); // creating chart area
|
|
129
|
-
initPlotArea(gTag, formatOptions, dataTableHeight, innerWidth, innerHeight, chartType);
|
|
130
|
-
initScale();
|
|
131
|
-
initAxis();
|
|
132
|
-
initYaxis(gTag, formatOptions, dataTableHeight, yLabel, yAxisLeft, innerHeight);
|
|
133
|
-
if (isSecondaryAxisDrawn) {
|
|
134
|
-
initYaxisRight(gTag, formatOptions, dataTableHeight, secondaryYLabel, yAxisRight, innerHeight, innerWidth);
|
|
135
|
-
}
|
|
136
|
-
horizontalScrollBar(seriesData, height, svg, margin, innerWidth);
|
|
137
|
-
if (formatOptions.dataTableProperties &&
|
|
138
|
-
formatOptions.dataTableProperties.dataTable) {
|
|
139
|
-
if (formatOptions.xAxisLabel.xAxisPosition != "1")
|
|
140
|
-
formatOptions.xAxisLabel.xAxisLabelVisibility = false;
|
|
141
|
-
addDataTable(formatOptions.plotArea.fitChart, svg, gTag, dataTable, columnWidth, yScaleLeft, xScale, xScaleForLegends, undefined, undefined, dataTableHeight, chartType, formatOptions, yLabel, yTitle, chartJSON.dimensionList, innerWidth, calculatedRange, chartJSON.formattedDimensionListMap, chartId, margin, innerHeight);
|
|
142
|
-
}
|
|
143
|
-
setXaxistitle(formatOptions, barChart, svg, margin, xLabel, height, xTitle, chartJSON.chartType, yLabel, innerWidth, innerHeight);
|
|
144
|
-
yAxistitle(innerHeight, formatOptions, dataTableHeight, barChart, svg, margin, yTitle, yLabel);
|
|
145
|
-
yAxistitleRight(svg, isSecondaryAxisDrawn, margin, formatOptions, dataTableHeight, innerHeight, innerWidth, secondaryYLabel, secondaryAxisTitleWidth); // to be added later
|
|
146
|
-
setChartTitle(svg, formatOptions, width, chartTitleHeight);
|
|
147
|
-
drawLegends(height, svg, dimensionHeightWidthArray, chartTitleHeight, width, legendMargin, formatOptions, seriesData, chartId, null
|
|
148
|
-
// legendShape.rectangle
|
|
149
|
-
);
|
|
150
|
-
};
|
|
151
|
-
const preProcessChartData = () => {
|
|
152
|
-
const allChartData = [];
|
|
153
|
-
const legendList = [];
|
|
154
|
-
let formatedDimensionList = [];
|
|
155
|
-
let yMaxLeft = -Infinity;
|
|
156
|
-
let yMinLeft = Infinity;
|
|
157
|
-
let yMaxRight = -Infinity;
|
|
158
|
-
let yMinRight = Infinity;
|
|
159
|
-
let tempChartData = [];
|
|
160
|
-
seriesData.forEach((series, i) => {
|
|
161
|
-
if (![actualChartTypes.stackColumn, actualChartTypes.stackArea].includes(series.properties.type)) {
|
|
162
|
-
tempChartData.push(series);
|
|
163
|
-
series.properties.type !== actualChartTypes.line &&
|
|
164
|
-
legendList.push(series.legend);
|
|
165
|
-
}
|
|
166
|
-
else if (!legendList.includes("stackLegend")) {
|
|
167
|
-
legendList.push(`stackLegend`);
|
|
168
|
-
}
|
|
169
|
-
// Determine stack chart data for both axes
|
|
170
|
-
if (series.properties.axis === "Secondary") {
|
|
171
|
-
secondaryStackAxisData.push(series);
|
|
172
|
-
if (series.properties.type == actualChartTypes.stackColumn) {
|
|
173
|
-
secondaryStackColumnAxisData.push(series);
|
|
174
|
-
}
|
|
175
|
-
if (series.properties.type == actualChartTypes.stackArea) {
|
|
176
|
-
secondaryStackAreaAxisData.push(series);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (series.properties.axis === "Primary") {
|
|
180
|
-
primaryStackAxisData.push(series);
|
|
181
|
-
if (series.properties.type == actualChartTypes.stackColumn) {
|
|
182
|
-
primaryStackColumnAxisData.push(series);
|
|
183
|
-
}
|
|
184
|
-
if (series.properties.type == actualChartTypes.stackArea) {
|
|
185
|
-
primaryStackAreaAxisData.push(series);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
//to determine Y min/max values
|
|
189
|
-
series.data.forEach((point) => {
|
|
190
|
-
// add chart type for individual series
|
|
191
|
-
point.type = series.properties.type;
|
|
192
|
-
point.axis = series.properties.axis;
|
|
193
|
-
point.labelPosition = series.properties.dataLabelPosition;
|
|
194
|
-
point.labelColor = series.properties.labelColor;
|
|
195
|
-
allChartData.push(point);
|
|
196
|
-
if (series.properties.axis === "Secondary") {
|
|
197
|
-
isSecondaryAxisDrawn = true;
|
|
198
|
-
yMaxRight = Math.max(yMaxRight, point.value);
|
|
199
|
-
yMinRight = Math.min(yMinRight, point.value);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
yMaxLeft = Math.max(yMaxLeft, point.value);
|
|
203
|
-
yMinLeft = Math.min(yMinLeft, point.value);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
chartJSON.chartData = tempChartData;
|
|
208
|
-
chartJSON.legendList = legendList;
|
|
209
|
-
chartJSON.yMaxLeft = yMaxLeft;
|
|
210
|
-
chartJSON.yMinLeft = yMinLeft > 0 ? 0 : yMinLeft;
|
|
211
|
-
chartJSON.yMaxRight = yMaxRight;
|
|
212
|
-
chartJSON.yMinRight = yMinRight;
|
|
213
|
-
// Apply formatted dimensions
|
|
214
|
-
formatedDimensionList = isDateType
|
|
215
|
-
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
216
|
-
: chartJSON.dimensionList;
|
|
217
|
-
chartJSON.dimensionList.forEach((dim, i) => {
|
|
218
|
-
chartJSON.formattedDimensionListMap.set(dim, formatedDimensionList[i]);
|
|
219
|
-
});
|
|
220
|
-
if (!formatOptions.plotArea.fitChart) {
|
|
221
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
filteredDimension = chartJSON.dimensionList;
|
|
225
|
-
}
|
|
226
|
-
if (formatOptions.plotArea.hideZeroValues) {
|
|
227
|
-
chartJSON.hideZeroValues = true;
|
|
228
|
-
}
|
|
229
|
-
// check and add data to filteredData for stack type charts
|
|
230
|
-
checkAndupdateInputData(primaryStackAreaAxisData, primaryStackColumnAxisData, secondaryStackAreaAxisData, secondaryStackColumnAxisData);
|
|
231
|
-
// check and update ymax values if stack chart is present w.r.t axes
|
|
232
|
-
if (primaryStackAxisData.length > 0) {
|
|
233
|
-
let valueArray = [];
|
|
234
|
-
let stackDataForPrimaryAxis = getStackedData(filteredDimension, primaryStackAxisData, false);
|
|
235
|
-
stackDataForPrimaryAxis.forEach((d) => {
|
|
236
|
-
valueArray.push(d.total);
|
|
237
|
-
});
|
|
238
|
-
chartJSON.yMaxLeft = Math.max(chartJSON.yMaxLeft, Math.max(...valueArray));
|
|
239
|
-
chartJSON.yMinLeft = Math.min(chartJSON.yMinLeft, Math.min(...valueArray));
|
|
240
|
-
}
|
|
241
|
-
if (secondaryStackAxisData.length > 0) {
|
|
242
|
-
let valueArray = [];
|
|
243
|
-
let stackDataForSecondaryAxis = getStackedData(filteredDimension, secondaryStackAxisData, false);
|
|
244
|
-
stackDataForSecondaryAxis.forEach((d) => {
|
|
245
|
-
valueArray.push(d.total);
|
|
246
|
-
});
|
|
247
|
-
chartJSON.yMaxRight = Math.max(chartJSON.yMaxRight, Math.max(...valueArray));
|
|
248
|
-
chartJSON.yMinRight = Math.min(chartJSON.yMinRight, Math.min(...valueArray));
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
const checkAndupdateInputData = (primaryStackAreaAxisData, primaryStackColumnAxisData, secondaryStackAreaAxisData, secondaryStackColumnAxisData) => {
|
|
252
|
-
let tempStackAreaChartDataForPrimaryAxis = getStackedData(filteredDimension, primaryStackAreaAxisData, false);
|
|
253
|
-
let tempStackAreaChartDataForSecondaryAxis = getStackedData(filteredDimension, secondaryStackAreaAxisData, false);
|
|
254
|
-
let tempStackColumnChartDataForPrimaryAxis = getStackedData(filteredDimension, primaryStackColumnAxisData, false);
|
|
255
|
-
let tempStackColumnChartDataForSecondaryAxis = getStackedData(filteredDimension, secondaryStackColumnAxisData, false);
|
|
256
|
-
requiredData = [];
|
|
257
|
-
stackAreaChartDataForPrimaryAxis = [];
|
|
258
|
-
stackAreaChartDataForSecondaryAxis = [];
|
|
259
|
-
stackColumnChartDataForPrimaryAxis = [];
|
|
260
|
-
stackColumnChartDataForSecondaryAxis = [];
|
|
261
|
-
// appending addtional properties to stack area chart data
|
|
262
|
-
if (primaryStackAreaAxisData.length) {
|
|
263
|
-
primaryStackAreaAxisData.forEach((d) => {
|
|
264
|
-
stackAreaChartDataForPrimaryAxis.push({
|
|
265
|
-
properties: {
|
|
266
|
-
axis: d.properties.axis,
|
|
267
|
-
type: d.properties.type,
|
|
268
|
-
legend: d.properties.legend,
|
|
269
|
-
},
|
|
270
|
-
stackData: tempStackAreaChartDataForPrimaryAxis,
|
|
271
|
-
data: primaryStackAreaAxisData,
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
if (secondaryStackAreaAxisData.length) {
|
|
276
|
-
secondaryStackAreaAxisData.forEach((d) => {
|
|
277
|
-
stackAreaChartDataForSecondaryAxis.push({
|
|
278
|
-
properties: {
|
|
279
|
-
axis: d.properties.axis,
|
|
280
|
-
type: d.properties.type,
|
|
281
|
-
legend: d.properties.legend,
|
|
282
|
-
},
|
|
283
|
-
stackData: tempStackAreaChartDataForSecondaryAxis,
|
|
284
|
-
data: secondaryStackAreaAxisData,
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
if (primaryStackColumnAxisData.length) {
|
|
289
|
-
primaryStackColumnAxisData.forEach((d) => {
|
|
290
|
-
stackAreaChartDataForSecondaryAxis.push({
|
|
291
|
-
properties: {
|
|
292
|
-
axis: d.properties.axis,
|
|
293
|
-
type: d.properties.type,
|
|
294
|
-
legend: d.properties.legend,
|
|
295
|
-
},
|
|
296
|
-
stackData: tempStackColumnChartDataForPrimaryAxis,
|
|
297
|
-
data: primaryStackColumnAxisData,
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
if (secondaryStackColumnAxisData.length) {
|
|
302
|
-
secondaryStackColumnAxisData.forEach((d) => {
|
|
303
|
-
stackColumnChartDataForSecondaryAxis.push({
|
|
304
|
-
properties: {
|
|
305
|
-
axis: d.properties.axis,
|
|
306
|
-
type: d.properties.type,
|
|
307
|
-
legend: d.properties.legend,
|
|
308
|
-
},
|
|
309
|
-
stackData: tempStackColumnChartDataForSecondaryAxis,
|
|
310
|
-
data: secondaryStackColumnAxisData,
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
// push these results in filteredData
|
|
315
|
-
requiredData.push(...chartJSON.chartData, ...stackAreaChartDataForPrimaryAxis, ...stackAreaChartDataForSecondaryAxis, ...stackColumnChartDataForPrimaryAxis, ...stackColumnChartDataForSecondaryAxis);
|
|
316
|
-
};
|
|
317
|
-
const initScale = () => {
|
|
318
|
-
// rounding the ymin & ymax
|
|
319
|
-
let yAxisLabelArray = responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray;
|
|
320
|
-
chartJSON.yMaxLeft = yAxisLabelArray[yAxisLabelArray.length - 1];
|
|
321
|
-
chartJSON.yMinLeft = yAxisLabelArray[0];
|
|
322
|
-
if (isPrimaryAxisDrawn) {
|
|
323
|
-
yScaleLeft = d3
|
|
324
|
-
.scaleLinear()
|
|
325
|
-
.domain([
|
|
326
|
-
chartJSON.yMinLeft >= 0 ?
|
|
327
|
-
customYaxisMinValue !== undefined &&
|
|
328
|
-
!Number.isNaN(customYaxisMinValue)
|
|
329
|
-
? customYaxisMinValue : 0
|
|
330
|
-
: chartJSON.yMinLeft < 0
|
|
331
|
-
? chartJSON.yMinLeft * 1.1
|
|
332
|
-
: chartJSON.yMinLeft * 0.9,
|
|
333
|
-
chartJSON.yMaxLeft <= 0
|
|
334
|
-
? 0
|
|
335
|
-
: customYaxisMaxValue !== undefined &&
|
|
336
|
-
!Number.isNaN(customYaxisMaxValue)
|
|
337
|
-
? customYaxisMaxValue
|
|
338
|
-
: chartJSON.yMaxLeft * 1.1,
|
|
339
|
-
])
|
|
340
|
-
.range([
|
|
341
|
-
dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
|
|
342
|
-
0,
|
|
343
|
-
]);
|
|
344
|
-
}
|
|
345
|
-
if (isSecondaryAxisDrawn) {
|
|
346
|
-
// rounding the ymin & ymax
|
|
347
|
-
let secondaryYAxisLabelArray = responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
|
|
348
|
-
? secondaryCustomYaxisMaxValue
|
|
349
|
-
: chartJSON.yMaxRight, secondaryCustomYaxisMinValue
|
|
350
|
-
? secondaryCustomYaxisMinValue
|
|
351
|
-
: chartJSON.yMinRight, formatOptions, chartJSON).secondaryYAxisLabelArray;
|
|
352
|
-
chartJSON.yMaxRight =
|
|
353
|
-
secondaryYAxisLabelArray[secondaryYAxisLabelArray.length - 1];
|
|
354
|
-
chartJSON.yMinRight = secondaryYAxisLabelArray[0];
|
|
355
|
-
yScaleRight = d3
|
|
356
|
-
.scaleLinear()
|
|
357
|
-
.domain([
|
|
358
|
-
chartJSON.yMinRight >= 0
|
|
359
|
-
? (secondaryCustomYaxisMinValue ||
|
|
360
|
-
secondaryCustomYaxisMinValue == 0) &&
|
|
361
|
-
!Number.isNaN(secondaryCustomYaxisMinValue)
|
|
362
|
-
? secondaryCustomYaxisMinValue
|
|
363
|
-
: 0
|
|
364
|
-
: (secondaryCustomYaxisMinValue ||
|
|
365
|
-
secondaryCustomYaxisMinValue == 0) &&
|
|
366
|
-
!Number.isNaN(secondaryCustomYaxisMinValue)
|
|
367
|
-
? secondaryCustomYaxisMinValue
|
|
368
|
-
: chartJSON.yMinRight * 1.1,
|
|
369
|
-
chartJSON.yMaxRight <= 0
|
|
370
|
-
? (secondaryCustomYaxisMaxValue ||
|
|
371
|
-
secondaryCustomYaxisMaxValue == 0) &&
|
|
372
|
-
!Number.isNaN(secondaryCustomYaxisMaxValue)
|
|
373
|
-
? secondaryCustomYaxisMaxValue
|
|
374
|
-
: 0
|
|
375
|
-
: (secondaryCustomYaxisMaxValue ||
|
|
376
|
-
secondaryCustomYaxisMaxValue == 0) &&
|
|
377
|
-
!Number.isNaN(secondaryCustomYaxisMaxValue)
|
|
378
|
-
? secondaryCustomYaxisMaxValue
|
|
379
|
-
: chartJSON.yMaxRight * 1.1,
|
|
380
|
-
])
|
|
381
|
-
.range([
|
|
382
|
-
dataTableHeight > 0 ? innerHeight - dataTableHeight : innerHeight,
|
|
383
|
-
0,
|
|
384
|
-
]);
|
|
385
|
-
}
|
|
386
|
-
calculatedRange = [0, innerWidth];
|
|
387
|
-
if (formatOptions.seriesLabel.seriesLabelVisibility) {
|
|
388
|
-
let labelObj = prepareDataForSeriesLabel(innerWidth, yScaleLeft, formatOptions, filteredData, yScaleRight, isSecondaryAxisDrawn);
|
|
389
|
-
seriesLabels = labelObj.labelArray;
|
|
390
|
-
formatOptions.seriesLabel.seriesLabelPosition == "Right" &&
|
|
391
|
-
(seriesLabelWidth = labelObj.heightWidth[0]);
|
|
392
|
-
formatOptions.seriesLabel.seriesLabelPosition == "Right"
|
|
393
|
-
? (calculatedRange = [0, innerWidth - labelObj.heightWidth[0]])
|
|
394
|
-
: (calculatedRange = [labelObj.heightWidth[0], innerWidth]);
|
|
395
|
-
}
|
|
396
|
-
getXScale();
|
|
397
|
-
};
|
|
398
|
-
const getXScale = () => {
|
|
399
|
-
columnWidth =
|
|
400
|
-
(0.51 +
|
|
401
|
-
(0.61 * (100 - parseFloat(formatOptions.plotArea.plotAreaGapWidth))) /
|
|
402
|
-
100) *
|
|
403
|
-
(innerWidth / filteredDimension.length);
|
|
404
|
-
xScaleForLegends = d3
|
|
405
|
-
.scaleBand()
|
|
406
|
-
// .domain(barLegendList.map((d) => d.legend))
|
|
407
|
-
.domain(chartJSON.legendList)
|
|
408
|
-
.range([0, columnWidth])
|
|
409
|
-
.paddingInner(chartJSON.legendList.length > 1
|
|
410
|
-
? (0.3 * parseFloat(formatOptions.plotArea.plotAreaSeriesWidth)) / 100
|
|
411
|
-
: 0);
|
|
412
|
-
xScale = d3
|
|
413
|
-
.scalePoint()
|
|
414
|
-
.domain(filteredDimension)
|
|
415
|
-
.range(calculatedRange)
|
|
416
|
-
.padding(0.5);
|
|
417
|
-
};
|
|
418
|
-
const initAxis = () => {
|
|
419
|
-
getXAxis();
|
|
420
|
-
if (isPrimaryAxisDrawn) {
|
|
421
|
-
yAxisLeft = d3
|
|
422
|
-
.axisLeft(yScaleLeft)
|
|
423
|
-
.tickFormat((d) => getNumberWithFormat(d, formatOptions.yAxisLabel.yAxisDisplayUnits, formatOptions.yAxisLabel.yAxisNumberFormat, formatOptions.yAxisLabel.yAxisLabelDecimalPrecision))
|
|
424
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
425
|
-
? formatOptions.plotArea.gridLinesHorizontal
|
|
426
|
-
? -innerWidth + (seriesLabelWidth ? seriesLabelWidth : 0)
|
|
427
|
-
: 0
|
|
428
|
-
: 0)
|
|
429
|
-
.tickValues(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).yAxisLabelArray)
|
|
430
|
-
.ticks(responsiveYaxisLabel(customYaxisMaxValue ? customYaxisMaxValue : chartJSON.yMaxLeft, chartJSON.yMinLeft, innerHeight, formatOptions, chartJSON, customYaxisMinValue, customYaxisMaxValue).customTickValue ??
|
|
431
|
-
(dataTableHeight > 0
|
|
432
|
-
? (innerHeight - dataTableHeight) / 30
|
|
433
|
-
: innerHeight / 30))
|
|
434
|
-
.tickSizeOuter(0);
|
|
435
|
-
}
|
|
436
|
-
if (isSecondaryAxisDrawn) {
|
|
437
|
-
yAxisRight = d3
|
|
438
|
-
.axisRight(yScaleRight)
|
|
439
|
-
.tickFormat((d) => getNumberWithFormat(d, formatOptions.secondaryYAxisLabel.secondaryYAxisDisplayUnits, formatOptions.secondaryYAxisLabel.secondaryYAxisNumberFormat, formatOptions.secondaryYAxisLabel
|
|
440
|
-
.secondaryYAxisLabelDecimalPrecision))
|
|
441
|
-
.tickValues(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
|
|
442
|
-
? secondaryCustomYaxisMaxValue
|
|
443
|
-
: chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryYAxisLabelArray)
|
|
444
|
-
.ticks(responsiveSecondaryYaxisLabel(secondaryCustomYaxisMaxValue
|
|
445
|
-
? secondaryCustomYaxisMaxValue
|
|
446
|
-
: chartJSON.yMaxRight, chartJSON.yMinRight, formatOptions, chartJSON).secondaryCustomTickValue ?? innerHeight / 30)
|
|
447
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
448
|
-
? formatOptions.plotArea.gridLinesHorizontal
|
|
449
|
-
? -innerWidth
|
|
450
|
-
: 0
|
|
451
|
-
: 0)
|
|
452
|
-
.tickSizeOuter(0);
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
const getXAxis = () => {
|
|
456
|
-
xAxis = d3
|
|
457
|
-
.axisBottom(xScale)
|
|
458
|
-
.tickSize(formatOptions.plotArea.gridLinesVisibility
|
|
459
|
-
? formatOptions.plotArea.gridLinesVertical
|
|
460
|
-
? formatOptions.plotArea.gridLinesVertical
|
|
461
|
-
? -(dataTableHeight > 0
|
|
462
|
-
? innerHeight - dataTableHeight
|
|
463
|
-
: innerHeight)
|
|
464
|
-
: parseFloat(formatOptions.plotArea.ticksHeight) *
|
|
465
|
-
((dataTableHeight > 0
|
|
466
|
-
? innerHeight - dataTableHeight
|
|
467
|
-
: innerHeight) /
|
|
468
|
-
100) *
|
|
469
|
-
(formatOptions.xAxisLabel.xAxisPosition == "1" ? 1 : -1)
|
|
470
|
-
: 0
|
|
471
|
-
: 0)
|
|
472
|
-
.tickSizeOuter(0)
|
|
473
|
-
.tickValues(responsiveXaxisLabel(filteredDimension, innerWidth));
|
|
474
|
-
};
|
|
475
|
-
const getChartType = (lineData) => {
|
|
476
|
-
// Bind dummy data to ensure a single group is created
|
|
477
|
-
lineData.forEach((data) => {
|
|
478
|
-
switch (data.properties.type) {
|
|
479
|
-
case actualChartTypes.column:
|
|
480
|
-
drawColumnChart(data);
|
|
481
|
-
break;
|
|
482
|
-
case actualChartTypes.line:
|
|
483
|
-
drawLineChart([data]);
|
|
484
|
-
break;
|
|
485
|
-
case actualChartTypes.area:
|
|
486
|
-
drawAreaChart([data]);
|
|
487
|
-
break;
|
|
488
|
-
case actualChartTypes.stackColumn:
|
|
489
|
-
stackColumnData = createStackData(data);
|
|
490
|
-
drawStackColumnChart();
|
|
491
|
-
break;
|
|
492
|
-
case actualChartTypes.stackArea:
|
|
493
|
-
stackAreaData = createStackData(data);
|
|
494
|
-
drawStackAreaChart(data);
|
|
495
|
-
break;
|
|
496
|
-
}
|
|
497
|
-
});
|
|
498
|
-
};
|
|
499
|
-
const drawColumnChart = (data) => {
|
|
500
|
-
// Step 1: Outer group for the whole chart
|
|
501
|
-
let column = gTag.selectAll(".parentGroup").data([data], (d) => d.legend); // use key so exit works
|
|
502
|
-
column = column
|
|
503
|
-
.enter()
|
|
504
|
-
.append("g")
|
|
505
|
-
.attr("class", `column parentGroup`)
|
|
506
|
-
.merge(column);
|
|
507
|
-
// Step 2: JOIN each data point inside the series
|
|
508
|
-
let columnGroups = column
|
|
509
|
-
.selectAll(".column-group")
|
|
510
|
-
.data(data.data, (d) => d.legend + d.dimension); // key on dimension + legend
|
|
511
|
-
// Step 3: ENTER - one group per bar (optional if you need transform)
|
|
512
|
-
let columnGroupsEnter = columnGroups
|
|
513
|
-
.enter()
|
|
514
|
-
.append("g")
|
|
515
|
-
.attr("class", "column-group")
|
|
516
|
-
.attr("hoverId", (d) => d.legend.includes("-")
|
|
517
|
-
? d.legend.replace("-", "`").split("`")[1].replace(/ /g, "-")
|
|
518
|
-
: d.legend.replace(/ /g, "-"))
|
|
519
|
-
.attr("transform", (d) => `translate(${xScale(d.dimension)}, 0)`);
|
|
520
|
-
// // ✨ Add this to handle UPDATE:
|
|
521
|
-
columnGroups.attr("transform", (d) => `translate(${xScale(d.dimension) - columnWidth / 2}, 0)`);
|
|
522
|
-
// // Merge ENTER + UPDATE
|
|
523
|
-
columnGroupsEnter
|
|
524
|
-
.merge(columnGroups)
|
|
525
|
-
.attr("transform", (d) => `translate(${xScale(d.dimension) - columnWidth / 2}, 0)`);
|
|
526
|
-
// Step 4: Draw the rects
|
|
527
|
-
columnGroupsEnter
|
|
528
|
-
.append("rect")
|
|
529
|
-
.attr("x", (d) => xScaleForLegends(d.legend))
|
|
530
|
-
.attr("width", xScaleForLegends.bandwidth())
|
|
531
|
-
.attr("y", (d) => {
|
|
532
|
-
const yScale = data.properties.axis === "Primary" ? yScaleLeft : yScaleRight;
|
|
533
|
-
return d.value > 0 ? yScale(d.value) : yScale(0);
|
|
534
|
-
})
|
|
535
|
-
.attr("height", (d) => {
|
|
536
|
-
const yScale = data.properties.axis === "Primary" ? yScaleLeft : yScaleRight;
|
|
537
|
-
return Math.abs(yScale(d.value) - yScale(0));
|
|
538
|
-
})
|
|
539
|
-
.attr("fill", data.properties.color)
|
|
540
|
-
.attr("stroke-dasharray", (d) => (d.stackBorderStyle === 2 ? "5,3" : "0"))
|
|
541
|
-
.attr("stroke-width", (d) => `${d.stackBorderWidth}px`)
|
|
542
|
-
.attr("stroke", (d) => data.properties.stackBorderStyle === 0
|
|
543
|
-
? "none"
|
|
544
|
-
: formatOptions.column.stackBorderVisibility
|
|
545
|
-
? data.properties.stackBorderStyle
|
|
546
|
-
: "none")
|
|
547
|
-
.style("clip-path", "inset(0px) fill-box")
|
|
548
|
-
.style("shape-rendering", "crispEdges")
|
|
549
|
-
.attr("visibility", (d) => d.value === 0 && formatOptions.xAxisLabel.hideZeroValues
|
|
550
|
-
? "hidden"
|
|
551
|
-
: "visible")
|
|
552
|
-
.on("mousemove", (event, d) => {
|
|
553
|
-
showTooltipOnMouseMove([
|
|
554
|
-
{
|
|
555
|
-
key: formatOptions.xAxisTitle.xAxisTitleText.includes("~$~")
|
|
556
|
-
? formatOptions.xAxisTitle.xAxisTitleText.split("~$~")[1]
|
|
557
|
-
: formatOptions.xAxisTitle.xAxisTitleText,
|
|
558
|
-
value: chartJSON.formattedDimensionListMap.get(Array.isArray(d.dimension) ? d.dimension[0] : d.dimension),
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
key: formatOptions.yAxisTitle.yAxisTitleText || d.value,
|
|
562
|
-
value: getNumberWithFormat([
|
|
563
|
-
actualChartTypes.stackLine100,
|
|
564
|
-
actualChartTypes.stackArea100,
|
|
565
|
-
"",
|
|
566
|
-
].includes(chartType)
|
|
567
|
-
? d[1] - d[0]
|
|
568
|
-
: d.value, formatOptions.toolTip.toolTipDisplayUnits, formatOptions.toolTip.toolTipNumberFormat, formatOptions.toolTip.toolTipDecimalPrecision),
|
|
569
|
-
},
|
|
570
|
-
{
|
|
571
|
-
key: "Legend",
|
|
572
|
-
value: d.legend.includes("~$~")
|
|
573
|
-
? d.legend.split("~$~")[1]
|
|
574
|
-
: d.legend,
|
|
575
|
-
},
|
|
576
|
-
], formatOptions, event);
|
|
577
|
-
})
|
|
578
|
-
.on("mouseout", hideTooltipOnMouseOut);
|
|
579
|
-
// Step 5: EXIT - remove old bars
|
|
580
|
-
columnGroups.exit().remove();
|
|
581
|
-
};
|
|
582
|
-
const drawLineChart = (lineData) => {
|
|
583
|
-
lineData.forEach((lData) => {
|
|
584
|
-
lData.data.forEach((cData) => {
|
|
585
|
-
cData.hideZero = lData.properties.hideZeroValues;
|
|
586
|
-
cData.axis = lData.properties.axis;
|
|
587
|
-
});
|
|
588
|
-
});
|
|
589
|
-
const lineGenerator = d3
|
|
590
|
-
.line()
|
|
591
|
-
.x((d) => xScale(d.dimension)
|
|
592
|
-
? xScale(d.dimension)
|
|
593
|
-
: null)
|
|
594
|
-
.y((d) => d.axis == "Primary"
|
|
595
|
-
? yScaleLeft(d.value)
|
|
596
|
-
: yScaleRight(d.value))
|
|
597
|
-
.defined((d) => (d.hideZero ? Boolean(d.value) : true))
|
|
598
|
-
.curve(getCurveType(formatOptions));
|
|
599
|
-
// Bind dummy data to ensure a single group is created
|
|
600
|
-
let lines = gTag.selectAll(".parentGroup").data([lineData]);
|
|
601
|
-
lines = lines
|
|
602
|
-
.enter()
|
|
603
|
-
.append("g")
|
|
604
|
-
.attr("class", "lines parentGroup")
|
|
605
|
-
.merge(lines);
|
|
606
|
-
// JOIN: one group per line
|
|
607
|
-
let lineGroups = lines.selectAll(".line-group").data((d) => d);
|
|
608
|
-
// ENTER: create group for each new line
|
|
609
|
-
let lineGroupsEnter = lineGroups
|
|
610
|
-
.enter()
|
|
611
|
-
.append("g")
|
|
612
|
-
.attr("class", "line-group");
|
|
613
|
-
// Append path to new groups
|
|
614
|
-
lineGroupsEnter
|
|
615
|
-
.attr("hoverId", (d) => d.legend.replace(/ /g, "-"))
|
|
616
|
-
.append("path")
|
|
617
|
-
.attr("class", "line")
|
|
618
|
-
.attr("fill", "none");
|
|
619
|
-
// ENTER + UPDATE
|
|
620
|
-
lineGroupsEnter
|
|
621
|
-
.merge(lineGroups)
|
|
622
|
-
.select("path")
|
|
623
|
-
.attr("d", (d) => lineGenerator(d.data))
|
|
624
|
-
.attr("stroke", (d) => d.properties.color !== "#ffffff" ? d.properties.color : "none")
|
|
625
|
-
.attr("stroke-dasharray", (d) => {
|
|
626
|
-
switch (d.properties.lineStyle) {
|
|
627
|
-
case staticLineStyle.dotted:
|
|
628
|
-
return "0,3";
|
|
629
|
-
case staticLineStyle.dashed:
|
|
630
|
-
return "20,10,5,5,5,10";
|
|
631
|
-
default:
|
|
632
|
-
return "";
|
|
633
|
-
}
|
|
634
|
-
})
|
|
635
|
-
.attr("stroke-linecap", (d) => d.properties.lineStyle === staticLineStyle.dotted ? "round" : "")
|
|
636
|
-
.attr("stroke-width", (d) => d.properties.lineStyle !== "None" ? d.properties.lineWidth : "0");
|
|
637
|
-
// EXIT: remove old groups
|
|
638
|
-
lineGroups.exit().remove();
|
|
639
|
-
//Markers
|
|
640
|
-
lineMarkers(lines, lineData, "CombiLine", xScale, yScaleLeft, yScaleRight, null, formatOptions, chartJSON, secondaryCustomYaxisMaxValue, secondaryCustomYaxisMinValue, customYaxisMinValue, customYaxisMaxValue, false);
|
|
641
|
-
};
|
|
642
|
-
const drawAreaChart = (lineData) => {
|
|
643
|
-
const areaGenerator = d3
|
|
644
|
-
.area()
|
|
645
|
-
.x((d) => xScale(d.dimension)
|
|
646
|
-
? xScale(d.dimension)
|
|
647
|
-
: null)
|
|
648
|
-
.y0((d) =>
|
|
649
|
-
// d.axis == "Primary" ?
|
|
650
|
-
yScaleLeft(0)
|
|
651
|
-
// : yScaleRight(0)
|
|
652
|
-
)
|
|
653
|
-
.y1((d) =>
|
|
654
|
-
// d.axis == "Primary" ?
|
|
655
|
-
yScaleLeft(d.value)
|
|
656
|
-
// : yScaleRight((d as TDataPoint).value)
|
|
657
|
-
)
|
|
658
|
-
.defined((d) => (d.hideZero ? Boolean(d.value) : true))
|
|
659
|
-
.curve(getCurveType(formatOptions));
|
|
660
|
-
// Bind dummy data to ensure a single group is created
|
|
661
|
-
let areas = gTag.selectAll(".parentGroup").data([lineData]);
|
|
662
|
-
let focus = gTag.append("g").attr("class", "focusClass");
|
|
663
|
-
areas = areas
|
|
664
|
-
.enter()
|
|
665
|
-
.append("g")
|
|
666
|
-
.attr("class", "areas parentGroup")
|
|
667
|
-
.merge(areas);
|
|
668
|
-
// JOIN: one group per line
|
|
669
|
-
let areaGroups = areas.selectAll(".area-group").data((d) => d);
|
|
670
|
-
// ENTER: create group for each new line
|
|
671
|
-
let areaGroupsEnter = areaGroups
|
|
672
|
-
.enter()
|
|
673
|
-
.append("g")
|
|
674
|
-
.attr("class", "area-group");
|
|
675
|
-
// Append path to new groups
|
|
676
|
-
areaGroupsEnter
|
|
677
|
-
.attr("hoverId", (d) => d.legend.replace(/ /g, "-"))
|
|
678
|
-
.append("path")
|
|
679
|
-
.attr("class", "area")
|
|
680
|
-
.attr("fill", (d) => d.properties.color !== "#ffffff" ? d.properties.color : "none")
|
|
681
|
-
.style("fill-opacity", formatOptions.plotArea.fillOpacity);
|
|
682
|
-
// ENTER + UPDATE
|
|
683
|
-
areaGroupsEnter
|
|
684
|
-
.merge(areaGroups)
|
|
685
|
-
.select("path")
|
|
686
|
-
.attr("d", (d) => areaGenerator(d.data))
|
|
687
|
-
.attr("stroke", (d) => d.properties.areaBorderColor !== "#ffffff"
|
|
688
|
-
? d.properties.areaBorderColor
|
|
689
|
-
: "none")
|
|
690
|
-
.attr("stroke-dasharray", (d) => {
|
|
691
|
-
switch (d.properties.lineStyle) {
|
|
692
|
-
case "dotted":
|
|
693
|
-
return "0,3";
|
|
694
|
-
case "dashed":
|
|
695
|
-
return "20,10,5,5,5,10";
|
|
696
|
-
default:
|
|
697
|
-
return "";
|
|
698
|
-
}
|
|
699
|
-
})
|
|
700
|
-
.attr("stroke-linecap", (d) => d.properties.lineStyle === "dotted" ? "round" : "")
|
|
701
|
-
.attr("stroke-width", (d) => d.properties.lineStyle !== "None" &&
|
|
702
|
-
formatOptions.plotArea.plotAreaHideLineAndMarkers
|
|
703
|
-
? d.properties.lineWidth
|
|
704
|
-
: "0");
|
|
705
|
-
onHoverMarkerForAreaChartFamily(formatOptions, areas, focus, filteredDimension, lineData, xScale, yScaleLeft, chartType);
|
|
706
|
-
// EXIT: remove old groups
|
|
707
|
-
areaGroups.exit().remove();
|
|
708
|
-
//Markers
|
|
709
|
-
// lineMarkers(
|
|
710
|
-
// areas,
|
|
711
|
-
// lineData,
|
|
712
|
-
// chartType,
|
|
713
|
-
// xScale,
|
|
714
|
-
// yScaleLeft,
|
|
715
|
-
// undefined,
|
|
716
|
-
// null,
|
|
717
|
-
// formatOptions,
|
|
718
|
-
// chartJSON,
|
|
719
|
-
// secondaryCustomYaxisMaxValue,
|
|
720
|
-
// secondaryCustomYaxisMinValue,
|
|
721
|
-
// customYaxisMinValue,
|
|
722
|
-
// customYaxisMaxValue
|
|
723
|
-
// );
|
|
724
|
-
};
|
|
725
|
-
const drawStackAreaChart = (data) => {
|
|
726
|
-
const areaGenerator = d3
|
|
727
|
-
.area()
|
|
728
|
-
.x((d) => xScale(d.data.dimension)
|
|
729
|
-
? xScale(d.data.dimension)
|
|
730
|
-
: null)
|
|
731
|
-
.y0((d) => d.data.axis == "Primary" ? yScaleLeft(0) : yScaleRight(0))
|
|
732
|
-
.y1((d) => d.data.axis == "Primary"
|
|
733
|
-
? d[1] > 0
|
|
734
|
-
? yScaleLeft(d[1])
|
|
735
|
-
: yScaleLeft(d[0])
|
|
736
|
-
: d[1] > 0
|
|
737
|
-
? yScaleRight(d[1])
|
|
738
|
-
: yScaleRight(d[0]))
|
|
739
|
-
.defined((d) => (d.hideZero ? Boolean(d.key) : true))
|
|
740
|
-
.curve(getCurveType(formatOptions));
|
|
741
|
-
// Bind dummy data to ensure a single group is created
|
|
742
|
-
let areas = gTag.selectAll(".parentGroup").data([stackAreaData]);
|
|
743
|
-
let focus = gTag.append("g").attr("class", "focusClass");
|
|
744
|
-
areas = areas
|
|
745
|
-
.enter()
|
|
746
|
-
.append("g")
|
|
747
|
-
.attr("class", "areas parentGroup")
|
|
748
|
-
.merge(areas);
|
|
749
|
-
// JOIN: one group per line
|
|
750
|
-
let areaGroups = areas.selectAll(".area-group").data((d) => d);
|
|
751
|
-
// ENTER: create group for each new line
|
|
752
|
-
let areaGroupsEnter = areaGroups
|
|
753
|
-
// .data((d) => d.stackData)
|
|
754
|
-
.enter()
|
|
755
|
-
.append("g")
|
|
756
|
-
.attr("class", (d) => "area-group " + d.key.replace(/ /g, "-"));
|
|
757
|
-
// .attr("class", (d) => d.key.replace(/ /g, "-"));
|
|
758
|
-
areaGroupsEnter
|
|
759
|
-
.attr("hoverId", (d) => d.key.includes("~$~")
|
|
760
|
-
? d.key.split("~$~")[1].replace(/ /g, "-")
|
|
761
|
-
: d.key.replace(/ /g, "-"))
|
|
762
|
-
.append("path")
|
|
763
|
-
.attr("class", "area")
|
|
764
|
-
.attr("fill", (d) => (d.color !== "#ffffff" ? d.color : "none"));
|
|
765
|
-
// ENTER + UPDATE
|
|
766
|
-
areaGroupsEnter
|
|
767
|
-
.merge(areaGroups)
|
|
768
|
-
.select("path")
|
|
769
|
-
.attr("d", (d, i) => areaGenerator(d))
|
|
770
|
-
.style("opacity", formatOptions.plotArea.fillOpacity)
|
|
771
|
-
.attr("stroke", (d) => (d.color !== "#ffffff" ? d.color : "none"))
|
|
772
|
-
// .style("visibility", (d,i) => (this.individualLegendStyle[i].hideZero && d[i].data[d.key] === 0) ? "hidden" : "visible")
|
|
773
|
-
.attr("stroke-dasharray", (d, i) => seriesData[i].properties.lineStyle === "dotted"
|
|
774
|
-
? "0,3"
|
|
775
|
-
: seriesData[i].properties.lineStyle === "dashed"
|
|
776
|
-
? "20,10,5,5,5,10"
|
|
777
|
-
: "")
|
|
778
|
-
.attr("stroke-linecap", (d, i) => seriesData[i].properties.lineStyle === "dotted" ? "round" : "")
|
|
779
|
-
.attr("stroke-width", (d, i) => seriesData[i].properties.lineStyle !== "None"
|
|
780
|
-
? seriesData[i].properties.lineWidth
|
|
781
|
-
: "0");
|
|
782
|
-
// onHoverMarkerForAreaChartFamily(formatOptions, areas, focus, filteredDimension, lineData, xScale, yScaleLeft, chartType);
|
|
783
|
-
// EXIT: remove old groups
|
|
784
|
-
areaGroups.exit().remove();
|
|
785
|
-
// Markers
|
|
786
|
-
lineMarkers(areas, data.data, "CombiStackArea", xScale, yScaleLeft, yScaleRight, null, formatOptions, chartJSON, secondaryCustomYaxisMaxValue, secondaryCustomYaxisMinValue, customYaxisMinValue, customYaxisMaxValue, false);
|
|
787
|
-
};
|
|
788
|
-
const drawStackColumnChart = () => {
|
|
789
|
-
let stackColumns = gTag.selectAll(".parentGroup").data([stackColumnData]);
|
|
790
|
-
stackColumns = stackColumns
|
|
791
|
-
.enter()
|
|
792
|
-
.append("g")
|
|
793
|
-
.attr("class", "stackcolumns parentGroup")
|
|
794
|
-
.merge(stackColumns);
|
|
795
|
-
// JOIN: one group per stack series
|
|
796
|
-
let stackColumnGroups = stackColumns
|
|
797
|
-
.selectAll(".stackcolumns-group")
|
|
798
|
-
.data((d) => d);
|
|
799
|
-
// ENTER
|
|
800
|
-
let stackColumnGroupsEnter = stackColumnGroups
|
|
801
|
-
.enter()
|
|
802
|
-
.append("g")
|
|
803
|
-
.attr("class", (d) => "stackcolumns-group ");
|
|
804
|
-
stackColumnGroups = stackColumnGroupsEnter.merge(stackColumnGroups);
|
|
805
|
-
// JOIN rects inside each series
|
|
806
|
-
let rects = stackColumnGroups.selectAll("rect").data((d) => d);
|
|
807
|
-
// ENTER
|
|
808
|
-
rects
|
|
809
|
-
.enter()
|
|
810
|
-
.append("rect")
|
|
811
|
-
.attr("transform", (d) => `translate(${xScale(d.data.dimension) - columnWidth / 2},0)`)
|
|
812
|
-
.merge(rects)
|
|
813
|
-
.attr("hoverId", (d) => d.key.includes("~$~")
|
|
814
|
-
? d.key.split("~$~")[1].replace(/ /g, "-")
|
|
815
|
-
: d.key.replace(/ /g, "-"))
|
|
816
|
-
.attr("x", (d) => xScaleForLegends("stackLegend"))
|
|
817
|
-
.attr("y", (d) => d.data.axis === "Primary" ? yScaleLeft(d[1]) : yScaleRight(d[1]))
|
|
818
|
-
.attr("height", (d) => d.data.axis === "Primary"
|
|
819
|
-
? customYaxisMaxValue && d[1] > customYaxisMaxValue
|
|
820
|
-
? yScaleLeft(d[0]) - yScaleLeft(customYaxisMaxValue)
|
|
821
|
-
: yScaleLeft(d[0]) - yScaleLeft(d[1])
|
|
822
|
-
: secondaryCustomYaxisMaxValue && d[1] > secondaryCustomYaxisMaxValue
|
|
823
|
-
? yScaleRight(d[0]) - yScaleRight(secondaryCustomYaxisMaxValue)
|
|
824
|
-
: yScaleRight(d[0]) - yScaleRight(d[1]))
|
|
825
|
-
.attr("width", xScaleForLegends.bandwidth())
|
|
826
|
-
.attr("fill", (d, i, nodes) => {
|
|
827
|
-
// `nodes[i]` gives access to parent node so we can infer which group (series) we're in
|
|
828
|
-
const seriesIndex = Array.from(seriesData).findIndex((sdata) => sdata.legend === d.key);
|
|
829
|
-
return seriesData[seriesIndex]?.properties?.color || "gray";
|
|
830
|
-
})
|
|
831
|
-
.attr("stroke", (d, i, nodes) => {
|
|
832
|
-
const seriesIndex = Array.from(seriesData).findIndex((sdata) => sdata.legend === d.key);
|
|
833
|
-
const props = seriesData[seriesIndex]?.properties;
|
|
834
|
-
return props?.stackBorderStyle === 0
|
|
835
|
-
? "none"
|
|
836
|
-
: formatOptions.column.stackBorderVisibility
|
|
837
|
-
? props.stackBorderColor
|
|
838
|
-
: "none";
|
|
839
|
-
})
|
|
840
|
-
.attr("stroke-dasharray", (d, i, nodes) => {
|
|
841
|
-
const seriesIndex = Array.from(seriesData).findIndex((sdata) => sdata.legend === d.key);
|
|
842
|
-
return seriesData[seriesIndex]?.properties.stackBorderStyle === 2
|
|
843
|
-
? "5,3"
|
|
844
|
-
: "0";
|
|
845
|
-
})
|
|
846
|
-
.attr("stroke-width", (d, i, nodes) => {
|
|
847
|
-
const seriesIndex = Array.from(seriesData).findIndex((sdata) => sdata.legend === d.key);
|
|
848
|
-
return ((seriesData[seriesIndex]?.properties.stackBorderWidth || 0) + "px");
|
|
849
|
-
})
|
|
850
|
-
.on("mousemove", (event, d) => {
|
|
851
|
-
showTooltipOnMouseMove([
|
|
852
|
-
{
|
|
853
|
-
key: formatOptions.xAxisTitle.xAxisTitleText.includes("~$~")
|
|
854
|
-
? formatOptions.xAxisTitle.xAxisTitleText.split("~$~")[1]
|
|
855
|
-
: formatOptions.xAxisTitle.xAxisTitleText,
|
|
856
|
-
value: chartJSON.formattedDimensionListMap.get(d.data.dimension),
|
|
857
|
-
},
|
|
858
|
-
{
|
|
859
|
-
key: formatOptions.yAxisTitle.yAxisTitleText || d.value,
|
|
860
|
-
value: getNumberWithFormat(d.data[d.key], formatOptions.toolTip.toolTipDisplayUnits, formatOptions.toolTip.toolTipNumberFormat, formatOptions.toolTip.toolTipDecimalPrecision),
|
|
861
|
-
},
|
|
862
|
-
{
|
|
863
|
-
key: "Legend",
|
|
864
|
-
value: d.key.includes("~$~") ? d.key.split("~$~")[1] : d.key,
|
|
865
|
-
},
|
|
866
|
-
], formatOptions, event);
|
|
867
|
-
})
|
|
868
|
-
.on("mouseout", hideTooltipOnMouseOut);
|
|
869
|
-
// EXIT: remove old groups
|
|
870
|
-
stackColumnGroups.exit().remove();
|
|
871
|
-
};
|
|
872
|
-
const setSVGContainer = (margin) => {
|
|
873
|
-
innerWidth = width - margin.left - margin.right;
|
|
874
|
-
innerHeight = height - margin.bottom - margin.top;
|
|
875
|
-
};
|
|
876
|
-
const horizontalScrollBar = (seriesData, height, svg, margin, innerWidth) => {
|
|
877
|
-
if (!formatOptions.plotArea.fitChart) {
|
|
878
|
-
// Scrollbar parameters
|
|
879
|
-
const scrollMax = seriesData[0].data.length - visibleBars;
|
|
880
|
-
// Scrollbar track & handle
|
|
881
|
-
const scrollbarY = height - 20;
|
|
882
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
883
|
-
// check and add data to filteredData for stack type charts
|
|
884
|
-
checkAndupdateInputData(primaryStackAreaAxisData, primaryStackColumnAxisData, secondaryStackAreaAxisData, secondaryStackColumnAxisData);
|
|
885
|
-
getXScale();
|
|
886
|
-
filteredData = JSON.parse(JSON.stringify(requiredData));
|
|
887
|
-
filteredData.forEach((data, i) => {
|
|
888
|
-
if (data.properties.type === actualChartTypes.stackColumn ||
|
|
889
|
-
data.properties.type === actualChartTypes.stackArea) {
|
|
890
|
-
data.data.forEach((stackData, pos) => {
|
|
891
|
-
filteredData[i].data[pos]["data"] = stackData.data.filter((d) => filteredDimension.includes(d.dimension));
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
else {
|
|
895
|
-
filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension));
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
getXAxis();
|
|
899
|
-
svg
|
|
900
|
-
.append("rect")
|
|
901
|
-
.attr("x", margin.left)
|
|
902
|
-
.attr("y", scrollbarY)
|
|
903
|
-
.attr("width", innerWidth)
|
|
904
|
-
.attr("height", 8)
|
|
905
|
-
.attr("fill", "#ddd")
|
|
906
|
-
.attr("rx", 4);
|
|
907
|
-
const handleWidth = (innerWidth * visibleBars) / chartJSON.dimensionList.length;
|
|
908
|
-
const handle = svg
|
|
909
|
-
.append("rect")
|
|
910
|
-
.attr("x", margin.left)
|
|
911
|
-
.attr("y", scrollbarY)
|
|
912
|
-
.attr("width", handleWidth)
|
|
913
|
-
.attr("height", 8)
|
|
914
|
-
.attr("fill", "#999")
|
|
915
|
-
.attr("rx", 4)
|
|
916
|
-
.style("cursor", "ew-resize")
|
|
917
|
-
.call(d3.drag().on("drag", (event) => {
|
|
918
|
-
let x = Math.min(Math.max(event.x, margin.left), margin.left + innerWidth - handleWidth);
|
|
919
|
-
handle.attr("x", x);
|
|
920
|
-
scrollPosition = Math.round(((x - margin.left) / (innerWidth - handleWidth)) * scrollMax);
|
|
921
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
922
|
-
// check and add data to filteredData for stack type charts
|
|
923
|
-
checkAndupdateInputData(primaryStackAreaAxisData, primaryStackColumnAxisData, secondaryStackAreaAxisData, secondaryStackColumnAxisData);
|
|
924
|
-
getXScale();
|
|
925
|
-
filteredData = JSON.parse(JSON.stringify(requiredData));
|
|
926
|
-
filteredData.forEach((data, i) => {
|
|
927
|
-
if (data.properties.type === actualChartTypes.stackColumn ||
|
|
928
|
-
data.properties.type === actualChartTypes.stackArea) {
|
|
929
|
-
data.data.forEach((stackData, pos) => (filteredData[i].data[pos]["data"] = stackData.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
930
|
-
}
|
|
931
|
-
else {
|
|
932
|
-
filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension));
|
|
933
|
-
}
|
|
934
|
-
});
|
|
935
|
-
getXAxis();
|
|
936
|
-
drawCustomChart();
|
|
937
|
-
}));
|
|
938
|
-
svg.on("wheel", (event) => {
|
|
939
|
-
event.preventDefault();
|
|
940
|
-
const scrollDelta = Math.abs(event.deltaX) > Math.abs(event.deltaY)
|
|
941
|
-
? event.deltaX
|
|
942
|
-
: event.deltaY;
|
|
943
|
-
scrollPosition += scrollDelta > 0 ? 1 : -1;
|
|
944
|
-
scrollPosition = Math.max(0, Math.min(scrollPosition, scrollMax));
|
|
945
|
-
const x = margin.left +
|
|
946
|
-
((innerWidth - handleWidth) * scrollPosition) / scrollMax;
|
|
947
|
-
handle.attr("x", x);
|
|
948
|
-
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
949
|
-
// check and add data to filteredData for stack type charts
|
|
950
|
-
checkAndupdateInputData(primaryStackAreaAxisData, primaryStackColumnAxisData, secondaryStackAreaAxisData, secondaryStackColumnAxisData);
|
|
951
|
-
getXScale();
|
|
952
|
-
filteredData = JSON.parse(JSON.stringify(requiredData));
|
|
953
|
-
filteredData.forEach((data, i) => {
|
|
954
|
-
if (data.properties.type === actualChartTypes.stackColumn ||
|
|
955
|
-
data.properties.type === actualChartTypes.stackArea) {
|
|
956
|
-
data.data.forEach((stackData, pos) => (filteredData[i].data[pos]["data"] = stackData.data.filter((d) => filteredDimension.includes(d.dimension))));
|
|
957
|
-
}
|
|
958
|
-
else {
|
|
959
|
-
filteredData[i].data = data.data.filter((d) => filteredDimension.includes(d.dimension));
|
|
960
|
-
}
|
|
961
|
-
});
|
|
962
|
-
getXAxis();
|
|
963
|
-
drawCustomChart();
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
else {
|
|
967
|
-
filteredData = JSON.parse(JSON.stringify(requiredData));
|
|
968
|
-
}
|
|
969
|
-
drawCustomChart();
|
|
970
|
-
};
|
|
971
|
-
const drawCustomChart = () => {
|
|
972
|
-
getChartType(filteredData);
|
|
973
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
974
|
-
commonAnnotationsForCustomChart(filteredData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
|
|
975
|
-
margin, d3Annotation, stackColumnData, stackAreaData, [], //labelExcludeList
|
|
976
|
-
[], // individualLabelColor
|
|
977
|
-
columnWidth, [], //old annotation list
|
|
978
|
-
formatOptions, height, width, innerWidth, filteredDimension, innerHeight, chartId, svg, xScaleForLegends);
|
|
979
|
-
};
|
|
980
|
-
const createStackData = (requiredStackChatData) => {
|
|
981
|
-
let legendList = requiredStackChatData.data.map((d) => d.legend);
|
|
982
|
-
stackChartData = d3
|
|
983
|
-
.stack()
|
|
984
|
-
.keys(legendList)
|
|
985
|
-
.offset(d3.stackOffsetDiverging)(requiredStackChatData.stackData);
|
|
986
|
-
requiredStackChatData.data.forEach((data, index) => data.data.forEach((axisData, position) => {
|
|
987
|
-
axisData["0"] = stackChartData[index][position][0];
|
|
988
|
-
axisData["1"] = stackChartData[index][position][1];
|
|
989
|
-
}));
|
|
990
|
-
//Appending Extra key for tooltip color
|
|
991
|
-
let seriesColor = formatOptions.annotation.annotationSetLabelColor;
|
|
992
|
-
stackChartData.forEach((stackData, j) => {
|
|
993
|
-
stackData.forEach((d) => {
|
|
994
|
-
d["key"] = stackData.key;
|
|
995
|
-
stackData["color"] = JSON.parse(JSON.stringify(requiredStackChatData.data[j].properties.color));
|
|
996
|
-
d.data.labelPosition =
|
|
997
|
-
requiredStackChatData.data[j].properties.dataLabelPosition;
|
|
998
|
-
d.data["labelColor"] =
|
|
999
|
-
seriesColor == "2"
|
|
1000
|
-
? JSON.parse(JSON.stringify(requiredStackChatData.data[j].properties.color))
|
|
1001
|
-
: JSON.parse(JSON.stringify(requiredStackChatData.data[j].properties.labelColor));
|
|
1002
|
-
d["hideZero"] = JSON.parse(JSON.stringify(requiredStackChatData.data[j].properties.hideZeroValues));
|
|
1003
|
-
d.data["axis"] = JSON.parse(JSON.stringify(requiredStackChatData.data[j].properties.axis));
|
|
1004
|
-
d.data["color"] = JSON.parse(JSON.stringify(requiredStackChatData.data[j].properties.color));
|
|
1005
|
-
d.data["legend"] = `stackLegend`;
|
|
1006
|
-
d.data["type"] = JSON.parse(JSON.stringify(requiredStackChatData.data[j].properties.type));
|
|
1007
|
-
});
|
|
1008
|
-
});
|
|
1009
|
-
return stackChartData;
|
|
1010
|
-
};
|
|
1011
|
-
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%" } })] }));
|
|
1012
|
-
};
|
|
1013
|
-
export default CustomColumnChart;
|