// Generated by scripts/generate-showcase.mjs. Do not edit directly. page ChartDetail { layout = "showcase" state playground_title = ctx.url.searchParams.get("pg_title") ?? "Weekly activity" state playground_description = ctx.url.searchParams.get("pg_description") ?? "Completed tasks this week" state playground_items = JSON.parse(ctx.url.searchParams.get("pg_items") ?? "[{\"label\":\"Mon\",\"value\":24},{\"label\":\"Tue\",\"value\":38},{\"label\":\"Wed\",\"value\":29},{\"label\":\"Thu\",\"value\":52},{\"label\":\"Fri\",\"value\":45}]") state playground_data = JSON.parse(ctx.url.searchParams.get("pg_data") ?? "[]") state playground_type = ctx.url.searchParams.get("pg_type") ?? "" state playground_valueKey = ctx.url.searchParams.get("pg_valueKey") ?? "value" state playground_labelKey = ctx.url.searchParams.get("pg_labelKey") ?? "label" state playground_height = Number(ctx.url.searchParams.get("pg_height") ?? "220") state playground_showLegend = (ctx.url.searchParams.get("pg_showLegend") ?? "false") === "true" state playground_showValues = (ctx.url.searchParams.get("pg_showValues") ?? "true") === "true" state playground_size = ctx.url.searchParams.get("pg_size") ?? "default" state playground_color = ctx.url.searchParams.get("pg_color") ?? "primary" state playground_variant = ctx.url.searchParams.get("pg_variant") ?? "bar" state playground_class = ctx.url.searchParams.get("pg_class") ?? "" seo { title = "Chart" description = "Theme-aware, responsive chart component." } view {
Integrations component

Chart

Theme-aware, responsive chart component.

14 props1 slots3 outputsTheme readyResponsive
Interactive playground

Configure Chart

Change any prop and inspect the server-rendered component immediately.

Live preview
Component code
page ChartExample {
  state items = [
  {
    "label": "Mon",
    "value": 24
  },
  {
    "label": "Tue",
    "value": 38
  },
  {
    "label": "Wed",
    "value": 29
  },
  {
    "label": "Thu",
    "value": 52
  },
  {
    "label": "Fri",
    "value": 45
  }
]
  state data = []
  view {
    <Chart
      title="Weekly activity"
      description="Completed tasks this week"
      items="{items}"
      data="{data}"
      height="220"
      showLegend="false"
    />
  }
}
Event outputInteract with the preview to inspect the typed payload.
Component props14 controls
Live examples

Designed for real product surfaces

Compare configurations and resize the browser to check responsive behavior.

Recommended

Bar chart

Pass an array of label/value objects through data.

01
Live preview
Component usage.wrn
page ChartExample {
  state items = []
  state data = [
  {
    "label": "Mon",
    "value": 24
  },
  {
    "label": "Tue",
    "value": 38
  },
  {
    "label": "Wed",
    "value": 29
  },
  {
    "label": "Thu",
    "value": 52
  },
  {
    "label": "Fri",
    "value": 45
  }
]
  view {
    <Chart
      title="Weekly signups"
      description="Completed tasks this week"
      items="{items}"
      data="{data}"
      type="bar"
      height="220"
      showLegend="false"
    />
  }
}
Compact

Line chart

Use type=line to compare a trend over time.

02
Live preview
Component usage.wrn
page ChartExample {
  state items = []
  state data = [
  {
    "label": "Jan",
    "value": 20
  },
  {
    "label": "Feb",
    "value": 35
  },
  {
    "label": "Mar",
    "value": 28
  },
  {
    "label": "Apr",
    "value": 55
  }
]
  view {
    <Chart
      title="Monthly revenue"
      description="Completed tasks this week"
      items="{items}"
      data="{data}"
      type="line"
      height="220"
      showLegend="false"
    />
  }
}
Component outputs

Receive every typed component output

Use declarative output handlers in .wrn files or register a direct output handler from JavaScript. The canonical API exposes payload and does not require event.detail.

@selectFires when an item, option, card, or result is selected.
@dataPointClickFires when the component emits the dataPointClick event.
@legendToggleFires when the component emits the legendToggle event.
Declarative handlers.wrn
<Chart
  @select='console.log(payload)'
  @dataPointClick='console.log(payload)'
  @legendToggle='console.log(payload)'
/>
Direct output handlers.js
import { registerOutputHandler } from "@wrnexus/csr/outputs"

const component = document.querySelector("[data-ui-component=\"Chart\"], [data-component=\"Chart\"]")

if (component) registerOutputHandler(component, "select", (payload) => {
  console.log("select", payload)
})

if (component) registerOutputHandler(component, "dataPointClick", (payload) => {
  console.log("dataPointClick", payload)
})

if (component) registerOutputHandler(component, "legendToggle", (payload) => {
  console.log("legendToggle", payload)
})
Component API

Props and configuration

All content and behavior shown above is supplied through these props and slots.

PropTypeDefaultRequired
titlestring"Chart"No
descriptionstring""No
itemsunknown[][]No
dataunknown[][]No
typestring""No
valueKeystring"value"No
labelKeystring"label"No
heightnumber240No
showLegendbooleantrueNo
showValuesbooleantrueNo
sizestring"default"No
colorstring"primary"No
variantstring"bar"No
classstring""No
} }