Bar Chart (Bar)
This chapter explains bar charts in EasyChart: the data interpretation rules (SeriesData.x/value), how grouping/stacking really behaves, and commonly used style fields.
1. Use cases
- Category comparisons (compare values of A/B/C)
- Grouped comparison (multiple Bar series side-by-side under the same category)
- Stacked totals (stack bars within the same category)
2. Minimum viable setup (checklist)
ChartProfile.coordinateSystem = Cartesian2D- Axes
- X: usually
AxisType.Category(filllabels) - Y: usually
AxisType.Value(recommended to start from 0)
- X: usually
- Series
- Add 1
Serie Serie.type = BarSerie.seriesDatahas at least 1 point
- Add 1
3. Inspector fields
-
Axis Settings
cartesian.xAxisId / cartesian.yAxisIdaxes[](AxisConfig for X/Y)
-
Series
series[i].type = Barseries[i].settings: actual type isBarSettingsbarWidthstacked/stackGroupbarGap/categoryGapcornerRadius/cornerSegmentstextureFill(color/texture)border/backgroundhover(enables picking/highlight)
4. SeriesData field interpretation (runtime behavior)
Bar charts primarily use:
-
Category / horizontal position:
SeriesData.x- Runtime rounds
xwithRoundToInt, so treat it as a category index.
- Runtime rounds
-
Bar height:
SeriesData.value -
SeriesData.y/SeriesData.zare not used for rendering in Bar charts (do not treatyas height).
5. Most common template: Category X + Value Y
5.1 X axis (Category)
AxisType = Categorylabels = ["A","B","C",...]- Recommended:
labelPlacement = CellCenter(easier to center-align bars)
5.2 Data pattern
x = category index(0/1/2…)value = bar height
6. Grouped bars (multiple series side-by-side): the actual rule
Key points:
- multiple
Serie, alltype=Bar - all series share the same X categories (same labels)
- each series uses the same
xindex to land in the same category
Spacing fields:
BarSettings.barGap: gap between bar groups within a categoryBarSettings.categoryGap: extra gap between categories (affects edge padding)
7. Stacked bars (stacked): the actual rule
Stacking happens between Bar series with the same stackGroup:
BarSettings.stacked = trueBarSettings.stackGroup = "Group1"
Runtime stacking notes:
- for the same
x(category index), it accumulates positive and negative values separately (positive/negative stacks are separate) - the top of each stacked segment = current accumulated base +
value
8. Common pitfalls and troubleshooting
-
Bars appear between labels / not aligned
- Check X axis
labelPlacement(recommendCellCenter) - Ensure
xis an integer index (runtime rounds)
- Check X axis
-
Bars do not start from 0
- Check whether Y axis (Value Axis) has
autoRangeMindisabled andminValue=0locked
- Check whether Y axis (Value Axis) has
-
Stacking result is wrong
- Check that all series that should stack use the same
stackGroup - Remember: positive and negative values stack separately
- Check that all series that should stack use the same
9. Further reading
- Axes/range, Series and data:
00_02-WorkflowAndLibrary.md - Common recipes:
04_08-CommonRecipes.md - FAQ:
04_09-FAQ.md