BoxChartComponent constructor
BoxChartComponent(
- RenderComponent parent,
- String id, {
- Map<
String, List< points = const {},BoxDataPoint> > - LinkedHashSet<
String> ? labelsX, - Set<
String> ? graphKeys, - Map<
String, String> ? graphAliases, - int? labelCountY,
- double? labelMinY,
- double? labelMaxY,
- double maxLabelWidthX = 50,
- double maxLabelWidthY = 20,
- double textMargin = 15,
- String labelFormatX()?,
- String labelFormatY()?,
- double aspectRatio = 1.5,
- double gridLineWidth = 1,
- String gridLineStrokeStyle = '#d7d7d7',
- String labelFillStyle = '#aaaaaa',
- String labelFontStyle = '14px sans-serif',
- String captionBgColor = '#2d2d2d',
- String captionFgColor = 'white',
- String captionFontFamily = 'sans-serif',
- bool drawGridY = false,
- Map<
String, String> barFillStyle = const {keyAllGraph : '#aaaaaa'}, - double minWidth = 500,
- bool minWidthOverride = false,
- double singleBarWidth = 15,
- double barMargin = 5,
- double barSetMargin = 45,
- dynamic onHover(
- String x,
- BoxDataPoint y
- dynamic onHoverOut()?,
- dynamic onClick(
- String x,
- BoxDataPoint y
Implementation
BoxChartComponent(super.parent, super.id, {
Map<String, List<BoxDataPoint>> points = const {},
LinkedHashSet<String>? labelsX,
Set<String>? graphKeys,
Map<String, String>? graphAliases,
int? labelCountY,
double? labelMinY,
double? labelMaxY,
super.maxLabelWidthX,
super.maxLabelWidthY,
super.textMargin,
String Function(double)? labelFormatX,
String Function(double)? labelFormatY,
super.aspectRatio,
super.gridLineWidth,
super.gridLineStrokeStyle,
super.labelFillStyle,
super.labelFontStyle,
super.captionBgColor,
super.captionFgColor,
super.captionFontFamily,
super.drawGridY,
this.barFillStyle = const {keyAllGraph: '#aaaaaa'},
this.minWidth = 500,
this.minWidthOverride = false,
this.singleBarWidth = 15,
this.barMargin = 5,
this.barSetMargin = 45,
this.onHover,
this.onHoverOut,
this.onClick,
}) : super(labelFormatX: labelFormatX ?? _defaultLabelFormat,
labelFormatY: labelFormatY ?? _defaultLabelFormat,
) {
if (!barFillStyle.containsKey(keyAllGraph)) barFillStyle[keyAllGraph] = '#aaaaaa';
_initialLabelCountY = labelCountY;
_initialLabelMinY = labelMinY;
_initialLabelMaxY = labelMaxY;
_userGraphKeys = graphKeys ?? {};
this.graphAliases = graphAliases ?? {};
if (labelsX != null) this.labelsX = labelsX;
var labelsXSet = labelsX != null && labelsX.isNotEmpty;
// Add empty data point in some X point that is defined in labels, but
// do not have any points.
labelsX?.forEach((element) {
if (_dataPoints[element] == null) {
_dataPoints[element] = points.map((key, value) => MapEntry(key, BoxDataPoint()));
}
});
_graphKeys.addAll(_userGraphKeys);
points.forEach((key, value) {
if (_userGraphKeys.isNotEmpty && !_userGraphKeys.contains(key)) return;
_graphKeys.add(key);
for (var dp in value) {
// If the labelsX has predefined X labels, ignore those points that are outside of defined labels.
if (labelsXSet && labelsX.contains(this.labelFormatX(dp.x))) continue;
if (_dataPoints[this.labelFormatX(dp.x)] == null) {
_dataPoints[this.labelFormatX(dp.x)] = {};
}
_dataPoints[this.labelFormatX(dp.x)]![key] = dp;
}
});
_setMinMaxY();
}