Add annotation information to ChartMetadata (#6136)

* add annotations information to ChartMetadata

* rename fields
This commit is contained in:
Krist Wongsuphasawat 2018-10-18 17:59:30 -07:00 committed by Chris Williams
parent d662e36442
commit 9d01af201e
5 changed files with 40 additions and 3 deletions

View File

@ -2,10 +2,15 @@ import ChartPlugin from '../core/models/ChartPlugin';
import ChartMetadata from '../core/models/ChartMetadata';
import transformProps from './transformProps';
import thumbnail from './images/thumbnail.png';
import { ANNOTATION_TYPES } from '../../modules/AnnotationTypes';
const metadata = new ChartMetadata({
name: 'Table',
description: '',
canBeAnnotationTypes: [
ANNOTATION_TYPES.EVENT,
ANNOTATION_TYPES.INTERVAL,
],
thumbnail,
});

View File

@ -2,14 +2,26 @@ export default class ChartMetadata {
constructor({
name,
credits = [],
description,
thumbnail,
description = '',
show = true,
canBeAnnotationTypes = [],
supportedAnnotationTypes = [],
thumbnail,
}) {
this.name = name;
this.credits = credits;
this.description = description;
this.thumbnail = thumbnail;
this.show = show;
this.canBeAnnotationTypesLookup = canBeAnnotationTypes.reduce((prev, type) => {
const lookup = prev;
lookup[type] = true;
return lookup;
}, {});
this.supportedAnnotationTypes = supportedAnnotationTypes;
this.thumbnail = thumbnail;
}
canBeAnnotationType(type) {
return this.canBeAnnotationTypesLookup[type] || false;
}
}

View File

@ -2,11 +2,16 @@ import ChartPlugin from '../../core/models/ChartPlugin';
import ChartMetadata from '../../core/models/ChartMetadata';
import transformProps from '../transformProps';
import thumbnail from './images/thumbnail.png';
import { ANNOTATION_TYPES } from '../../../modules/AnnotationTypes';
const metadata = new ChartMetadata({
name: 'Area Chart',
description: '',
credits: ['http://nvd3.org'],
supportedAnnotationTypes: [
ANNOTATION_TYPES.INTERVAL,
ANNOTATION_TYPES.EVENT,
],
thumbnail,
});

View File

@ -2,11 +2,16 @@ import ChartPlugin from '../../core/models/ChartPlugin';
import ChartMetadata from '../../core/models/ChartMetadata';
import transformProps from '../transformProps';
import thumbnail from './images/thumbnail.png';
import { ANNOTATION_TYPES } from '../../../modules/AnnotationTypes';
const metadata = new ChartMetadata({
name: 'Time-series Bar Chart',
description: 'A bar chart where the x axis is time',
credits: ['http://nvd3.org'],
supportedAnnotationTypes: [
ANNOTATION_TYPES.INTERVAL,
ANNOTATION_TYPES.EVENT,
],
thumbnail,
});

View File

@ -2,11 +2,21 @@ import ChartPlugin from '../../core/models/ChartPlugin';
import ChartMetadata from '../../core/models/ChartMetadata';
import transformProps from '../transformProps';
import thumbnail from './images/thumbnail.png';
import { ANNOTATION_TYPES } from '../../../modules/AnnotationTypes';
const metadata = new ChartMetadata({
name: 'Line Chart',
description: '',
credits: ['http://nvd3.org'],
canBeAnnotationTypes: [
ANNOTATION_TYPES.TIME_SERIES,
],
supportedAnnotationTypes: [
ANNOTATION_TYPES.TIME_SERIES,
ANNOTATION_TYPES.INTERVAL,
ANNOTATION_TYPES.EVENT,
ANNOTATION_TYPES.FORMULA,
],
thumbnail,
});