fix(frontend): fix time on `MkChart`'s story (#13958)

This commit is contained in:
zyoshoka 2024-06-15 16:35:41 +09:00 committed by GitHub
parent 34458d767b
commit 379ce0145b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -76,6 +76,7 @@ const Base = {
args: { args: {
src: 'federation', src: 'federation',
span: 'hour', span: 'hour',
nowForChromatic: 1716263640000,
}, },
parameters: { parameters: {
layout: 'centered', layout: 'centered',
@ -100,18 +101,21 @@ const Base = {
export const FederationChart = { export const FederationChart = {
...Base, ...Base,
args: { args: {
...Base.args,
src: 'federation', src: 'federation',
}, },
} satisfies StoryObj<typeof MkChart>; } satisfies StoryObj<typeof MkChart>;
export const NotesTotalChart = { export const NotesTotalChart = {
...Base, ...Base,
args: { args: {
...Base.args,
src: 'notes-total', src: 'notes-total',
}, },
} satisfies StoryObj<typeof MkChart>; } satisfies StoryObj<typeof MkChart>;
export const DriveChart = { export const DriveChart = {
...Base, ...Base,
args: { args: {
...Base.args,
src: 'drive', src: 'drive',
}, },
} satisfies StoryObj<typeof MkChart>; } satisfies StoryObj<typeof MkChart>;

View File

@ -77,6 +77,7 @@ const props = withDefaults(defineProps<{
stacked?: boolean; stacked?: boolean;
bar?: boolean; bar?: boolean;
aspectRatio?: number | null; aspectRatio?: number | null;
nowForChromatic?: number;
}>(), { }>(), {
args: undefined, args: undefined,
limit: 90, limit: 90,
@ -84,6 +85,13 @@ const props = withDefaults(defineProps<{
stacked: false, stacked: false,
bar: false, bar: false,
aspectRatio: null, aspectRatio: null,
/**
* @desc Overwrites current date to fix background lines of chart.
* @ignore Only used for Chromatic. Don't use this for production.
* @see https://github.com/misskey-dev/misskey/pull/13830#issuecomment-2155886151
*/
nowForChromatic: undefined,
}); });
const legendEl = shallowRef<InstanceType<typeof MkChartLegend>>(); const legendEl = shallowRef<InstanceType<typeof MkChartLegend>>();
@ -106,7 +114,8 @@ const getColor = (i) => {
return colorSets[i % colorSets.length]; return colorSets[i % colorSets.length];
}; };
const now = new Date(); // eslint-disable-next-line vue/no-setup-props-destructure
const now = props.nowForChromatic != null ? new Date(props.nowForChromatic) : new Date();
let chartInstance: Chart | null = null; let chartInstance: Chart | null = null;
let chartData: { let chartData: {
series: { series: {