Skip to content

Commit

Permalink
feat: add custom chart description (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Feb 24, 2025
1 parent 9ef6bd2 commit 8d08b18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/backend/src/api/v1/dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ dashboards.get("/charts/custom", async (ctx: Context) => {
custom_chart
where
project_id = ${projectId}
order by
created_at desc
`;

ctx.body = customCharts;
Expand Down
11 changes: 11 additions & 0 deletions packages/frontend/components/analytics/ChartCreator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
Loader,
Select,
Stack,
Textarea,
TextInput,
} from "@mantine/core";
import { useEffect, useMemo, useState } from "react";

Expand Down Expand Up @@ -60,6 +62,7 @@ export function CustomChartCreator({
dashboardGranularity?: string;
}) {
const [name, setName] = useState(config?.name || "");
const [description, setDescription] = useState(config?.description || "");
const [metric, setMetric] = useState(config?.dataKey || "users/active");
const [primaryDimension, setPrimaryDimension] = useState<string | undefined>(
config?.primaryDimension || undefined,
Expand Down Expand Up @@ -171,6 +174,7 @@ export function CustomChartCreator({

const chartPayload = {
name: chartName,
description, // Pass custom description here
type: isCustomEventsMetric
? "area"
: secondaryDimension === "date"
Expand Down Expand Up @@ -198,6 +202,13 @@ export function CustomChartCreator({
return (
<Stack p="xl">
<RenamableField value={name} onRename={setName} defaultValue={name} />
<TextInput
w="500px"
label="Description (optional)"
placeholder="Enter a custom description"
value={description}
onChange={(e) => setDescription(e.currentTarget.value)}
/>
<Group mb="lg" mt="md">
<Select
label="Metric"
Expand Down

0 comments on commit 8d08b18

Please sign in to comment.