Skip to content

Commit

Permalink
v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
entronad committed Dec 28, 2021
1 parent be67b5e commit fe461e9
Show file tree
Hide file tree
Showing 48 changed files with 433 additions and 346 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 0.7.0

**2021-12-28**

- Dimensions now has a enum type `Dim` instead of int [1, 2], which is always confused with [0, 1]: https://github.com/entronad/graphic/issues/31.
- `layer` now replace `zIndex`, which may confuse with z dimension and has a flavour of HTML.
- Fix `ScaleUpdateDetails.delta` problem.
- Fix resize problem. Now chart will resize properly and will inflate even if parent has no indicated size: https://github.com/entronad/graphic/issues/37.
- Fix and recover the auto spec diff feature.
- Add dash line feature.

## 0.6.2

**2021-12-19**
Expand Down
10 changes: 10 additions & 0 deletions DEVLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3920,6 +3920,16 @@ Spec的相等用自己写的函数,只要涉及到函数就一律不判断。

由于集合判断函数主要用来处理字面量,所以set也按list判断,这就要求顺序相同,但能避免多对一。

最里层的CustomPaint组件需要设置个infinity的size(默认是0),就能起到撑满父元素的效果

View 不持有 size,sizeop初始化用graffiti中的。

维度的指定,经过仔细思考,除了gpl之外,没有哪一个不是用的x,y,而且从0开始还是从1开始确实很容易混淆。所以我们也用枚举吧,但是先不要用 Dim.xy 这种,同时指定还是null

zIndex 改名叫 layer,因为z以后可能指坐标轴,而且摆脱html的影响,固定的那个叫IntrinsicLayer

ScaleUpdateDetails.delta 改成 focalPointDelta之后,那个从初始算起的bug也修复了。

## TODO

整合errorlog,需处理:throw, assert, list.single,singleIntersection
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final routes = {
'/examples/Custom': (context) => CustomPage(),
'/examples/Bigdata': (context) => BigdataPage(),
'/examples/Echarts': (context) => EchartsPage(),
// '/examples/Debug': (context) => const DebugPage(),
// '/examples/Debug': (context) => DebugPage(),
};

class MyApp extends StatelessWidget {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/custom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class CustomPage extends StatelessWidget {
Defaults.horizontalAxis,
Defaults.verticalAxis,
],
selections: {'tap': PointSelection(dim: 1)},
selections: {'tap': PointSelection(dim: Dim.x)},
tooltip: TooltipGuide(renderer: simpleTooltip),
crosshair: CrosshairGuide(),
),
Expand Down
251 changes: 125 additions & 126 deletions example/lib/pages/debug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,108 @@ import 'dart:math';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:graphic/graphic.dart';
import 'package:graphic_example/data.dart';

// class DebugPage extends StatelessWidget {
// DebugPage({Key? key}) : super(key: key);
class DebugPage extends StatelessWidget {
DebugPage({Key? key}) : super(key: key);

final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
// Commenting out the next two lines is causing the problem
// width: 600,
// height: 400,
child: Chart(
data: [
{'year': DateTime(2010), 'price': 10},
{'year': DateTime(2011), 'price': 8},
{'year': DateTime(2012), 'price': 12},
{'year': DateTime(2013), 'price': 16},
{'year': DateTime(2014), 'price': 9},
{'year': DateTime(2015), 'price': 17},
{'year': DateTime(2016), 'price': 13},
],
variables: {
'year': Variable(
accessor: (Map map) => map['year'] as DateTime,
),
'price': Variable(
accessor: (Map map) => map['price'] as int,
),
},
elements: [LineElement()],
axes: [
Defaults.horizontalAxis,
Defaults.verticalAxis,
],
selections: {
// 'tooltipMouse': PointSelection(
// on: {GestureType.hover},
// devices: {PointerDeviceKind.mouse},
// ),
'p': PointSelection(),
},
crosshair: CrosshairGuide(),
),
),
),
);
}
}

// class DebugPage extends StatefulWidget {
// const DebugPage({Key? key}) : super(key: key);

// @override
// _DebugPageState createState() => _DebugPageState();
// }

// class _DebugPageState extends State<DebugPage> {
// final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

// final rdm = Random();

// List<Map> data = [];

// @override
// void initState() {
// const cv = -7;

// data = [
// {'genre': 'Sports', 'sold': cv},
// {'genre': 'Strategy', 'sold': cv},
// {'genre': 'Action', 'sold': cv},
// {'genre': 'Shooter', 'sold': cv},
// {'genre': 'Other', 'sold': cv},
// ];

// // data = [
// // {'genre': 'Sports', 'sold': rdm.nextInt(300)},
// // {'genre': 'Strategy', 'sold': rdm.nextInt(300)},
// // {'genre': 'Action', 'sold': rdm.nextInt(300)},
// // {'genre': 'Shooter', 'sold': rdm.nextInt(300)},
// // {'genre': 'Other', 'sold': rdm.nextInt(300)},
// // ];

// final timer = Timer.periodic(Duration(seconds: 3), (_) {
// setState(() {
// data = [
// {'genre': 'Sports', 'sold': rdm.nextInt(300)},
// {'genre': 'Strategy', 'sold': rdm.nextInt(300)},
// {'genre': 'Action', 'sold': rdm.nextInt(300)},
// {'genre': 'Shooter', 'sold': rdm.nextInt(300)},
// {'genre': 'Other', 'sold': rdm.nextInt(300)},
// ];
// });
// });

// super.initState();
// }

