Skip to content

feat(chart): Implement axis labels rendering for all chart types#3

Open
moksha-hub wants to merge 1 commit intomofa-org:mainfrom
moksha-hub:feat/axis-labels-rendering
Open

feat(chart): Implement axis labels rendering for all chart types#3
moksha-hub wants to merge 1 commit intomofa-org:mainfrom
moksha-hub:feat/axis-labels-rendering

Conversation

@moksha-hub
Copy link

@moksha-hub moksha-hub commented Feb 27, 2026

issue : #2
Implement axis labels rendering for all chart types in the makepad-chart library to provide proper visual context for data visualization.

Motivation

Currently, charts render data points but lack axis labels, making it difficult for users to:

  • Understand the scale of values on the Y-axis
  • Identify categories/data points on the X-axis
  • Interpret the data being visualized

Axis labels are essential for any production-ready charting library.

Proposed Solution

Add comprehensive axis label rendering support with the following components:

ChartAxis Component

  • ChartAxis struct with configurable orientation (Horizontal / Vertical)
  • Position support (Bottom, Top, Left, Right)
  • Customizable styling (colors, fonts, padding)
  • Show/hide options for line, ticks, and labels

AxisRenderer

  • Coordinated rendering of X and Y axes
  • Automatic tick label positioning
  • Support for different axis positions

DrawLabel Element

  • Text label rendering element for charts
  • AxisLabelRenderer for batch label rendering
  • Configurable text styling

Label Formatting

  • Automatic number formatting with K (thousands) and M (millions) suffixes
  • Custom label formatter support via closures
  • Configurable font size and colors

Implementation Details

// Example usage
let axis = ChartAxis::new()
    .with_orientation(AxisOrientation::Vertical)
    .with_position(AxisPosition::Left)
    .with_label_formatter(|v| format!("${:.0}", v));

// Render labels
axis.render_labels(cx, &ticks, chart_area, scale);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant