td-plots 1.5.0 → 1.5.2
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/Utils.d.ts +2 -0
- package/dist/index.esm.js +98 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +97 -22
- package/dist/index.js.map +1 -1
- package/package.json +7 -1
package/dist/index.js
CHANGED
|
@@ -57,6 +57,7 @@ var css_248z = ".plot-container{height:100%;max-width:100%;min-height:300px;over
|
|
|
57
57
|
styleInject(css_248z);
|
|
58
58
|
|
|
59
59
|
// Utility functions for our components
|
|
60
|
+
var ONEAVGMONTH = 2629800000; // Average month length in ms, copied from plotly constants in plotly.js/src/constants/numerical.js
|
|
60
61
|
// Type guard to check if array contains only numbers
|
|
61
62
|
var isNumberArray = function (arr) {
|
|
62
63
|
return arr.every(function (item) { return typeof item === 'number' && !isNaN(item); });
|
|
@@ -109,6 +110,44 @@ var roundToPrevDay = function (timestamp) {
|
|
|
109
110
|
date.setHours(0, 0, 0, 0); // Start of day
|
|
110
111
|
return date.toISOString();
|
|
111
112
|
};
|
|
113
|
+
// Convert plotly M# string to number of milliseconds
|
|
114
|
+
// According to the docs, plotly will use M# whenever the bin size is
|
|
115
|
+
// larger than one average month. Even if the bin size is 2 years, plotly
|
|
116
|
+
// will still use M24 instead of Y2 (plotly.js/src/plots/cartesian/axes.js).
|
|
117
|
+
var plotlyMToMilliseconds = function (mString) {
|
|
118
|
+
var match = mString.match(/^M(\d+)$/);
|
|
119
|
+
if (match) {
|
|
120
|
+
var months = parseInt(match[1], 10);
|
|
121
|
+
return months * ONEAVGMONTH;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
console.error("plotlyMToMilliseconds: Invalid M# string: ".concat(mString));
|
|
125
|
+
}
|
|
126
|
+
return 0;
|
|
127
|
+
};
|
|
128
|
+
// Convert a string specifying a day (with no time) to a timestamp
|
|
129
|
+
var convertDateDescriptionToTimestamp = function (startValue) {
|
|
130
|
+
if (typeof startValue === 'number') {
|
|
131
|
+
// Then we're assuming it's already a timestamp
|
|
132
|
+
return startValue;
|
|
133
|
+
}
|
|
134
|
+
if (typeof startValue === 'string') {
|
|
135
|
+
// Try to parse the date string.
|
|
136
|
+
var date = new Date(startValue);
|
|
137
|
+
// Sometimes the date will fail to be a proper Date if it does not
|
|
138
|
+
// have a time component. Add a time stamp if necessary.
|
|
139
|
+
if (isNaN(date.getTime())) {
|
|
140
|
+
// Then date did not have a time and is just a day. Try adding a time.
|
|
141
|
+
var dateWithTime = new Date(startValue + 'T00:00:00');
|
|
142
|
+
if (isNaN(dateWithTime.getTime())) {
|
|
143
|
+
throw new Error("Cannot parse date: ".concat(startValue));
|
|
144
|
+
}
|
|
145
|
+
return dateWithTime.getTime();
|
|
146
|
+
}
|
|
147
|
+
return date.getTime();
|
|
148
|
+
}
|
|
149
|
+
throw new Error("Unexpected type for start value: ".concat(typeof startValue));
|
|
150
|
+
};
|
|
112
151
|
|
|
113
152
|
function getDefaultExportFromCjs (x) {
|
|
114
153
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -1412,8 +1451,8 @@ function requireReactIs_production () {
|
|
|
1412
1451
|
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
1413
1452
|
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
1414
1453
|
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
1415
|
-
REACT_PROFILER_TYPE = Symbol.for("react.profiler")
|
|
1416
|
-
|
|
1454
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
|
|
1455
|
+
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
1417
1456
|
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
1418
1457
|
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
1419
1458
|
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
@@ -1583,8 +1622,8 @@ function requireReactIs_development () {
|
|
|
1583
1622
|
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
1584
1623
|
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
1585
1624
|
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
1586
|
-
REACT_PROFILER_TYPE = Symbol.for("react.profiler")
|
|
1587
|
-
|
|
1625
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
|
|
1626
|
+
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
1588
1627
|
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
1589
1628
|
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
1590
1629
|
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
@@ -2780,7 +2819,7 @@ const styleFunctionSx = unstable_createStyleFunctionSx();
|
|
|
2780
2819
|
styleFunctionSx.filterProps = ['sx'];
|
|
2781
2820
|
|
|
2782
2821
|
/**
|
|
2783
|
-
* @mui/styled-engine v7.3.
|
|
2822
|
+
* @mui/styled-engine v7.3.3
|
|
2784
2823
|
*
|
|
2785
2824
|
* @license MIT
|
|
2786
2825
|
* This source code is licensed under the MIT license found in the
|
|
@@ -5079,7 +5118,7 @@ function createColorScheme(options) {
|
|
|
5079
5118
|
opacity,
|
|
5080
5119
|
overlays,
|
|
5081
5120
|
colorSpace,
|
|
5082
|
-
...
|
|
5121
|
+
...other
|
|
5083
5122
|
} = options;
|
|
5084
5123
|
// need to cast because `colorSpace` is considered internal at the moment.
|
|
5085
5124
|
const palette = createPalette({
|
|
@@ -5093,7 +5132,7 @@ function createColorScheme(options) {
|
|
|
5093
5132
|
...opacity
|
|
5094
5133
|
},
|
|
5095
5134
|
overlays: overlays || getOverlays(palette.mode),
|
|
5096
|
-
...
|
|
5135
|
+
...other
|
|
5097
5136
|
};
|
|
5098
5137
|
}
|
|
5099
5138
|
|
|
@@ -5603,7 +5642,7 @@ function createTheme(options = {},
|
|
|
5603
5642
|
light: true
|
|
5604
5643
|
} : undefined,
|
|
5605
5644
|
defaultColorScheme: initialDefaultColorScheme = palette?.mode,
|
|
5606
|
-
...
|
|
5645
|
+
...other
|
|
5607
5646
|
} = options;
|
|
5608
5647
|
const defaultColorSchemeInput = initialDefaultColorScheme || 'light';
|
|
5609
5648
|
const defaultScheme = initialColorSchemes?.[defaultColorSchemeInput];
|
|
@@ -5660,7 +5699,7 @@ function createTheme(options = {},
|
|
|
5660
5699
|
colorSchemesInput.light = true;
|
|
5661
5700
|
}
|
|
5662
5701
|
return createThemeWithVars({
|
|
5663
|
-
...
|
|
5702
|
+
...other,
|
|
5664
5703
|
colorSchemes: colorSchemesInput,
|
|
5665
5704
|
defaultColorScheme: defaultColorSchemeInput,
|
|
5666
5705
|
...(typeof cssVariables !== 'boolean' && cssVariables)
|
|
@@ -5749,7 +5788,7 @@ function createSimplePaletteValueFilter(additionalPropertiesToCheck = []) {
|
|
|
5749
5788
|
function getCircularProgressUtilityClass(slot) {
|
|
5750
5789
|
return generateUtilityClass('MuiCircularProgress', slot);
|
|
5751
5790
|
}
|
|
5752
|
-
generateUtilityClasses('MuiCircularProgress', ['root', 'determinate', 'indeterminate', 'colorPrimary', 'colorSecondary', 'svg', 'circle', 'circleDeterminate', 'circleIndeterminate', 'circleDisableShrink']);
|
|
5791
|
+
generateUtilityClasses('MuiCircularProgress', ['root', 'determinate', 'indeterminate', 'colorPrimary', 'colorSecondary', 'svg', 'track', 'circle', 'circleDeterminate', 'circleIndeterminate', 'circleDisableShrink']);
|
|
5753
5792
|
|
|
5754
5793
|
const SIZE = 44;
|
|
5755
5794
|
const circularRotateKeyframe = react.keyframes`
|
|
@@ -5797,6 +5836,7 @@ const useUtilityClasses = ownerState => {
|
|
|
5797
5836
|
const slots = {
|
|
5798
5837
|
root: ['root', variant, `color${capitalize(color)}`],
|
|
5799
5838
|
svg: ['svg'],
|
|
5839
|
+
track: ['track'],
|
|
5800
5840
|
circle: ['circle', `circle${capitalize(variant)}`, disableShrink && 'circleDisableShrink']
|
|
5801
5841
|
};
|
|
5802
5842
|
return composeClasses(slots, getCircularProgressUtilityClass, classes);
|
|
@@ -5882,6 +5922,15 @@ const CircularProgressCircle = styled('circle', {
|
|
|
5882
5922
|
}
|
|
5883
5923
|
}]
|
|
5884
5924
|
})));
|
|
5925
|
+
const CircularProgressTrack = styled('circle', {
|
|
5926
|
+
name: 'MuiCircularProgress',
|
|
5927
|
+
slot: 'Track'
|
|
5928
|
+
})(memoTheme(({
|
|
5929
|
+
theme
|
|
5930
|
+
}) => ({
|
|
5931
|
+
stroke: 'currentColor',
|
|
5932
|
+
opacity: (theme.vars || theme).palette.action.activatedOpacity
|
|
5933
|
+
})));
|
|
5885
5934
|
|
|
5886
5935
|
/**
|
|
5887
5936
|
* ## ARIA
|
|
@@ -5899,6 +5948,7 @@ const CircularProgress = /*#__PURE__*/React__namespace.forwardRef(function Circu
|
|
|
5899
5948
|
className,
|
|
5900
5949
|
color = 'primary',
|
|
5901
5950
|
disableShrink = false,
|
|
5951
|
+
enableTrackSlot = false,
|
|
5902
5952
|
size = 40,
|
|
5903
5953
|
style,
|
|
5904
5954
|
thickness = 3.6,
|
|
@@ -5913,7 +5963,8 @@ const CircularProgress = /*#__PURE__*/React__namespace.forwardRef(function Circu
|
|
|
5913
5963
|
size,
|
|
5914
5964
|
thickness,
|
|
5915
5965
|
value,
|
|
5916
|
-
variant
|
|
5966
|
+
variant,
|
|
5967
|
+
enableTrackSlot
|
|
5917
5968
|
};
|
|
5918
5969
|
const classes = useUtilityClasses(ownerState);
|
|
5919
5970
|
const circleStyle = {};
|
|
@@ -5939,11 +5990,20 @@ const CircularProgress = /*#__PURE__*/React__namespace.forwardRef(function Circu
|
|
|
5939
5990
|
role: "progressbar",
|
|
5940
5991
|
...rootProps,
|
|
5941
5992
|
...other,
|
|
5942
|
-
children: /*#__PURE__*/jsxRuntime.
|
|
5993
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(CircularProgressSVG, {
|
|
5943
5994
|
className: classes.svg,
|
|
5944
5995
|
ownerState: ownerState,
|
|
5945
5996
|
viewBox: `${SIZE / 2} ${SIZE / 2} ${SIZE} ${SIZE}`,
|
|
5946
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
5997
|
+
children: [enableTrackSlot ? /*#__PURE__*/jsxRuntime.jsx(CircularProgressTrack, {
|
|
5998
|
+
className: classes.track,
|
|
5999
|
+
ownerState: ownerState,
|
|
6000
|
+
cx: SIZE,
|
|
6001
|
+
cy: SIZE,
|
|
6002
|
+
r: (SIZE - thickness) / 2,
|
|
6003
|
+
fill: "none",
|
|
6004
|
+
strokeWidth: thickness,
|
|
6005
|
+
"aria-hidden": "true"
|
|
6006
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsx(CircularProgressCircle, {
|
|
5947
6007
|
className: classes.circle,
|
|
5948
6008
|
style: circleStyle,
|
|
5949
6009
|
ownerState: ownerState,
|
|
@@ -5952,7 +6012,7 @@ const CircularProgress = /*#__PURE__*/React__namespace.forwardRef(function Circu
|
|
|
5952
6012
|
r: (SIZE - thickness) / 2,
|
|
5953
6013
|
fill: "none",
|
|
5954
6014
|
strokeWidth: thickness
|
|
5955
|
-
})
|
|
6015
|
+
})]
|
|
5956
6016
|
})
|
|
5957
6017
|
});
|
|
5958
6018
|
});
|
|
@@ -5987,6 +6047,12 @@ process.env.NODE_ENV !== "production" ? CircularProgress.propTypes /* remove-pro
|
|
|
5987
6047
|
}
|
|
5988
6048
|
return null;
|
|
5989
6049
|
}),
|
|
6050
|
+
/**
|
|
6051
|
+
* If `true`, a track circle slot is mounted to show a subtle background for the progress.
|
|
6052
|
+
* The `size` and `thickness` apply to the track slot to be consistent with the progress circle.
|
|
6053
|
+
* @default false
|
|
6054
|
+
*/
|
|
6055
|
+
enableTrackSlot: PropTypes.bool,
|
|
5990
6056
|
/**
|
|
5991
6057
|
* The size of the component.
|
|
5992
6058
|
* If using a number, the pixel unit is assumed.
|
|
@@ -6086,8 +6152,8 @@ var HistogramPlot = function (props) {
|
|
|
6086
6152
|
// This is the start of the first bin out of all the traces. The global first bin.
|
|
6087
6153
|
var globalFirstBinStart = void 0;
|
|
6088
6154
|
if (isDateArray(data)) {
|
|
6089
|
-
// Date bins are represented as strings. We'll need to convert
|
|
6090
|
-
globalFirstBinStart =
|
|
6155
|
+
// Date bins are represented as strings (sometimes). We'll need to convert whatever plotly gives us to timestamps.
|
|
6156
|
+
globalFirstBinStart = convertDateDescriptionToTimestamp(event.points[0].data.xbins.start);
|
|
6091
6157
|
minTraceValue = Math.min.apply(Math, data.map(function (d) { return d.getTime(); }));
|
|
6092
6158
|
}
|
|
6093
6159
|
else {
|
|
@@ -6100,10 +6166,14 @@ var HistogramPlot = function (props) {
|
|
|
6100
6166
|
minTraceValue = Math.min.apply(Math, data);
|
|
6101
6167
|
globalFirstBinStart = event.points[0].data.xbins.start;
|
|
6102
6168
|
}
|
|
6169
|
+
// Finally, we need to calculate the min and max values of the clicked bin.
|
|
6170
|
+
// If the bin size is a month or more, plotly records it in their "mstring" format like "M3" for 3 months.
|
|
6171
|
+
// We then must convert it back to milliseconds. Otherwise, it's always ms.
|
|
6172
|
+
var binSize = typeof event.points[0].data.xbins.size === 'string'
|
|
6173
|
+
? plotlyMToMilliseconds(event.points[0].data.xbins.size)
|
|
6174
|
+
: event.points[0].data.xbins.size;
|
|
6103
6175
|
// This minTraceValue is in the 0th bin of this trace. Find the index of this bin in the whole plot.
|
|
6104
|
-
var clickedBinGlobalIndex = clickedBinIndex + Math.floor((minTraceValue - globalFirstBinStart) /
|
|
6105
|
-
// Finally we can calculate the min and max values of the clicked bin.
|
|
6106
|
-
var binSize = event.points[0].data.xbins.size;
|
|
6176
|
+
var clickedBinGlobalIndex = clickedBinIndex + Math.floor((minTraceValue - globalFirstBinStart) / binSize);
|
|
6107
6177
|
var _a = [
|
|
6108
6178
|
globalFirstBinStart + clickedBinGlobalIndex * binSize,
|
|
6109
6179
|
globalFirstBinStart + (clickedBinGlobalIndex + 1) * binSize
|
|
@@ -6136,7 +6206,11 @@ var HistogramPlot = function (props) {
|
|
|
6136
6206
|
// Means at least one bin has been selected
|
|
6137
6207
|
var firstBinMidPoint = new Date(event.points[0].x).getTime();
|
|
6138
6208
|
var lastBinMidPoint = new Date(event.points[event.points.length - 1].x).getTime();
|
|
6139
|
-
|
|
6209
|
+
// If the bin size is a month or more, plotly records it in their "mstring" format like "M3" for 3 months.
|
|
6210
|
+
// We then must convert it back to milliseconds. Otherwise, it's always ms.
|
|
6211
|
+
var binSize = typeof event.points[0].data.xbins.size === 'string'
|
|
6212
|
+
? plotlyMToMilliseconds(event.points[0].data.xbins.size)
|
|
6213
|
+
: event.points[0].data.xbins.size;
|
|
6140
6214
|
minValue = new Date(firstBinMidPoint - binSize / 2);
|
|
6141
6215
|
maxValue = new Date(lastBinMidPoint + binSize / 2);
|
|
6142
6216
|
}
|
|
@@ -6301,7 +6375,7 @@ var HistogramPlot = function (props) {
|
|
|
6301
6375
|
// If binSizeOverride is provided, use it to set the bin size and range explicitly.
|
|
6302
6376
|
// Plotly does a better job of setting bins and ending them at nice numbers, so only use
|
|
6303
6377
|
// this prop when necessary.
|
|
6304
|
-
var xBins = binSizeOverride
|
|
6378
|
+
var xBins = (binSizeOverride && allData.length > 0)
|
|
6305
6379
|
? (isDateArray(allData)
|
|
6306
6380
|
? {
|
|
6307
6381
|
start: roundToPrevDay(Math.min.apply(Math, allData.map(function (d) { return d.getTime(); }))), // Find a nice round number as a starting point.
|
|
@@ -6331,7 +6405,7 @@ var HistogramPlot = function (props) {
|
|
|
6331
6405
|
width: 0.5,
|
|
6332
6406
|
},
|
|
6333
6407
|
},
|
|
6334
|
-
hovertemplate: '[%{x})<br>Count: %{y}<extra></extra>',
|
|
6408
|
+
hovertemplate: '[%{x})<br>Count: %{y}<extra></extra>',
|
|
6335
6409
|
};
|
|
6336
6410
|
var meanAnnotation = (statsAnnotations.includes('mean') && meanLine && data.length > 0) ? [{
|
|
6337
6411
|
x: meanValue,
|
|
@@ -6422,6 +6496,7 @@ var HistogramPlot = function (props) {
|
|
|
6422
6496
|
ticklabelposition: 'outside',
|
|
6423
6497
|
tickformat: isDateArray(data) ? dateTickFormat : undefined, // Format ticks for dates
|
|
6424
6498
|
automargin: true, // Adjust margin if tick labels rotate
|
|
6499
|
+
hoverformat: (isNumberArray(allData) && Math.max.apply(Math, allData) - Math.min.apply(Math, allData) > 3) ? '.1~f' : undefined,
|
|
6425
6500
|
},
|
|
6426
6501
|
yaxis: {
|
|
6427
6502
|
title: {
|