index.community/frontend/src/types.ts

45 lines
1.6 KiB
TypeScript
Raw Normal View History

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-07-24 15:51:44 +00:00
// We could also extract the values from the server response, but this would slow things down...
values: ["mastodon", "gab", "pleroma"]
};
2019-07-27 17:58:40 +00:00
export const activityColorScheme: IQuantitativeColorScheme = {
cytoscapeDataKey: "statusesPerDay",
description: "The average number of statuses posted per day. Note that this is colored by an exponential scale.",
2019-07-27 17:58:40 +00:00
exponential: true,
name: "Activity (total)",
type: "quantitative"
};
export const activityPerUserColorScheme: IQuantitativeColorScheme = {
cytoscapeDataKey: "statusesPerUserPerDay",
description: "The average number of statuses posted per person per day.",
exponential: false,
name: "Activity (per person)",
2019-07-27 17:58:40 +00:00
type: "quantitative"
};
2019-07-24 15:51:44 +00:00
export const colorSchemes: IColorScheme[] = [typeColorScheme, activityColorScheme, activityPerUserColorScheme];