pace-chart-lib 0.0.12 → 1.0.1
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/Charts/ChartsWithAxis/AreaFamily/AreaChart.js +9 -11
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/NormalizedStackAreaChart.js +6 -9
- package/dist/components/Charts/ChartsWithAxis/AreaFamily/StackAreaChart.js +7 -10
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +4 -4
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +12 -17
- package/dist/components/Charts/ChartsWithAxis/ChartsWithAxisTypes.types.d.ts +2 -4
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnChart.js +9 -11
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/ColumnHistogramChart.js +8 -7
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/CustomColumnChart.js +11 -13
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/LayeredColumnChart.js +11 -13
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/NormalizedStackColumnChart.js +7 -10
- package/dist/components/Charts/ChartsWithAxis/ColumnFamily/StackColumnChart.js +7 -10
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalBarChart.js +9 -11
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/HorizontalHistogramChart.js +11 -13
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/LayeredHorizontalBarChart.js +11 -13
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/NormalizedStackHorizontalBarChart.js +6 -7
- package/dist/components/Charts/ChartsWithAxis/HorizontalBarFamily/StackHorizontalBarChart.js +3 -3
- package/dist/components/Charts/ChartsWithAxis/LineFamily/LineChart.js +9 -11
- package/dist/components/Charts/ChartsWithAxis/LineFamily/NormalizedStackLineChart.js +7 -10
- package/dist/components/Charts/ChartsWithAxis/LineFamily/StackLineChart.js +7 -10
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/TornadoChart.js +10 -12
- package/dist/components/Charts/ChartsWithAxis/MiscellaneousChartFamily/WaterfallChart.js +19 -22
- package/dist/components/Charts/ChartsWithoutAxis/OtherCharts/OrganizationChart.js +4 -3
- package/dist/components/Charts/Core/Common.types.d.ts +3 -3
- package/dist/components/Charts/Core/CommonFunctions.js +3 -1
- package/package.json +27 -11
- package/dist/Components1/Charts/ChartsWithAxis/BarFamily/BarChart.d.ts +0 -12
- package/dist/Components1/Charts/ChartsWithAxis/BarFamily/BarChart.js +0 -9
- package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.d.ts +0 -46
- package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisFunctions.js +0 -2285
- package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.d.ts +0 -169
- package/dist/Components1/Charts/ChartsWithAxis/ChartsWithAxisTypes.type.js +0 -47
- package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.d.ts +0 -4
- package/dist/Components1/Charts/ChartsWithAxis/LineFamily/LineChart.js +0 -403
- package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.d.ts +0 -0
- package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisFunctions.js +0 -0
- package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.d.ts +0 -0
- package/dist/Components1/Charts/ChartsWithoutAxis/ChartsWithoutAxisTypes.type.js +0 -0
- package/dist/Components1/Charts/Core/Common.type.d.ts +0 -8
- package/dist/Components1/Charts/Core/Common.type.js +0 -9
- package/dist/Components1/Charts/Core/CommonFunctions.d.ts +0 -12
- package/dist/Components1/Charts/Core/CommonFunctions.js +0 -512
- package/dist/Components1/Charts/Core/DefaultProperties.d.ts +0 -586
- package/dist/Components1/Charts/Core/DefaultProperties.js +0 -585
|
@@ -10,8 +10,9 @@ import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, dra
|
|
|
10
10
|
// initYaxisRight,
|
|
11
11
|
commonAnnotations, marginCalculation, prepareDataForSeriesLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight, } from "../ChartsWithAxisFunctions";
|
|
12
12
|
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
13
|
-
const AreaChart = ({
|
|
13
|
+
const AreaChart = ({ isDateType, formatOptions, data, }) => {
|
|
14
14
|
// adding variables as per requirement
|
|
15
|
+
const chartId = crypto.randomUUID();
|
|
15
16
|
const barWidth = 0; // coz line chart
|
|
16
17
|
const chartType = actualChartTypes.area;
|
|
17
18
|
const svgRef = useRef();
|
|
@@ -103,7 +104,7 @@ const AreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, })
|
|
|
103
104
|
secondaryYLabel,
|
|
104
105
|
} = marginCalculation(
|
|
105
106
|
// for all margin related calculations
|
|
106
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart,
|
|
107
|
+
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
107
108
|
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
108
109
|
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
109
110
|
// calculations for data tables
|
|
@@ -141,7 +142,7 @@ const AreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, })
|
|
|
141
142
|
const preProcessChartData = () => {
|
|
142
143
|
const allChartData = [];
|
|
143
144
|
const legendList = [];
|
|
144
|
-
let
|
|
145
|
+
let formatedDimensionList = [];
|
|
145
146
|
let yMaxLeft = -Infinity;
|
|
146
147
|
let yMinLeft = Infinity;
|
|
147
148
|
let yMaxRight = -Infinity;
|
|
@@ -168,14 +169,11 @@ const AreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, })
|
|
|
168
169
|
chartJSON.yMaxRight = yMaxRight;
|
|
169
170
|
chartJSON.yMinRight = yMinRight;
|
|
170
171
|
// Apply formatted dimensions
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
xAxisObject.dataType === "DATE"
|
|
175
|
-
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
176
|
-
: chartJSON.dimensionList;
|
|
172
|
+
formatedDimensionList = isDateType
|
|
173
|
+
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
174
|
+
: chartJSON.dimensionList;
|
|
177
175
|
chartJSON.dimensionList.forEach((dim, i) => {
|
|
178
|
-
chartJSON.formattedDimensionListMap.set(dim,
|
|
176
|
+
chartJSON.formattedDimensionListMap.set(dim, formatedDimensionList[i]);
|
|
179
177
|
});
|
|
180
178
|
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
181
179
|
if (!formatOptions.plotArea.fitChart) {
|
|
@@ -483,7 +481,7 @@ const AreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, })
|
|
|
483
481
|
};
|
|
484
482
|
const drawAreaChart = () => {
|
|
485
483
|
getChartType(filteredData);
|
|
486
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions,
|
|
484
|
+
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
487
485
|
commonAnnotations(seriesData, xScale, yScaleLeft, undefined, // need to pass secondary axis scale if secondary axis is drawn
|
|
488
486
|
margin, d3Annotation, [], //this.labelExcludeList,
|
|
489
487
|
[], //this.individualLabelColor,
|
|
@@ -8,16 +8,15 @@ import { staticLegendShape } from "../../Core/Common.types";
|
|
|
8
8
|
import { drawLegends, generalizedChartData, lineMarkers, onHoverMarkerForAreaChartFamily, } from "../../Core/CommonFunctions";
|
|
9
9
|
import { addDataTable, dataTablePreCalculation, drawSeriesLabels, firstFunctionBeforeRender, getCurveType, getStackedData, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, prepareDataForSeriesLabel, responsiveXaxisLabel, setChartTitle, setDateFormats, setXaxistitle, stacklineAnnotations, yAxistitle, yAxistitleRight, } from "../ChartsWithAxisFunctions";
|
|
10
10
|
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
11
|
-
const NormalizedStackAreaChart = ({
|
|
11
|
+
const NormalizedStackAreaChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
12
|
// adding variables as per requirement
|
|
13
|
+
const chartId = crypto.randomUUID();
|
|
13
14
|
const barWidth = 0; // coz line chart
|
|
14
15
|
const chartType = actualChartTypes.stackArea100;
|
|
15
16
|
const svgRef = useRef();
|
|
16
17
|
const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
|
|
17
18
|
const dimensionList = data.DimensionList;
|
|
18
19
|
const barChart = false;
|
|
19
|
-
const chartsWithXScrollFlag = true;
|
|
20
|
-
const chartsWithYScrollFlag = false;
|
|
21
20
|
const isSecondaryAxisDrawn = false;
|
|
22
21
|
let isPrimaryAxisDrawn = true;
|
|
23
22
|
let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
|
|
@@ -113,7 +112,7 @@ const NormalizedStackAreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, fo
|
|
|
113
112
|
secondaryYLabel,
|
|
114
113
|
} = marginCalculation(
|
|
115
114
|
// for all margin related calculations
|
|
116
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart,
|
|
115
|
+
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
117
116
|
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
118
117
|
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
119
118
|
// calculations for data tables
|
|
@@ -198,13 +197,11 @@ const NormalizedStackAreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, fo
|
|
|
198
197
|
chartJSON.yMinLeft = yMinLeft > 0 ? 0 : yMinLeft;
|
|
199
198
|
chartJSON.yMaxLeft = 1; // as per your original override
|
|
200
199
|
// Format dimensions
|
|
201
|
-
const
|
|
202
|
-
const formatedDimesionList = (xAxisObject.groupBy === "NA" || xAxisObject.groupBy === undefined) &&
|
|
203
|
-
xAxisObject.dataType === "DATE"
|
|
200
|
+
const formatedDimensionList = isDateType
|
|
204
201
|
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
205
202
|
: chartJSON.dimensionList;
|
|
206
203
|
// Assign formatted dimension list map (cleanest one-liner)
|
|
207
|
-
chartJSON.formattedDimensionListMap = new Map(chartJSON.dimensionList.map((d, i) => [d,
|
|
204
|
+
chartJSON.formattedDimensionListMap = new Map(chartJSON.dimensionList.map((d, i) => [d, formatedDimensionList[i]]));
|
|
208
205
|
// let secondaryAxisMinValue = 0;
|
|
209
206
|
// let secondaryAxisMaxValue = 0;
|
|
210
207
|
// if (isSecondaryAxisDrawn) {
|
|
@@ -481,7 +478,7 @@ const NormalizedStackAreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, fo
|
|
|
481
478
|
const drawLineChart = () => {
|
|
482
479
|
// filteredData.forEach((data) => getChartType([data]));
|
|
483
480
|
getChartType(filteredData);
|
|
484
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions,
|
|
481
|
+
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
485
482
|
stacklineAnnotations(stackChartData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
|
|
486
483
|
margin, d3Annotation, [], //this.labelExcludeList,
|
|
487
484
|
[], //this.individualLabelColor,
|
|
@@ -5,19 +5,18 @@ import * as d3Annotation from "d3-svg-annotation";
|
|
|
5
5
|
import { useEffect, useRef } from "react";
|
|
6
6
|
import { logError } from "../../../../Services/ErrorLog";
|
|
7
7
|
import { staticLegendShape } from "../../Core/Common.types";
|
|
8
|
-
import { drawLegends, generalizedChartData, lineMarkers, onHoverMarkerForAreaChartFamily
|
|
8
|
+
import { drawLegends, generalizedChartData, lineMarkers, onHoverMarkerForAreaChartFamily } from "../../Core/CommonFunctions";
|
|
9
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
10
|
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
11
|
-
const StackAreaChart = ({
|
|
11
|
+
const StackAreaChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
12
|
// adding variables as per requirement
|
|
13
|
+
const chartId = crypto.randomUUID();
|
|
13
14
|
const barWidth = 0; // coz line chart
|
|
14
15
|
const chartType = actualChartTypes.stackArea;
|
|
15
16
|
const svgRef = useRef();
|
|
16
17
|
const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
|
|
17
18
|
const dimensionList = data.DimensionList;
|
|
18
19
|
const barChart = false;
|
|
19
|
-
const chartsWithXScrollFlag = true;
|
|
20
|
-
const chartsWithYScrollFlag = false;
|
|
21
20
|
const isSecondaryAxisDrawn = false;
|
|
22
21
|
let isPrimaryAxisDrawn = true;
|
|
23
22
|
let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
|
|
@@ -107,7 +106,7 @@ const StackAreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOption
|
|
|
107
106
|
secondaryYLabel,
|
|
108
107
|
} = marginCalculation(
|
|
109
108
|
// for all margin related calculations
|
|
110
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart,
|
|
109
|
+
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
111
110
|
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
112
111
|
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
113
112
|
// calculations for data tables
|
|
@@ -186,13 +185,11 @@ const StackAreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOption
|
|
|
186
185
|
}
|
|
187
186
|
chartJSON.yMinLeft = yMinLeft > 0 ? 0 : yMinLeft;
|
|
188
187
|
chartJSON.yMaxLeft = yMaxLeft;
|
|
189
|
-
let
|
|
190
|
-
let formatedDimesionList = (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
|
|
191
|
-
xAxisObject.dataType === "DATE"
|
|
188
|
+
let formatedDimensionList = isDateType
|
|
192
189
|
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
193
190
|
: chartJSON.dimensionList;
|
|
194
191
|
chartJSON.dimensionList.forEach((d, i) => {
|
|
195
|
-
chartJSON.formattedDimensionListMap.set(d,
|
|
192
|
+
chartJSON.formattedDimensionListMap.set(d, formatedDimensionList[i]);
|
|
196
193
|
});
|
|
197
194
|
if (formatOptions.plotArea.hideZeroValues) {
|
|
198
195
|
chartJSON.hideZeroValues = true;
|
|
@@ -481,7 +478,7 @@ const StackAreaChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOption
|
|
|
481
478
|
const drawLineChart = () => {
|
|
482
479
|
// filteredData.forEach((data) => getChartType([data]));
|
|
483
480
|
getChartType(filteredData);
|
|
484
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions,
|
|
481
|
+
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
485
482
|
stacklineAnnotations(stackChartData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
|
|
486
483
|
margin, d3Annotation, [], //this.labelExcludeList,
|
|
487
484
|
[], //this.individualLabelColor,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as d3 from "d3";
|
|
2
2
|
import { TSeries } from "../Core/Common.types";
|
|
3
3
|
import { TDefaultChartFormatOptionsType } from "../Core/DefaultProperties.types";
|
|
4
|
-
import {
|
|
4
|
+
import { TChartJSON, TMargin } from "./ChartsWithAxisTypes.types";
|
|
5
5
|
/**
|
|
6
6
|
* Dynamically calculates the width and height of a text element rendered with given styles.
|
|
7
7
|
* Optionally supports text rotation and fixed width wrapping.
|
|
@@ -56,7 +56,7 @@ export declare function getYAxisLabel(formatOptions: TDefaultChartFormatOptionsT
|
|
|
56
56
|
* secondaryAxisTitleWidth: number
|
|
57
57
|
* }} Object containing calculated margins and supporting layout measurements.
|
|
58
58
|
*/
|
|
59
|
-
export declare function marginCalculation(windowWidth: number, windowHeight: number, maxNumberForPrimaryAxis: number, maxNumberForSecondaryAxis: number, yMaxLeft: number, formatOptions: TDefaultChartFormatOptionsType, legendList: string[], dimensionList: string[], yMaxRight: number, isSecondaryAxisDrawn: boolean, isNormalizedChart: boolean,
|
|
59
|
+
export declare function marginCalculation(windowWidth: number, windowHeight: number, maxNumberForPrimaryAxis: number, maxNumberForSecondaryAxis: number, yMaxLeft: number, formatOptions: TDefaultChartFormatOptionsType, legendList: string[], dimensionList: string[], yMaxRight: number, isSecondaryAxisDrawn: boolean, isNormalizedChart: boolean, isDateType: boolean, isBarChart?: boolean): {
|
|
60
60
|
margin: TMargin;
|
|
61
61
|
yLabel: any;
|
|
62
62
|
xLabel: number;
|
|
@@ -332,7 +332,7 @@ export declare function responsiveXaxisLabel(dimensionList: string[], innerWidth
|
|
|
332
332
|
*
|
|
333
333
|
* @returns {any} The updated SVG group element (`gTag`) with the initialized X axis.
|
|
334
334
|
*/
|
|
335
|
-
export declare function initXaxis(gTag: any, chartJSON: TChartJSON, xLabel: number, formatOptions: TDefaultChartFormatOptionsType,
|
|
335
|
+
export declare function initXaxis(gTag: any, chartJSON: TChartJSON, xLabel: number, formatOptions: TDefaultChartFormatOptionsType, dataTableHeight: number, yScaleLeft: any, xAxis: any, dimensionHeightWidthArray: number[], height: number, barWidth: number, isDateType: string, innerWidth: number, innerHeight: number, filteredDimensionList: string[]): any;
|
|
336
336
|
export declare function detectBrowserName(): string;
|
|
337
337
|
/**
|
|
338
338
|
* Formats date dimension marks based on the specified format and datasource.
|
|
@@ -620,7 +620,7 @@ export declare const initXaxisBar: (formatOptions: TDefaultChartFormatOptionsTyp
|
|
|
620
620
|
*
|
|
621
621
|
* @returns {void} This function does not return a value; it modifies the chart by rendering or adjusting axes.
|
|
622
622
|
*/
|
|
623
|
-
export declare const initYaxisBar: (formatOptions: TDefaultChartFormatOptionsType, gTag: any, xLabel: number, innerHeight: number, innerWidth: number, yAxis: any, xAxisTop: any, xScaleBottom: any, yMaxLeft: number, dimensionList: string[], chartType: string,
|
|
623
|
+
export declare const initYaxisBar: (formatOptions: TDefaultChartFormatOptionsType, gTag: any, xLabel: number, innerHeight: number, innerWidth: number, yAxis: any, xAxisTop: any, xScaleBottom: any, yMaxLeft: number, dimensionList: string[], chartType: string, isDateType: any, width: number, dimensionHeightWidthArray: number[], columnWidth: number) => void;
|
|
624
624
|
export declare const dataLabelsPositionForBarChartFamily: (formatOptions: TDefaultChartFormatOptionsType, xCordinate: number, position: number, xScale: any, minValue: number, prevValue?: number, chartType?: string, isSensitivityChart?: boolean, axis?: string) => any;
|
|
625
625
|
export declare const initXaxisTop: (formatOptions: TDefaultChartFormatOptionsType, gTag: any, xLabelSecondary: number, xAxisTop: any) => void;
|
|
626
626
|
export declare const xAxisTitleTop: (formatOptions: TDefaultChartFormatOptionsType, svg: any, margin: TMargin, isSecondaryAxisDrawn: boolean, xLabelSecondary: number, xTitleSecondary: number) => void;
|
|
@@ -139,7 +139,7 @@ export function getYAxisLabel(formatOptions, maxLegendLength) {
|
|
|
139
139
|
* secondaryAxisTitleWidth: number
|
|
140
140
|
* }} Object containing calculated margins and supporting layout measurements.
|
|
141
141
|
*/
|
|
142
|
-
export function marginCalculation(windowWidth, windowHeight, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, yMaxLeft, formatOptions, legendList, dimensionList, yMaxRight, isSecondaryAxisDrawn, isNormalizedChart,
|
|
142
|
+
export function marginCalculation(windowWidth, windowHeight, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, yMaxLeft, formatOptions, legendList, dimensionList, yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType, isBarChart) {
|
|
143
143
|
try {
|
|
144
144
|
// min svg height/width final values are yet to decide.
|
|
145
145
|
let isDataTableDrawnWithAxis = formatOptions.dataTableProperties &&
|
|
@@ -161,16 +161,15 @@ export function marginCalculation(windowWidth, windowHeight, maxNumberForPrimary
|
|
|
161
161
|
: legend?.includes("-")
|
|
162
162
|
? legend?.slice(legend.indexOf("-") + 1).length
|
|
163
163
|
: legend?.length);
|
|
164
|
-
let
|
|
165
|
-
xAxisObject.dataType === "DATE"
|
|
164
|
+
let formatedDimensionList = isDateType
|
|
166
165
|
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, dimensionList).map((d) => d)
|
|
167
166
|
: dimensionList;
|
|
168
|
-
let maxDimension =
|
|
169
|
-
?
|
|
167
|
+
let maxDimension = formatedDimensionList
|
|
168
|
+
? formatedDimensionList[0] + ""
|
|
170
169
|
: "";
|
|
171
170
|
let maxDimensionLength = maxDimension.length;
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
formatedDimensionList &&
|
|
172
|
+
formatedDimensionList.forEach((dim) => {
|
|
174
173
|
dim = dim + "";
|
|
175
174
|
let length = dim.trim()?.length || 0;
|
|
176
175
|
if (length > maxDimensionLength) {
|
|
@@ -1237,19 +1236,16 @@ export function responsiveXaxisLabel(dimensionList, innerWidth) {
|
|
|
1237
1236
|
*
|
|
1238
1237
|
* @returns {any} The updated SVG group element (`gTag`) with the initialized X axis.
|
|
1239
1238
|
*/
|
|
1240
|
-
export function initXaxis(gTag, chartJSON, xLabel, formatOptions,
|
|
1239
|
+
export function initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, barWidth, isDateType, innerWidth, innerHeight, filteredDimensionList) {
|
|
1241
1240
|
try {
|
|
1242
1241
|
let responsiveDimList = chartJSON.chartType !== actualChartTypes.columnHistogram ? responsiveXaxisLabel(filteredDimensionList, innerWidth) : [];
|
|
1243
|
-
let xAxisObject = xAxisObj;
|
|
1244
1242
|
let formatedResponsiveDimList = [];
|
|
1245
1243
|
let actualDimesionWidth = dimensionHeightWidthArray[0] + 5;
|
|
1246
1244
|
let maxDimensionWidth = dimensionHeightWidthArray[3] + 10;
|
|
1247
1245
|
if (chartJSON.chartType != actualChartTypes.waterfall && chartJSON.chartType != actualChartTypes.columnHistogram) {
|
|
1248
|
-
formatedResponsiveDimList =
|
|
1249
|
-
(
|
|
1250
|
-
|
|
1251
|
-
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, responsiveDimList.map((d) => d)).map((d) => d)
|
|
1252
|
-
: responsiveDimList;
|
|
1246
|
+
formatedResponsiveDimList = isDateType
|
|
1247
|
+
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, responsiveDimList.map((d) => d)).map((d) => d)
|
|
1248
|
+
: responsiveDimList;
|
|
1253
1249
|
}
|
|
1254
1250
|
else {
|
|
1255
1251
|
responsiveDimList.forEach((item) => {
|
|
@@ -4693,15 +4689,14 @@ export const initXaxisBar = (formatOptions, gTag, yLabel, innerHeight, innerWidt
|
|
|
4693
4689
|
*
|
|
4694
4690
|
* @returns {void} This function does not return a value; it modifies the chart by rendering or adjusting axes.
|
|
4695
4691
|
*/
|
|
4696
|
-
export const initYaxisBar = (formatOptions, gTag, xLabel, innerHeight, innerWidth, yAxis, xAxisTop, xScaleBottom, yMaxLeft, dimensionList, chartType,
|
|
4692
|
+
export const initYaxisBar = (formatOptions, gTag, xLabel, innerHeight, innerWidth, yAxis, xAxisTop, xScaleBottom, yMaxLeft, dimensionList, chartType, isDateType, width, dimensionHeightWidthArray, columnWidth) => {
|
|
4697
4693
|
try {
|
|
4698
4694
|
let fontStyle = formatOptions.xAxisLabel.xAxisLabelFontStyle;
|
|
4699
4695
|
let xaxisLabelPosition = parseInt(formatOptions.xAxisLabel.xAxisPosition);
|
|
4700
4696
|
let responsiveDimList = responsiveXaxisLabel(dimensionList, innerWidth);
|
|
4701
4697
|
let labelWidth = formatOptions.xAxisLabel.labelTextWrap ? ((dimensionHeightWidthArray[3] + 10) < width * 0.1) ? (dimensionHeightWidthArray[3] + 10) : width * 0.1 : (formatOptions.xAxisLabel.xAxisLabelRotation == 0 ? columnWidth : (dimensionHeightWidthArray[0] + 5));
|
|
4702
4698
|
let xLabelMargin = (formatOptions.xAxisLabel.labelTextWrap) ? xLabel : labelWidth;
|
|
4703
|
-
let formatedResponsiveDimList =
|
|
4704
|
-
xAxisObject.dataType === "DATE"
|
|
4699
|
+
let formatedResponsiveDimList = isDateType
|
|
4705
4700
|
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, responsiveDimList.map((d) => d)).map((d) => d)
|
|
4706
4701
|
: responsiveDimList;
|
|
4707
4702
|
gTag
|
|
@@ -52,11 +52,9 @@ export declare enum actualChartTypes {
|
|
|
52
52
|
radialBarChart = "RadialBarChart"
|
|
53
53
|
}
|
|
54
54
|
export type TChartProps = {
|
|
55
|
-
title?: string;
|
|
56
55
|
data: TData;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
chartId: string;
|
|
56
|
+
isDateType: any;
|
|
57
|
+
chartId?: string;
|
|
60
58
|
formatOptions?: TDefaultChartFormatOptionsType;
|
|
61
59
|
};
|
|
62
60
|
export type TChartJSON = {
|
|
@@ -8,8 +8,9 @@ import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, showTooltipOn
|
|
|
8
8
|
import { addDataTable, commonAnnotations, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, initYaxisRight, marginCalculation, prepareDataForSeriesLabel, responsiveSecondaryYaxisLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight, } from "../ChartsWithAxisFunctions";
|
|
9
9
|
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
10
10
|
import { staticLegendShape, } from "../../Core/Common.types";
|
|
11
|
-
const ColumnChart = ({
|
|
11
|
+
const ColumnChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
12
|
// adding variables as per requirement
|
|
13
|
+
const chartId = crypto.randomUUID();
|
|
13
14
|
let columnWidth = 0; // coz line chartO
|
|
14
15
|
const chartType = actualChartTypes.column;
|
|
15
16
|
const svgRef = useRef();
|
|
@@ -102,7 +103,7 @@ const ColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions,
|
|
|
102
103
|
secondaryYLabel,
|
|
103
104
|
} = marginCalculation(
|
|
104
105
|
// for all margin related calculations
|
|
105
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart,
|
|
106
|
+
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
106
107
|
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
107
108
|
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
108
109
|
// calculations for data tables
|
|
@@ -134,7 +135,7 @@ const ColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions,
|
|
|
134
135
|
const preProcessChartData = () => {
|
|
135
136
|
const allChartData = [];
|
|
136
137
|
const legendList = [];
|
|
137
|
-
let
|
|
138
|
+
let formatedDimensionList = [];
|
|
138
139
|
let yMaxLeft = -Infinity;
|
|
139
140
|
let yMinLeft = Infinity;
|
|
140
141
|
let yMaxRight = -Infinity;
|
|
@@ -161,14 +162,11 @@ const ColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions,
|
|
|
161
162
|
chartJSON.yMaxRight = yMaxRight;
|
|
162
163
|
chartJSON.yMinRight = yMinRight;
|
|
163
164
|
// Apply formatted dimensions
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
xAxisObject.dataType === "DATE"
|
|
168
|
-
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
169
|
-
: chartJSON.dimensionList;
|
|
165
|
+
formatedDimensionList = isDateType
|
|
166
|
+
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
167
|
+
: chartJSON.dimensionList;
|
|
170
168
|
chartJSON.dimensionList.forEach((dim, i) => {
|
|
171
|
-
chartJSON.formattedDimensionListMap.set(dim,
|
|
169
|
+
chartJSON.formattedDimensionListMap.set(dim, formatedDimensionList[i]);
|
|
172
170
|
});
|
|
173
171
|
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
174
172
|
if (!formatOptions.plotArea.fitChart) {
|
|
@@ -487,7 +485,7 @@ const ColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions,
|
|
|
487
485
|
};
|
|
488
486
|
const drawColumnChart = () => {
|
|
489
487
|
getChartType(filteredData);
|
|
490
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions,
|
|
488
|
+
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
491
489
|
commonAnnotations(seriesData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
|
|
492
490
|
margin, d3Annotation, [], //this.labelExcludeList,
|
|
493
491
|
[], //this.individualLabelColor,
|
|
@@ -3,13 +3,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as d3 from "d3";
|
|
4
4
|
import { useEffect, useRef } from "react";
|
|
5
5
|
import { logError } from "../../../../Services/ErrorLog";
|
|
6
|
+
import { responsiveXaxisLabelForNumericValue } from "../../ChartsWithoutAxis/ChartsWithoutAxisFunctions";
|
|
7
|
+
import { staticLegendShape } from "../../Core/Common.types";
|
|
6
8
|
import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
|
|
7
|
-
import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, responsiveYaxisLabel, setChartTitle, setXaxistitle, yAxistitle, yAxistitleRight
|
|
9
|
+
import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, responsiveYaxisLabel, setChartTitle, setXaxistitle, yAxistitle, yAxistitleRight } from "../ChartsWithAxisFunctions";
|
|
8
10
|
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
9
|
-
|
|
10
|
-
import { responsiveXaxisLabelForNumericValue } from "../../ChartsWithoutAxis/ChartsWithoutAxisFunctions";
|
|
11
|
-
const ColumnHistogramChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
|
|
11
|
+
const ColumnHistogramChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
12
|
// adding variables as per requirement
|
|
13
|
+
const chartId = crypto.randomUUID();
|
|
13
14
|
const columnWidth = 0; // coz line chartO
|
|
14
15
|
const chartType = actualChartTypes.columnHistogram;
|
|
15
16
|
const svgRef = useRef();
|
|
@@ -107,7 +108,7 @@ const ColumnHistogramChart = ({ title, data, yAxisObj, xAxisObj, chartId, format
|
|
|
107
108
|
secondaryYLabel,
|
|
108
109
|
} = marginCalculation(
|
|
109
110
|
// for all margin related calculations
|
|
110
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart,
|
|
111
|
+
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
111
112
|
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
112
113
|
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
113
114
|
// calculations for data tables
|
|
@@ -137,7 +138,7 @@ const ColumnHistogramChart = ({ title, data, yAxisObj, xAxisObj, chartId, format
|
|
|
137
138
|
const preProcessChartData = () => {
|
|
138
139
|
const allChartData = [];
|
|
139
140
|
const legendList = [];
|
|
140
|
-
let
|
|
141
|
+
let formatedDimensionList = [];
|
|
141
142
|
let cumulativeDataPoints = [];
|
|
142
143
|
let yMaxLeft = -Infinity;
|
|
143
144
|
let yMinLeft = Infinity;
|
|
@@ -388,7 +389,7 @@ const ColumnHistogramChart = ({ title, data, yAxisObj, xAxisObj, chartId, format
|
|
|
388
389
|
};
|
|
389
390
|
const drawColumnChart = () => {
|
|
390
391
|
getChartType(filteredData);
|
|
391
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions,
|
|
392
|
+
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
392
393
|
// commonAnnotations(
|
|
393
394
|
// seriesData,
|
|
394
395
|
// xScale,
|
|
@@ -4,12 +4,13 @@ import * as d3 from "d3";
|
|
|
4
4
|
import * as d3Annotation from "d3-svg-annotation";
|
|
5
5
|
import { useEffect, useRef } from "react";
|
|
6
6
|
import { logError } from "../../../../Services/ErrorLog";
|
|
7
|
+
import { staticLineStyle } from "../../Core/Common.types";
|
|
7
8
|
import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, lineMarkers, onHoverMarkerForAreaChartFamily, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
|
|
8
|
-
import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, initYaxisRight, marginCalculation, prepareDataForSeriesLabel, responsiveSecondaryYaxisLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight
|
|
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";
|
|
9
10
|
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
10
|
-
|
|
11
|
-
const CustomColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
|
|
11
|
+
const CustomColumnChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
12
|
// adding variables as per requirement
|
|
13
|
+
const chartId = crypto.randomUUID();
|
|
13
14
|
let columnWidth = 0; // for column width calculation
|
|
14
15
|
let stackChartData = [];
|
|
15
16
|
const chartType = actualChartTypes.customColumnChart;
|
|
@@ -116,7 +117,7 @@ const CustomColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOpt
|
|
|
116
117
|
secondaryYLabel,
|
|
117
118
|
} = marginCalculation(
|
|
118
119
|
// for all margin related calculations
|
|
119
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart,
|
|
120
|
+
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
120
121
|
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
121
122
|
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
122
123
|
// calculations for data tables
|
|
@@ -150,7 +151,7 @@ const CustomColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOpt
|
|
|
150
151
|
const preProcessChartData = () => {
|
|
151
152
|
const allChartData = [];
|
|
152
153
|
const legendList = [];
|
|
153
|
-
let
|
|
154
|
+
let formatedDimensionList = [];
|
|
154
155
|
let yMaxLeft = -Infinity;
|
|
155
156
|
let yMinLeft = Infinity;
|
|
156
157
|
let yMaxRight = -Infinity;
|
|
@@ -210,14 +211,11 @@ const CustomColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOpt
|
|
|
210
211
|
chartJSON.yMaxRight = yMaxRight;
|
|
211
212
|
chartJSON.yMinRight = yMinRight;
|
|
212
213
|
// Apply formatted dimensions
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
xAxisObject.dataType === "DATE"
|
|
217
|
-
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
218
|
-
: chartJSON.dimensionList;
|
|
214
|
+
formatedDimensionList = isDateType
|
|
215
|
+
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
216
|
+
: chartJSON.dimensionList;
|
|
219
217
|
chartJSON.dimensionList.forEach((dim, i) => {
|
|
220
|
-
chartJSON.formattedDimensionListMap.set(dim,
|
|
218
|
+
chartJSON.formattedDimensionListMap.set(dim, formatedDimensionList[i]);
|
|
221
219
|
});
|
|
222
220
|
if (!formatOptions.plotArea.fitChart) {
|
|
223
221
|
filteredDimension = chartJSON.dimensionList.slice(scrollPosition, scrollPosition + visibleBars);
|
|
@@ -972,7 +970,7 @@ const CustomColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOpt
|
|
|
972
970
|
};
|
|
973
971
|
const drawCustomChart = () => {
|
|
974
972
|
getChartType(filteredData);
|
|
975
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions,
|
|
973
|
+
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
976
974
|
commonAnnotationsForCustomChart(filteredData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
|
|
977
975
|
margin, d3Annotation, stackColumnData, stackAreaData, [], //labelExcludeList
|
|
978
976
|
[], // individualLabelColor
|
|
@@ -4,12 +4,13 @@ import * as d3 from "d3";
|
|
|
4
4
|
import * as d3Annotation from "d3-svg-annotation";
|
|
5
5
|
import { useEffect, useRef } from "react";
|
|
6
6
|
import { logError } from "../../../../Services/ErrorLog";
|
|
7
|
+
import { staticLegendShape } from "../../Core/Common.types";
|
|
7
8
|
import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
|
|
8
|
-
import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis,
|
|
9
|
+
import { addDataTable, commonAnnotations, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, prepareDataForSeriesLabel, responsiveSecondaryYaxisLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, yAxistitle, yAxistitleRight } from "../ChartsWithAxisFunctions";
|
|
9
10
|
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
10
|
-
|
|
11
|
-
const LayeredColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
|
|
11
|
+
const LayeredColumnChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
12
|
// adding variables as per requirement
|
|
13
|
+
const chartId = crypto.randomUUID();
|
|
13
14
|
let columnWidth = 0; // coz line chartO
|
|
14
15
|
const chartType = actualChartTypes.layeredColumnChart;
|
|
15
16
|
const svgRef = useRef();
|
|
@@ -102,7 +103,7 @@ const LayeredColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOp
|
|
|
102
103
|
secondaryYLabel,
|
|
103
104
|
} = marginCalculation(
|
|
104
105
|
// for all margin related calculations
|
|
105
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart,
|
|
106
|
+
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
106
107
|
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
107
108
|
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
108
109
|
// calculations for data tables
|
|
@@ -140,7 +141,7 @@ const LayeredColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOp
|
|
|
140
141
|
const preProcessChartData = () => {
|
|
141
142
|
const allChartData = [];
|
|
142
143
|
const legendList = [];
|
|
143
|
-
let
|
|
144
|
+
let formatedDimensionList = [];
|
|
144
145
|
let yMaxLeft = -Infinity;
|
|
145
146
|
let yMinLeft = Infinity;
|
|
146
147
|
let yMaxRight = -Infinity;
|
|
@@ -166,14 +167,11 @@ const LayeredColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOp
|
|
|
166
167
|
chartJSON.yMaxRight = yMaxRight;
|
|
167
168
|
chartJSON.yMinRight = yMinRight;
|
|
168
169
|
// Apply formatted dimensions
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
xAxisObject.dataType === "DATE"
|
|
173
|
-
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
174
|
-
: chartJSON.dimensionList;
|
|
170
|
+
formatedDimensionList = isDateType
|
|
171
|
+
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
172
|
+
: chartJSON.dimensionList;
|
|
175
173
|
chartJSON.dimensionList.forEach((dim, i) => {
|
|
176
|
-
chartJSON.formattedDimensionListMap.set(dim,
|
|
174
|
+
chartJSON.formattedDimensionListMap.set(dim, formatedDimensionList[i]);
|
|
177
175
|
});
|
|
178
176
|
filteredData = JSON.parse(JSON.stringify(seriesData));
|
|
179
177
|
if (!formatOptions.plotArea.fitChart) {
|
|
@@ -468,7 +466,7 @@ const LayeredColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOp
|
|
|
468
466
|
};
|
|
469
467
|
const drawColumnChart = () => {
|
|
470
468
|
getChartType(filteredData);
|
|
471
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions,
|
|
469
|
+
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
472
470
|
commonAnnotations(seriesData, xScale, yScaleLeft, undefined, // need to pass secondary axis scale if secondary axis is drawn
|
|
473
471
|
margin, d3Annotation, [], //this.labelExcludeList,
|
|
474
472
|
[], //this.individualLabelColor,
|
|
@@ -4,20 +4,19 @@ import * as d3 from "d3";
|
|
|
4
4
|
import * as d3Annotation from "d3-svg-annotation";
|
|
5
5
|
import { useEffect, useRef } from "react";
|
|
6
6
|
import { logError } from "../../../../Services/ErrorLog";
|
|
7
|
+
import { staticLegendShape } from "../../Core/Common.types";
|
|
7
8
|
import { drawLegends, generalizedChartData, hideTooltipOnMouseOut, showTooltipOnMouseMove, } from "../../Core/CommonFunctions";
|
|
8
9
|
import { addDataTable, customYscaleLabelFormatting, dataTablePreCalculation, firstFunctionBeforeRender, getNumberWithFormat, getStackedData, initChartArea, initPlotArea, initSvg, initXaxis, initYaxis, marginCalculation, prepareDataForSeriesLabel, responsiveXaxisLabel, responsiveYaxisLabel, setChartTitle, setDateFormats, setXaxistitle, stacklineAnnotations, yAxistitle, yAxistitleRight, } from "../ChartsWithAxisFunctions";
|
|
9
10
|
import { actualChartTypes, } from "../ChartsWithAxisTypes.types";
|
|
10
|
-
|
|
11
|
-
const NormalizedStackColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId, formatOptions, }) => {
|
|
11
|
+
const NormalizedStackColumnChart = ({ isDateType, formatOptions, data, }) => {
|
|
12
12
|
// adding variables as per requirement
|
|
13
|
+
const chartId = crypto.randomUUID();
|
|
13
14
|
let columnWidth = 0; // coz line chart
|
|
14
15
|
const chartType = actualChartTypes.stackColumn100;
|
|
15
16
|
const svgRef = useRef();
|
|
16
17
|
const seriesData = generalizedChartData(data.ChartData, data.DimensionList);
|
|
17
18
|
const dimensionList = data.DimensionList;
|
|
18
19
|
const barChart = false;
|
|
19
|
-
const chartsWithXScrollFlag = true;
|
|
20
|
-
const chartsWithYScrollFlag = false;
|
|
21
20
|
const isSecondaryAxisDrawn = false;
|
|
22
21
|
let isPrimaryAxisDrawn = true;
|
|
23
22
|
let customYaxisMinValue = parseFloat(formatOptions.yAxisLabel.yAxisMinText);
|
|
@@ -107,7 +106,7 @@ const NormalizedStackColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId,
|
|
|
107
106
|
secondaryYLabel,
|
|
108
107
|
} = marginCalculation(
|
|
109
108
|
// for all margin related calculations
|
|
110
|
-
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart,
|
|
109
|
+
width, height, maxNumberForPrimaryAxis, maxNumberForSecondaryAxis, chartJSON.yMaxLeft, formatOptions, chartJSON.legendList, chartJSON.dimensionList, chartJSON.yMaxRight, isSecondaryAxisDrawn, isNormalizedChart, isDateType));
|
|
111
110
|
setSVGContainer(margin); // for innerWidth/height static width/height
|
|
112
111
|
({ dataTable, dataTableHeight } = dataTablePreCalculation(
|
|
113
112
|
// calculations for data tables
|
|
@@ -185,13 +184,11 @@ const NormalizedStackColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId,
|
|
|
185
184
|
}
|
|
186
185
|
chartJSON.yMinLeft = yMinLeft > 0 ? 0 : yMinLeft;
|
|
187
186
|
chartJSON.yMaxLeft = 1; // as per your original override
|
|
188
|
-
let
|
|
189
|
-
let formatedDimesionList = (xAxisObject.groupBy == "NA" || xAxisObject.groupBy == undefined) &&
|
|
190
|
-
xAxisObject.dataType === "DATE"
|
|
187
|
+
let formatedDimensionList = isDateType
|
|
191
188
|
? setDateFormats(formatOptions.xAxisLabel.xAxisNumberFormat, chartJSON.dimensionList).map((d) => d)
|
|
192
189
|
: chartJSON.dimensionList;
|
|
193
190
|
chartJSON.dimensionList.forEach((d, i) => {
|
|
194
|
-
chartJSON.formattedDimensionListMap.set(d,
|
|
191
|
+
chartJSON.formattedDimensionListMap.set(d, formatedDimensionList[i]);
|
|
195
192
|
});
|
|
196
193
|
if (formatOptions.plotArea.hideZeroValues) {
|
|
197
194
|
chartJSON.hideZeroValues = true;
|
|
@@ -499,7 +496,7 @@ const NormalizedStackColumnChart = ({ title, data, yAxisObj, xAxisObj, chartId,
|
|
|
499
496
|
const drawLineChart = () => {
|
|
500
497
|
// filteredData.forEach((data) => getChartType([data]));
|
|
501
498
|
getChartType(filteredData);
|
|
502
|
-
initXaxis(gTag, chartJSON, xLabel, formatOptions,
|
|
499
|
+
initXaxis(gTag, chartJSON, xLabel, formatOptions, dataTableHeight, yScaleLeft, xAxis, dimensionHeightWidthArray, height, columnWidth, isDateType, innerWidth, innerHeight, filteredDimension);
|
|
503
500
|
stacklineAnnotations(stackChartData, xScale, yScaleLeft, yScaleRight, // need to pass secondary axis scale if secondary axis is drawn
|
|
504
501
|
margin, d3Annotation, [], //this.labelExcludeList,
|
|
505
502
|
[], //this.individualLabelColor,
|