Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/frontend/src/components/MkChart.stories.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const Base = {
args: {
src: 'federation',
span: 'hour',
nowForChromatic: 1716263640000,
},
parameters: {
layout: 'centered',
Expand All @@ -100,18 +101,21 @@ const Base = {
export const FederationChart = {
...Base,
args: {
...Base.args,
src: 'federation',
},
} satisfies StoryObj<typeof MkChart>;
export const NotesTotalChart = {
...Base,
args: {
...Base.args,
src: 'notes-total',
},
} satisfies StoryObj<typeof MkChart>;
export const DriveChart = {
...Base,
args: {
...Base.args,
src: 'drive',
},
} satisfies StoryObj<typeof MkChart>;
11 changes: 10 additions & 1 deletion packages/frontend/src/components/MkChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,21 @@ const props = withDefaults(defineProps<{
stacked?: boolean;
bar?: boolean;
aspectRatio?: number | null;
nowForChromatic?: number;
}>(), {
args: undefined,
limit: 90,
detailed: false,
stacked: false,
bar: false,
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>>();
Expand All @@ -106,7 +114,8 @@ const getColor = (i) => {
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 chartData: {
series: {
Expand Down
Loading