Class PieRenderer

java.lang.Object
com.arbergashi.charts.render.BaseRenderer
com.arbergashi.charts.render.circular.PieRenderer
All Implemented Interfaces:
ChartRenderer
Direct Known Subclasses:
DonutRenderer

public class PieRenderer extends BaseRenderer

Modern Pie Renderer

Draws a professional, interactive pie chart with intelligent external labeling and hover effects, adhering to strict zero-allocation guidelines.

Features:

  • Smart Labels: Automatically places labels outside with leader lines to avoid clutter.
  • Rich Labels: Displays category name and percentage value.
  • Hover Effect: Segments brighten on mouse hover for better interactivity.
  • Zero-Allocation: Highly optimized for performance.
Since:
2025-06-01
Version:
1.0.0
Author:
Arber Gashi
  • Constructor Details

    • PieRenderer

      public PieRenderer()
    • PieRenderer

      protected PieRenderer(String key)
  • Method Details

    • drawData

      protected void drawData(Graphics2D g2, ChartModel model, PlotContext context)
      Description copied from class: BaseRenderer
      Implementation-specific drawing logic. Must follow Zero-Allocation rules.
      Specified by:
      drawData in class BaseRenderer
    • getPointAt

      public Optional<Integer> getPointAt(Point2D pixel, ChartModel model, PlotContext context)
      Description copied from class: BaseRenderer
      Returns the data index nearest to the given pixel coordinate, if supported.
      Specified by:
      getPointAt in interface ChartRenderer
      Overrides:
      getPointAt in class BaseRenderer
      Parameters:
      pixel - mouse/crosshair position in component coordinates
      model - data model for this layer
      context - current plot context
      Returns:
      optional point index
    • clearHover

      public void clearHover()
      Description copied from interface: ChartRenderer
      Clears any hover/highlight state.
    • setHoverIndex

      public void setHoverIndex(int index)