LineGraphComponent constructor

LineGraphComponent(
  1. RenderComponent parent,
  2. String id, {
  3. Map<String, List<DataPoint>> points = const {},
  4. int? labelCountX,
  5. int? labelCountY,
  6. double? labelMinX,
  7. double? labelMinY,
  8. double? labelMaxX,
  9. double? labelMaxY,
  10. double maxLabelWidthX = 50,
  11. double maxLabelWidthY = 20,
  12. double textMargin = 15,
  13. String labelFormatX(
    1. double label
    ) = _defaultLabelFormat,
  14. String labelFormatY(
    1. double label
    ) = _defaultLabelFormat,
  15. double aspectRatio = 1.5,
  16. double gridLineWidth = 1,
  17. String gridLineStrokeStyle = '#d7d7d7',
  18. String labelFillStyle = '#aaaaaa',
  19. String labelFontStyle = '14px sans-serif',
  20. Map<String, double> dotRadius = const {keyAllGraph : 6},
  21. Map<String, double> hoverDotRadiusOffset = const {keyAllGraph : 0},
  22. Map<String, String> dotFillStyle = const {keyAllGraph : 'white'},
  23. Map<String, String> dotStrokeStyle = const {keyAllGraph : '#2d2d2d'},
  24. Map<String, double> dotStrokeWidth = const {keyAllGraph : 1},
  25. Map<String, String> dataLineStrokeStyle = const {keyAllGraph : '#aaaaaa'},
  26. Map<String, double> dataLineWidth = const {keyAllGraph : 2},
  27. Map<String, String> shadingFillStyle = const {keyAllGraph : 'rgba(0, 0, 0, 0.2)'},
  28. String captionBgColor = '#2d2d2d',
  29. String captionFgColor = 'white',
  30. String captionFontFamily = 'sans-serif',
  31. bool drawGridY = false,
  32. double minWidth = 500,
  33. bool minWidthOverride = false,
  34. dynamic onHover(
    1. double x,
    2. double y,
    3. double coordX,
    4. double coordY,
    )?,
  35. dynamic onHoverOut()?,
})

Implementation

LineGraphComponent(super.parent, super.id,
    {Map<String, List<DataPoint>> points = const {},
      int? labelCountX,
      int? labelCountY,
      double? labelMinX,
      double? labelMinY,
      double? labelMaxX,
      double? labelMaxY,
      super.maxLabelWidthX,
      super.maxLabelWidthY,
      super.textMargin,
      super.labelFormatX = _defaultLabelFormat,
      super.labelFormatY = _defaultLabelFormat,
      super.aspectRatio,
      super.gridLineWidth,
      super.gridLineStrokeStyle,
      super.labelFillStyle,
      super.labelFontStyle,
      this.dotRadius = const {keyAllGraph: 6},
      this.hoverDotRadiusOffset = const {keyAllGraph: 0},
      this.dotFillStyle = const {keyAllGraph: 'white'},
      this.dotStrokeStyle = const {keyAllGraph: '#2d2d2d'},
      this.dotStrokeWidth = const {keyAllGraph: 1},
      this.dataLineStrokeStyle = const {keyAllGraph: '#aaaaaa'},
      this.dataLineWidth = const {keyAllGraph: 2},
      this.shadingFillStyle = const {keyAllGraph: 'rgba(0, 0, 0, 0.2)'},
      super.captionBgColor,
      super.captionFgColor,
      super.captionFontFamily,
      super.drawGridY,
      this.minWidth = 500,
      this.minWidthOverride = false,
      this.onHover,
      this.onHoverOut
    }) {
  _dataPoints = points.map(
          (key, value) =>
              MapEntry<String, SplayTreeMap<double, double>>(
                  key,
                  SplayTreeMap<double, double>.fromIterable(value, key: (e) => e.x, value: (e) => e.y)
              )
  );
  if (!dotRadius.containsKey(keyAllGraph)) dotRadius[keyAllGraph] = 6;
  if (!hoverDotRadiusOffset.containsKey(keyAllGraph)) hoverDotRadiusOffset[keyAllGraph] = 0;
  if (!dotFillStyle.containsKey(keyAllGraph)) dotFillStyle[keyAllGraph] = 'white';
  if (!dotStrokeStyle.containsKey(keyAllGraph)) dotStrokeStyle[keyAllGraph] = '#2d2d2d';
  if (!dotStrokeWidth.containsKey(keyAllGraph)) dotStrokeWidth[keyAllGraph] = 1;
  if (!dataLineStrokeStyle.containsKey(keyAllGraph)) dataLineStrokeStyle[keyAllGraph] = '#aaaaaa';
  if (!dataLineWidth.containsKey(keyAllGraph)) dataLineWidth[keyAllGraph] = 2;
  if (!shadingFillStyle.containsKey(keyAllGraph)) shadingFillStyle[keyAllGraph] = 'rgba(0, 0, 0, 0.2)';

  _initialLabelCountX = labelCountX;
  _initialLabelCountY = labelCountY;
  _initialLabelMinX = labelMinX;
  _initialLabelMinY = labelMinY;
  _initialLabelMaxX = labelMaxX;
  _initialLabelMaxY = labelMaxY;

  _setMinMaxXY();
}