// @override
// Widget build(BuildContext context) {
// return Scaffold(
Expand All @@ -27,27 +123,37 @@ import 'package:graphic/graphic.dart';
// width: 650,
// height: 300,
// child: Chart(
// rebuild: true,
// data: const [
// {'genre': 'Sports', 'sold': 275},
// {'genre': 'Strategy', 'sold': 115},
// {'genre': 'Action', 'sold': 120},
// {'genre': 'Shooter', 'sold': 350},
// {'genre': 'Other', 'sold': 150},
// ],
// // rebuild: true,
// data: data,
// variables: {
// 'genre': Variable(
// accessor: (Map map) => map['genre'] as String,
// ),
// 'sold': Variable(
// accessor: (Map map) => map['sold'] as num,
// ),
// 'genre': Variable(
// accessor: (Map map) => map['genre'] as String,
// ),
// 'sold': Variable(
// accessor: (Map map) => map['sold'] as num,
// ),
// },
// elements: [LineElement()],
// elements: [IntervalElement()],
// axes: [
// Defaults.horizontalAxis,
// Defaults.verticalAxis,
// Defaults.horizontalAxis,
// Defaults.verticalAxis,
// ],
// selections: {
// 'tap': PointSelection(
// on: {
// GestureType.hover,
// GestureType.tap,
// },
// dim: 1,
// )
// },
// tooltip: TooltipGuide(
// backgroundColor: Colors.black,
// elevation: 5,
// textStyle: Defaults.textStyle,
// variables: ['genre', 'sold'],
// ),
// crosshair: CrosshairGuide(),
// ),
// ),
// ],
Expand All @@ -57,110 +163,3 @@ import 'package:graphic/graphic.dart';
// );
// }
// }

class DebugPage extends StatefulWidget {
const DebugPage({Key? key}) : super(key: key);

@override
_DebugPageState createState() => _DebugPageState();
}

class _DebugPageState extends State<DebugPage> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

final rdm = Random();

List<Map> data = [];

@override
void initState() {
const cv = -7;

data = [
{'genre': 'Sports', 'sold': cv},
{'genre': 'Strategy', 'sold': cv},
{'genre': 'Action', 'sold': cv},
{'genre': 'Shooter', 'sold': cv},
{'genre': 'Other', 'sold': cv},
];

// data = [
// {'genre': 'Sports', 'sold': rdm.nextInt(300)},
// {'genre': 'Strategy', 'sold': rdm.nextInt(300)},
// {'genre': 'Action', 'sold': rdm.nextInt(300)},
// {'genre': 'Shooter', 'sold': rdm.nextInt(300)},
// {'genre': 'Other', 'sold': rdm.nextInt(300)},
// ];

final timer = Timer.periodic(Duration(seconds: 3), (_) {
setState(() {
data = [
{'genre': 'Sports', 'sold': rdm.nextInt(300)},
{'genre': 'Strategy', 'sold': rdm.nextInt(300)},
{'genre': 'Action', 'sold': rdm.nextInt(300)},
{'genre': 'Shooter', 'sold': rdm.nextInt(300)},
{'genre': 'Other', 'sold': rdm.nextInt(300)},
];
});
});

super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: const Text('Debug'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Center(
child: Column(
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 10),
width: 650,
height: 300,
child: Chart(
// rebuild: true,
data: data,
variables: {
'genre': Variable(
accessor: (Map map) => map['genre'] as String,
),
'sold': Variable(
accessor: (Map map) => map['sold'] as num,
),
},
elements: [IntervalElement()],
axes: [
Defaults.horizontalAxis,
Defaults.verticalAxis,
],
selections: {
'tap': PointSelection(
on: {
GestureType.hover,
GestureType.tap,
},
dim: 1,
)
},
tooltip: TooltipGuide(
backgroundColor: Colors.black,
elevation: 5,
textStyle: Defaults.textStyle,
variables: ['genre', 'sold'],
),
crosshair: CrosshairGuide(),
),
),
],
),
),
),
);
}
}
2 changes: 1 addition & 1 deletion example/lib/pages/dynamic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class _DynamicPageState extends State<DynamicPage> {
GestureType.hover,
GestureType.tap,
},
dim: 1,
dim: Dim.x,
)
},
tooltip: TooltipGuide(
Expand Down
12 changes: 6 additions & 6 deletions example/lib/pages/echarts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ class EchartsPage extends StatelessWidget {
GestureType.hover,
}, devices: {
PointerDeviceKind.mouse
}, variable: 'day', dim: 1),
}, variable: 'day', dim: Dim.x),
'tooltipTouch': PointSelection(on: {
GestureType.scaleUpdate,
GestureType.tapDown,
GestureType.longPressMoveUpdate
}, devices: {
PointerDeviceKind.touch
}, variable: 'day', dim: 1),
}, variable: 'day', dim: Dim.x),
},
tooltip: TooltipGuide(
followPointer: [true, true],
Expand All @@ -226,15 +226,15 @@ class EchartsPage extends StatelessWidget {
),
annotations: [
LineAnnotation(
dim: 2,
dim: Dim.y,
value: 11.14,
style: StrokeStyle(
color: const Color(0xff5470c6).withAlpha(100),
dash: [2],
),
),
LineAnnotation(
dim: 2,
dim: Dim.y,
value: 1.57,
style: StrokeStyle(
color: const Color(0xff91cc75).withAlpha(100),
Expand Down Expand Up @@ -339,14 +339,14 @@ class EchartsPage extends StatelessWidget {
GestureType.hover,
}, devices: {
PointerDeviceKind.mouse
}, dim: 1),
}, dim: Dim.x),
'tooltipTouch': PointSelection(on: {
GestureType.scaleUpdate,
GestureType.tapDown,
GestureType.longPressMoveUpdate
}, devices: {
PointerDeviceKind.touch
}, dim: 1),
}, dim: Dim.x),
},
tooltip: TooltipGuide(
followPointer: [true, true],
Expand Down
Loading

0 comments on commit fe461e9

Please sign in to comment.