raphael

Weird chart maximum axis x value (Real Challenge)

∥☆過路亽.° 提交于 2019-12-04 06:15:48
问题 Here you can see a chart created using graphael. http://jsfiddle.net/aNJxf/4/ It is shown with it's y axis correctly. The first y value is 0.03100 and the maximum value at y axis is at 0.031 If we change the value to 0.03104 the maximum value at y axis becomes 1.03 and now all our points are in the bottom. If we add another 0.00001, which makes that value 0.03105, the maximum at the axis y becomes 0.531 and now our points are shown at the wrong position of the chart. It seems that something

Get y coordinate of point along SVG path with given an x coordinate

旧街凉风 提交于 2019-12-04 04:50:17
I am using raphael.js to draw a simple SVG line graph like this: When the user hovers the graph, id like to display a popover pointing to the line at the X position of the cursor, and at the Y position where the line is for that X position like so: I need to take the path and find the Y coordinate for a given X coordinate. Based on @Duopixel's D3 solution, I wrote the following function for my own use, in pure javascript using DOM API: function findY(path, x) { var pathLength = path.getTotalLength() var start = 0 var end = pathLength var target = (start + end) / 2 // Ensure that x is within

Raphaeljs renders all text as Italic in IE

ε祈祈猫儿з 提交于 2019-12-04 03:39:25
I'm using RaphaelJS for visually representing some data. The underlying technology is SVG so obviously things don't always work that well in IE, but the library does a relatively ok job of still rendering something useful, although it often tends to look pretty poor. In any case, I can't seem to get around this basic issue. Text is rendered fine in Chrome or FireFox, but everything renders as bold and italic in IE8. To see my issue in action, go to the RaphaelJS playground and use the following code paper.text(100, 100, "this is the text") Here is the result in Chrome and IE. Is there any

How can I check if something is a Raphael object?

时间秒杀一切 提交于 2019-12-04 03:20:53
问题 Given a JavaScript object, how can I check if it is a Raphael object (not the paper, but a circle, path, etc.)? Raphael.el represents the generic element prototype; I think I want to test x.__proto__ === Raphael.el in a cross browser way, but I am not completely sure. 回答1: To elaborate a little and add some more relevant info (it took me a little while to figure out the accepted answer, and I'm clearly not alone looking at the other answers, also, the accepted answer only works for one type

RaphaelJS Set.forEach()

时间秒杀一切 提交于 2019-12-04 02:20:07
I read in the documentation raphaeljs description of Set.forEach , and can't understand how it works. Please can anyone give me an example of usage. Here you have a working example: http://jsfiddle.net/9X6rM/ And this is the important part of It: set.forEach(function(e){ e.attr({fill:'#000'}) }) Its a little bit tricky at first, but its pretty handy when you get it. You need to pass to the forEach() method the function that you want to execute on each element, and this function need to have, like an argument, a variable name to bind to the element. So in this case e is the rectangle that is

How to add text to a raphael js element

半城伤御伤魂 提交于 2019-12-04 01:47:18
I want to add text to a element in raphael js, I have added text with r.text(30, 20, "ellipse").attr({fill: color}); But how to add this text to ec = r.ellipse(190, 100, 30, 20); regards Raphael does not have child/parent relationship between elements, so you will set same position for them e.g. ec = paper.ellipse(190, 100, 30, 20); paper.text(190, 100, "ellipse").attr({fill: '#ff0000'}); So if you want a ellipse with text, create your own JavaScript object which handles positioning of both. or alternate way is to group elements via set e.g. var eltext = paper.set(); el = paper.ellipse(0, 0,

How to use svg filters with raphael js?

久未见 提交于 2019-12-04 01:28:03
问题 i would like to know, which techniques should i use to apply svg filters to raphael paths? I know that raphael tries to be as much cross browser with IE it can, but i was wondering if there was a way to add the filters using javascript. 回答1: I built a library to do this. You can do something like: var paper = Raphael("test"); var circle = paper.circle(100, 100, 50, 50).attr({fill: "red", stroke: "black"}); circle.emboss(); Have a look at a fiddle: http://jsfiddle.net/chrismichaelscott/5vYwJ/

how to change svg text tag using javascript innerHTML

我怕爱的太早我们不能终老 提交于 2019-12-03 22:18:52
i was using raphaeljs , and i want to show html(not only text) in svg, so i use this code : var r = Raphael("holder", 200, 300); var t = r.text(10, 10, "ssdwqdwq"); t.node.innerHTML='dddd' but i cant change the svg's content , so i console it in firebug , console.log(t.node) it show this : <text x="10" y="13.5" text-anchor="middle" style="font: 10px "Arial";" font="10px "Arial"" stroke="none" fill="#000000"> so how to change the text using javscript on svg thanks SVG nodes don't have a innerHTML property (they're not HTML). Use textContent instead: t.node.textContent='dddd' if the code for the

Boolean operations on a SVG pathstring

邮差的信 提交于 2019-12-03 21:14:13
问题 I've come to a conceptually difficult problem. In short, I need to find the vector path of two vector paths combined through different boolean operations. Such as the Union, the Difference, the Intersection, and Subtraction. It would be nice if I could do it similar to how Canvas does it's globalCompositeOperation. How in the world would I go about doing this? 回答1: There is a JavaScript library that allows for boolean operations on SVG paths under the condition that the path is a polygon.

Raphaël and D3.JS - Better Browser Compatibility

老子叫甜甜 提交于 2019-12-03 20:38:56
Is it possible to use D3 and Raphael together so that visualizations are produced by D3 (using D3's API to produce svg output) and correctly visualized in IE by Raphael ? I appreciate any example/sample code. Yes you can. We've improved r2d3 from a compatibility project to an IE fallback for D3. This was achieved by having D3 wrap Raphael elements which we extended with methods such as setAttribute. This enables D3 to work with Raphael elements like they were DOM nodes. The project still needs some work to iron out issues with things like groups, but I encourage you to check it out to see if