Skip to content

[Release 1.1] Create renderers #90546

@luacmartins

Description

@luacmartins

Part of Add Charts to Virtual CFO Report.

Tasks

  • Register victorychart, victorybar, victoryline, victorypie, victoryaxis, victorylabel, victorylegend, victorytooltip, victorygroup HTML element models in BaseHTMLEngineProvider.tsx
  • Create src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer.tsx — tnode → victory-native translator:
    • <victorychart><CartesianChart> (bar/line) or <PolarChart> (pie), determined by first child type
    • <victorybar><Bar>, <victoryline><Line>, <victorypie><Pie>
    • <victoryaxis> forwarded as axis config, <victorylegend> → legend, <victorygroup><VictoryGroup>
    • JSON.parse all json attributes (data, tickValues, tickFormat, style, events); forward non-json props as-is
    • Return null on any parse failure (invalid json, pie+cartesian mix, unrecognized tag, empty series)
  • Register victorychart: VictoryChartRenderer in HTMLRenderers/index.ts

Automated Tests

VictoryChartRenderer.test.tsx:

  • Given a tnode containing one <VictoryBar data="...">, the renderer emits a <CartesianChart> with one <Bar> child whose data prop matches the parsed json
  • Given a tnode containing both <VictoryBar> and <VictoryLine>, the renderer emits a <CartesianChart> with one <Bar> and one <Line> child, both consuming the same parsed data
  • Given a tnode containing two <VictoryBar> children, the renderer emits a <CartesianChart> with two <Bar> children
  • Given a tnode containing one <VictoryPie>, the renderer emits a <PolarChart> containing a <Pie> child (not a <CartesianChart>)
  • Given a <VictoryBar horizontal="true">, the renderer propagates horizontal onto the <Bar> primitive
  • Given malformed json in data, a pie+cartesian mix, or an unrecognized inner tag, the renderer returns null and emits a warning log

Manual Test

  • Render a static reportAction containing a <VictoryChart> with one <VictoryBar> and confirm it draws correctly on all platforms
  • Render a static reportAction containing a <VictoryChart> with two <VictoryBar> children and also one with a <VictoryBar> + <VictoryLine> mix, and confirm both series share axes and render correctly
  • Render a static reportAction containing a <VictoryChart> whose only child is a <VictoryPie> and confirm the pie renders correctly
  • Render a reportAction with a <VictoryChart> containing invalid json in data or an unrecognized inner tag, and confirm the surrounding narrative text still renders (no crash, chart silently dropped)
Issue OwnerCurrent Issue Owner: @s77rt

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions