| OLD | NEW |
| (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 /// Area for rendering cartesian charts. A cartesian chart creates | |
| 13 /// visualization by carefully placing elements along the dimension | |
| 14 /// and measure axes (in a 2 dimensional plane). | |
| 15 /// | |
| 16 /// Some renderers may use additional dimensions that is made visible | |
| 17 /// by size and color of the rendered elements. | |
| 18 /// | |
| 19 /// For example: | |
| 20 /// - A bar-chart draws bars indicating a value along measure axis. | |
| 21 /// - A bubble-chart where a circle is positioned across two dimension | |
| 22 /// axes. A bubble-chart may also use color and size of circles to | |
| 23 /// indicate more dimensions. | |
| 24 /// | |
| 25 /// In a [CartesianArea], more than one series can be rendered together. | |
| 26 /// | |
| 27 abstract class CartesianArea implements ChartArea { | |
| 28 /// When set to true, [ChartArea] uses both 'x' and 'y' axes for dimensions. | |
| 29 /// Examples: | |
| 30 /// - A bar-chart has one dimension axis (typically the 'x' axis) | |
| 31 /// - A bubble-chart has two dimension axis (both 'x' and 'y') | |
| 32 bool get useTwoDimensionAxes; | |
| 33 | |
| 34 /// Scales used to render the measure axis of the given [ChartSeries]. Each | |
| 35 /// series may use more than one measure scale. | |
| 36 /// | |
| 37 /// For example, a scatter plot may use different scales for color, shape | |
| 38 /// and size of the rendering. | |
| 39 Iterable<Scale> measureScales(ChartSeries s); | |
| 40 | |
| 41 /// Scales used to render the dimension axes. The number of scales returned | |
| 42 /// is either one or two based on [useTwoDimensions] | |
| 43 Iterable<Scale> get dimensionScales; | |
| 44 | |
| 45 /// List of dimensions using a band of space on the axis | |
| 46 Iterable<int> get dimensionsUsingBands; | |
| 47 | |
| 48 /// Stream to notify when chart axes get updated. | |
| 49 Stream<ChartArea> get onChartAxesUpdated; | |
| 50 | |
| 51 /// Factory method to create an instance of the default implementation | |
| 52 /// - [host] must be an Element that has clientHeight and clientWidth | |
| 53 /// properties defined (i.e cannot be inline elements) | |
| 54 /// - [data] is an instance of [ChartData] | |
| 55 /// - [config] is an implementation of [ChartConfig] | |
| 56 /// - If [autoUpdate] is set, chart is updated when data or config | |
| 57 /// change. When not set, [draw] must be called to update the chart. | |
| 58 /// - When [useTwoDimensionAxes] is set, the chart uses both 'x' and 'y' | |
| 59 /// axes as dimensions. | |
| 60 factory CartesianArea( | |
| 61 dynamic host, | |
| 62 ChartData data, | |
| 63 ChartConfig config, { | |
| 64 bool autoUpdate: false, | |
| 65 bool useTwoDimensionAxes: false, | |
| 66 bool useRowColoring: false, | |
| 67 ChartState state }) => | |
| 68 new DefaultCartesianAreaImpl(host, data, config, autoUpdate, | |
| 69 useTwoDimensionAxes, useRowColoring, state); | |
| 70 } | |
| 71 | |
| 72 /// | |
| 73 /// Area for rendering layout charts. A layout chart creates visualization by | |
| 74 /// distributing available space to each measure. | |
| 75 /// | |
| 76 /// For example: | |
| 77 /// - A pie-chart distributes a radial area to each measure. | |
| 78 /// - In a tree-map a rectangular area is distributed to each measure. | |
| 79 /// | |
| 80 /// In a [LayoutArea], only one series can be rendered and the area does | |
| 81 /// not have any scales and axes. | |
| 82 /// | |
| 83 abstract class LayoutArea implements ChartArea { | |
| 84 /// Layout area always uses row coloring. | |
| 85 bool get useRowColoring => true; | |
| 86 | |
| 87 factory LayoutArea( | |
| 88 dynamic host, | |
| 89 ChartData data, | |
| 90 ChartConfig config, { | |
| 91 bool autoUpdate: false, | |
| 92 ChartState state }) => | |
| 93 new DefaultLayoutAreaImpl(host, data, config, autoUpdate, state); | |
| 94 } | |
| 95 | |
| 96 /// | |
| 97 /// Base interface for all implementations of a chart drawing area. | |
| 98 /// | |
| 99 abstract class ChartArea implements ChartAreaBehaviorSource { | |
| 100 /// Data used by the chart. Chart isn't updated till the next call to | |
| 101 /// draw function if [autoUpdate] is set to false. | |
| 102 /// | |
| 103 /// Setting new value to [data] will update chart if [autoUpdate] is set. | |
| 104 ChartData data; | |
| 105 | |
| 106 /// Configuration for this chart. [ChartArea] subscribes to changes on | |
| 107 /// [config] and calls draw upon any changes. | |
| 108 /// | |
| 109 /// Refer to [ChartConfig] for further documentation about which changes | |
| 110 /// are added to the stream, which in turn trigger an update on the chart. | |
| 111 ChartConfig config; | |
| 112 | |
| 113 /// Theme for this chart. Any changes to [theme] are not applied to the chart | |
| 114 /// until it is redrawn. Changes can be forced by calling [draw] function. | |
| 115 ChartTheme theme; | |
| 116 | |
| 117 /// When set to true, [ChartArea] subscribes to changes on data and updates | |
| 118 /// the chart when [data] or [config] changes. Defaults to false. | |
| 119 bool autoUpdate; | |
| 120 | |
| 121 /// Geometry of components in this [ChartArea] | |
| 122 ChartAreaLayout get layout; | |
| 123 | |
| 124 /// Host element of the ChartArea | |
| 125 Element get host; | |
| 126 | |
| 127 /// True when all components of the chart have been updated - either already | |
| 128 /// drawn or are in the process of transitioning in. | |
| 129 bool get isReady; | |
| 130 | |
| 131 /// When true, [ChartArea] and renderers that support coloring by row, | |
| 132 /// use row indices and values to color the chart. Defaults to false. | |
| 133 bool get useRowColoring; | |
| 134 | |
| 135 /// State of the chart - selection and highlights. | |
| 136 ChartState get state; | |
| 137 | |
| 138 /// Draw the chart with current data and configuration. | |
| 139 /// - If [preRender] is set, [ChartArea] attempts to build all non data | |
| 140 /// dependant elements of the chart. | |
| 141 /// - When [schedulePostRender] is not null, non-essential elements/tasks | |
| 142 /// of chart building are postponed until the future is resolved. | |
| 143 void draw({bool preRender: false, Future schedulePostRender}); | |
| 144 | |
| 145 /// Force destroy the ChartArea. | |
| 146 /// - Clear references to all passed objects and subscriptions. | |
| 147 /// - Call dispose on all renderers and behaviors. | |
| 148 void dispose(); | |
| 149 } | |
| 150 | |
| 151 /// | |
| 152 /// Class representing geometry of the [ChartArea] and various components | |
| 153 /// that are created by the ChartArea. | |
| 154 /// | |
| 155 abstract class ChartAreaLayout { | |
| 156 /// Sizes of axes by orientation. | |
| 157 /// Only valid on [CartesianArea], null otherwise. | |
| 158 Map<String, Rect> get axes; | |
| 159 | |
| 160 /// Size of render area. | |
| 161 Rect get renderArea => new Rect(); | |
| 162 | |
| 163 /// Size of chart area. | |
| 164 Rect get chartArea => new Rect(); | |
| 165 } | |
| OLD | NEW |