Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: charted/lib/charts/chart_state.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « charted/lib/charts/chart_series.dart ('k') | charted/lib/charts/chart_theme.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //
2 // Copyright 2014 Google Inc. All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 //
8
9 part of charted.charts;
10
11 ///
12 /// Model to provide highlight, selection and visibility in a ChartArea.
13 /// Selection and visibility
14 ///
15 abstract class ChartState implements ChangeNotifier {
16 static int COL_SELECTED = 0x001;
17 static int COL_UNSELECTED = 0x002;
18 static int COL_PREVIEW = 0x004;
19 static int COL_HIDDEN = 0x008;
20 static int COL_HIGHLIGHTED = 0x010;
21 static int COL_UNHIGHLIGHTED = 0x020;
22 static int COL_HOVERED = 0x040;
23 static int VAL_HIGHLIGHTED = 0x080;
24 static int VAL_UNHIGHLIGHTED = 0x100;
25 static int VAL_HOVERED = 0x200;
26
27 static const COL_SELECTED_CLASS = 'col-selected';
28 static const COL_UNSELECTED_CLASS = 'col-unselected';
29 static const COL_PREVIEW_CLASS = 'col-previewed';
30 static const COL_HIDDEN_CLASS = 'col-hidden';
31 static const COL_HIGHLIGHTED_CLASS = 'col-highlighted';
32 static const COL_UNHIGHLIGHTED_CLASS = 'col-unhighlighted';
33 static const COL_HOVERED_CLASS = 'col-hovered';
34 static const VAL_HIGHLIGHTED_CLASS = 'row-highlighted';
35 static const VAL_UNHIGHLIGHTED_CLASS = 'row-unhighlighted';
36 static const VAL_HOVERED_CLASS = 'row-hovered';
37
38 static const COLUMN_CLASS_NAMES = const[
39 COL_SELECTED_CLASS, COL_UNSELECTED_CLASS, COL_PREVIEW_CLASS,
40 COL_HIGHLIGHTED_CLASS, COL_UNHIGHLIGHTED_CLASS, COL_HIDDEN_CLASS,
41 COL_HOVERED_CLASS];
42
43 static const VALUE_CLASS_NAMES = const[
44 COL_SELECTED_CLASS, COL_UNSELECTED_CLASS, COL_PREVIEW_CLASS,
45 COL_HIGHLIGHTED_CLASS, COL_UNHIGHLIGHTED_CLASS, COL_HIDDEN_CLASS,
46 COL_HOVERED_CLASS, VAL_HIGHLIGHTED_CLASS, VAL_UNHIGHLIGHTED_CLASS,
47 VAL_HOVERED_CLASS];
48
49 /// List of selected items.
50 /// - Contains a column on CartesianArea if useRowColoring is false.
51 /// - Row index in all other cases.
52 Iterable<int> get selection;
53
54 /// List of visible items.
55 /// - Contains a column on CartesianArea if useRowColoring is false.
56 /// - Row index in all other cases.
57 Iterable<int> get hidden;
58
59 /// Currently previewed row or column. Hidden items can be previewed
60 /// by hovering on the corresponding label in Legend
61 /// - Contains a column on CartesianArea if useRowColoring is false.
62 /// - Row index in all other cases.
63 int preview;
64
65 /// Currently highlighted value, if any, represented as column and row.
66 /// Highlight is result of a click on certain value.
67 Iterable<Pair<int,int>> highlights;
68
69 /// Currently hovered value, if any, represented as column and row.
70 /// Hover is result of mouse moving over a certian value in chart.
71 Pair<int,int> hovered;
72
73 /// Ensure that a row or column is visible.
74 bool unhide(int id);
75
76 /// Ensure that a row or column is invisible.
77 bool hide(int id);
78
79 /// Returns current visibility of a row or column.
80 bool isVisible(int id);
81
82 /// Select a row or column.
83 bool select(int id);
84
85 /// Unselect a row or column.
86 bool unselect(int id);
87
88 /// Returns current selection state of a row or column.
89 bool isSelected(int id);
90
91 /// Select a row or column.
92 bool highlight(int column, int row);
93
94 /// Unselect a row or column.
95 bool unhighlight(int column, int row);
96
97 /// Returns current selection state of a row or column.
98 bool isHighlighted(int column, int row);
99
100 factory ChartState({bool isMultiSelect: false}) =>
101 new DefaultChartStateImpl(isMultiSelect: isMultiSelect);
102 }
103
104 ///
105 /// Implementation of [ChangeRecord], that is used to notify changes to
106 /// values in [ChartData].
107 ///
108 class ChartSelectionChangeRecord implements ChangeRecord {
109 final int add;
110 final int remove;
111 const ChartSelectionChangeRecord({this.add, this.remove});
112 }
113
114 ///
115 /// Implementation of [ChangeRecord], that is used to notify changes to
116 /// values in [ChartData].
117 ///
118 class ChartVisibilityChangeRecord implements ChangeRecord {
119 final int unhide;
120 final int hide;
121 const ChartVisibilityChangeRecord({this.unhide, this.hide});
122 }
123
124 ///
125 /// Implementation of [ChangeRecord], that is used to notify changes to
126 /// values in [ChartData].
127 ///
128 class ChartHighlightChangeRecord implements ChangeRecord {
129 final Pair<int,int> remove;
130 final Pair<int,int> add;
131 const ChartHighlightChangeRecord({this.add, this.remove});
132 }
133
134 ///
135 /// Implementation of [ChangeRecord], that is used to notify changes to
136 /// values in [ChartData].
137 ///
138 class ChartHoverChangeRecord implements ChangeRecord {
139 final Pair<int,int> hovered;
140 const ChartHoverChangeRecord(this.hovered);
141 }
142
143 ///
144 /// Implementation of [ChangeRecord], that is used to notify changes to
145 /// values in [ChartData].
146 ///
147 class ChartPreviewChangeRecord implements ChangeRecord {
148 final int previewed;
149 const ChartPreviewChangeRecord(this.previewed);
150 }
OLDNEW
« no previous file with comments | « charted/lib/charts/chart_series.dart ('k') | charted/lib/charts/chart_theme.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698