# Candlestick Chart

Animated financial charts for open, high, low, and close data.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).





<ComponentPreview base="chartgpu" title="Basic Chart" name="candlestick-chart-demo">
  <CandlestickChartDemo />
</ComponentPreview>

## Installation [#installation]

<CodeTabs>
  <TabsList>
    <TabsTrigger value="cli">
      Command
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add @chartcn/chartgpu/candlestick-chart
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      npm install @chartgpu/chartgpu
      ```

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource src="registry/bases/chartgpu/ui/chart.tsx" title="components/chart/chart.tsx" />

      <ComponentSource src="registry/bases/chartgpu/ui/tooltip.ts" title="components/chart/tooltip.ts" />

      <ComponentSource src="registry/bases/chartgpu/components/financial-chart/financial-chart.tsx" title="components/chart/financial-chart.tsx" />

      <ComponentSource src="registry/bases/chartgpu/components/candlestick-chart/candlestick-chart.tsx" title="components/chart/candlestick-chart.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</CodeTabs>

## Usage [#usage]

```tsx
import { ChartcnCandlestickChart } from "@/components/chart/candlestick-chart";
```

```tsx
<ChartcnCandlestickChart config={chartConfig} data={data}>
  <ChartcnCandlestickChart.Grid />
  <ChartcnCandlestickChart.XAxis />
  <ChartcnCandlestickChart.YAxis />
  <ChartcnCandlestickChart.Legend />
  <ChartcnCandlestickChart.Tooltip />
  <ChartcnCandlestickChart.Candlestick barWidth="58%" />
</ChartcnCandlestickChart>
```

## Examples [#examples]

### Hollow candles [#hollow-candles]

<ComponentPreview base="chartgpu" title="style='hollow'" name="hollow-candlestick-chart-demo">
  <HollowCandlestickChartDemo />
</ComponentPreview>

## API Reference [#api-reference]

| Prop        | Type                         | Default                                 |
| ----------- | ---------------------------- | --------------------------------------- |
| `data`      | `readonly OHLCDataPoint[]`   | -                                       |
| `config`    | `ChartConfig`                | -                                       |
| `animation` | `boolean \| AnimationConfig` | `{ duration: 700, easing: "cubicOut" }` |
| `isLoading` | `boolean`                    | `false`                                 |

### Candlestick [#candlestick]

| Prop         | Type                                     | Default          |
| ------------ | ---------------------------------------- | ---------------- |
| `barWidth`   | `number \| string`                       | -                |
| `style`      | `"classic" \| "hollow"`                  | `"classic"`      |
| `priceLabel` | `boolean \| CandlestickPriceLabelConfig` | ChartGPU default |
