You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Ivy.Docs.Shared/Docs/02_Widgets/06_Charts/02_BarChart.md
+81Lines changed: 81 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -227,3 +227,84 @@ public class TiobeIndexDemo : ViewBase
227
227
228
228
</Body>
229
229
</Details>
230
+
231
+
## Dual-axis charts
232
+
233
+
BarChart supports multiple Y-axes through the `YAxisIndex` property on `Bar`. This lets different bar series use different scales — useful when comparing metrics with very different ranges (e.g., revenue in thousands alongside a conversion rate as a percentage).
234
+
235
+
Y-axes are indexed starting from 0. The first Y-axis defaults to the left side and additional axes can be placed on the right using `.Orientation(YAxis.Orientations.Right)`. Assign each bar to its axis with `.YAxisIndex(index)`.
236
+
237
+
### Manual BarChart construction
238
+
239
+
```csharp demo-below
240
+
publicclassDualAxisBarChart : ViewBase
241
+
{
242
+
publicoverrideobject? Build()
243
+
{
244
+
vardata=new[]
245
+
{
246
+
new { Month="Jan", Revenue=4200, ConversionRate=2.1 },
247
+
new { Month="Feb", Revenue=5800, ConversionRate=3.4 },
248
+
new { Month="Mar", Revenue=5100, ConversionRate=2.8 },
249
+
new { Month="Apr", Revenue=7400, ConversionRate=4.2 },
250
+
new { Month="May", Revenue=6200, ConversionRate=3.6 },
When building charts from queryable data with `ToBarChart()`, use the `polish` callback to add extra Y-axes and reassign bars. The default style already creates bars from your measures, so `polish` modifies the scaffolded chart — replacing bars with versions that have `YAxisIndex` set:
> **Note:** The `polish` callback receives the fully scaffolded `BarChart` which already includes one Y-axis and bars from the style. The example above adds a second Y-axis and replaces the `Bars` array with versions that specify `YAxisIndex`. Use contrasting colors for bars on different axes so readers can quickly match each bar to its scale.
0 commit comments