xAxisTimeInterval

This commit is contained in:
Nate Kelley 2025-02-06 12:22:14 -07:00
parent a58b8057b8
commit a519a772ee
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
9 changed files with 21 additions and 9 deletions

View File

@ -18,6 +18,7 @@ export const DEFAULT_CHART_CONFIG: IBusterMetricChartConfig = {
y2AxisShowAxisTitle: true,
y2AxisStartAxisAtZero: true,
y2AxisScaleType: 'linear',
xAxisTimeInterval: null,
xAxisShowAxisLabel: true,
xAxisShowAxisTitle: true,
xAxisAxisTitle: null,

View File

@ -18,7 +18,7 @@ import { SelectAxisEmptyState } from './SelectAxisEmptyState';
export const SelectAxis: React.FC<
Required<YAxisConfig> &
Required<XAxisConfig> &
Required<Omit<XAxisConfig, 'xAxisTimeInterval'>> &
Required<CategoryAxisStyleConfig> &
Required<Y2AxisConfig> &
ISelectAxisContext

View File

@ -17,7 +17,7 @@ import React from 'react';
export interface ISelectAxisContext
extends Required<YAxisConfig>,
Required<Y2AxisConfig>,
Required<XAxisConfig>,
Required<Omit<XAxisConfig, 'xAxisTimeInterval'>>,
Required<CategoryAxisStyleConfig> {
selectedAxis: ChartEncodes | null;
columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats'];

View File

@ -23,7 +23,6 @@ export const StylingAppVisualize: React.FC<
colors: string[];
disableTooltip: IBusterMetricChartConfig['disableTooltip'];
} & Required<YAxisConfig> &
Required<XAxisConfig> &
Required<CategoryAxisStyleConfig> &
Required<Y2AxisConfig> &
Omit<ISelectAxisContext, 'selectedAxis'> &

View File

@ -64,6 +64,7 @@ export const BusterChartJSComponent = React.memo(
goalLines,
lineGroupType,
disableTooltip,
xAxisTimeInterval,
//TODO
xAxisDataZoom,
useRapidResizeObserver = false,
@ -158,7 +159,8 @@ export const BusterChartJSComponent = React.memo(
y2AxisStartAxisAtZero,
yAxisScaleType,
animate,
disableTooltip
disableTooltip,
xAxisTimeInterval
});
const type = useMemo(() => {

View File

@ -54,6 +54,7 @@ interface UseOptionsProps {
goalLinesAnnotations: AnnotationPluginOptions['annotations'];
trendlineAnnotations: AnnotationPluginOptions['annotations'];
disableTooltip: boolean;
xAxisTimeInterval: BusterChartProps['xAxisTimeInterval'];
}
export const useOptions = ({
@ -92,7 +93,8 @@ export const useOptions = ({
animate,
goalLinesAnnotations,
trendlineAnnotations,
disableTooltip
disableTooltip,
xAxisTimeInterval
}: UseOptionsProps) => {
const xAxis = useXAxis({
columnLabelFormats,
@ -106,7 +108,8 @@ export const useOptions = ({
xAxisAxisTitle,
xAxisShowAxisTitle,
lineGroupType,
barGroupType
barGroupType,
xAxisTimeInterval
});
const yAxis = useYAxis({

View File

@ -27,7 +27,8 @@ export const useXAxis = ({
xAxisShowAxisTitle,
gridLines,
lineGroupType,
barGroupType
barGroupType,
xAxisTimeInterval
}: {
columnLabelFormats: NonNullable<BusterChartConfigProps['columnLabelFormats']>;
selectedAxis: ChartEncodes;
@ -41,6 +42,7 @@ export const useXAxis = ({
lineGroupType: BusterChartProps['lineGroupType'];
barGroupType: BusterChartProps['barGroupType'];
columnSettings: BusterChartProps['columnSettings'];
xAxisTimeInterval: BusterChartProps['xAxisTimeInterval'];
}): DeepPartial<ScaleChartOptions<'bar'>['scales']['x']> | undefined => {
const isScatterChart = selectedChartType === ChartType.Scatter;
const isPieChart = selectedChartType === ChartType.Pie;
@ -161,7 +163,11 @@ export const useXAxis = ({
callback: useTicketCallback ? tickCallback : null,
autoSkip: true,
autoSkipPadding: 3,
align: 'center'
align: 'center',
time: {
unit: xAxisTimeInterval
},
source: 'auto'
},
display: true,
border: {

View File

@ -16,6 +16,7 @@ export type Y2AxisConfig = {
};
export type XAxisConfig = {
xAxisTimeInterval?: 'day' | 'week' | 'month' | 'quarter' | 'year' | null; //OPTIONAL: default is null. Will only apply to combo and line charts
xAxisShowAxisLabel?: boolean; //OPTIONAL: default is true.
xAxisShowAxisTitle?: boolean; //OPTIONAL: default is true.
xAxisAxisTitle?: string | null; //OPTIONAL: default is null. If null the axis title will be a concatenation of all the x columns applied to the axis.

View File

@ -17,7 +17,7 @@ import { RustApiError } from '@/api/buster_rest/errors';
import { resolveEmptyMetric, upgradeMetricToIMetric } from './helpers';
import { MetricUpdateMetric } from '@/api/buster_socket/metrics';
import { useBusterMetricDataContextSelector } from '../MetricData';
import { createMockMetric, MOCK_METRIC } from './MOCK_METRIC';
import { createMockMetric } from './MOCK_METRIC';
import { useUpdateMetricConfig } from './useUpdateMetricConfig';
import { useUpdateMetricAssosciations } from './useUpdateMetricAssosciations';