How can I apply slide methods of jQuery to a non-SVG DOM element in d3.js?
Is there something I can use out of the box?
No, there's nothing out of the box, but you can do this by simply animating the relevant dimensional attributes, e.g. slide down would be something like
d3.select("#element").attr("height", 0)
.transition().duration(500).attr("height", realheight);
Depending on what you want to animate, you might have to work with clip paths to hide part of the element as it is being slid in.
You can of course simply use the JQuery methods. There should be no problem with that unless you want to run D3 transitions on the same object at the same time.
Related
Is there such a thing as an edit control (meaning a rectangle of text containing a caret and modify-able by user input) for THREE.js? If so, could somebody give me an example of its use? . and, if not, must this functionality be simulated through DOM/JavaScript?
There is no such control class in three.js. You probably want to work with plain HTML textarea elements. If you want to apply a 2D or 3D transformation to a DOM element, consider to include one of the CSS renderers of three.js into your project:
https://threejs.org/docs/index.html#examples/en/renderers/CSS2DRenderer
https://threejs.org/docs/index.html#examples/en/renderers/CSS3DRenderer
We need to make it move like here.example The code is complex there, I can't figure it out.
I wrote the code my code, but I don’t understand how to make the tooltip move horizontally not behind the mouse, but near the nearest horizontal mark (as in the example)
It is not yet clear where the text above the bold text in the tooltip comes from. How to remove it so that it looks like in the picture?
How do I make the title of the tooltip match the label on the X-axis?
There are many ways to accomplish this. The way I typically do this is to create a series of SVG elements -- such as circles or rects -- using the same scale and data as the paths.
You can make these objects visible or invisible. Either way, you can attach mouseenter, mouseleave events to each to render and populate the tooltip.
I will like to override the style for charts in dc.js
I want to change, fonts, colors, font-weights, for axes, legends, and similar.
What is the best way to make this changes, without modifying the lib?
Styles/elements that are not driven by data
Anything that is not driven by data is best modified by using CSS. I usually just use the browser's inspector/developer tools to determine the correct selectors to use, but you can also get some clues by looking at the sass source for dc.css.
All of the visual attributes you list above fall in this category. Generally anything that is outside of the plot area is not data-driven.
Many of the visual attributes for things inside the chart are also not data-driven. For example, if you wanted to change the text labels inside the plot area, those styles all come from dc.css and are best modified with CSS.
Styles/elements that are driven by data
For changing anything that is data-driven, using a pretransition hook is going to be the best way - this fires after a render or redraw when all elements have been added or removed (but before they transition from old values to new values).
The form for this is
chart.on('pretransition', function(chart) {
chart.select('something').attr(...);
});
where something is a selector like rect.bar - in-chart selectors are starting to be documented in the Wiki.
I am using Flot to plot images for our project. For pre-defined shapes like line, pie, I can add tooltip through flot.tooltip.
However, we have some images that are drawn through Html5 canvas API, such as Here. I would like to add a tooltip for the red rectangle and another tooltip for the blank area. Any library to make it work?
With canvas there isn't a good way to detect when the mouse hovers over a particular drawn item; it's just a buffer, with no idea of what operations were used to draw into it. Flot's own hover detection has no concept of what was drawn on the canvas; it just knows that, e.g. the pie starts at a particular point and extend outwards a certain number of pixels.
So no matter what, you will have to write a function that accepts a mouse event, examines whatever data you used to draw the image, and decides what that corresponds to.
Where Flot could help is in providing a way to override the built-in hover function with your own; then the tooltip plugin would simply work with your function. Since you can't currently do that, you have a choice of a) modifying the tooltip plugin to use your function, or b) registering your own mousemove listener on the overlay element, which then generates 'fake' plothover events for the tooltip plugin to consume.
I'm setting up an experimental html5 website using canvas.
I am drawing 3 circles all next to each other and all I want to know is how to be able to select them.
I'd like them to become links, in a way. Not tags, since everything's gonna be created using javascript.
Something like kinetic JS : http://www.kineticjs.com/, but without the extra library.
I have found some scripts that are using ghost canvas and contexts, but the examples are for dragging and stuff. I only want to be able to select my shape and execute some code.
Thank you!
I am thinking you might want to look into the IsPointInPath() method. It will help you figure out whether or not the mouse clicked on your canvas object.
See Detect mouseover of certain points within an HTML canvas?
if you are talented in xml i suggest you to use canvas + SVG (http://www.w3schools.com/svg/)
And follow this simple example.
http://jsvectoreditor.googlecode.com/svn/trunk/index.html
regarding to SVG and Canvas , the differences are obvious, as you can load bitmaps in SVG, and you can draw lines using the canvas API. However, creating the image may be easier using one technology over the other, depending on whether your graphic is mainly line-based or more image-like.