diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99125e0..2cfb865 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,9 @@
- Borrow band chart points and bands through native slice props.
+- Borrow dashboard chart slices through TSX view props and fully initialize
+ the dashboard example records.
+
- Align Plot with Kryon b0636e491's deterministic AVIF pin.
- Align band chart axes with shared plot bounds and both labelled gridlines.
diff --git a/examples/dashboard_charts.tsx b/examples/dashboard_charts.tsx
index 03109ff..4d9712f 100644
--- a/examples/dashboard_charts.tsx
+++ b/examples/dashboard_charts.tsx
@@ -10,14 +10,16 @@ function Beside(bounds: Rectangle): Rectangle {
// The second panel uses the original strategy values with its own observed range.
function Equity(session: Session, bounds: Rectangle): void {
const selected: [Plot.XYPointValue, Plot.XYPointValue, Plot.XYPointValue, Plot.XYPointValue] = [
- {x: 1640995200, y: 100}, {x: 1648771200, y: 102.9},
- {x: 1664582400, missing: true}, {x: 1672444800, y: 110.37},
+ {x: 1640995200, y: 100, missing: false}, {x: 1648771200, y: 102.9, missing: false},
+ {x: 1664582400, y: 0, missing: true}, {x: 1672444800, y: 110.37, missing: false},
];
const benchmark: [Plot.XYPointValue, Plot.XYPointValue, Plot.XYPointValue] = [
- {x: 1640995200, y: 100}, {x: 1648771200, y: 163.7}, {x: 1672444800, y: 293.58},
+ {x: 1640995200, y: 100, missing: false}, {x: 1648771200, y: 163.7, missing: false},
+ {x: 1672444800, y: 293.58, missing: false},
];
const series: [Plot.XYSeries, Plot.XYSeries] = [
- {name: "Selected", points: nativeSlice(selected)}, {name: "Buy and hold", points: nativeSlice(benchmark)},
+ {name: "Selected", color: u32(0), mark: Plot.XYMark.XYLine, points: nativeSlice(selected)},
+ {name: "Buy and hold", color: u32(0), mark: Plot.XYMark.XYLine, points: nativeSlice(benchmark)},
];
;
@@ -27,18 +29,25 @@ function Equity(session: Session, bounds: Rectangle): void {
function Returns(session: Session, bounds: Rectangle): void {
const years: [string, string, string] = ["2020", "2022", "2025"];
- const strategy: [Plot.ChartValue, Plot.ChartValue, Plot.ChartValue] = [{value: 4}, {value: 10.37}, {value: -6.43}];
- const hold: [Plot.ChartValue, Plot.ChartValue, Plot.ChartValue] = [{value: -14.8}, {value: -64.2}, {value: -18.5}];
+ const strategy: [Plot.ChartValue, Plot.ChartValue, Plot.ChartValue] = [
+ {value: 4, missing: false}, {value: 10.37, missing: false}, {value: -6.43, missing: false},
+ ];
+ const hold: [Plot.ChartValue, Plot.ChartValue, Plot.ChartValue] = [
+ {value: -14.8, missing: false}, {value: -64.2, missing: false}, {value: -18.5, missing: false},
+ ];
const returns: [Plot.BarSeries, Plot.BarSeries] = [
- {name: "Selected", values: nativeSlice(strategy)}, {name: "Buy and hold", values: nativeSlice(hold)},
+ {name: "Selected", color: u32(0), values: nativeSlice(strategy)},
+ {name: "Buy and hold", color: u32(0), values: nativeSlice(hold)},
];
;
- let differences: [Plot.ChartValue, Plot.ChartValue, Plot.ChartValue] = [{}, {}, {}];
+ let differences: [Plot.ChartValue, Plot.ChartValue, Plot.ChartValue] = [
+ {value: 0, missing: false}, {value: 0, missing: false}, {value: 0, missing: false},
+ ];
for (let index = s32(0); index < s32(3); index += s32(1)) {
- differences[index] = {value: strategy[index].value - hold[index].value};
+ differences[index] = {value: strategy[index].value - hold[index].value, missing: false};
}
- const delta: [Plot.BarSeries] = [{name: "Return difference", values: nativeSlice(differences)}];
+ const delta: [Plot.BarSeries] = [{name: "Return difference", color: u32(0), values: nativeSlice(differences)}];
;
}
@@ -47,13 +56,14 @@ function Contributions(session: Session, bounds: Rectangle): void {
const columns: [string, string, string] = ["2020", "2022", "2025"];
const rows: [string, string] = ["Momentum", "Carry"];
const cells: [Plot.ChartValue, Plot.ChartValue, Plot.ChartValue, Plot.ChartValue, Plot.ChartValue, Plot.ChartValue] = [
- {value: 6}, {value: -12}, {missing: true}, {}, {value: 5}, {value: -4.2},
+ {value: 6, missing: false}, {value: -12, missing: false}, {value: 0, missing: true},
+ {value: 0, missing: false}, {value: 5, missing: false}, {value: -4.2, missing: false},
];
;
const steps: [Plot.WaterfallStep, Plot.WaterfallStep, Plot.WaterfallStep, Plot.WaterfallStep] = [
- {label: "Start", value: 18.5, total: true}, {label: "Signals", value: 7.25},
- {label: "Costs", value: -4.38}, {label: "End", value: 21.37, total: true},
+ {label: "Start", value: 18.5, total: true, missing: false}, {label: "Signals", value: 7.25, total: false, missing: false},
+ {label: "Costs", value: -4.38, total: false, missing: false}, {label: "End", value: 21.37, total: true, missing: false},
];
;
@@ -61,17 +71,20 @@ function Contributions(session: Session, bounds: Rectangle): void {
function Diagnostics(session: Session, bounds: Rectangle): void {
const bars: [Plot.PriceBar64, Plot.PriceBar64, Plot.PriceBar64] = [
- {timestamp: s64(1640995200), open: 100, high: 118, low: 98, close: 111},
- {timestamp: s64(1641081600), open: 110, high: 115, low: 104, close: 106},
- {timestamp: s64(1641340800), open: 106, high: 125, low: 105, close: 121},
+ {timestamp: s64(1640995200), open: 100, high: 118, low: 98, close: 111, volume: 0},
+ {timestamp: s64(1641081600), open: 110, high: 115, low: 104, close: 106, volume: 0},
+ {timestamp: s64(1641340800), open: 106, high: 125, low: 105, close: 121, volume: 0},
];
const allocation: [Plot.XYPointValue, Plot.XYPointValue, Plot.XYPointValue, Plot.XYPointValue] = [
- {x: 1640995200, y: 25}, {x: 1641081600, y: 60}, {x: 1641254400, y: 15}, {x: 1641340800, y: 15},
+ {x: 1640995200, y: 25, missing: false}, {x: 1641081600, y: 60, missing: false},
+ {x: 1641254400, y: 15, missing: false}, {x: 1641340800, y: 15, missing: false},
+ ];
+ const trades: [Plot.XYPointValue, Plot.XYPointValue] = [
+ {x: 1641081600, y: 60, missing: false}, {x: 1641254400, y: 15, missing: false},
];
- const trades: [Plot.XYPointValue, Plot.XYPointValue] = [{x: 1641081600, y: 60}, {x: 1641254400, y: 15}];
const marks: [Plot.XYSeries, Plot.XYSeries] = [
- {name: "Allocation", mark: Plot.XYMark.XYStep, points: nativeSlice(allocation)},
- {name: "Trade", mark: Plot.XYMark.XYPoint, points: nativeSlice(trades)},
+ {name: "Allocation", color: u32(0), mark: Plot.XYMark.XYStep, points: nativeSlice(allocation)},
+ {name: "Trade", color: u32(0), mark: Plot.XYMark.XYPoint, points: nativeSlice(trades)},
];
const hit = ;
diff --git a/src/tsx/dashboard_chart_views.tsx b/src/tsx/dashboard_chart_views.tsx
index 3d56cd3..f41e72b 100644
--- a/src/tsx/dashboard_chart_views.tsx
+++ b/src/tsx/dashboard_chart_views.tsx
@@ -4,34 +4,34 @@ import { Session } from "kryon/session";
export interface XYChartProps {
session: Session;
props: Native.ChartProps;
- series: Native.XYSeries[];
+ series: NativeSlice;
}
export interface BarChartProps {
session: Session;
props: Native.ChartProps;
- categories: string[];
- series: Native.BarSeries[];
+ categories: NativeSlice;
+ series: NativeSlice;
}
export interface HeatmapChartProps {
session: Session;
props: Native.ChartProps;
- columns: string[];
- rows: string[];
- cells: Native.ChartValue[];
+ columns: NativeSlice;
+ rows: NativeSlice;
+ cells: NativeSlice;
}
export interface WaterfallChartProps {
session: Session;
props: Native.ChartProps;
- steps: Native.WaterfallStep[];
+ steps: NativeSlice;
}
export interface TimeCandleChartProps {
session: Session;
props: Native.ChartProps;
- bars: Bar[];
+ bars: NativeSlice;
}
export function XYChart(widget: XYChartProps): Native.ChartHit {