Skip to content

Commit b226c5e

Browse files
committed
v0.4.1
1 parent cbe0682 commit b226c5e

23 files changed

+301
-235
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.4.1
2+
3+
**2021-10-27**
4+
5+
- Optimize the documentation.
6+
- Move specifications to Chart class.
7+
18
## 0.4.0
29

310
**2021-10-26**

DEVLOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -3746,7 +3746,15 @@ bigdata
37463746

37473747
避免label-text的设置过长,将核心参数设为位置参数,将lebel syle设为可选位置参数
37483748

3749+
```
3750+
variable scale aesthetic shape
3751+
| | | |
3752+
data --> tuples --> scaled tuples --> aesthetic attributes --> figures
3753+
```
3754+
3755+
37493756

3757+
将所有的spec都放到chart中,移除spec类,这样做文档最简洁。
37503758

37513759
## TODO
37523760

lib/graphic.dart

+129-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,116 @@
1-
/// This library includes a [Chart] Flutter widget for data visualization and classes
2-
/// for it's specification. Besids, it also provides some util classes and functions
1+
/// Graphic provides a Flutter charting library for data visualization. it has a
2+
/// chart widget, calsses for specification, and some util classes and funtions
33
/// for customization.
44
///
5-
/// There are some basic conccepts for this data visualization, most of witch derive
6-
/// from the Grammar of Graphics. they compose the parameters of the [Chart]'s constructor:
7-
///
8-
/// - **data**, the input data list, can be of any item type.
9-
/// - **variable**, defines the fields of **tuple**, which is the real datum object
10-
/// inside the chart.
11-
/// - **scale**, to scale and normalize the values.
12-
/// - **aesthetic**, to assign values to certain attributes for rendering.
13-
/// - **element**, the graphics visualizing data tuples.
14-
/// - **coordinate**, to locate abstract position values on the canvas.
15-
/// - **shape**, decide how to render the elements.
16-
/// - **signal**, a event that may cause a value changing.
17-
/// - **selection**, the state whether a tuple is selected.
18-
/// - **figure**, which is generated by chart evaluation and carries graphic information
19-
/// for rendering engine to paint.
20-
///
21-
/// See details and others in the class documents below.
5+
/// To use this charting library, you only need to do one thing: to create a [Chart]
6+
/// widget. This widget will evaluate and paint automatically in initial and on
7+
/// update.
8+
///
9+
/// A start example of bar chart is as below:
10+
///
11+
/// ```dart
12+
/// Chart(
13+
/// data: [
14+
/// { 'genre': 'Sports', 'sold': 275 },
15+
/// { 'genre': 'Strategy', 'sold': 115 },
16+
/// { 'genre': 'Action', 'sold': 120 },
17+
/// { 'genre': 'Shooter', 'sold': 350 },
18+
/// { 'genre': 'Other', 'sold': 150 },
19+
/// ],
20+
/// variables: {
21+
/// 'genre': Variable(
22+
/// accessor: (Map map) => map['genre'] as String,
23+
/// ),
24+
/// 'sold': Variable(
25+
/// accessor: (Map map) => map['sold'] as num,
26+
/// ),
27+
/// },
28+
/// elements: [IntervalElement()],
29+
/// axes: [
30+
/// Defaults.horizontalAxis,
31+
/// Defaults.verticalAxis,
32+
/// ],
33+
/// )
34+
/// ```
35+
///
36+
/// All specifications of data visualization are set by parameters of [Chart]'s
37+
/// constructor as class properties.
38+
///
39+
/// The main processing flow of charting and some important concepts are as below.
40+
/// Most concepts derive form the Grammar of Graphics. They will help to take full
41+
/// advantage of this library. These are brif introcuction, and details see into
42+
/// the Classes and [Chart] properties.
43+
///
44+
/// ```
45+
/// variable scale aesthetic shape
46+
/// | | | |
47+
/// data --> tuples --> scaled tuples --> aesthetic attributes --> figures
48+
/// ```
49+
///
50+
/// ## Variable
51+
///
52+
/// Variables define the fields of [Tuple]s. The input data of the chart is a [List]
53+
/// of any generic type. Yet they are not used directly inside the chart, instead,
54+
/// the data are converted to [Tuple]s.
55+
///
56+
/// They are specified by [Chart.variables] or [Chart.transforms] with [Variable] or
57+
/// [VariableTransform].
58+
///
59+
/// ## Algebra
60+
///
61+
/// The graphic algebra determins how variable values are assigned to position dimensions.
62+
///
63+
/// It is specified by [GeomElement.position] with [Varset]. See details of the algebra
64+
/// rules in [Varset].
65+
///
66+
/// ## Scale
67+
///
68+
/// Scales convert [Tuple] values to to scaled values, which is easier to prosess
69+
/// for aesthetic [Attr]s.
70+
///
71+
/// They are specified by [Variable.scale] with [Scale].
72+
///
73+
/// ## Coordinate
74+
///
75+
/// The coordinate determins how abstract positions are located on the canvas in
76+
/// painting. The same element may look quite different in [RectCoord] and [PolarCoord].
77+
///
78+
/// It is specified by [Chart.coord] with [Coord].
79+
///
80+
/// ## Aesthetic
81+
///
82+
/// Aesthetic means to make [Tuple]s percivable. That is to give them aesthetic attributes
83+
/// from the scaled values.
84+
///
85+
/// Aesthetic attributes are specified in [GeomElement] with [Attr]. And attributes
86+
/// values are stored in [Aes].
87+
///
88+
/// ## Shape
89+
///
90+
/// Shapes render [Tuple]s with [Aes] attributes. Rendering means to get [Figure]s,
91+
/// which carry the painting information for the rendering engine. Extending a shape
92+
/// subclass is the way to custom charts.
93+
///
94+
/// Shape is also a aesthetic attribute is self. It is defined with [Shape], and
95+
/// generated by [ShapeAttr] wich is defined by [GeomElement.shape]. The [Shape]
96+
/// type should corresponds to [GeomElement] type.
97+
///
98+
/// ## Interaction
99+
///
100+
/// There are two kinds of interactions: [Signal] and [Selection]. Signal means
101+
/// a certain specification value changes to [GestureSignal], [ResizeSignal], or
102+
/// [ChangeDataSignal]. Selection means a tuple aesthetic attribute values change
103+
/// when it is selected or not.
104+
///
105+
/// Signals are used by properties named in "on...Signal" with [SignalUpdate]. Selections
106+
/// are specified by [Chart.selections] and used by [Attr.onSelection] with [SelectionUpdate].
107+
///
108+
/// ## Guide
109+
///
110+
/// Guides are various components that helps to read the chart.
111+
///
112+
/// They include [Axis] specified by [Chart.axes], [Tooltip] specified by [Chart.tooltip],
113+
/// [Crosshair] specified by [Chart.crosshair], and [Annotation]s specified by [Chart.annotations],
22114
library graphic;
23115

