Skip to content
Open
Show file tree
Hide file tree
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
48 changes: 47 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
## newVersion
## 1.2.0
* **BUGFIX** (by @imaNNeo) Consider the `enabled` property in [LineTouchData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/line_chart.md#linetouchdata-read-about-touch-handling), [BarTouchData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/bar_chart.md#bartouchdata-read-about-touch-handling), [PieTouchData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/pie_chart.md#pietouchdata-read-about-touch-handling), [ScatterTouchData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/scatter_chart.md#scattertouchdata-read-about-touch-handling), [RadarTouchData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/radar_chart.md#radartouchdata-read-about-touch-handling) and [CandlestickTouchData](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/candlestick_chart.md#candlesticktouchdata-read-about-touch-handling), #1676
* **BREAKING** ⚠️ (by @huanghui1998hhh) Enhanced line chart curve function with a new extensible curve system. Introduced `LineChartCurve` abstract class. You can implement your own curve or use built-in curve: `LineChartCubicTensionCurve`(old curve implementation), and `LineChartCubicMonotoneCurve`.
**Migration Guide:**

Old API (deprecated):
```dart
LineChartBarData(
spots: spots,
isCurved: true,
curveSmoothness: 0.35,
preventCurveOverShooting: true,
preventCurveOvershootingThreshold: 10.0,
)
```

New API:
```dart
LineChartBarData(
spots: spots,
curve: LineChartCurve.cubicTension( // or use LineChartCubicTensionCurve()
smoothness: 0.35,
preventCurveOverShooting: true,
preventCurveOvershootingThreshold: 10.0,
),
)
```

Or use the new monotone curve:
```dart
LineChartBarData(
spots: spots,
curve: LineChartCurve.cubicMonotone( // or use LineChartCubicMonotoneCurve()
smooth: 0.5,
monotone: SmoothMonotone.x, // Prevents overshooting along X-axis
),
)
```

For straight lines (isCurved: false):
```dart
LineChartBarData(
spots: spots,
curve: LineChartCurve.noCurve, // or omit the curve parameter (default)
)
```

Check the updated [LineChart documentation](https://github.com/imaNNeo/fl_chart/blob/main/repo_files/documentations/line_chart.md#linechartcurve) for more details.

## 1.1.1
* **IMPROVEMENT** (by @imaNNeo) Upgrade `vector_math` dependency to `2.2.0`, #1985
Expand Down
3 changes: 2 additions & 1 deletion example/lib/presentation/samples/bar/bar_chart_sample7.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ class _IconWidgetState extends AnimatedWidgetBaseState<_IconWidget> {
final rotation = math.pi * 4 * _rotationTween!.evaluate(animation);
final scale = 1 + _rotationTween!.evaluate(animation) * 0.5;
return Transform(
transform: Matrix4.rotationZ(rotation).scaledByDouble(scale, scale, scale, 1.0),
transform:
Matrix4.rotationZ(rotation).scaledByDouble(scale, scale, scale, 1.0),
origin: const Offset(14, 14),
child: Icon(
widget.isSelected ? Icons.face_retouching_natural : Icons.face,
Expand Down
14 changes: 6 additions & 8 deletions example/lib/presentation/samples/line/line_chart_sample1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class _LineChart extends StatelessWidget {
);

LineChartBarData get lineChartBarData1_1 => LineChartBarData(
isCurved: true,
curve: const LineChartCubicTensionCurve(),
color: AppColors.contentColorGreen,
barWidth: 8,
isStrokeCapRound: true,
Expand All @@ -181,7 +181,7 @@ class _LineChart extends StatelessWidget {
);

LineChartBarData get lineChartBarData1_2 => LineChartBarData(
isCurved: true,
curve: const LineChartCubicTensionCurve(),
color: AppColors.contentColorPink,
barWidth: 8,
isStrokeCapRound: true,
Expand All @@ -201,7 +201,7 @@ class _LineChart extends StatelessWidget {
);

LineChartBarData get lineChartBarData1_3 => LineChartBarData(
isCurved: true,
curve: const LineChartCubicMonotoneCurve(),
color: AppColors.contentColorCyan,
barWidth: 8,
isStrokeCapRound: true,
Expand All @@ -217,8 +217,7 @@ class _LineChart extends StatelessWidget {
);

LineChartBarData get lineChartBarData2_1 => LineChartBarData(
isCurved: true,
curveSmoothness: 0,
curve: LineChartCurve.noCurve,
color: AppColors.contentColorGreen.withValues(alpha: 0.5),
barWidth: 4,
isStrokeCapRound: true,
Expand All @@ -236,7 +235,7 @@ class _LineChart extends StatelessWidget {
);

LineChartBarData get lineChartBarData2_2 => LineChartBarData(
isCurved: true,
curve: const LineChartCubicTensionCurve(),
color: AppColors.contentColorPink.withValues(alpha: 0.5),
barWidth: 4,
isStrokeCapRound: true,
Expand All @@ -256,8 +255,7 @@ class _LineChart extends StatelessWidget {
);

LineChartBarData get lineChartBarData2_3 => LineChartBarData(
isCurved: true,
curveSmoothness: 0,
curve: LineChartCurve.noCurve,
color: AppColors.contentColorCyan.withValues(alpha: 0.5),
barWidth: 2,
isStrokeCapRound: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class _LineChartSample10State extends State<LineChartSample10> {
stops: const [0.1, 1.0],
),
barWidth: 4,
isCurved: false,
curve: LineChartCurve.noCurve,
);
}

Expand All @@ -134,7 +134,7 @@ class _LineChartSample10State extends State<LineChartSample10> {
stops: const [0.1, 1.0],
),
barWidth: 4,
isCurved: false,
curve: LineChartCurve.noCurve,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class _LineChartSample13State extends State<LineChartSample13> {
),
);
}).toList(),
isCurved: false,
curve: LineChartCurve.noCurve,
dotData: const FlDotData(show: false),
color: AppColors.contentColorBlue,
barWidth: 1,
Expand Down
4 changes: 2 additions & 2 deletions example/lib/presentation/samples/line/line_chart_sample2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class _LineChartSample2State extends State<LineChartSample2> {
FlSpot(9.5, 3),
FlSpot(11, 4),
],
isCurved: true,
curve: const LineChartCubicTensionCurve(),
gradient: LinearGradient(
colors: gradientColors,
),
Expand Down Expand Up @@ -242,7 +242,7 @@ class _LineChartSample2State extends State<LineChartSample2> {
FlSpot(9.5, 3.44),
FlSpot(11, 3.44),
],
isCurved: true,
curve: const LineChartCubicTensionCurve(),
gradient: LinearGradient(
colors: [
ColorTween(begin: gradientColors[0], end: gradientColors[1])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class _LineChartSample3State extends State<LineChartSample3> {
spots: widget.yValues.asMap().entries.map((e) {
return FlSpot(e.key.toDouble(), e.value);
}).toList(),
isCurved: false,
curve: LineChartCurve.noCurve,
barWidth: 4,
color: widget.lineColor,
belowBarData: BarAreaData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class LineChartSample4 extends StatelessWidget {
FlSpot(10, 6),
FlSpot(11, 7),
],
isCurved: true,
curve: const LineChartCubicTensionCurve(),
barWidth: 8,
color: mainLineColor,
belowBarData: BarAreaData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class _LineChartSample5State extends State<LineChartSample5> {
LineChartBarData(
showingIndicators: showingTooltipOnSpots,
spots: allSpots,
isCurved: true,
curve: const LineChartCubicTensionCurve(),
barWidth: 4,
shadow: const Shadow(
blurRadius: 8,
Expand Down
4 changes: 2 additions & 2 deletions example/lib/presentation/samples/line/line_chart_sample6.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class LineChartSample6 extends StatelessWidget {
],
),
spots: reverseSpots(spots, minSpotY, maxSpotY),
isCurved: true,
curve: const LineChartCubicTensionCurve(),
isStrokeCapRound: true,
barWidth: 10,
belowBarData: BarAreaData(
Expand Down Expand Up @@ -195,7 +195,7 @@ class LineChartSample6 extends StatelessWidget {
],
),
spots: reverseSpots(spots2, minSpotY, maxSpotY),
isCurved: true,
curve: const LineChartCubicTensionCurve(),
isStrokeCapRound: true,
barWidth: 10,
belowBarData: BarAreaData(
Expand Down
4 changes: 2 additions & 2 deletions example/lib/presentation/samples/line/line_chart_sample7.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class LineChartSample7 extends StatelessWidget {
FlSpot(10, 6),
FlSpot(11, 7),
],
isCurved: true,
curve: const LineChartCubicTensionCurve(),
barWidth: 2,
color: line1Color,
dotData: const FlDotData(
Expand All @@ -109,7 +109,7 @@ class LineChartSample7 extends StatelessWidget {
FlSpot(10, 1),
FlSpot(11, 3),
],
isCurved: false,
curve: LineChartCurve.noCurve,
barWidth: 2,
color: line2Color,
dotData: const FlDotData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class _LineChartSample8State extends State<LineChartSample8> {
FlSpot(11, 2.5),
],
dashArray: [10, 6],
isCurved: true,
curve: const LineChartCubicTensionCurve(),
color: AppColors.contentColorRed,
barWidth: 4,
isStrokeCapRound: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class LineChartSample9 extends StatelessWidget {
LineChartBarData(
color: AppColors.contentColorPink,
spots: spots,
isCurved: true,
curve: const LineChartCubicTensionCurve(),
isStrokeCapRound: true,
barWidth: 3,
belowBarData: BarAreaData(
Expand Down
1 change: 1 addition & 0 deletions lib/fl_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export 'src/chart/base/base_chart/fl_touch_event.dart';
export 'src/chart/candlestick_chart/candlestick_chart.dart';
export 'src/chart/candlestick_chart/candlestick_chart_data.dart';
export 'src/chart/line_chart/line_chart.dart';
export 'src/chart/line_chart/line_chart_curve.dart';
export 'src/chart/line_chart/line_chart_data.dart';
export 'src/chart/pie_chart/pie_chart.dart';
export 'src/chart/pie_chart/pie_chart_data.dart';
Expand Down
Loading