DatumLegend<D>.customLayout constructor

DatumLegend<D>.customLayout(
  1. LegendContentBuilder contentBuilder, {
  2. BehaviorPosition? position,
  3. OutsideJustification? outsideJustification,
  4. InsideJustification? insideJustification,
  5. bool? showMeasures,
  6. LegendDefaultMeasure? legendDefaultMeasure,
  7. MeasureFormatter? measureFormatter,
  8. MeasureFormatter? secondaryMeasureFormatter,
  9. 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.

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 DatumLegend.customLayout(
  LegendContentBuilder contentBuilder, {
  common.BehaviorPosition? position,
  common.OutsideJustification? outsideJustification,
  common.InsideJustification? insideJustification,
  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 new DatumLegend._internal(
    contentBuilder: contentBuilder,
    selectionModelType: common.SelectionModelType.info,
    position: position,
    outsideJustification: outsideJustification,
    insideJustification: insideJustification,
    showMeasures: showMeasures ?? false,
    legendDefaultMeasure:
        legendDefaultMeasure ?? common.LegendDefaultMeasure.none,
    measureFormatter: measureFormatter,
    secondaryMeasureFormatter: secondaryMeasureFormatter,
    entryTextStyle: entryTextStyle,
  );
}