| OLD | NEW |
| 1 // | 1 // |
| 2 // Copyright 2014 Google Inc. All rights reserved. | 2 // Copyright 2014 Google Inc. All rights reserved. |
| 3 // | 3 // |
| 4 // Use of this source code is governed by a BSD-style | 4 // Use of this source code is governed by a BSD-style |
| 5 // license that can be found in the LICENSE file or at | 5 // license that can be found in the LICENSE file or at |
| 6 // https://developers.google.com/open-source/licenses/bsd | 6 // https://developers.google.com/open-source/licenses/bsd |
| 7 // | 7 // |
| 8 | 8 |
| 9 part of charted.charts; | 9 part of charted.charts; |
| 10 | 10 |
| 11 /// | 11 /// |
| 12 /// Interface that is implemented by classes that support | 12 /// Interface that is implemented by classes that support |
| 13 /// displaying legend. | 13 /// displaying legend. |
| 14 /// | 14 /// |
| 15 abstract class ChartLegend { | 15 abstract class ChartLegend { |
| 16 /// Title of the legend, dynamically updates the legend title when set. | 16 /// Title of the legend, dynamically updates the legend title when set. |
| 17 String title; | 17 String title; |
| 18 | 18 |
| 19 /// Called by [ChartArea] to notify changes to legend. | 19 /// Called by [ChartArea] to notify changes to legend. |
| 20 update(Iterable<ChartLegendItem> legend, ChartArea chart); | 20 update(Iterable<ChartLegendItem> legend, ChartArea chart); |
| 21 | 21 |
| 22 /// Called by [ChartArea] to dispose selection listeners. | 22 /// Called by [ChartArea] to dispose selection listeners. |
| 23 dispose(); | 23 dispose(); |
| 24 | 24 |
| 25 /// Factory to create an instance of the default implementation. | 25 /// Factory to create an instance of the default implementation. |
| 26 factory ChartLegend(Element host, | 26 factory ChartLegend(Element host, |
| 27 {maxItems: 0, title: '', showValues: false}) => | 27 {maxItems: 0, title: '', showValues: false}) => |
| 28 new DefaultChartLegendImpl(host, maxItems, showValues, title); | 28 new DefaultChartLegendImpl(host, maxItems, showValues, title); |
| 29 } | 29 } |
| 30 | 30 |
| 31 /// | 31 /// |
| 32 /// Class representing an item in the legend. | 32 /// Class representing an item in the legend. |
| 33 /// | 33 /// |
| 34 class ChartLegendItem { | 34 class ChartLegendItem { |
| 35 /// Index of the row/column in [ChartData]. Legend uses column based coloring | 35 /// Index of the row/column in [ChartData]. Legend uses column based coloring |
| 36 /// in [CartesianArea] that has useRowColoring set to false and row based | 36 /// in [CartesianArea] that has useRowColoring set to false and row based |
| 37 /// coloring in all other cases. | 37 /// coloring in all other cases. |
| 38 int index; | 38 int index; |
| 39 | 39 |
| 40 /// HTML color used for the row/column in chart | 40 /// HTML color used for the row/column in chart |
| 41 String color; | 41 String color; |
| 42 | 42 |
| 43 /// The label of the item. | 43 /// The label of the item. |
| 44 String label; | 44 String label; |
| 45 | 45 |
| 46 /// Description of the item. | 46 /// Description of the item. |
| 47 String description; | 47 String description; |
| 48 | 48 |
| 49 /// Pre-formatted value to use as value. | 49 /// Pre-formatted value to use as value. |
| 50 String value; | 50 String value; |
| 51 | 51 |
| 52 /// List of series that this column is part of | 52 /// List of series that this column is part of |
| 53 Iterable<ChartSeries> series; | 53 Iterable<ChartSeries> series; |
| 54 | 54 |
| 55 ChartLegendItem({this.index, this.color, | 55 ChartLegendItem( |
| 56 this.label, this.description, this.series, this.value}); | 56 {this.index, |
| 57 this.color, |
| 58 this.label, |
| 59 this.description, |
| 60 this.series, |
| 61 this.value}); |
| 57 } | 62 } |
| OLD | NEW |