td-plots 1.3.1 → 1.3.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/index.js CHANGED
@@ -5860,13 +5860,19 @@ var Loading = function () {
5860
5860
  var Plot$2 = React.lazy(function () { return import('react-plotly.js'); });
5861
5861
  var HistogramPlot = function (props) {
5862
5862
  var _a, _b;
5863
- var data = props.data, title = props.title, xAxisTitle = props.xAxisTitle, _c = props.barColor, barColor = _c === void 0 ? 'rgb(72, 72, 74)' : _c, _d = props.unselectedBarColor, unselectedBarColor = _d === void 0 ? 'rgba(203, 195, 195, 0.88)' : _d, _e = props.selectorsColor, selectorsColor = _e === void 0 ? 'black' : _e, _f = props.showMeanLines, showMeanLines = _f === void 0 ? true : _f, containerStyleOverrides = props.containerStyleOverrides, _g = props.unselectedData, unselectedData = _g === void 0 ? [] : _g, _h = props.handleClickOrSelection, handleClickOrSelection = _h === void 0 ? function () { } : _h, _j = props.onDeselect, onDeselect = _j === void 0 ? function () { } : _j, plotId = props.plotId, _k = props.selectByBin, selectByBin = _k === void 0 ? false : _k;
5863
+ var data = props.data, title = props.title, xAxisTitle = props.xAxisTitle, _c = props.barColor, barColor = _c === void 0 ? 'rgb(72, 72, 74)' : _c, _d = props.unselectedBarColor, unselectedBarColor = _d === void 0 ? 'rgba(203, 195, 195, 0.88)' : _d, _e = props.selectorsColor, selectorsColor = _e === void 0 ? 'black' : _e, _f = props.showMeanLines, showMeanLines = _f === void 0 ? true : _f, containerStyleOverrides = props.containerStyleOverrides, _g = props.unselectedData, unselectedData = _g === void 0 ? [] : _g, _h = props.handleClickOrSelection, handleClickOrSelection = _h === void 0 ? function () { } : _h, _j = props.onDeselect, onDeselect = _j === void 0 ? function () { } : _j, plotId = props.plotId, _k = props.selectByBin, selectByBin = _k === void 0 ? false : _k, dateTickFormat = props.dateTickFormat;
5864
5864
  // Ref for plot container
5865
5865
  var containerRef = React.useRef(null);
5866
5866
  // Track any selections made in this plot so we can style the selection box.
5867
5867
  var _l = React.useState(null), selectedRange = _l[0], setSelectedRange = _l[1];
5868
+ // If all the data becomes selected, we should forget any old selections.
5869
+ React.useEffect(function () {
5870
+ if (unselectedData.length === 0) {
5871
+ setSelectedRange(null); // Clear selection box if all data is selected
5872
+ }
5873
+ }, [unselectedData]);
5868
5874
  // Set the bins based on the entire data set.
5869
- var nBins = Math.ceil(Math.sqrt(data.length + unselectedData.length));
5875
+ var nBins = (data.length + unselectedData.length) >= 10 ? Math.ceil(Math.sqrt(data.length + unselectedData.length)) : 0;
5870
5876
  // Plotly determines "nice" bins which consequently means it internally decides the axis range. We need
5871
5877
  // to access that information once the plot has been initialized so that we can prevent the
5872
5878
  // axis range from changing during interaction. Dates use strings.
@@ -5883,10 +5889,7 @@ var HistogramPlot = function (props) {
5883
5889
  if (range[0] === -1 && range[1] === 1) {
5884
5890
  return;
5885
5891
  }
5886
- var computedRange = typeof (range[0]) === 'string'
5887
- ? [new Date(range[0]), new Date(range[1])]
5888
- : [range[0], range[1]];
5889
- setFixedXAxisRange(computedRange);
5892
+ setFixedXAxisRange(range);
5890
5893
  }
5891
5894
  }
5892
5895
  };
@@ -6138,6 +6141,8 @@ var HistogramPlot = function (props) {
6138
6141
  linewidth: 1,
6139
6142
  fixedrange: true, // Disable zooming
6140
6143
  ticklabelposition: 'outside',
6144
+ tickformat: isDateArray(data) ? dateTickFormat : undefined, // Format ticks for dates
6145
+ automargin: true, // Adjust margin if tick labels rotate
6141
6146
  },
6142
6147
  yaxis: {
6143
6148
  title: {