ChartJS4 Integration
Introduction
Technical Highlights
Modern Serialization
// Pass any Chart.js option not yet covered by a first-class property
chart.ChartOptions.ExtensionData = new Dictionary<string, object>
{
["interaction"] = new { mode = "nearest", intersect = false },
["parsing"] = new { xAxisKey = "date", yAxisKey = "value" }
};Inline Scripting & Widget Functions
// Named function — define once, reference anywhere
chart.WidgetFunctions = new[]
{
new ChartJS4.WidgetFunction
{
Name = "barColor",
Source = "function(ctx) { return ctx.parsed.y > 100 ? 'crimson' : 'steelblue'; }"
}
};
ds.ExtensionData = new Dictionary<string, object>
{
["backgroundColor"] = "(ctx)=>barColor"
};
// Or just assign an inline function string directly — no registration needed
ds.ExtensionData = new Dictionary<string, object>
{
["borderColor"] = "ctx => ctx.dataIndex % 2 === 0 ? 'red' : 'blue'"
};Automatic Plugin Discovery
Strongly-Typed Options Model
Full Chart.js API Surface
Design-Time Support
ChartValue.NaN
When to use it
Example: Create a gap in a line chart
What you should see
Use Cases
Live Demo
Last updated
Was this helpful?

