Skip to content

Commit 597ff20

Browse files
committed
chore: Release v2.0.0 - Major refactor with breaking changes, dynamic opacity, and enhanced styling
1 parent 3c91049 commit 597ff20

4 files changed

Lines changed: 39 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 2.0.0
2+
3+
* **Breaking Change:** Refactored `CircleNode` data model. Renamed `upperLabel` to `displayValue` and reordered constructor arguments (`value` now comes before `displayValue`).
4+
* **New Feature:** Added `showValue` and `showLabels` flags to `FlutterCirclePackChart` for granular display control.
5+
* **New Feature:** Implemented **Dynamic Opacity**: Circles now automatically scale their opacity (0.85 - 1.0) based on their relative values to highlight data importance.
6+
* **Typographic Refinement:** Implemented independent "anti-scaling" for value and label lines, ensuring perfect sharpness and a balanced visual hierarchy.
7+
* Refactored example app with three distinct demo categories: Countries, Budget, and Stress Tests.
8+
19
## 1.0.4
210

311
* Implemented "Deck of Cards" drawing order: larger circles now stay on top of smaller ones during all transitions.

example/lib/main.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ class WorldPopulationExample extends StatelessWidget {
257257
children: [
258258
CircleNode(
259259
label: 'Asia',
260+
value: 4700.0,
261+
displayValue: '4.7B',
260262
color: Colors.red,
261263
children: [
262264
CircleNode(label: 'China', value: 1400.0, displayValue: '1.4B'),
@@ -268,6 +270,8 @@ class WorldPopulationExample extends StatelessWidget {
268270
),
269271
CircleNode(
270272
label: 'Europe',
273+
value: 745.0,
274+
displayValue: '745M',
271275
color: Colors.blue,
272276
children: [
273277
CircleNode(label: 'Germany', value: 83.0, displayValue: '83M'),
@@ -278,13 +282,26 @@ class WorldPopulationExample extends StatelessWidget {
278282
),
279283
CircleNode(
280284
label: 'Americas',
285+
value: 1000.0,
286+
displayValue: '1.0B',
281287
color: Colors.green,
282288
children: [
283289
CircleNode(label: 'USA', value: 330.0, displayValue: '330M'),
284290
CircleNode(label: 'Brazil', value: 210.0, displayValue: '210M'),
285291
CircleNode(label: 'Canada', value: 38.0, displayValue: '38M'),
286292
],
287293
),
294+
CircleNode(
295+
label: 'Africa',
296+
value: 1400.0,
297+
displayValue: '1.4B',
298+
color: Colors.orange,
299+
children: [
300+
CircleNode(label: 'Nigeria', value: 200.0, displayValue: '200M'),
301+
CircleNode(label: 'Ethiopia', value: 110.0, displayValue: '110M'),
302+
CircleNode(label: 'Egypt', value: 100.0, displayValue: '100M'),
303+
],
304+
),
288305
],
289306
);
290307

lib/flutter_circle_pack_chart_painter.dart

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ class FlutterCirclePackChartPainter extends CustomPainter {
6565
final double minValue = node.children.isEmpty ? 0.0 : node.children.map((c) => c.node.value).reduce((a, b) => a < b ? a : b);
6666

6767
for (final child in sortedChildren) {
68-
// Dynamic opacity only applies when we are drilled in deeper than root.
69-
// If focusedNode is root, everything at level 1 is 100% opaque.
70-
// We use a tight range (0.85 - 1.0) to keep boxes looking solid.
68+
// Dynamic opacity with a tight range (0.85 - 1.0)
7169
final double importance = (focusedNode == root.node)
7270
? 1.0
7371
: (maxValue == minValue
@@ -166,37 +164,29 @@ class FlutterCirclePackChartPainter extends CustomPainter {
166164
) {
167165
if (!showValue && !showLabels) return;
168166

169-
// Use "Anti-Scaling": divide baseFontSize by cameraScale to keep it constant on screen.
170-
final double fontSize = (baseFontSize / cameraScale).clamp(0.1, 100.0);
167+
// Use two distinct, anti-scaled font sizes for perfect sharpness.
168+
final double valueFontSize = (baseFontSize / cameraScale).clamp(0.1, 100.0);
169+
// Label is exactly 25% smaller than the base/value size, but using a whole number where possible
170+
final double labelFontSize = ((baseFontSize * 0.75) / cameraScale).clamp(0.1, 100.0);
171171

172172
final TextSpan span = TextSpan(
173173
children: [
174174
if (showValue) ...[
175-
if (node.displayValue != null)
176-
TextSpan(
177-
text: '${node.displayValue}${showLabels ? '\n' : ''}',
178-
style: TextStyle(
179-
color: Colors.white.withValues(alpha: opacity),
180-
fontSize: fontSize * 1.2,
181-
fontWeight: FontWeight.bold,
182-
),
183-
)
184-
else
185-
TextSpan(
186-
text: '${node.value.toStringAsFixed(0)}${showLabels ? '\n' : ''}',
187-
style: TextStyle(
188-
color: Colors.white.withValues(alpha: opacity),
189-
fontSize: fontSize * 1.2,
190-
fontWeight: FontWeight.bold,
191-
),
175+
TextSpan(
176+
text: '${node.displayValue ?? node.value.toStringAsFixed(0)}${showLabels ? '\n' : ''}',
177+
style: TextStyle(
178+
color: Colors.white.withValues(alpha: opacity),
179+
fontSize: valueFontSize,
180+
fontWeight: FontWeight.bold,
192181
),
182+
),
193183
],
194184
if (showLabels)
195185
TextSpan(
196186
text: node.label,
197187
style: TextStyle(
198188
color: Colors.white.withValues(alpha: opacity),
199-
fontSize: fontSize,
189+
fontSize: labelFontSize,
200190
fontWeight: FontWeight.normal,
201191
),
202192
),
@@ -211,7 +201,6 @@ class FlutterCirclePackChartPainter extends CustomPainter {
211201
ellipsis: '...',
212202
);
213203

214-
// Allow some overflow for tiny circles but keep it tighter than before to avoid edges.
215204
textPainter.layout(maxWidth: radius * 2.5);
216205

217206
textPainter.paint(

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_circle_pack_chart
22
description: A powerful and interactive circle pack chart (circular treemap) library for Flutter.
3-
version: 1.0.4
3+
version: 2.0.0
44
homepage: https://fabiocarneiro.github.io/FlutterCirclePackChart/
55
repository: https://github.com/fabiocarneiro/FlutterCirclePackChart
66
issue_tracker: https://github.com/fabiocarneiro/FlutterCirclePackChart/issues

0 commit comments

Comments
 (0)