Skip to content

Commit

Permalink
Temporary fix for the build problem.
Browse files Browse the repository at this point in the history
npm is really a terriable package manager...

Ref:
- apache#3445
  • Loading branch information
Xiao Hanyu committed Sep 18, 2017
1 parent b3fd352 commit a87e13c
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 135 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ app.db
*.js.map
node_modules
npm-debug.log
yarn.lock
superset/assets/version_info.json
log
2 changes: 1 addition & 1 deletion superset/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"react-draggable": "^2.1.2",
"react-gravatar": "^2.6.1",
"react-grid-layout": "^0.14.4",
"react-map-gl": "^2.0.0",
"react-map-gl": "^3.0.4",
"react-redux": "^5.0.2",
"react-resizable": "^1.3.3",
"react-select": "git+https://github.com/songyanho/react-select-draggable.git",
Expand Down
69 changes: 63 additions & 6 deletions superset/assets/visualizations/mapbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import MapGL from 'react-map-gl';
import ScatterPlotOverlay from 'react-map-gl/dist/overlays/scatterplot.react';
import Immutable from 'immutable';
import supercluster from 'supercluster';
import ViewportMercator from 'viewport-mercator-project';
Expand All @@ -20,7 +19,15 @@ import {

require('./mapbox.css');

class ScatterPlotGlowOverlay extends ScatterPlotOverlay {
class ScatterPlotGlowOverlay extends React.Component {
componentDidMount() {
this.redraw();
}

componentDidUpdate() {
this.redraw();
}

drawText(ctx, pixel, options = {}) {
const IS_DARK_THRESHOLD = 110;
const { fontHeight = 0, label = '', radius = 0, rgb = [0, 0, 0], shadow = false } = options;
Expand Down Expand Up @@ -50,7 +57,7 @@ class ScatterPlotGlowOverlay extends ScatterPlotOverlay {
}

// Modified: https://github.com/uber/react-map-gl/blob/master/src/overlays/scatterplot.react.js
_redraw() {
redraw() {
const props = this.props;
const pixelRatio = window.devicePixelRatio || 1;
const canvas = this.refs.overlay;
Expand Down Expand Up @@ -179,8 +186,58 @@ class ScatterPlotGlowOverlay extends ScatterPlotOverlay {

ctx.restore();
}
render() {
let width = 0;
let height = 0;
if (this.context.viewport) {
width = this.context.viewport.width;
height = this.context.viewport.height;
}
const { globalOpacity } = this.props;
const pixelRatio = window.devicePixelRatio || 1;
return (
React.createElement('canvas', {
ref: 'overlay',
width: width * pixelRatio,
height: height * pixelRatio,
style: {
width: `${width}px`,
height: `${height}px`,
position: 'absolute',
pointerEvents: 'none',
opacity: globalOpacity,
left: 0,
top: 0,
},
})
);
}
}

ScatterPlotGlowOverlay.propTypes = {
locations: PropTypes.instanceOf(Immutable.List).isRequired,
lngLatAccessor: PropTypes.func,
renderWhileDragging: PropTypes.bool,
globalOpacity: PropTypes.number,
dotRadius: PropTypes.number,
dotFill: PropTypes.string,
compositeOperation: PropTypes.string,
};

ScatterPlotGlowOverlay.defaultProps = {
lngLatAccessor: location => [location.get(0), location.get(1)],
renderWhileDragging: true,
dotRadius: 4,
dotFill: '#1FBAD6',
globalOpacity: 1,
// Same as browser default.
compositeOperation: 'source-over',
};
ScatterPlotGlowOverlay.contextTypes = {
viewport: PropTypes.object,
isDragging: PropTypes.bool,
};

class MapboxViz extends React.Component {
constructor(props) {
super(props);
Expand All @@ -197,10 +254,10 @@ class MapboxViz extends React.Component {
},
};

this.onChangeViewport = this.onChangeViewport.bind(this);
this.onViewportChange = this.onViewportChange.bind(this);
}

onChangeViewport(viewport) {
onViewportChange(viewport) {
this.setState({
viewport,
});
Expand Down Expand Up @@ -232,7 +289,7 @@ class MapboxViz extends React.Component {
width={this.props.sliceWidth}
height={this.props.sliceHeight}
mapboxApiAccessToken={this.props.mapboxApiKey}
onChangeViewport={this.onChangeViewport}
onViewportChange={this.onViewportChange}
>
<ScatterPlotGlowOverlay
{...this.state.viewport}
Expand Down
20 changes: 0 additions & 20 deletions superset/assets/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ const config = {
],
alias: {
webworkify: 'webworkify-webpack',
'mapbox-gl/js/geo/transform': path.join(
__dirname, '/node_modules/mapbox-gl/js/geo/transform'),
'mapbox-gl': path.join(__dirname, '/node_modules/mapbox-gl/dist/mapbox-gl.js'),
},

},
module: {
noParse: /mapbox-gl\/dist/,
loaders: [
{
test: /datatables\.net.*/,
Expand All @@ -56,12 +52,6 @@ const config = {
],
},
},
/* for react-map-gl overlays */
{
test: /\.react\.js$/,
include: APP_DIR + '/node_modules/react-map-gl/src/overlays',
loader: 'babel-loader',
},
/* for require('*.scss') */
{
test: /\.scss$/,
Expand Down Expand Up @@ -115,16 +105,6 @@ const config = {
include: APP_DIR,
loader: 'style-loader!css-loader!less-loader',
},
/* for mapbox */
{
test: /\.json$/,
loader: 'json-loader',
},
{
test: /\.js$/,
include: APP_DIR + '/node_modules/mapbox-gl/js/render/painter/use_program.js',
loader: 'transform/cacheable?brfs',
},
],
},
externals: {
Expand Down
Loading

0 comments on commit a87e13c

Please sign in to comment.