Open alr2413 opened 6 months ago
@imaNNeo, is there any issue with this PR? please let me know, thanks.
Yes, there are issues with this PR,
LineChartBarData
to add your own custom data, you can check out this messageThanks for your reply :) Here is my comments:
I defined the type of properties
attribute, because if we want to include that attribute in lerp
operation, the type must be known. so we can't use the dynamic
or Object
type.
I think it would be the best if you include this hint in readme
file (since currently there are multiple PR requests for this types of features). I tried to do that and it worked. Just need to override the copyWith
operation. I added here as a reference:
class LineChartBarDataWrapper extends LineChartBarData {
final String label;
LineChartBarDataWrapper({
super.spots,
super.show,
super.color,
super.gradient,
super.barWidth,
super.isCurved,
super.curveSmoothness,
super.preventCurveOverShooting,
super.preventCurveOvershootingThreshold,
super.isStrokeCapRound,
super.isStrokeJoinRound,
super.belowBarData,
super.aboveBarData,
super.dotData,
super.showingIndicators,
super.dashArray,
super.shadow,
super.isStepLineChart,
super.lineChartStepData,
required this.label,
});
@override
LineChartBarDataWrapper copyWith({
List<FlSpot>? spots,
bool? show,
Color? color,
Gradient? gradient,
double? barWidth,
bool? isCurved,
double? curveSmoothness,
bool? preventCurveOverShooting,
double? preventCurveOvershootingThreshold,
bool? isStrokeCapRound,
bool? isStrokeJoinRound,
BarAreaData? belowBarData,
BarAreaData? aboveBarData,
FlDotData? dotData,
List<int>? dashArray,
List<int>? showingIndicators,
Shadow? shadow,
bool? isStepLineChart,
LineChartStepData? lineChartStepData,
String? label,
}) {
return LineChartBarDataWrapper(
spots: spots ?? this.spots,
show: show ?? this.show,
color: color ?? this.color,
gradient: gradient ?? this.gradient,
barWidth: barWidth ?? this.barWidth,
isCurved: isCurved ?? this.isCurved,
curveSmoothness: curveSmoothness ?? this.curveSmoothness,
preventCurveOverShooting:
preventCurveOverShooting ?? this.preventCurveOverShooting,
preventCurveOvershootingThreshold: preventCurveOvershootingThreshold ??
this.preventCurveOvershootingThreshold,
isStrokeCapRound: isStrokeCapRound ?? this.isStrokeCapRound,
isStrokeJoinRound: isStrokeJoinRound ?? this.isStrokeJoinRound,
belowBarData: belowBarData ?? this.belowBarData,
aboveBarData: aboveBarData ?? this.aboveBarData,
dotData: dotData ?? this.dotData,
dashArray: dashArray ?? this.dashArray,
showingIndicators: showingIndicators ?? this.showingIndicators,
shadow: shadow ?? this.shadow,
isStepLineChart: isStepLineChart ?? this.isStepLineChart,
lineChartStepData: lineChartStepData ?? this.lineChartStepData,
label: label ?? this.label,
);
}
}
Hi, thanks for providing this awesome library. In this PR, I added a
properties
attribute asMap<string, dynamic>
in order to store optional line curve parameters, like name or any other curve setting. by this change if you have multiple curves in a chart, now it's possible to show the name of each curve next to the value on the tooltip message.