24116
export 'src/chart/chart.dart' show Chart;
@@ -27,35 +119,48 @@ export 'src/chart/size.dart' show ResizeSignal;
27119
export 'src/data/data_set.dart' show ChangeDataSignal;
28120

29121
export 'src/variable/variable.dart' show Variable;
122+
export 'src/variable/transform/transform.dart' show VariableTransform;
30123
export 'src/variable/transform/filter.dart' show Filter;
31124
export 'src/variable/transform/map.dart' show MapTrans;
32125
export 'src/variable/transform/proportion.dart' show Proportion;
33126
export 'src/variable/transform/sort.dart' show Sort;
34127

128+
export 'src/scale/scale.dart' show Scale;
129+
export 'src/scale/discrete.dart' show DiscreteScale;
130+
export 'src/scale/continuous.dart' show ContinuousScale;
35131
export 'src/scale/linear.dart' show LinearScale;
36132
export 'src/scale/ordinal.dart' show OrdinalScale;
37133
export 'src/scale/time.dart' show TimeScale;
38134

135+
export 'src/geom/element.dart' show GeomElement;
136+
export 'src/geom/function.dart' show FunctionElement;
137+
export 'src/geom/partition.dart' show PartitionElement;
39138
export 'src/geom/area.dart' show AreaElement;
40139
export 'src/geom/custom.dart' show CustomElement;
41140
export 'src/geom/interval.dart' show IntervalElement;
42141
export 'src/geom/line.dart' show LineElement;
43142
export 'src/geom/point.dart' show PointElement;
44143
export 'src/geom/polygon.dart' show PolygonElement;
144+
export 'src/geom/modifier/modifier.dart' show Modifier;
45145
export 'src/geom/modifier/dodge.dart' show DodgeModifier;
46146
export 'src/geom/modifier/stack.dart' show StackModifier;
47147
export 'src/geom/modifier/jitter.dart' show JitterModifier;
48148
export 'src/geom/modifier/symmetric.dart' show SymmetricModifier;
49149

150+
export 'src/aes/aes.dart' show Attr;
151+
export 'src/aes/channel.dart' show ChannelAttr;
50152
export 'src/aes/color.dart' show ColorAttr;
51153
export 'src/aes/elevation.dart' show ElevationAttr;
52154
export 'src/aes/gradient.dart' show GradientAttr;
53155
export 'src/aes/label.dart' show LabelAttr;
54156
export 'src/aes/shape.dart' show ShapeAttr;
55157
export 'src/aes/size.dart' show SizeAttr;
56158

