buildChart method

  1. @override
Widget buildChart()
override

Implementation

@override
Widget buildChart() {
  // Apply number formatting
  String formattedValue = numberFormat?.format(value) ?? '$value';

  // Define text styles, potentially based on the provided theme data
  TextStyle labelStyle =
      themeData?.labelStyle ?? const ChartThemeData().labelStyle;
  TextStyle valueStyle = themeData?.valueStyle ??
      const ChartThemeData()
          .valueStyle
          .copyWith(fontSize: 38); // Enlarged for emphasis
  TextStyle unitStyle =
      themeData?.unitStyle ?? const ChartThemeData().unitStyle;

  // Construct the chart widget using the ChartCard for common styling
  return ChartCard(
    themeData: themeData ?? const ChartThemeData(),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Text(label, style: labelStyle),
        const Spacer(),
        Text(formattedValue, style: valueStyle),
        const Spacer(),
        Text(unit, style: unitStyle),
      ],
    ),
  );
}