Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
$.when($.getJSON('/assets/data/usa.geo.json'),
$.getJSON('/assets/data/flights-airport.json'),
$.getJSON('/assets/data/airport.json'))
.then((mapData, flights, airports) => {
mapData = mapData[0];
flights = flights[0];
airports = airports[0];
var map = [];
var features = mapData.features;
// 获取出所有的地图区域名称
for (var i = 0; i < features.length; i++) {
var name = features[i].properties.name;
map.push({
"name": name
});
}
type: "GET",
url: this.panel.jsonpUrl + "?callback=?",
contentType: "application/json",
jsonpCallback: this.panel.jsonpCallback,
dataType: "jsonp",
success: res => {
this.locations = res;
this.render();
}
});
} else if (this.panel.locationData === "json endpoint") {
if (!this.panel.jsonUrl) {
return;
}
$.getJSON(this.panel.jsonUrl).then(res => {
this.locations = res;
this.render();
});
} else if (this.panel.locationData === "table") {
// .. Do nothing
} else if (
this.panel.locationData !== "geohash" &&
this.panel.locationData !== "json result"
) {
$.getJSON(
"public/plugins/grafana-worldmap-panel/data/" +
this.panel.locationData +
".json"
).then(this.reloadLocations.bind(this));
}
}
if (page) {
var loaded = false;
var status = self.pageStatus[page];
if (status == 'loading' || status == 'loaded') {
loaded = true;
}
if (loaded) {
if (callback) {
callback();
}
return;
}
self.pageStatus[page] = 'loading';
}
$.getJSON(this.url, { pictureId: pictureId, page: page }, function(
json
) {
self.count = json.count;
self.pages = json.pages;
if (!self.pageStatus[self.pages]) {
self.pageStatus[self.pages] = null;
}
self.pageStatus[json.page] = 'loaded';
let $activeItem: JQuery | undefined = undefined;
var offset = self.perPage * (json.page - 1);
for (let idx in json.items) {
let item = json.items[idx];
var position: number = offset + Number(idx);
load: function() {
this.map = L.map(this.$("#DataLibraryMap")[0], {
zoomControl: false,
attributionControl: false
}).setView([44,-31], 3);
var sqlDomain = cdb.config.get('sql_api_template').replace('{user}', cdb.config.get('data_library_user'));
var geojsonURL = sqlDomain + '/api/v2/sql?q=' + encodeURIComponent("select * from world_borders") + '&format=geojson&filename=world_borders';
$.getJSON(geojsonURL).done(this._addGeojsonData);
},
mounted(){
$.getJSON('/assets/data/baby-names.json', (data) => {
var ds = new DataSet();
var dv = ds.createView('demo').source(data).transform({
type: 'fill-rows',
groupBy: ['name'],
orderBy: ['year']
}).transform({
type: 'impute',
field: 'n',
method: 'value',
value: 0
}).transform({
type: 'aggregate',
fields: ['n'],
operations: ['sum'],
groupBy: ['year', 'name'],
orderBy: ['year'],
onConnect: (u) => {
this.props.setActiveSub(u);
this.props.didConnect();
this.addMessages([{ message: "CONNECTED!", cls: "open" }]);
$.getJSON(this.props.chatHistoryUrl, r => {
this.addMessages(r.results);
});
this.props.refreshUsers();
},
onReconnect() {
downloadMainTiles (cb) {
$.getJSON({
dataType: "json",
url: this.mainTileUrl,
success: (data) => {
this.switchMainLayer(new TileLayer({
source: new TileJSON({
tileJSON: data,
crossOrigin: "anonymous",
transition: 0
}),
opacity: this.opacity
}));
this.hook("timeHandler", data.version.toString());
if (cb) { cb(data); }
}
});