superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccwilli...@apache.org
Subject [incubator-superset] branch master updated: Add annotation information to ChartMetadata (#6136)
Date Fri, 19 Oct 2018 00:59:36 GMT
This is an automated email from the ASF dual-hosted git repository.

ccwilliams pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 9d01af2  Add annotation information to ChartMetadata (#6136)
9d01af2 is described below

commit 9d01af201e168e9c41935bd4492c0393d6a374ff
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Thu Oct 18 17:59:30 2018 -0700

    Add annotation information to ChartMetadata (#6136)
    
    * add annotations information to ChartMetadata
    
    * rename fields
---
 .../src/visualizations/Table/TableChartPlugin.js       |  5 +++++
 .../src/visualizations/core/models/ChartMetadata.js    | 18 +++++++++++++++---
 .../src/visualizations/nvd3/Area/AreaChartPlugin.js    |  5 +++++
 .../src/visualizations/nvd3/Bar/BarChartPlugin.js      |  5 +++++
 .../src/visualizations/nvd3/Line/LineChartPlugin.js    | 10 ++++++++++
 5 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/superset/assets/src/visualizations/Table/TableChartPlugin.js b/superset/assets/src/visualizations/Table/TableChartPlugin.js
index 2b76f9b..b8d379e 100644
--- a/superset/assets/src/visualizations/Table/TableChartPlugin.js
+++ b/superset/assets/src/visualizations/Table/TableChartPlugin.js
@@ -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,
 });
 
diff --git a/superset/assets/src/visualizations/core/models/ChartMetadata.js b/superset/assets/src/visualizations/core/models/ChartMetadata.js
index 653ebc6..daa3f32 100644
--- a/superset/assets/src/visualizations/core/models/ChartMetadata.js
+++ b/superset/assets/src/visualizations/core/models/ChartMetadata.js
@@ -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;
   }
 }
diff --git a/superset/assets/src/visualizations/nvd3/Area/AreaChartPlugin.js b/superset/assets/src/visualizations/nvd3/Area/AreaChartPlugin.js
index 638f2f8..fcfdbde 100644
--- a/superset/assets/src/visualizations/nvd3/Area/AreaChartPlugin.js
+++ b/superset/assets/src/visualizations/nvd3/Area/AreaChartPlugin.js
@@ -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,
 });
 
diff --git a/superset/assets/src/visualizations/nvd3/Bar/BarChartPlugin.js b/superset/assets/src/visualizations/nvd3/Bar/BarChartPlugin.js
index cf1d1e4..6b88403 100644
--- a/superset/assets/src/visualizations/nvd3/Bar/BarChartPlugin.js
+++ b/superset/assets/src/visualizations/nvd3/Bar/BarChartPlugin.js
@@ -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,
 });
 
diff --git a/superset/assets/src/visualizations/nvd3/Line/LineChartPlugin.js b/superset/assets/src/visualizations/nvd3/Line/LineChartPlugin.js
index 7a43c5f..a1ea0d9 100644
--- a/superset/assets/src/visualizations/nvd3/Line/LineChartPlugin.js
+++ b/superset/assets/src/visualizations/nvd3/Line/LineChartPlugin.js
@@ -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,
 });
 


Mime
View raw message