Extract the list of keys to use when stacking and coloring the bars.
(data: &Vec<impl BarDatum>)
| 150 | |
| 151 | /// Extract the list of keys to use when stacking and coloring the bars. |
| 152 | fn extract_keys(data: &Vec<impl BarDatum>) -> Vec<String> { |
| 153 | let mut keys = Vec::new(); |
| 154 | let mut map = HashMap::new(); |
| 155 | |
| 156 | for datum in data.iter() { |
| 157 | match map.insert(datum.get_key(), 0) { |
| 158 | Some(_) => {}, |
| 159 | None => keys.push(datum.get_key()), |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | keys |
| 164 | } |
| 165 | |
| 166 | /// Add a [Bar] entry to the dataset entries list. |
| 167 | fn add_bar(&mut self, bar: Bar) { |