Skip to main content

Overview

The Credit Usage Chart widget provides a visual breakdown of how credits are consumed over time. It helps customers understand their spending patterns and identify which features or services drive the most usage.

Layout

  • Stacked bar chart β€” shows daily credit consumption across different features or services.
  • Color-coded legend β€” distinguishes usage by feature (e.g., Feature 1, Feature 2, Feature 3).
  • Total spend β€” aggregate credits consumed over the selected timeframe.
  • Date range selector β€” allows filtering usage data (e.g., last 7 days, last 30 days).
This widget is especially useful for monitoring consumption trends, analyzing feature-level usage, and forecasting future credit needs.

Customization

  • Brand via the no-code widget designer.
  • Use custom CSS when deeper styling is required.

Main component

  • stigg-credit-usage-chart-container β€” The main wrapper for the entire CreditUsageChart component
  • stigg-credit-usage-chart-card β€” The card container that holds the chart layout and styling
  • stigg-credit-usage-chart-skeleton β€” The loading skeleton displayed while usage data is being fetched
  • stigg-credit-usage-chart-bar β€” The bar element used in the usage visualization

Header component

  • stigg-credit-usage-chart-header β€” The header container at the top of the chart
  • stigg-credit-usage-chart-title β€” The chart title text
  • stigg-credit-usage-chart-total β€” Displays the total spend or total usage amount
  • stigg-credit-usage-chart-time-range-select β€” Dropdown or selector to change the chart’s time range

Tooltip component

  • stigg-credit-usage-chart-tooltip β€” Tooltip showing detailed usage values on hover

Legend component

  • stigg-credit-usage-chart-legend β€” Wrapper for the entire legend section
  • stigg-credit-usage-chart-legend-title β€” Title for the legend block
  • stigg-credit-usage-chart-legend-title-currency-units β€” Currency or unit label in the legend header
  • stigg-credit-usage-chart-legend-item β€” Base class for each legend row
  • stigg-credit-usage-chart-legend-item-{featureId} β€” Dynamic class applied per feature, where {featureId} is the feature’s unique identifier
  • stigg-credit-usage-chart-legend-bar-container β€” Container holding the color bar representing each feature
  • stigg-credit-usage-chart-legend-feature-name β€” Wrapper for the feature name in the legend
  • stigg-credit-usage-chart-legend-feature-name-text β€” Text label of the feature name
  • stigg-credit-usage-chart-legend-value β€” The usage amount displayed for each feature

Empty state component

  • stigg-credit-usage-chart-empty-state β€” Displayed when no usage data is available

Error state component

  • stigg-credit-usage-chart-error-state β€” Shown when the chart fails to load due to an error

Snippet

import React from 'react';
import { StiggProvider, CreditUsageChart, CreditUsageTimeRange } from '@stigg/react-sdk';

function App() {
  return (
    <StiggProvider
      apiKey="your-stigg-api-key"
      customerId="customer-demo-01"
    >
      <div className="credit-widgets">
        <CreditUsageChart
          currencyId="cred-type-ai-tokens" // Required: currency identifier
          timeRange={CreditUsageTimeRange.LastMonth}
          // Optional: Custom column labels and messages
          localization={{
            title: 'Usage',
            totalSpend: 'Total spend','
          }}
        />
      </div>
    </StiggProvider>
  );
}

export default App;