td-plots 1.11.2 → 1.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BarPlot.d.ts +1 -0
- package/dist/components/SplitBoxPlot.d.ts +2 -0
- package/dist/components/SummaryComparisonPlot.d.ts +1 -0
- package/dist/index.esm.js +21 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1820,7 +1820,7 @@ const PairedComparisonsBoxPlot = (props) => {
|
|
|
1820
1820
|
// This component shows a set of main boxplots as one collection, then allowes for additional
|
|
1821
1821
|
// boxes to be shown in a subplot above the main boxplots for comparison.
|
|
1822
1822
|
const SplitBoxPlot = (props) => {
|
|
1823
|
-
const { groups, additionalGroups = [], width = 600, height = 400, title = "", xAxisTitle, yAxisTitle, secondXAxisTitle, secondYAxisTitle, containerStyleOverrides, plotId = "paired-comparisons-boxplot", xAnnotations = [], } = props;
|
|
1823
|
+
const { groups, additionalGroups = [], width = 600, height = 400, title = "", xAxisTitle, yAxisTitle, secondXAxisTitle, secondYAxisTitle, containerStyleOverrides, plotId = "paired-comparisons-boxplot", xAnnotations = [], d3FormatValueString = ".1f", addExtraYTitleRoom = false, } = props;
|
|
1824
1824
|
// Transform the grouped data into an array for BoxPlot
|
|
1825
1825
|
const boxPlotData = [
|
|
1826
1826
|
...groups.flatMap((group, groupIndex) => {
|
|
@@ -1924,23 +1924,14 @@ const SplitBoxPlot = (props) => {
|
|
|
1924
1924
|
});
|
|
1925
1925
|
const totalGroups = groups.length + additionalGroups.length;
|
|
1926
1926
|
const yAxisSplitProportion = additionalGroups.length > 0 ? groups.length / totalGroups : 1;
|
|
1927
|
-
|
|
1928
|
-
// Calculating approximate label width in pixels to ensure the title is far enough away from the longest label,
|
|
1929
|
-
// with a minimum distance to look good even with short labels.
|
|
1930
|
-
const charWidth = 8; // ~px per character for Open Sans 14px (Plotly title font)
|
|
1931
|
-
const primaryMaxChars = Math.max(0, ...groups.map((g) => g.label.length));
|
|
1932
|
-
const secondaryMaxChars = additionalGroups.length > 0
|
|
1933
|
-
? Math.max(0, ...additionalGroups.map((g) => g.label.length))
|
|
1934
|
-
: primaryMaxChars;
|
|
1935
|
-
const maxLabelChars = Math.max(primaryMaxChars, secondaryMaxChars);
|
|
1936
|
-
const approxLabelPx = maxLabelChars * charWidth;
|
|
1927
|
+
const xshift = addExtraYTitleRoom ? -140 : -130; // Add extra shift if we're adding extra room for y-axis titles
|
|
1937
1928
|
const yAxisTitleAnnotations = [];
|
|
1938
1929
|
if (yAxisTitle) {
|
|
1939
1930
|
const domainTop = additionalGroups.length > 0 ? yAxisSplitProportion - 0.01 : 1;
|
|
1940
1931
|
yAxisTitleAnnotations.push({
|
|
1941
1932
|
text: yAxisTitle,
|
|
1942
1933
|
x: 0,
|
|
1943
|
-
xshift:
|
|
1934
|
+
xshift: xshift,
|
|
1944
1935
|
y: domainTop / 2,
|
|
1945
1936
|
xref: "paper",
|
|
1946
1937
|
yref: "paper",
|
|
@@ -1959,7 +1950,7 @@ const SplitBoxPlot = (props) => {
|
|
|
1959
1950
|
yAxisTitleAnnotations.push({
|
|
1960
1951
|
text: secondYAxisTitle,
|
|
1961
1952
|
x: 0,
|
|
1962
|
-
xshift:
|
|
1953
|
+
xshift: xshift,
|
|
1963
1954
|
y: (yAxisSplitProportion + 1) / 2,
|
|
1964
1955
|
xref: "paper",
|
|
1965
1956
|
yref: "paper",
|
|
@@ -1990,15 +1981,17 @@ const SplitBoxPlot = (props) => {
|
|
|
1990
1981
|
ticklabelstandoff: 7,
|
|
1991
1982
|
ticklabelposition: "outside left",
|
|
1992
1983
|
title: { text: "" }, // rendered via annotation instead
|
|
1984
|
+
hoverformat: d3FormatValueString, // Format hover values using provided d3 format string
|
|
1993
1985
|
}, xaxis: {
|
|
1994
1986
|
anchor: "y", // Anchor to primary y-axis
|
|
1987
|
+
tickformat: d3FormatValueString, // Format ticks using provided d3 format string
|
|
1988
|
+
hoverformat: d3FormatValueString, // Format hover values using provided d3 format string
|
|
1995
1989
|
}, margin: {
|
|
1996
1990
|
t: title ? 50 : 70,
|
|
1997
1991
|
r: 20,
|
|
1998
|
-
l:
|
|
1992
|
+
l: 80, // Got to complicated to calculate. Adjust if necessary.
|
|
1999
1993
|
}, shapes: [
|
|
2000
1994
|
...separatorShapes,
|
|
2001
|
-
// ...differenceBetweenMediansLines,
|
|
2002
1995
|
...xAnnotations.map((annotation, annotationIndex) => ({
|
|
2003
1996
|
type: "line",
|
|
2004
1997
|
x0: annotation.x,
|
|
@@ -2051,6 +2044,7 @@ const SplitBoxPlot = (props) => {
|
|
|
2051
2044
|
fixedrange: true,
|
|
2052
2045
|
automargin: true,
|
|
2053
2046
|
matches: "x", // Match the range of xaxis to keep them synchronized
|
|
2047
|
+
tickformat: d3FormatValueString, // Format ticks using provided d3 format string
|
|
2054
2048
|
},
|
|
2055
2049
|
})), (additionalGroups.length > 0 && {
|
|
2056
2050
|
yaxis2: {
|
|
@@ -2086,7 +2080,7 @@ const Plot$2 = React.lazy(() => Promise.resolve().then(function () { return reac
|
|
|
2086
2080
|
const SummaryComparisonPlot = (props) => {
|
|
2087
2081
|
const { groups, userColor = "orange", height = 250, title = "", xAxisTitle, yAxisTitle, containerStyleOverrides, plotId = "summary-comparison-plot", tooltipPosition = "right", startXAxisAtZero = true, unit = "",
|
|
2088
2082
|
// xAnnotations = [], TO DO
|
|
2089
|
-
tooltipLabels = {}, } = props;
|
|
2083
|
+
tooltipLabels = {}, d3FormatValueString = ".1f", } = props;
|
|
2090
2084
|
// Ref for plot container
|
|
2091
2085
|
const containerRef = React.useRef(null);
|
|
2092
2086
|
// State for custom tooltip
|
|
@@ -2229,7 +2223,7 @@ const SummaryComparisonPlot = (props) => {
|
|
|
2229
2223
|
y: 1.1,
|
|
2230
2224
|
xref: "x",
|
|
2231
2225
|
yref: "paper",
|
|
2232
|
-
text: `${group.data.userValue
|
|
2226
|
+
text: `${format$1(d3FormatValueString)(group.data.userValue)} ${unit}`,
|
|
2233
2227
|
showarrow: false,
|
|
2234
2228
|
xanchor: "center",
|
|
2235
2229
|
yanchor: "bottom",
|
|
@@ -2271,7 +2265,7 @@ const SummaryComparisonPlot = (props) => {
|
|
|
2271
2265
|
height: height,
|
|
2272
2266
|
autosize: true,
|
|
2273
2267
|
margin: {
|
|
2274
|
-
l:
|
|
2268
|
+
l: 100,
|
|
2275
2269
|
r: 35, // Balance between ensuring the mean annotation doesn't get cut off and having too much margin.
|
|
2276
2270
|
t: title ? 70 : 40,
|
|
2277
2271
|
b: 50,
|
|
@@ -2312,6 +2306,7 @@ const SummaryComparisonPlot = (props) => {
|
|
|
2312
2306
|
zerolinewidth: 1,
|
|
2313
2307
|
linecolor: "#bababa",
|
|
2314
2308
|
linewidth: 1,
|
|
2309
|
+
tickformat: d3FormatValueString, // Format ticks using provided d3 format string
|
|
2315
2310
|
},
|
|
2316
2311
|
yaxis: {
|
|
2317
2312
|
title: {
|
|
@@ -2649,7 +2644,7 @@ const BarPlot = (props) => {
|
|
|
2649
2644
|
xAxisTitle = "X Axis", yAxisTitle = "Y Axis", xAxis2Title = "", yAxis2Title = "", xAccessor = (d) => d.x, yAccessor = (d) => d.y, containerStyleOverrides = {}, plotId = "bar-plot", xAnnotations = [], barHoverTemplate = "", // Default hover template for bars
|
|
2650
2645
|
barGroups = [], // Optional array of bar groups for grouping bars by color
|
|
2651
2646
|
barGroupTooltipTitle = "Group", // Default title for the bar group tooltip
|
|
2652
|
-
|
|
2647
|
+
d3FormatValueString = ".1f", } = props;
|
|
2653
2648
|
// Ref for plot container
|
|
2654
2649
|
const containerRef = React.useRef(null);
|
|
2655
2650
|
const plotMetaRef = React.useRef(null);
|
|
@@ -2785,8 +2780,8 @@ const BarPlot = (props) => {
|
|
|
2785
2780
|
xref: "paper",
|
|
2786
2781
|
yref: "paper",
|
|
2787
2782
|
x0: 0,
|
|
2788
|
-
y0: y2AxisPosition - 0.
|
|
2789
|
-
x1: 0.02 + title.length * 0.
|
|
2783
|
+
y0: y2AxisPosition - 0.11, // Position behind the primary title
|
|
2784
|
+
x1: 0.02 + title.length * 0.01, // Approximate width based on title length 0.3/
|
|
2790
2785
|
y1: y2AxisPosition - 0.01,
|
|
2791
2786
|
fillcolor: "rgba(255, 255, 255, 0.5)",
|
|
2792
2787
|
line: {
|
|
@@ -2924,6 +2919,7 @@ const BarPlot = (props) => {
|
|
|
2924
2919
|
text: xAxisTitle,
|
|
2925
2920
|
},
|
|
2926
2921
|
anchor: "y", // Anchor to primary y-axis
|
|
2922
|
+
hoverformat: d3FormatValueString, // Format hover values using provided d3 format string
|
|
2927
2923
|
showgrid: true,
|
|
2928
2924
|
zeroline: false,
|
|
2929
2925
|
showline: true,
|
|
@@ -2940,6 +2936,7 @@ const BarPlot = (props) => {
|
|
|
2940
2936
|
? BAR_GROUP_SHAPE_TOP_PX + BAR_GROUP_SHAPE_HEIGHT_PX
|
|
2941
2937
|
: 8, // tick length in px.
|
|
2942
2938
|
tickcolor: "white",
|
|
2939
|
+
tickformat: d3FormatValueString, // Format ticks using provided d3 format string
|
|
2943
2940
|
} }, (data2 && {
|
|
2944
2941
|
xaxis2: {
|
|
2945
2942
|
title: {
|
|
@@ -2961,6 +2958,7 @@ const BarPlot = (props) => {
|
|
|
2961
2958
|
fixedrange: true,
|
|
2962
2959
|
automargin: true,
|
|
2963
2960
|
matches: "x", // Match the range of xaxis to keep them synchronized
|
|
2961
|
+
tickformat: d3FormatValueString, // Format ticks using provided d3 format string
|
|
2964
2962
|
},
|
|
2965
2963
|
})), { yaxis: {
|
|
2966
2964
|
title: {
|
|
@@ -2968,6 +2966,8 @@ const BarPlot = (props) => {
|
|
|
2968
2966
|
standoff: 15, // Add space between title and axis
|
|
2969
2967
|
},
|
|
2970
2968
|
domain: data2 ? [0, y2AxisPosition - 0.01] : [0, 1], // Ensure primary y-axis takes full height
|
|
2969
|
+
hoverformat: d3FormatValueString, // Format hover values using provided d3 format string
|
|
2970
|
+
nticks: 7, // Limit number of ticks to prevent overcrowding with the histogram
|
|
2971
2971
|
automargin: true, // Required for standoff to work properly
|
|
2972
2972
|
showgrid: true,
|
|
2973
2973
|
zeroline: false,
|