|
1 | 1 | import type { AltGoslingSpec, AltTrackSingle } from '@alt-gosling/schema/alt-gosling-schema';
|
2 |
| - |
3 | 2 | import { arrayToString, markToText, channelToText, capDesc } from '../util';
|
4 | 3 |
|
| 4 | +import { GetColorName } from 'hex-color-to-color-name'; |
5 | 5 |
|
6 | 6 | export function addTreeDescriptions(altGoslingSpec: AltGoslingSpec) {
|
7 | 7 | addTrackPositionDescriptions(altGoslingSpec);
|
@@ -186,11 +186,15 @@ function addTrackAppearanceDescriptions(altGoslingSpec: AltGoslingSpec) {
|
186 | 186 | desc = desc.concat(capDesc(track.charttype) + '.');
|
187 | 187 | } else {
|
188 | 188 | if (markToText.get(track.appearance.details.mark)) {
|
189 |
| - desc = desc.concat('Chart with ' + markToText.get(track.appearance.details.mark) + '.'); |
| 189 | + desc = desc.concat(`Chart with ${markToText.get(track.appearance.details.mark)}.`); |
190 | 190 | } else {
|
191 |
| - desc = desc.concat('Unknown chart.') |
| 191 | + desc = desc.concat(`Unknown chart.`) |
192 | 192 | }
|
193 | 193 | }
|
| 194 | + |
| 195 | + if (track.title) { |
| 196 | + desc = desc.concat(` Chart is titled '${track.title}'.`) |
| 197 | + } |
194 | 198 |
|
195 | 199 | const encodingDescriptions = addEncodingDescriptions(track);
|
196 | 200 | // console.log('encdesc', encodingDescriptions);
|
@@ -328,6 +332,12 @@ function addEncodingDescriptions(track: AltTrackSingle) {
|
328 | 332 | for (let i = 0; i < track.appearance.details.encodings.encodingValue.length; i++) {
|
329 | 333 | const e = track.appearance.details.encodings.encodingValue[i];
|
330 | 334 | if (e.name === 'color') {
|
| 335 | + // if the color is denoted as a hex code, get the name of the color value |
| 336 | + if (typeof e.details.value === 'string') { |
| 337 | + if (e.details.value[0] === '#') { |
| 338 | + e.details.value = GetColorName(e.details.value.slice(0)).toLowerCase(); |
| 339 | + } |
| 340 | + } |
331 | 341 | descValue = descValue.concat('The color of the ' + markToText.get(mark) + ' is ' + e.details.value + '.');
|
332 | 342 | descList.push(['color', 'The color of the ' + markToText.get(mark) + ' is ' + e.details.value + '.']);
|
333 | 343 | }
|
|
0 commit comments