index.community/frontend/src/types.ts

39 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2019-08-04 11:39:29 +00:00
import { INSTANCE_TYPES } from "./constants";
2019-07-27 17:58:40 +00:00
interface IColorSchemeBase {
2019-07-24 15:51:44 +00:00
// The name of the coloring, e.g. "Instance type"
name: string;
// The name of the key in a cytoscape node's `data` field to color by.
// For example, use cytoscapeDataKey: "type" to color according to type.
cytoscapeDataKey: string;
2019-07-27 17:58:40 +00:00
description?: string;
type: "qualitative" | "quantitative";
}
interface IQualitativeColorScheme extends IColorSchemeBase {
2019-07-24 15:51:44 +00:00
// The values the color scheme is used for. E.g. ["mastodon", "pleroma", "misskey"].
values: string[];
2019-07-27 17:58:40 +00:00
type: "qualitative";
}
interface IQuantitativeColorScheme extends IColorSchemeBase {
type: "quantitative";
exponential: boolean;
2019-07-24 15:51:44 +00:00
}
2019-07-27 17:58:40 +00:00
export type IColorScheme = IQualitativeColorScheme | IQuantitativeColorScheme;
export const typeColorScheme: IQualitativeColorScheme = {
2019-07-24 15:51:44 +00:00
cytoscapeDataKey: "type",
name: "Instance type",
2019-07-27 17:58:40 +00:00
type: "qualitative",
2019-08-04 11:39:29 +00:00
values: INSTANCE_TYPES
2019-07-24 15:51:44 +00:00
};
2019-07-27 17:58:40 +00:00
export const activityColorScheme: IQuantitativeColorScheme = {
cytoscapeDataKey: "statusesPerDay",
description: "The average number of statuses posted per day. This is an exponential scale.",
2019-07-27 17:58:40 +00:00
exponential: true,
name: "Activity",
2019-07-27 17:58:40 +00:00
type: "quantitative"
};
2019-07-24 15:51:44 +00:00
export const colorSchemes: IColorScheme[] = [typeColorScheme, activityColorScheme];