td-plots 1.11.2 → 1.11.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/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 +22 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +22 -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
|
|
@@ -2172,6 +2166,7 @@ const SummaryComparisonPlot = (props) => {
|
|
|
2172
2166
|
};
|
|
2173
2167
|
const comparedLines = [];
|
|
2174
2168
|
const comparedAnnotations = [];
|
|
2169
|
+
console.log("d3FormatValueString:", d3FormatValueString);
|
|
2175
2170
|
// Transform the data into a format suitable for a plotly scatterplot
|
|
2176
2171
|
const plotlyData = groups.flatMap((group, groupIndex) => {
|
|
2177
2172
|
const traces = [];
|
|
@@ -2229,7 +2224,7 @@ const SummaryComparisonPlot = (props) => {
|
|
|
2229
2224
|
y: 1.1,
|
|
2230
2225
|
xref: "x",
|
|
2231
2226
|
yref: "paper",
|
|
2232
|
-
text: `${group.data.userValue
|
|
2227
|
+
text: `${format$1(d3FormatValueString)(group.data.userValue)} ${unit}`,
|
|
2233
2228
|
showarrow: false,
|
|
2234
2229
|
xanchor: "center",
|
|
2235
2230
|
yanchor: "bottom",
|
|
@@ -2271,7 +2266,7 @@ const SummaryComparisonPlot = (props) => {
|
|
|
2271
2266
|
height: height,
|
|
2272
2267
|
autosize: true,
|
|
2273
2268
|
margin: {
|
|
2274
|
-
l:
|
|
2269
|
+
l: 100,
|
|
2275
2270
|
r: 35, // Balance between ensuring the mean annotation doesn't get cut off and having too much margin.
|
|
2276
2271
|
t: title ? 70 : 40,
|
|
2277
2272
|
b: 50,
|
|
@@ -2312,6 +2307,7 @@ const SummaryComparisonPlot = (props) => {
|
|
|
2312
2307
|
zerolinewidth: 1,
|
|
2313
2308
|
linecolor: "#bababa",
|
|
2314
2309
|
linewidth: 1,
|
|
2310
|
+
tickformat: d3FormatValueString, // Format ticks using provided d3 format string
|
|
2315
2311
|
},
|
|
2316
2312
|
yaxis: {
|
|
2317
2313
|
title: {
|
|
@@ -2649,7 +2645,7 @@ const BarPlot = (props) => {
|
|
|
2649
2645
|
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
2646
|
barGroups = [], // Optional array of bar groups for grouping bars by color
|
|
2651
2647
|
barGroupTooltipTitle = "Group", // Default title for the bar group tooltip
|
|
2652
|
-
|
|
2648
|
+
d3FormatValueString = ".1f", } = props;
|
|
2653
2649
|
// Ref for plot container
|
|
2654
2650
|
const containerRef = React.useRef(null);
|
|
2655
2651
|
const plotMetaRef = React.useRef(null);
|
|
@@ -2785,8 +2781,8 @@ const BarPlot = (props) => {
|
|
|
2785
2781
|
xref: "paper",
|
|
2786
2782
|
yref: "paper",
|
|
2787
2783
|
x0: 0,
|
|
2788
|
-
y0: y2AxisPosition - 0.
|
|
2789
|
-
x1: 0.02 + title.length * 0.
|
|
2784
|
+
y0: y2AxisPosition - 0.11, // Position behind the primary title
|
|
2785
|
+
x1: 0.02 + title.length * 0.01, // Approximate width based on title length 0.3/
|
|
2790
2786
|
y1: y2AxisPosition - 0.01,
|
|
2791
2787
|
fillcolor: "rgba(255, 255, 255, 0.5)",
|
|
2792
2788
|
line: {
|
|
@@ -2924,6 +2920,7 @@ const BarPlot = (props) => {
|
|
|
2924
2920
|
text: xAxisTitle,
|
|
2925
2921
|
},
|
|
2926
2922
|
anchor: "y", // Anchor to primary y-axis
|
|
2923
|
+
hoverformat: d3FormatValueString, // Format hover values using provided d3 format string
|
|
2927
2924
|
showgrid: true,
|
|
2928
2925
|
zeroline: false,
|
|
2929
2926
|
showline: true,
|
|
@@ -2940,6 +2937,7 @@ const BarPlot = (props) => {
|
|
|
2940
2937
|
? BAR_GROUP_SHAPE_TOP_PX + BAR_GROUP_SHAPE_HEIGHT_PX
|
|
2941
2938
|
: 8, // tick length in px.
|
|
2942
2939
|
tickcolor: "white",
|
|
2940
|
+
tickformat: d3FormatValueString, // Format ticks using provided d3 format string
|
|
2943
2941
|
} }, (data2 && {
|
|
2944
2942
|
xaxis2: {
|
|
2945
2943
|
title: {
|
|
@@ -2961,6 +2959,7 @@ const BarPlot = (props) => {
|
|
|
2961
2959
|
fixedrange: true,
|
|
2962
2960
|
automargin: true,
|
|
2963
2961
|
matches: "x", // Match the range of xaxis to keep them synchronized
|
|
2962
|
+
tickformat: d3FormatValueString, // Format ticks using provided d3 format string
|
|
2964
2963
|
},
|
|
2965
2964
|
})), { yaxis: {
|
|
2966
2965
|
title: {
|
|
@@ -2968,6 +2967,8 @@ const BarPlot = (props) => {
|
|
|
2968
2967
|
standoff: 15, // Add space between title and axis
|
|
2969
2968
|
},
|
|
2970
2969
|
domain: data2 ? [0, y2AxisPosition - 0.01] : [0, 1], // Ensure primary y-axis takes full height
|
|
2970
|
+
hoverformat: d3FormatValueString, // Format hover values using provided d3 format string
|
|
2971
|
+
nticks: 7, // Limit number of ticks to prevent overcrowding with the histogram
|
|
2971
2972
|
automargin: true, // Required for standoff to work properly
|
|
2972
2973
|
showgrid: true,
|
|
2973
2974
|
zeroline: false,
|