Graph: Fixed issue with x-axis labels showing "MM/DD" after viewing dashboard with pie chart .
This commit is contained in:
@@ -10,7 +10,7 @@ import { TooltipProps, TooltipContentProps, ActiveDimensions, Tooltip } from '..
|
||||
import { GraphTooltip } from './GraphTooltip/GraphTooltip';
|
||||
import { GraphContextMenu, GraphContextMenuProps, ContextDimensions } from './GraphContextMenu';
|
||||
import { GraphDimensions } from './GraphTooltip/types';
|
||||
import { graphTimeFormat, graphTimeFormatter } from './utils';
|
||||
import { graphTimeFormat, graphTickFormatter } from './utils';
|
||||
|
||||
export interface GraphProps {
|
||||
children?: JSX.Element | JSX.Element[];
|
||||
@@ -314,6 +314,7 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
|
||||
shadowSize: 0,
|
||||
},
|
||||
xaxis: {
|
||||
timezone: timeZone,
|
||||
show: true,
|
||||
mode: 'time',
|
||||
min: min,
|
||||
@@ -321,7 +322,7 @@ export class Graph extends PureComponent<GraphProps, GraphState> {
|
||||
label: 'Datetime',
|
||||
ticks: ticks,
|
||||
timeformat: graphTimeFormat(ticks, min, max),
|
||||
timeFormatter: graphTimeFormatter(timeZone),
|
||||
tickFormatter: graphTickFormatter,
|
||||
},
|
||||
yaxes,
|
||||
grid: {
|
||||
|
||||
@@ -102,8 +102,12 @@ export const getMultiSeriesGraphHoverInfo = (
|
||||
};
|
||||
};
|
||||
|
||||
export const graphTimeFormatter = (timeZone?: TimeZone) => (epoch: number, format: string) =>
|
||||
dateTimeFormat(epoch, { format, timeZone });
|
||||
export const graphTickFormatter = (epoch: number, axis: any) => {
|
||||
return dateTimeFormat(epoch, {
|
||||
format: axis?.options?.timeformat,
|
||||
timeZone: axis?.options?.timezone,
|
||||
});
|
||||
};
|
||||
|
||||
export const graphTimeFormat = (ticks: number | null, min: number | null, max: number | null): string => {
|
||||
if (min && max && ticks) {
|
||||
|
||||
@@ -68,7 +68,7 @@ export { GraphContextMenu } from './Graph/GraphContextMenu';
|
||||
export { BarGauge, BarGaugeDisplayMode } from './BarGauge/BarGauge';
|
||||
export { GraphTooltipOptions } from './Graph/GraphTooltip/types';
|
||||
export { VizRepeater, VizRepeaterRenderValueProps } from './VizRepeater/VizRepeater';
|
||||
export { graphTimeFormat, graphTimeFormatter } from './Graph/utils';
|
||||
export { graphTimeFormat, graphTickFormatter } from './Graph/utils';
|
||||
|
||||
export {
|
||||
LegendOptions,
|
||||
|
||||
Reference in New Issue
Block a user