Iam using d3 version 4.12.2
and eventDrops.js downloaded from this below link
https://gist.githubusercontent.com/thoka/ca508531e9a016fb815477621f9d6aae/raw/32b3a1e79208a840666882fec60804c68a96bf7f/eventdrops.js
and my code is
<html>
<head><title>asdasd</title>
<script src="./d3.js"></script>
<script src="./eventDrops.js"></script>
<script lang="javascript">
function test() {
var hardData = [{
name: 'sensor1',
dates: [
new Date(1458068401000),
new Date(1458068401000),
new Date(1458068403000),
new Date(1458068404000),
new Date(1458068405000),
new Date(1458068406000),
new Date(1458068411000),
new Date(1458068413000),
new Date(1458068415000),
new Date(1458068416000),
],}]; var eventDropsChart = d3.chart.eventDrops(); d3.select('body')
.datum(hardData)
.call(eventDropsChart);
}
</script>
</head>
<body onload="test()"></body></html>
2). which version of d3 works with eventDrops?
Thanks & Regards,
Govardhan
I'm not sure which version is the one you mentionned. I would recommend using the official one, available on: https://unpkg.com/event-drops. Be careful: this is the last version with breaking changes compared to previous versions.
D3 version 4 works with the 1.0.0 version.
For a working example of how it works, you can take a look on the demo code and adapt it according to your needs. :)
Related
I am trying to load external geojson by using leaflet ajax.
I think the structure of geojson is true. This is the link of it.
Here is what i did based on HERE:
in the head:
<script src="../external/js/leaflet.js"></script>
<script src="../external/js/leaflet.functionaltilelayer.js"></script>
<script src="../external/js/leaflet.ajax.min.js"></script>
In javascript:
var mymap = L.map('mapid',{ center: new L.LatLng(the_center_splitted[0],the_center_splitted[1]),maxZoom: 17, minZoom:11, zoom: 14}); //creating the map
var gs = new L.TileLayer('../external/maps/qom/gs/gs_{x}_{y}_{z}.jpg', {opacity: 1,scheme: 'TMS'}).addTo(mymap); //loading image layer
var geojsonLayer = new L.GeoJSON.AJAX("../external/map/qom/geojson/qom.geojson");
geojsonLayer.addTo(mymap);
But the geojson file is not shown and i get this error:
ncaught TypeError: L.GeoJSON.AJAX is not a constructor
I appreciate if any one can help.
Thank you.
What is "functionaltilelayer.js" for? In the code Snippet you don't need that.
And var gs = new L.tileLayer with a lower t - change that and try it again!
<script src="../external/js/leaflet.js"></script>
<script src="../external/js/leaflet.ajax.min.js"></script>
var mymap = L.map('mapid',{ center: new L.LatLng(the_center_splitted[0],the_center_splitted[1]),maxZoom: 17, minZoom:11, zoom: 14}); //creating the map
var gs = new L.TileLayer('../external/maps/qom/gs/gs_{x}_{y}_{z}.jpg', {opacity: 1,tms: true}).addTo(mymap); //loading image layer
var geojsonLayer = new L.GeoJSON.AJAX("../external/map/qom/geojson/qom.geojson");
geojsonLayer.addTo(mymap);
Your code seems okay - did you import
<script src='leaflet-ajax.js'></script>
If yes, please show your whole code!
Its a bit tricky to import files via AJAX.
First remember that the relative path your giving the AJAX() method should be a Your Geojson file should be path from the location of the leaflet-ajax script file. (Since it is there the AJAX-call gets done).
I would recommend a different approach (without AJAX calls):
Your GeJson file (rename it to gejson.js) should look like this:
var json = { "type": "FeatureCollection",
"features": [{
...
Import this file before your leaflet ajax code:
<script src="../../geojson.js" type="text/javascript"></script>
This will give you access to a variable called json which you then can use to import the json object in your layer:
var geojsonLayer = L.geoJSON().addTo(mymap);
geojsonLayer.addData(json);
I can't figure out how to make a draggable pushpin. I used this code that is similar to tutorial I can find everywhere:
<script type='text/javascript'>
function GetMap()
{
var loc = new Microsoft.Maps.Location(47.1, 2.20696);
var map = new Microsoft.Maps.Map('#myMap', {
credentials: 'XXXXXXXXXXXXX'
, center: loc,
zoom:16
});
var pin = new Microsoft.Maps.Pushpin(loc);
pin.setOptions( { draggable: true, text:'1' });
map.entities.push(pin);
}
</script>
<script type='text/javascript' src='//www.bing.com/api/maps/mapcontrol?callback=GetMap' async defer></script>
<div id="myMap" class="bing"></div>
But it is not working.
What may be wrong?
Pushpins were not draggable in the initial release of V8, however this functionality has been added in the experimental branch of V8. Simply add "&branch=experimental" to the map script URL and your pushpin will be draggable. All new features and bug fixes that are currently in the experimental branch will be rolled into the main release branch at the end of the month.
I've followed a tutorial to create a Website Menu, this involves JQuery to provide some transitions.
I've got it working as intended, but to prove I understand this new code and framework, and also, to follow development guidelines, I want to move to the Menu code to a plug-in.
Working (not-plug-in) version:
This appears in the .ascx, along with a UL tag, ID = MainMenu
<script type="text/javascript">
NavBarMenu();
</script>
In another file, NavBar.js, the following code is used to associate some JQuery events:
function NavBarMenu() {
$(function() {
var $menu = $('#MainMenu');
var $menu_items = $menu.children('li');
...
Not working version:
Now the plug-in code is created, the NavBarMenu function is called like this from the .ascx:
<script type="text/javascript">
$("#MainMenu").NavBarMenu();
</script>
In NavBar.js I now have:
(function($) {
$.fn.NavBarMenu = function() {
var $menu_items = this.children('li');
However, the $menu_items variable is unpopulated?
Shouldn't this (2nd example) be equivalent to $('#MainMenu') (1st example)
I followed this example, where a JQuery selector is switched for the this pointer. http://learn.jquery.com/plugins/basic-plugin-creation/
Thanks in advance :D
There must be other factor affecting my implementation, I will revisit it.
I have created 2 JSFiddle pages, as part of my investigation and it has proved that the JQuery Selector can be swapped for the this pointer in a plug-in.
Fiddle detailing 1st example: http://jsfiddle.net/rL7zpr15/1/
$('input[type=button]').click( function() {
$( "div" ).css( "background", "green" );
});
Is equivalent to
Fiddle detailing 2nd example: http://jsfiddle.net/hds7advx/
$.fn.greenify = function() {
this.css( "background", "green" );
};
$('input[type=button]').click( function() {
$( "div" ).greenify();
});
I'm trying to use google geochart on my website. But the problem is when draw geochart, I receive error: "Object # has no method 'each'"
Here the code I'm trying:
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {'packages': ['geochart']});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Country', 'Popularity'],
['Germany', 200],
['United States', 300],
['Brazil', 400],
['Canada', 500],
['France', 600],
['RU', 700]
]);
var options = {};
var chart = new google.visualization.GeoChart(document.getElementById('chart_1'));
chart.draw(data, options);
};
</script>
<div id="chart_1">Chart should be here</div>
Everything works fine when I remove prototype.js from the page, but I have to leave it.
Any suggestions how to resolve this conflict?
Look at https://developers.google.com/speed/libraries/devguide#prototype
and try to include 1.7.1.0, 1.7.0.0, 1.6.1.0, 1.6.0.3 or 1.6.0.2
You will get the error Object #<Object> has no method 'each' for any version prior to 1.7.1.0, so you just have to update your prototype with latest version available.
Some explanation would here be required, but I really cant tell exactly why. According to the 1.7.1 announcement the dom.js has been totally rewritten. An update from 1.7 to 1.7.1 which took 18 months (!!) The 1.7.0 RC3 is as far back as oct 2010, "including support for IE9" (!!) - so I guess a lot of programming regarding "new" HTML5 tags especially as the <svg>-tag google visualization uses a lot, is the reason behind it was not working prior to 1.7.1.
I began reading about Auto-loading a google map at:
http://code.google.com/apis/ajax/documentation/#AutoLoading
What's unclear to me is how to actually load the google map.
I have tried:
<script src="http://www.google.com/jsapi?autoload=%7B%22modules%22%3A
%5B%7B%22name%22%3A%22search%22%2C%22version%22%3A%221.0%22%2C
%22language%22%3A%22en%22%7D%2C%7B%22name%22%3A%22maps%22%2C%22version
%22%3A%222.X%22%7D%2C%7B%22name%22%3A%22elements%22%2C%22version%22%3A
%221.0%22%2C%22packages%22%3A%5B%22localsearch%22%5D%7D%5D
%7D&key=MY_KEY"></script>
<script type="text/javascript">
//<![CDATA[
google.load("maps", "2.x");
google.setOnLoadCallback(function() {
map = new google.maps.Map2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 6);
map.addControl(new GSmallMapControl());
}
);
//]]>
</script>
But the map doesn't load.
Strange thing is that if I simply remove the "autoload=..." from the
URL - the map loads and works fine.
If I keep the autoload=... in the url and comment out the manually loading "google.load("maps", "2.x");", it still doesn't work.
Any ideas on how to properly use the auto-load functionality to gain
the most performance (least latency)?
You should use:
<script src="http://www.google.com/jsapi?autoload=%7B%22modules%22%3A
%5B%7B%22name%22%3A%22search%22%2C%22version%22%3A%221.0%22%2C
%22language%22%3A%22en%22%7D%2C%7B%22name%22%3A%22maps%22%2C%22version
%22%3A%222.X%22%7D%2C%7B%22name%22%3A%22elements%22%2C%22version%22%3A
%221.0%22%2C%22packages%22%3A%5B%22localsearch%22%5D%7D%5D
%7D&key=MY_KEY"></script>
Any nothing else. Remove the code after this in you example