# Plot `plot` is a Ziran package that depends on the separate Kryon package. It owns `PlotWidget`, a retained Kryon widget that draws lines, bars, markers, and axes over caller-owned values, and its candle chart draws OHLC bodies and wicks, volume, SMA 20, SMA 50, and EMA 20 over that surface. `ChartMarker` and `CandleMarkers` add dated, clickable markers while leaving each marker's meaning to the caller. The simple line and candle charts accept caller-owned values and colors. The dashboard charts below add shared axes, date labels, legends and value formatting to caller-supplied datasets. The shared plot surface, text, border and marks use Kryon's active palette on each draw. The `surface`, `text`, `border` and `accent` style tokens can supply custom colors, including within a scoped widget palette. Installed style rules can also override the defaults. Existing charts pick up theme changes on their next draw, and callers retain control of their series colors. Install the Ziran launcher once with `make install-user` in Ziran, then run `ziran fetch` and `make build` here. `make run` opens the chart cookbook on the native Cairo backend. `make check` checks the source and runs the chart and indicator tests. The checked-in `ziran.lock` pins both Ziran and Kryon to exact commits. Plot exports `src/Plot/module.zi` for other packages, so `plot/Plot` resolves by its file both in projects and in builds that name `--module-path plot=DIR`. That module exports native chart data and algorithms; application screens use the typed TSX components below. To add Plot to another Ziran project, run: ```sh ziran add https://git.waozi.xyz/kryonlabs/plot.git ``` Then import its public module, or only the chart surface: ```zi using Charts :: #import "plot/Plot"; using Surface :: #import "plot/PlotWidget"; ``` The native modules export `PriceBar`, `CandleChartProps`, `CandleRangeFor`, `ChartMarker`, `ChartPriceLevel`, `SMAAt`, `EMAAt`, chart data, projections, ranges and hit tests. Retained chart composition is package-private; application screens import the typed TSX components. Ziran locks Plot and Kryon to exact commits. No source links or copied chart files are needed in a consuming package. Run `ziran update` to refresh every dependency in a project, or `ziran update kryon` in this package to refresh only Kryon. ATR consumes the published Plot dependency through its package manifest and generated lock, using the same workflow as other applications. Public module names use `UpperCamelCase` (`Kryon`, `PlotWidget`, `Plot`). Lowercase names such as `plot_widget` are implementation modules; the lowercase `plot` export remains available for existing consumers. ## TSX authoring Import `Plot` from `plot/tsx/plot`, line and candle charts from `plot/tsx/charts`, `BandChart` from `plot/tsx/band_chart`, and `XYChart`, grouped bars, heatmaps, waterfalls and linked time candles from `plot/tsx/dashboard`. Each component takes the draw session and its native checked props. Numeric algorithms, data declarations and ranges stay available from `plot/Plot` and `plot/PlotWidget`. Use `nativeSlice(values)` to pass a fixed array as chart data. The band component imports only its native widget and shared records from `plot/band_chart_props`. Hosted UI bundles use this same TSX component through the existing chart host capability, without importing the desktop chart tree. `CandleMarkers` and `CandlePriceLevels` from `plot/tsx/charts` compose the native interactive annotations. They take the session, native candle props and marker or level slices; price levels also take the checked candle range. Each returns the activated index, or `-1`, so TSX event wiring can call the native application action. The annotation data types remain native exports. ```tsx import { Session } from "kryon/session"; import { ChartRangeFor } from "plot/Plot"; import { LineChart } from "plot/tsx/charts"; export function DrawTrend(session: Session, values: float32[]): void { ; } ``` `BandChart` returns `BandChartResult`, and the dashboard components return `ChartHit`. Keep application selection or crosshair state in your frame code. `AnimatedLineChart` borrows animation state through `state={nativeRef(chart)}` and returns whether another frame is needed. Supply monotonic seconds, the duration, reduced-motion preference and easing as component attributes. ## Animated line charts `AnimatedLineChart` uses the same props and drawing as `LineChart` and takes one retained `AnimatedLineChartState` per chart. Give it a workspace of three `float32` values per point of capacity. Keep that workspace alive and exclusive to the state. Plot snapshots each target, so you can update or replace the input slice between calls. Keep the `ChartRange` fixed during motion so the axes stay in place. `ChartRangeForBoth` can set the scale for two known series. Call it with monotonic seconds each frame. It returns `true` while the host needs to schedule another frame. The first series appears immediately. A new target starts at the values sampled at the current time, including when it interrupts an animation. When the length changes, Plot samples the current line at the new evenly spaced x positions. A single point uses the right edge. Empty or over-capacity input draws directly and clears the transition. The next in-capacity series appears immediately. A null state also draws directly. The default duration is 0.25 seconds with ease-out, scaled by Kryon's theme motion multiplier. Pass the optional `duration`, `reduced_motion`, and `easing` arguments to control playback. A disabled theme, an explicit reduced motion preference, or a nonpositive duration settles immediately. The widget requires a Kryon revision that exports `kryon/motion`. `make check-animated-line` runs its native regression test without opening a window. Keep the native chart state and its workspace alive between frames. Pass the current monotonic time and retain the returned selection for the next draw: ```tsx import * as Charts from "plot/Plot"; import { AnimatedLineChart } from "plot/tsx/charts"; import { Button } from "kryon/tsx/button"; import { ColorFromPacked } from "kryon/drawing_props"; import { DesktopRequestFrame } from "kryon/desktop_runtime"; import { Easing } from "kryon/motion"; import { Session } from "kryon/session"; export interface WeeklyVisitsProps { session: Session; chart: NativeRef; previous: float32[]; current: float32[]; showCurrent: boolean; now: float64; } export function WeeklyVisits(widget: WeeklyVisitsProps): boolean { const switched =