Skip to content

Commit

Permalink
copyWith method added in RadarChart data class
Browse files Browse the repository at this point in the history
  • Loading branch information
payam-zahedi committed Feb 23, 2021
1 parent 718c8a6 commit 6eb1fba
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions lib/src/chart/radar_chart/radar_chart_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,36 @@ class RadarChartData extends BaseChartData {

int get titleCount => dataSets[0].dataEntries.length;

RadarChartData copyWith({
@required List<RadarDataSet> dataSets,
Color radarBackgroundColor,
BorderSide radarBorderData,
GetTitleByIndexFunction getTitle,
TextStyle titleTextStyle,
double titlePositionPercentageOffset,
int tickCount,
TextStyle ticksTextStyle,
BorderSide tickBorderData,
BorderSide gridBorderData,
RadarTouchData radarTouchData,
FlBorderData borderData,
}) =>
RadarChartData(
dataSets: dataSets ?? this.dataSets,
radarBackgroundColor: radarBackgroundColor ?? this.radarBackgroundColor,
radarBorderData: radarBorderData ?? this.radarBorderData,
getTitle: getTitle ?? this.getTitle,
titleTextStyle: titleTextStyle ?? this.titleTextStyle,
titlePositionPercentageOffset:
titlePositionPercentageOffset ?? this.titlePositionPercentageOffset,
tickCount: tickCount ?? this.tickCount,
ticksTextStyle: ticksTextStyle ?? this.ticksTextStyle,
tickBorderData: tickBorderData ?? this.tickBorderData,
gridBorderData: gridBorderData ?? this.gridBorderData,
radarTouchData: radarTouchData ?? this.radarTouchData,
borderData: borderData ?? this.borderData,
);

@override
RadarChartData lerp(BaseChartData a, BaseChartData b, double t) {
if (a is RadarChartData && b is RadarChartData && t != null) {
Expand Down Expand Up @@ -157,6 +187,21 @@ class RadarDataSet extends Equatable {
borderWidth = borderWidth ?? 2,
entryRadius = entryRadius ?? 5.0;

RadarDataSet copyWith({
List<RadarEntry> dataEntries,
Color fillColor,
Color borderColor,
double borderWidth,
double entryRadius,
}) =>
RadarDataSet(
dataEntries: dataEntries ?? this.dataEntries,
fillColor: fillColor ?? this.fillColor,
borderColor: borderColor ?? this.borderColor,
borderWidth: borderWidth ?? this.borderWidth,
entryRadius: entryRadius ?? this.entryRadius,
);

static RadarDataSet lerp(RadarDataSet a, RadarDataSet b, double t) {
return RadarDataSet(
dataEntries: lerpRadarEntryList(a.dataEntries, b.dataEntries, t),
Expand All @@ -182,6 +227,8 @@ class RadarEntry extends Equatable {

const RadarEntry({double value}) : value = value ?? 0;

RadarEntry copyWith({double value}) => RadarEntry(value: value ?? this.value);

static RadarEntry lerp(RadarEntry a, RadarEntry b, double t) {
return RadarEntry(value: lerpDouble(a.value, b.value, t));
}
Expand Down

0 comments on commit 6eb1fba

Please sign in to comment.