Protovis Jquery Tooltip problem - javascript

I would like to display data using Jquery tooltip in my web application.
I have followed the example on this website http://flowplayer.org/tools/demos/tooltip/index.html and have managed to display out a tooltip on a picture on my application.
However, I am generating some bulletchart using Protovis now and would like to display out the data when I mouse over on the bullet chart.
I want to know how do I edit to make the tooltip appear? Currently I am able to display using html tags, but what I really want is to display the tooltip using javascript code.
Below my codes for bullet chart:
var vis = new pv.Panel()
.data(patientData)
.width(140)
.height(20)
.right(10)
.bottom(20)
.left(5);
var bullet = vis.add(pv.Layout.Bullet)
.orient("left")
.ranges(function(d) d.ranges)
.measures(function(d) d.measures)
.markers(function(d) d.markers);
bullet.range.add(pv.Bar);
bullet.measure.add(pv.Bar)
.fillStyle("black")
.text(function(d) "Current Month: "+ d.toFixed(1)+"%")
.tooltip(); -->This give me an error!
Would appreciate any inputs. thanks!

The problem here is that you're trying to chain a jQuery function, .tooltip(), on a Protovis object, in this case a pv.Bar. That's not going to work. A couple of options:
If you're willing to change your jQuery plugin, you could probably follow this example, which uses Tipsy.
You could adapt the pv.Behavior.tipsy code shown here to use tooltip() instead. It looks like you could do this pretty easily, just by editing lines 33 and 64 to use a different plugin - the hard work in this code is creating a div element to attach the tooltip to, and that's the same for both plugins.

Related

using tooltipster to display tool tips as part of innerHTML for a div

I am using tooltipster to generate tool tips. All works fine except in the situation where I need to set the contents of a div based on user input using a simple JavaScript function. The div contents consists of images, when hovering over each image, a tool tip should display. However, the tip displays as the default browser behaves for displaying title= with an image. The JavaScript I use is simple:
function setAwards() {
var awardsdiv=document.getElementById("awards"); awardsdiv.innerHTML="";
if (document.setvalues.superstar.checked == true) awardsdiv.innerHTML=awardsdiv.innerHTML + "<img class=\"tooltip\" title=\"Description of award\" width=\"16\" src=\"/pix/superstar.png\" alt=\"[ Super Star ]\" />";
[... stuff removed ...]
}
Is there a way to make this work? Tool tips do display elsewhere on this web page, so the resources needed appear to be set up correctly.
Thank you!
You must initialize the tooltip ($(...).tooltipster({...})) after you have inserted your new HTML content or use delegation.
For "automatic" initialization, you might want to use delegated event listeners for that, see https://github.com/iamceege/tooltipster/issues/499

hide one of the axes of a parallel-coordinates plot

i'm representing some data with the parallel coordinates library (based on d3.js) ( https://github.com/syntagmatic/parallel-coordinates#parallel-coordinates )
main functional part of the code is the following:
var parcoords = d3.parcoords()("#example") //#example is the div for the drowing
.data(eingabe) // eingabe is the var, which contains the data
.render()
.reorderable()
.shadows()
.brushMode("1D-axes")
so far it works fine :)
but now i want to hide one specific axis of the parallel coordinates; i only don't want to show it.
I want that the axis is completeley removed, so that it takes no place and the lines don't be affected of the values of this dimension, but i don´t want to do that by manipulating the data. i only want to manipulate the plot (thats the reason i called it hide).
i've searched on the api description but didn't find something. I searched in the internet but didn't find anything, too. But i think i remember that i've seen a peace of code, where the first axis was hidden, but i can't find it again.
Can anybody tell me, how i can hide an axis or where i can find the solution?
thank you, greetings
Jones
You're missing a .hideAxis(array) method call, where the array is a list of keys of the exact column names in your dataset that you want to hide. This method does exactly what you said you wanted:
"...hide one specific axis of the parallel coordinates; i only don't want to show it."
"I want that the axis is completley [sic] removed, so that it takes no place"
"the lines dont [sic] be affected of the values of this dimension, but i don´t want to do that by manupulating [sic] the data. i only want to manipulate the plot."
To implement this method, your code would need to be
var parcoords = d3.parcoords()("#example") //#example is the div for the drowing
.data(eingabe) // eingabe is the var, which contains the data
.hideAxis(["col1", "col2"])
.render()
.reorderable()
.shadows()
.brushMode("1D-axes")
Note: .hideAxis can take in a blank array if you don't want to hide any axis, i.e. .hideAxis([])
You can implement this method in some sort of update/redraw function if you want to allow the user to specify which axis(es) to remove; else, removing it completely via the DOM is impossible. This, performing the axis(es) hide via code, is your only option to implement what you want.
To see this method in action, take a look at the API documentation, specifically, their "example1" graph and code at http://syntagmatic.github.io/parallel-coordinates/index.html#example1
Assuming you just want to hide the axes (i.e. make it invisible) and not remove it completely
d3.selectAll("#example0 > svg > g > g.dimension:nth-child(3)").attr("opacity", "0");
Assuming example0 is the id of the wrapper around your svg element. You could also do the same thing directly on your svg element if you have it.
The above would still leave you able to interact with the filter of the hidden axis. To make it non-interactable, use .attr("display", "none");
Don't have a fiddle, but you should be able to copy paste the above line and run it from the console at http://syntagmatic.github.io/parallel-coordinates/ and see the effect on the chart in the Bundling section.
Here is the effect - before and after respectively

