Skip to content

Commit

Permalink
feat: add params to RadarChartData - elevation, radarShadowColor
Browse files Browse the repository at this point in the history
  • Loading branch information
frybitsinc committed Nov 5, 2024
1 parent fd4ade0 commit a086ef2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.15.2
COCOAPODS: 1.16.1
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class _RadarChartSample2State extends State<RadarChartSample2> {
aspectRatio: 1.0,
child: RadarChart(
RadarChartData(
elevation: 6,
radarShape: RadarShape.polygon,
radarBackgroundColor: Colors.white,
radarShadowColor: Colors.white,
radarTouchData: RadarTouchData(
touchCallback: (FlTouchEvent event, response) {
if (!event.isInterestedForInteractions) {
Expand All @@ -156,7 +160,6 @@ class _RadarChartSample2State extends State<RadarChartSample2> {
},
),
dataSets: showingDataSets(),
radarBackgroundColor: Colors.transparent,
borderData: FlBorderData(show: false),
radarBorderData: const BorderSide(color: Colors.transparent),
titlePositionPercentageOffset: 0.1,
Expand Down Expand Up @@ -250,7 +253,7 @@ class _RadarChartSample2State extends State<RadarChartSample2> {
rawDataSet.color.withOpacity(0.4),
]
: List.filled(6, Colors.grey.withOpacity(0.2)),
stops: [0, 0.16, 0.32, 0.48, 0.64, 0.8],
stops: const [0, 0.16, 0.32, 0.48, 0.64, 0.8],
),
dataEntries:
rawDataSet.values.map((e) => RadarEntry(value: e)).toList(),
Expand Down
18 changes: 18 additions & 0 deletions lib/src/chart/radar_chart/radar_chart_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class RadarChartData extends BaseChartData with EquatableMixin {
RadarChartData({
@required List<RadarDataSet>? dataSets,
Color? radarBackgroundColor,
Color? radarShadowColor,
BorderSide? radarBorderData,
double? elevation,
RadarShape? radarShape,
this.getTitle,
this.titleTextStyle,
Expand All @@ -88,7 +90,9 @@ class RadarChartData extends BaseChartData with EquatableMixin {
),
dataSets = dataSets ?? const [],
radarBackgroundColor = radarBackgroundColor ?? Colors.transparent,
radarShadowColor = radarShadowColor ?? Colors.transparent,
radarBorderData = radarBorderData ?? const BorderSide(width: 2),
elevation = elevation ?? 0,
radarShape = radarShape ?? RadarShape.circle,
radarTouchData = radarTouchData ?? RadarTouchData(),
titlePositionPercentageOffset = titlePositionPercentageOffset ?? 0.2,
Expand All @@ -105,9 +109,15 @@ class RadarChartData extends BaseChartData with EquatableMixin {
/// [radarBackgroundColor] draw the background color of the [RadarChart]
final Color radarBackgroundColor;

/// [radarShadowColor] draw the elevation shadow color of the [RadarChart]
final Color radarShadowColor;

/// [radarBorderData] is used to draw [RadarChart] border
final BorderSide radarBorderData;

/// [elevation] is used to draw [RadarChart] elevation
final double elevation;

/// [radarShape] is used to draw [RadarChart] border and background
final RadarShape radarShape;

Expand Down Expand Up @@ -193,7 +203,9 @@ class RadarChartData extends BaseChartData with EquatableMixin {
RadarChartData copyWith({
List<RadarDataSet>? dataSets,
Color? radarBackgroundColor,
Color? radarShadowColor,
BorderSide? radarBorderData,
double? elevation,
RadarShape? radarShape,
GetTitleByIndexFunction? getTitle,
TextStyle? titleTextStyle,
Expand All @@ -208,7 +220,9 @@ class RadarChartData extends BaseChartData with EquatableMixin {
RadarChartData(
dataSets: dataSets ?? this.dataSets,
radarBackgroundColor: radarBackgroundColor ?? this.radarBackgroundColor,
radarShadowColor: radarShadowColor ?? this.radarShadowColor,
radarBorderData: radarBorderData ?? this.radarBorderData,
elevation: elevation ?? this.elevation,
radarShape: radarShape ?? this.radarShape,
getTitle: getTitle ?? this.getTitle,
titleTextStyle: titleTextStyle ?? this.titleTextStyle,
Expand All @@ -230,6 +244,7 @@ class RadarChartData extends BaseChartData with EquatableMixin {
dataSets: lerpRadarDataSetList(a.dataSets, b.dataSets, t),
radarBackgroundColor:
Color.lerp(a.radarBackgroundColor, b.radarBackgroundColor, t),
radarShadowColor: Color.lerp(a.radarShadowColor, b.radarShadowColor, t),
getTitle: b.getTitle,
titleTextStyle: TextStyle.lerp(a.titleTextStyle, b.titleTextStyle, t),
titlePositionPercentageOffset: lerpDouble(
Expand All @@ -242,6 +257,7 @@ class RadarChartData extends BaseChartData with EquatableMixin {
gridBorderData: BorderSide.lerp(a.gridBorderData, b.gridBorderData, t),
radarBorderData:
BorderSide.lerp(a.radarBorderData, b.radarBorderData, t),
elevation: lerpDouble(a.elevation, b.elevation, t),
radarShape: b.radarShape,
tickBorderData: BorderSide.lerp(a.tickBorderData, b.tickBorderData, t),
borderData: FlBorderData.lerp(a.borderData, b.borderData, t),
Expand All @@ -259,7 +275,9 @@ class RadarChartData extends BaseChartData with EquatableMixin {
touchData,
dataSets,
radarBackgroundColor,
radarShadowColor,
radarBorderData,
elevation,
radarShape,
getTitle,
titleTextStyle,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/chart/radar_chart/radar_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ class RadarChartPainter extends BaseChartPainter<RadarChartData> {

/// draw radar border
..drawPath(path, _borderPaint);
if (data.elevation > 0) {
canvasWrapper.canvas
.drawShadow(path, data.radarShadowColor, data.elevation, true);
}
}

final tickSpace = getSpaceBetweenTicks(data);
Expand Down

0 comments on commit a086ef2

Please sign in to comment.