import { Chart, Tooltip, Coord, View, Polygon, Point } from 'viser-react';
import * as React from 'react';
import * as $ from 'jquery';
const DataSet = require('@antv/data-set');
const tooltipOpts = {
showTitle: false,
containerTpl: '
',
itemTpl: '| {name} | {value} |
',
g2Tooltip: {
borderRadius: '2px',
backgroundColor: '#DDDDDD',
padding: 0,
border: '1px solid #333'
}
};
const scale = [{
dataKey: 'x',
sync: true,
nice: false,
}, {
dataKey: 'y',
sync: true,
nice: false,
}];
export default class App extends React.Component {
state = {
geoData: {},
data: [],
};
componentDidMount() {
$.when(
$.getJSON('/assets/data/worldGeo.json'),
$.getJSON('/assets/data/map-1.json')
).then((geoData, data) => {
const dv = new DataSet.View().source(geoData[0], {
type: 'GeoJSON'
}).transform({
type: 'geo.projection',
projection: 'geoMercator',
as: ['x', 'y', 'centroidX', 'centroidY'],
});
const userData = new DataSet.View().source(data[0]).transform({
type: 'map',
callback: (obj) => {
const projectedCoord = dv.geoProjectPosition([obj.lng * 1, obj.lat * 1], 'geoMercator');
obj.x = projectedCoord[0];
obj.y = projectedCoord[1];
obj.deaths = obj.deaths * 1;
obj.magnitude = obj.magnitude * 1;
return obj;
}
});
this.setState({ geoData: dv, data: userData });
});
}
render() {
const { geoData, data } = this.state;
return (
);
}
}