Interactivity on map using SVG and RaphaelJS with Links

I've been researching the easiest way to create an interactive map for my company with a custom of USA map I've created in Illustrator. I found this tutorial: http://parall.ax/blog/view/2985/tutorial-creating-an-interactive-svg-map which is very complete and will help me partially to achieve the results im looking.
But what about when i want to add a link on click and Text on hover of the region to each area of the map?
I'm not well versed with JavaScript so I will appreciate a lot the help and understanding from the community.
Let's assume you have an element called regionShape defined in raphael which corresponds to one of the regions in your map. Adding a link on click should be quite easy:
regionShape.node.onclick = function(e) {
window.location.href = "somepage.html";
}
In order to display a text on hover, I would recommend using jQuery. What I normally do is define a div element #hoverInfo and set its css display property to none, and then modify this property with rafael node.onmouseover, like this:
regionShape.node.onmouseover = function(e) {
$("#hoverInfo").css("display", "block");
};
And then you remove it by using onmouseout:
regionShape.node.onmouseout = function(e) {
$("#hoverInfo").css("display", "none");
};

Ruby on Rails - Gmap4Rails popup for a bigger map

I'm a rails beginner and am using rails 3.2.3.
In my app I'm using the awesome Google-Maps-for-Rails by apneadiving (it's just awesome)
Everything works wonderfully but I have got an issue and didn't find any answers here and there for what I want to do.
Basically I'm displaying a small map and wanted to have a button bellow it and when users clicked it, a bigger map would be displayed of that location.
(basically it would be the same map, only with a bigger size)
Something like this:
<input type="button" onclick="myFunction()" value="Show a bigger map" />
Bu my question is what to put inside that javascript function and how do I say a bigger map with #gmaps values should be displayed?
Create a new id with bigger With and Height in the gmaps css?
How to provide the JS the data from my #gmaps?
Any tips?
Sorry if this is a naive question, I'm still getting used to RoR and the Gmaps4Rails gem.
Thanks in advance for your time.
Regards
I'm not quite sure of what you want to do, but I'd say it's really easy to copy the parameters of one map to another.
Indeed, the whole code needed to create a map is visible in your html, simply reproduce the steps.
The gmaps_helper will do the job for your little map. Basically, it follows the following steps:
Gmaps.map = new Gmaps4RailsGoogle();
//mandatory
Gmaps.map.initialize();
// then some code depending on your options
Gmaps.map.markers = some_array;
Gmaps.map.create_markers();
Whenever you want to duplicate the map, you should simply follow the same steps:
Gmaps.bigmap = new Gmaps4RailsGoogle();
//mandatory to have the map created in the proper place
Gmaps.bigmap.map_options.id = the_id_of_your_html_div;
//still mandatory
Gmaps.bigmap.initialize();
//copy the specific parameters from the other map
Gmaps.bigmap.markers = Gmaps.map.markers;
Gmaps.bigmap.create_markers();

how to describe or highlight certain points in charts and give hyperlink on that points

I am using protovis for charts....I am kind of a new here...
What I want to do is I want to show area charts. And in that I want to show few points with different color or highlight some point...And when I click on that point I want to open up new page or show some panel on same page...Any idea how to do that with protovis? If it is not possible with the protovis can you suggest some other framework which does that?
I think you're looking for is something like this:
vis.add(pv.Area)
.data(data)
.left(function(d) x(d.x))
.height(function(d) y(d.y))
.anchor("top").add(pv.Dot)
.size(20)
.event("click", function (d) alert("Clicked point " + this.index));
The important part is the .event("click", function (d) some_code()) bit. If you're using pure JavaScript, you would do .event("click", function (d) { return some_code(); }).
Here's a working (albeit sloppy) example.
You might also want to note that Protovis is being superseded by Mike Bostock's D3.
I don't know about protovis, but you can do that in html.
http://www.w3schools.com/tags/tag_map.asp
I hope you are looking for something like this.

Categories