You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/11/27 10:00:17 UTC

[GitHub] aboganas closed pull request #6437: fix mapbox and calendar heat map

aboganas closed pull request #6437: fix mapbox and calendar heat map
URL: https://github.com/apache/incubator-superset/pull/6437
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/src/modules/geo.js b/superset/assets/src/modules/geo.js
index 2fc2744ae4..f41113ba96 100644
--- a/superset/assets/src/modules/geo.js
+++ b/superset/assets/src/modules/geo.js
@@ -1,5 +1,3 @@
-import { round as d3Round } from 'd3-format';
-
 export const defaultViewport = {
   longitude: 6.85236157047845,
   latitude: 31.222656842808707,
@@ -35,5 +33,5 @@ export function kmToPixels(kilometers, latitude, zoomLevel) {
   const latitudeRad = latitude * (Math.PI / 180);
   // Seems like the zoomLevel is off by one
   const kmPerPixel = (EARTH_CIRCUMFERENCE_KM * Math.cos(latitudeRad)) / Math.pow(2, zoomLevel + 9);
-  return d3Round(kilometers / kmPerPixel, 2);
+  return Math.round(kilometers / kmPerPixel, 2);
 }
diff --git a/superset/assets/src/visualizations/Calendar/Calendar.js b/superset/assets/src/visualizations/Calendar/Calendar.js
index 5b7bfe755e..a20db6dfec 100644
--- a/superset/assets/src/visualizations/Calendar/Calendar.js
+++ b/superset/assets/src/visualizations/Calendar/Calendar.js
@@ -95,7 +95,7 @@ function Calendar(element, props) {
     cal.init({
       start: UTCTS(data.start),
       data: timestamps,
-      itemSelector: calContainer[0][0],
+      itemSelector: calContainer._groups[0][0],
       legendVerticalPosition: 'top',
       cellSize,
       cellPadding,
diff --git a/superset/assets/src/visualizations/MapBox/ScatterPlotGlowOverlay.jsx b/superset/assets/src/visualizations/MapBox/ScatterPlotGlowOverlay.jsx
index 5a6ba27314..609387b7e9 100644
--- a/superset/assets/src/visualizations/MapBox/ScatterPlotGlowOverlay.jsx
+++ b/superset/assets/src/visualizations/MapBox/ScatterPlotGlowOverlay.jsx
@@ -2,7 +2,6 @@ import Immutable from 'immutable';
 import React from 'react';
 import PropTypes from 'prop-types';
 import ViewportMercator from 'viewport-mercator-project';
-import { round as d3Round } from 'd3-format';
 import { kmToPixels, MILES_PER_KM } from '../../modules/geo';
 import { rgbLuminance } from '../../utils/common';
 
@@ -128,7 +127,7 @@ class ScatterPlotGlowOverlay extends React.Component {
     if ((props.renderWhileDragging || !props.isDragging) && props.locations) {
       props.locations.forEach(function _forEach(location, i) {
         const pixel = mercator.project(props.lngLatAccessor(location));
-        const pixelRounded = [d3Round(pixel[0], 1), d3Round(pixel[1], 1)];
+        const pixelRounded = [Math.round(pixel[0], 1), Math.round(pixel[1], 1)];
 
         if (pixelRounded[0] + radius >= 0
               && pixelRounded[0] - radius < props.width
@@ -137,8 +136,8 @@ class ScatterPlotGlowOverlay extends React.Component {
           ctx.beginPath();
           if (location.get('properties').get('cluster')) {
             let clusterLabel = clusterLabelMap[i];
-            const scaledRadius = d3Round(Math.pow(clusterLabel / maxLabel, 0.5) * radius, 1);
-            const fontHeight = d3Round(scaledRadius * 0.5, 1);
+            const scaledRadius = Math.round(Math.pow(clusterLabel / maxLabel, 0.5) * radius, 1);
+            const fontHeight = Math.round(scaledRadius * 0.5, 1);
             const gradient = ctx.createRadialGradient(
               pixelRounded[0], pixelRounded[1], scaledRadius,
               pixelRounded[0], pixelRounded[1], 0,
@@ -174,17 +173,17 @@ class ScatterPlotGlowOverlay extends React.Component {
             if (radiusProperty !== null) {
               const pointLatitude = props.lngLatAccessor(location)[1];
               if (props.pointRadiusUnit === 'Kilometers') {
-                pointLabel = d3Round(pointRadius, 2) + 'km';
+                pointLabel = Math.round(pointRadius, 2) + 'km';
                 pointRadius = kmToPixels(pointRadius, pointLatitude, props.zoom);
               } else if (props.pointRadiusUnit === 'Miles') {
-                pointLabel = d3Round(pointRadius, 2) + 'mi';
+                pointLabel = Math.round(pointRadius, 2) + 'mi';
                 pointRadius = kmToPixels(pointRadius * MILES_PER_KM, pointLatitude, props.zoom);
               }
             }
 
             if (pointMetric !== null) {
               pointLabel = Number.isFinite(parseFloat(pointMetric))
-                ? d3Round(pointMetric, 2)
+                ? Math.round(pointMetric, 2)
                 : pointMetric;
             }
 
@@ -193,13 +192,13 @@ class ScatterPlotGlowOverlay extends React.Component {
               pointRadius = defaultRadius;
             }
 
-            ctx.arc(pixelRounded[0], pixelRounded[1], d3Round(pointRadius, 1), 0, Math.PI * 2);
+            ctx.arc(pixelRounded[0], pixelRounded[1], Math.round(pointRadius, 1), 0, Math.PI * 2);
             ctx.fillStyle = 'rgb(' + rgb[1] + ', ' + rgb[2] + ', ' + rgb[3] + ')';
             ctx.fill();
 
             if (pointLabel !== undefined) {
               this.drawText(ctx, pixelRounded, {
-                fontHeight: d3Round(pointRadius, 1),
+                fontHeight: Math.round(pointRadius, 1),
                 label: pointLabel,
                 radius: pointRadius,
                 rgb,
diff --git a/superset/viz.py b/superset/viz.py
index e3e891ac07..62998c7114 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -790,7 +790,7 @@ def get_data(self, df):
         records = df.to_dict('records')
         for metric in self.metric_labels:
             data[metric] = {
-                str(obj[DTTM_ALIAS] / 10**9): obj.get(metric)
+                str(obj[DTTM_ALIAS].value / 10**9): obj.get(metric)
                 for obj in records
             }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org