@dataloop-ai/components 0.16.20 → 0.16.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.16.20",
3
+ "version": "0.16.22",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -101,6 +101,7 @@ import {
101
101
  import type { Chart, ChartMeta, ChartDataset, ActiveElement } from 'chart.js'
102
102
  import { unionBy, orderBy, merge, isEqual } from 'lodash'
103
103
  import { useThemeVariables } from '../../../../../hooks/use-theme'
104
+ import { getMaxDatasetValue } from '../../utils'
104
105
 
105
106
  ChartJS.register(
106
107
  Title,
@@ -365,7 +366,17 @@ export default defineComponent({
365
366
  const chartOptions = reactive(
366
367
  updateKey(
367
368
  merge(
368
- { onResize, onHover },
369
+ {
370
+ onResize,
371
+ onHover,
372
+ scales: {
373
+ y: {
374
+ suggestedMax: getMaxDatasetValue(
375
+ chartData.value.datasets
376
+ )
377
+ }
378
+ }
379
+ },
369
380
  defaultColumnChartProps.options,
370
381
  props.options
371
382
  ),
@@ -125,6 +125,7 @@ export const defaultColumnChartProps = {
125
125
  },
126
126
  scales: {
127
127
  y: {
128
+ suggestedMin: 0,
128
129
  title: {
129
130
  color: '--dl-color-medium',
130
131
  display: true,
@@ -151,3 +151,10 @@ export function getElementsAtEvent(chart: Chart, event: MouseEvent) {
151
151
  false
152
152
  )
153
153
  }
154
+
155
+ export const getMaxDatasetValue = (chartDataset: [{ data: number[] }]) => {
156
+ return Math.max.apply(
157
+ null,
158
+ chartDataset.map((data) => [...data.data]).flat(1)
159
+ )
160
+ }
@@ -147,12 +147,18 @@ export default defineComponent({
147
147
  {
148
148
  title: 'today',
149
149
  key: DAY_SIDEBAR_OPTION.today,
150
- value: { from: today, to: today }
150
+ value: {
151
+ from: today,
152
+ to: new CustomDate(today).endOf('day').toDate()
153
+ }
151
154
  },
152
155
  {
153
156
  title: 'yesterday',
154
157
  key: DAY_SIDEBAR_OPTION.yesterday,
155
- value: { from: yesterday, to: yesterday }
158
+ value: {
159
+ from: yesterday,
160
+ to: new CustomDate(yesterday).endOf('day').toDate()
161
+ }
156
162
  },
157
163
  {
158
164
  title: 'last 7 days',