Skip to content

Commit

Permalink
fix issue imaNNeo#627
Browse files Browse the repository at this point in the history
  • Loading branch information
payam-zahedi authored and imaNNeo committed Apr 30, 2021
1 parent 2d42fdb commit 590351e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/src/chart/radar_chart/radar_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ class RadarChartPainter extends BaseChartPainter<RadarChartData> {
/// controls Radar chart size
final radius = _radarRadius(size);

/// draw radar background
_backgroundPaint.color = data.radarBackgroundColor;

/// draw radar background
canvasWrapper.drawCircle(centerOffset, radius, _backgroundPaint);

_borderPaint
..color = data.radarBorderData.color
..strokeWidth = data.radarBorderData.width;

/// draw radar border
canvasWrapper.drawCircle(centerOffset, radius, _borderPaint);

Expand All @@ -90,11 +95,15 @@ class RadarChartPainter extends BaseChartPainter<RadarChartData> {

final tickDistance = radius / (ticks.length);

_tickPaint
..color = data.tickBorderData.color
..strokeWidth = data.tickBorderData.width;

/// draw radar ticks
ticks.sublist(0, ticks.length - 1).asMap().forEach(
(index, tick) {
final tickRadius = tickDistance * (index + 1);
_tickPaint.color = data.tickBorderData.color;
_tickPaint.strokeWidth = data.tickBorderData.width;

canvasWrapper.drawCircle(centerOffset, tickRadius, _tickPaint);
_ticksTextPaint
..text = TextSpan(
Expand Down Expand Up @@ -124,15 +133,16 @@ class RadarChartPainter extends BaseChartPainter<RadarChartData> {

final angle = (2 * pi) / data.titleCount;

//drawing grids
/// drawing grids
for (var index = 0; index < data.titleCount; index++) {
final endX = centerX + radius * cos(angle * index - pi / 2);
final endY = centerY + radius * sin(angle * index - pi / 2);

final gridOffset = Offset(endX, endY);

_gridPaint.color = data.gridBorderData.color;
_gridPaint.strokeWidth = data.gridBorderData.width;
_gridPaint
..color = data.gridBorderData.color
..strokeWidth = data.gridBorderData.width;
canvasWrapper.drawLine(centerOffset, gridOffset, _gridPaint);
}
}
Expand Down

0 comments on commit 590351e

Please sign in to comment.