Skip to content

Commit

Permalink
fix(frontend): fix time on MkChart's story (misskey-dev#13958)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyoshoka authored Jun 15, 2024
1 parent 34458d7 commit 379ce01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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

1 comment on commit 379ce01

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromatic detects changes. Please review the changes on Chromatic.

Please sign in to comment.