Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gradient color in Radarchart #1669

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/src/chart/radar_chart/radar_chart_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class RadarDataSet with EquatableMixin {
Color? borderColor,
double? borderWidth,
double? entryRadius,
Gradient? gradientcolor,
}) : assert(
dataEntries == null || dataEntries.isEmpty || dataEntries.length >= 3,
'Radar needs at least 3 RadarEntry',
Expand All @@ -292,7 +293,9 @@ class RadarDataSet with EquatableMixin {
fillColor = fillColor ?? Colors.cyan.withOpacity(0.2),
borderColor = borderColor ?? Colors.cyan,
borderWidth = borderWidth ?? 2.0,
entryRadius = entryRadius ?? 5.0;
entryRadius = entryRadius ?? 5.0,
gradientcolor = gradientcolor ??
LinearGradient(colors: [Colors.transparent, Colors.transparent]);

/// each section or dataSets consists of a set of [dataEntries].
final List<RadarEntry> dataEntries;
Expand All @@ -312,6 +315,10 @@ class RadarDataSet with EquatableMixin {
/// the default value of this field is 5.0
final double entryRadius;

/// defines the lineargardient
/// the default value of this field is transparent
final Gradient gradientcolor;

/// Copies current [RadarDataSet] to a new [RadarDataSet],
/// and replaces provided values.
RadarDataSet copyWith({
Expand All @@ -320,13 +327,15 @@ class RadarDataSet with EquatableMixin {
Color? borderColor,
double? borderWidth,
double? entryRadius,
Gradient? gradientcolor,
}) =>
RadarDataSet(
dataEntries: dataEntries ?? this.dataEntries,
fillColor: fillColor ?? this.fillColor,
borderColor: borderColor ?? this.borderColor,
borderWidth: borderWidth ?? this.borderWidth,
entryRadius: entryRadius ?? this.entryRadius,
gradientcolor: gradientcolor ?? this.gradientcolor,
);

/// Lerps a [RadarDataSet] based on [t] value, check [Tween.lerp].
Expand All @@ -348,6 +357,7 @@ class RadarDataSet with EquatableMixin {
borderColor,
borderWidth,
entryRadius,
gradientcolor
];
}

Expand Down