Query the Time Series API from frontend applications.
Use Access Policies and multi-tenant JWT tokens to control access to your data.
'use client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { useTimeSeries, RelativeTimeRange, TimeSeriesGranularity } from "@propeldata/ui-kit";

const queryClient = new QueryClient();

function UseTimeSeries() {
  const { data } = useTimeSeries({
    metric: {
      count: { dataPool: { name: "TacoSoft Demo Data" } },
    },
    timeRange: { relative: RelativeTimeRange.LastNDays, n: 30 },
    granularity: TimeSeriesGranularity.Day,
  });

  return (
    <pre>
      {JSON.stringify(data?.timeSeries?.labels, null, 2)}
      {JSON.stringify(data?.timeSeries?.values, null, 2)}
    </pre>
  );
}

export default function UseSqlExample() {
  return (
    <QueryClientProvider client={queryClient}>
      <UseTimeSeries />
    </QueryClientProvider>
  );
}

Props API

granularity
TimeSeriesGranularity
Granularity that the chart will respond to
timestampFormat
string
Timestamp format that the chart will respond to
groupBy
string[]
Query groups based on columns for multi-dimensional time series
timeZone
string
Indicates specific time zone region
timeRange
TimeRangeInput
Specify the time range for a time series, counter, or leaderboard Metric query
metric
string | DeepPartial<MetricInput>
The metric prop allows you to specify which metric to query. You can query predefined metrics by passing their name or ID as a string, or you can query metrics on-the-fly by passing an inline metric definition to the prop.
filters
FilterInput[]
Filters that the chart will respond to
accessToken
string
Access token used for the query. While you can pass this one to each component, we recommend wrapping components in the AccessTokenProvider instead:
refetchInterval
number
Interval in milliseconds for refetching the data
retry
boolean
Whether to retry on errors.
propelApiUrl
string
This prop allows you to override the URL for Propel’s GraphQL API. You shouldn’t need to set this unless you are testing.
enabled
boolean
When false, the component will not make any GraphQL requests, default is true.