SeriesLegend<D>.customLayout constructor

SeriesLegend<D>.customLayout(
  1. LegendContentBuilder contentBuilder, {
  2. BehaviorPosition? position,
  3. OutsideJustification? outsideJustification,
  4. InsideJustification? insideJustification,
  5. List<String>? defaultHiddenSeries,
  6. bool? showMeasures,
  7. LegendDefaultMeasure? legendDefaultMeasure,
  8. MeasureFormatter? measureFormatter,
  9. MeasureFormatter? secondaryMeasureFormatter,
  10. TextStyleSpec? entryTextStyle,
})

Create a legend with custom layout.

By default, the legend is place above the chart and horizontally aligned to the start of the draw area.

contentBuilder builder for the custom layout.

position the legend will be positioned relative to the chart. Default position is top.

outsideJustification justification of the legend relative to the chart if the position is top, bottom, left, right. Default to start of the draw area.

insideJustification justification of the legend relative to the chart if the position is inside. Default to top of the chart, start of draw area. Start of draw area means left for LTR directionality, and right for RTL.

defaultHiddenSeries lists the IDs of series that should be hidden on first chart draw.

showMeasures show measure values for each series.

legendDefaultMeasure if measure should show when there is no selection. This is set to none by default (only shows measure for selected data).

measureFormatter formats measure value if measures are shown.

secondaryMeasureFormatter formats measures if measures are shown for the series that uses secondary measure axis.

Implementation

factory SeriesLegend.customLayout(
  LegendContentBuilder contentBuilder, {
  common.BehaviorPosition? position,
  common.OutsideJustification? outsideJustification,
  common.InsideJustification? insideJustification,
  List<String>? defaultHiddenSeries,
  bool? showMeasures,
  common.LegendDefaultMeasure? legendDefaultMeasure,
  common.MeasureFormatter? measureFormatter,
  common.MeasureFormatter? secondaryMeasureFormatter,
  common.TextStyleSpec? entryTextStyle,
}) {
  // Set defaults if empty.
  position ??= defaultBehaviorPosition;
  outsideJustification ??= defaultOutsideJustification;
  insideJustification ??= defaultInsideJustification;

  return SeriesLegend._internal(
    contentBuilder: contentBuilder,
    selectionModelType: common.SelectionModelType.info,
    position: position,
    outsideJustification: outsideJustification,
    insideJustification: insideJustification,
    defaultHiddenSeries: defaultHiddenSeries,
    showMeasures: showMeasures ?? false,
    legendDefaultMeasure:
        legendDefaultMeasure ?? common.LegendDefaultMeasure.none,
    measureFormatter: measureFormatter,
    secondaryMeasureFormatter: secondaryMeasureFormatter,
    entryTextStyle: entryTextStyle,
  );
}