Using jsPlumb with highmaps - highcharts

I am using Highmaps and I have a map of the world with map markers all over. I want to show connection between map markers so I decided to use jsPlumb. I set an id to the highcharts data as so:
data: [{
id: "MT",
x: 907.49,
y: -1485.43
}
],
I tried to get the id defined here using javascript and it worked. jsPlumb requires id of an element both for the source and target, as so:
jsPlumb.connect({
source: 'MT',
target: 'GPin1',
anchors: [['Right'], ['Left']],
endpoint: ["Dot", {
radius: 0.1
}],
The problem is that jsPlumb does not recognize the id defined in highcharts and returns an error on console. How can I settle this any ideas please?

Related

Google Docs API : How to update alignment of the table?

I have a Table in the google docs and want to change its alignment to -0.71 but i do not see any Python API to change table properties. This can be done easily using following UI on google UI (as shown below):
I also tries looking at following requests but could not find it:
updateTableColumnProperties
updateTableCellStyle
For debugging, i created a doc with mentioned alignment and tried dumping JSON of it. But i do not see alignment keyword in the JSON.
Thanks #jescanellas for reply.
I found a hack, this may not be the best solution but works.
1) Update paragraph style and set the indentation, alignment as required. Here the start_idx is the index where table needs to be created.
request = [{
'updateParagraphStyle': {
'paragraphStyle': {
'namedStyleType': 'HEADING_5',
'direction': 'LEFT_TO_RIGHT',
'alignment': 'START',
'indentFirstLine': {
'magnitude': -51.839999999999996,
'unit': 'PT'
},
'indentStart': {
'magnitude': -51.839999999999996,
'unit': 'PT'
},
},
'fields': '*',
'range': {
'startIndex': start_idx,
'endIndex': end_idx
}
}
}]
2) Create the table, it will get created at new indented place.
request = [{
'insertTable': {
'rows': 1,
'columns': 1,
'location': {
'segmentId':'',
'index': start_idx
}
},
}]
It's not currently possible to do so. You can create a Feature Request for the Docs API, and you can also subscribe to this one for Apps Script by clicking on the star next to the Issue number to give more priority to the request and to receive updates.
In case of the second request being implemented, you could call the script from the command line using Clasp.

Google Geolocation API is always returning the same location regardless of cellTower specified

I'm using the Google Geolocation API to approximate location based on cell towers that are visible. However, I always get the same location as the result.
Using the following body:
{
"considerIp": false,
"radioType": "lte",
"cellTowers": [{
"signalStrength": -78,
"cellId": 133978007,
"mobileNetworkCode": 410,
"mobileCountryCode": 310,
"locationAreaCode": 27196
}]
}
Produces the following result:
{"location": {"lat": 31.968598800000002, "lng": -99.9018131}, "accuracy": 1457406}
The actual location of that tower/cell is approx (32.783062, 96.795769). In fact, the cell tower specified is take directly from OpenCellID's database (opencellid.org)
If I then select a tower somewhere else (e.g. Palo Alto)
{
"considerIp": false,
"radioType": "lte",
"cellTowers": [{
"signalStrength": -78,
"cellId": 84785686,
"mobileNetworkCode": 480,
"mobileCountryCode": 311,
"locationAreaCode": 7943
}]
}
The response is:
{"location": {"lat": 31.968598800000002, "lng": -99.9018131}, "accuracy": 1457406}
which is exactly the same.
If I can my public IP (via changing VPN end-point location) the results DO change. Using the same Palo Alto query but changing from a Texas to Chicago end-node my result changes to:
{"location": {"lat": 37.09024, "lng": -95.712891}, "accuracy": 1488703}
It looks like the considerIp=false argument is being ignored and that is only being used instead of the provided cell tower.
Any ideas how to fix this?
Thanks!
I figured it out. Apparently if the Content-Type is not being explicitly set to application/json then the body is silently ignored and only the local IP is considered.
I would like to request that Google updates the API response body to include something to that effect.

Get Highchart (/ Highstock) from public data (json)

Here's an example how to plot the chart with json data
Is there a way to chart this from public data (meaning any listed company)? For example from bloomberg data? https://www.bloomberg.com/markets/chart/data/1D/AAPL:US
I guess the format is just wrong?
For Highcharts the structure of data is important, not the source. All you should do is set the correct link and series data, but unfortunately I see a problem with CORS: How does Access-Control-Allow-Origin header work?
series: [{
data: data.data_values,
...
}]
Live demo: http://jsfiddle.net/BlackLabel/5u0jv31y/

Using a geojson with highmaps

I want to display some data about San Francisco using highmaps but there is no maps of the different neighborhoods in SF in the highmaps library so I found an geojson of San Francisco wich was validate by this site: geojson validator but when I use the highmaps validator he doesn't read it: the highmap validator
$('#run').click(function () {
var geojson = $.parseJSON($('#geojson').val());
// Initiate the chart
$('#container').slideDown().highcharts('Map', {
series: [{
mapData: geojson
}]
});
});
This is my geojson: pastebin code.
Do you know why it's not validated by highmaps but it's validate by the geojson validator? Or do you know a San Francisco map which will be validated by highmaps?
Consider importing your .geojson into QGis, then exporting it out again. In my experience any .geojson that QGis produces is usable by Highmaps. Also see this tutorial Creating custom geojson maps for Highmaps with QGis.

jquery autocomplete cities with geonames - avoid duplicates in autocomplete suggestion

I'm using the jqueryUI autocomplete functionality (http://jqueryui.com/demos/autocomplete/#remote-jsonp) to search surrounding shops of cities in germany and austria. my code is the following:
$.ajax({
url: "http://ws.geonames.org/searchJSON?lang=de&country=DE&country=AT&isNameRequired=true&featureClass=A&featureCode=ADM3&featureCode=ADM4&featureCode=ADM1",
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
}...
the problem now is, for austria, i need all the administrative devisions ADM3, ADM1... to get all of the cities. For Germany ADM4 would be enough. But because of the other codes, I get Berlin for example three times, because its ADM3, ADM1 and ADM4.
How can i remove the duplicates of certain cities to autosuggest it only once?

Resources