57-
export 'src/algebra/varset.dart' show Varset;
159+
export 'src/algebra/varset.dart' show Varset, AlgForm, AlgTerm;
58160

161+
export 'src/shape/shape.dart' show Shape;
162+
export 'src/shape/function.dart' show FunctionShape;
163+
export 'src/shape/partition.dart' show PartitionShape;
59164
export 'src/shape/area.dart' show AreaShape, BasicAreaShape;
60165
export 'src/shape/custom.dart' show CustomShape, CandlestickShape;
61166
export 'src/shape/interval.dart' show IntervalShape, RectShape, FunnelShape;
@@ -67,14 +172,16 @@ export 'src/shape/util/render_basic_item.dart' show renderBasicItem;
67172
export 'src/graffiti/figure.dart'
68173
show Figure, PathFigure, ShadowFigure, TextFigure, RotatedTextFigure;
69174

70-
export 'src/coord/coord.dart' show CoordConv;
175+
export 'src/coord/coord.dart' show Coord, CoordConv;
71176
export 'src/coord/polar.dart' show PolarCoord, PolarCoordConv;
72177
export 'src/coord/rect.dart' show RectCoord, RectCoordConv;
73178

74179
export 'src/guide/axis/axis.dart'
75180
show TickLine, TickLineMapper, LabelMapper, GridMapper, AxisGuide;
76181
export 'src/guide/interaction/tooltip.dart' show TooltipGuide, RenderTooltip;
77182
export 'src/guide/interaction/crosshair.dart' show CrosshairGuide;
183+
export 'src/guide/annotation/annotation.dart' show Annotation;
184+
export 'src/guide/annotation/figure.dart' show FigureAnnotation;
78185
export 'src/guide/annotation/line.dart' show LineAnnotation;
79186
export 'src/guide/annotation/region.dart' show RegionAnnotation;
80187
export 'src/guide/annotation/mark.dart' show MarkAnnotation;
@@ -83,7 +190,7 @@ export 'src/guide/annotation/custom.dart' show CustomAnnotation;
83190

84191
export 'src/interaction/signal.dart' show Signal, SignalType, SignalUpdate;
85192
export 'src/interaction/gesture.dart' show GestureType, Gesture, GestureSignal;
86-
export 'src/interaction/selection/selection.dart' show SelectionUpdate;
193+
export 'src/interaction/selection/selection.dart' show Selection, SelectionUpdate;
87194
export 'src/interaction/selection/interval.dart' show IntervalSelection;
88195
export 'src/interaction/selection/point.dart' show PointSelection;
89196

lib/src/aes/aes.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:graphic/src/dataflow/operator.dart';
99
import 'package:graphic/src/geom/element.dart';
1010
import 'package:graphic/src/interaction/selection/selection.dart';
1111
import 'package:graphic/src/parse/parse.dart';
12-
import 'package:graphic/src/parse/spec.dart';
1312
import 'package:graphic/src/shape/shape.dart';
1413
import 'package:graphic/src/util/assert.dart';
1514
import 'package:graphic/src/common/converter.dart';
@@ -141,7 +140,7 @@ class AesOp extends Operator<List<Aes>> {
141140
}
142141

143142
void parseAes(
144-
Spec spec,
143+
Chart spec,
145144
View view,
146145
Scope scope,
147146
) {

lib/src/algebra/varset.dart

+17-5
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,25 @@ Varset _normalize(Varset varset) {
1818
return varset;
1919
}
2020

21-
/// To store the tags.
22-
/// The term is directly composed of tags, whitch are numerators of factors.
23-
/// Nesting denominators is not supported now.
21+
/// The term composing algebracal forms.
22+
///
23+
/// The list items are tags representing the factor variables.
24+
///
25+
/// See also:
26+
///
27+
/// - [AlgForm], composed of terms.
2428
typedef AlgTerm = List<String>;
2529

26-
/// Expressions(monomial or polynomial) will be automatically convert to forms when calculated.
27-
/// tag -> term -> form
30+
/// The algebracal form storing the expression of a varset.
31+
///
32+
/// A form is an algebra expression whose all items have same orders. Operators
33+
/// of [Varset] guarantee the results are forms.
34+
///
35+
/// List wrapping is `form[term[tag]]]`.
36+
///
37+
/// See also:
38+
///
39+
/// - [Varset], which uses a form to store its expression.
2840
typedef AlgForm = List<AlgTerm>;
2941

3042
extension AlgFormExt on AlgForm {

0 commit comments

Comments
 (0)