npm install react-raphael

reactify raphael
# or specify the externals in webpack config
npm install --save raphael
# install react-raphael in your react-raphael project
npm install --save react-raphael
- react-raphael-example
- react-raphael-map
- react-raphael-chart
- react-raphael-workflow
- react-raphael-scrawl
- react-raphael-mine-sweeping
``js
var React = require('react');
var ReactDOM = require('react-dom');
const {Raphael,Paper,Set,Circle,Ellipse,Image,Rect,Text,Path,Line} = require('react-raphael');
class App extends React.Component{
render(){
var data = [
{x:50,y:50,r:40,attr:{"stroke":"#0b8ac9","stroke-width":5},animate:Raphael.animation({cx:60},500,"<>")},
{x:100,y:100,r:40,attr:{"stroke":"#f0c620","stroke-width":5},animate:Raphael.animation({cx:105},500,"<>")},
{x:150,y:50,r:40,attr:{"stroke":"#1a1a1a","stroke-width":5}},
{x:200,y:100,r:40,attr:{"stroke":"#10a54a","stroke-width":5},animate:Raphael.animation({cx:195},500,"<>")},
{x:250,y:50,r:40,attr:{"stroke":"#e11032","stroke-width":5},animate:Raphael.animation({cx:240},500,"<>")}
]
return (
{
data.map(function(ele,pos){
return (
})
}
}
}
`
#### All Element Props
- Paper
- width number width of the canvas.number
- height height of the canvas.object
- container props of the canvas's container.default value: { style:{}, className:"" }object
- Element
- attr Sets the attributes of the element.object
- animate Creates and starts animation for given element.object
- animateWith Acts similar to Element.animate, but ensure that given animation runs in sync with another given element.function
- click Adds event handler for click for the element.object
- data Adds or retrieves given value asociated with given key. function
- dblclick Adds event handler for double click for the element.object
- drag Adds event handlers for drag of the element. object {move,start,end,mcontext,scontext,econtext}function
- glow Return set of elements that create glow-like effect around given element.object
- hover Adds event handlers for hover for the element. object {in,out,icontext,ocontext}boolean
- hide Makes element invisible. function
- mousedown Adds event handler for mousedown for the element.function
- mousemove Adds event handler for mousemove for the element.function
- mouseout Adds event handler for mouseout for the element.function
- mouseover Adds event handler for mouseover for the element.function
- mouseup Adds event handler for mouseup for the element.function
- load Adds event handler for load for the element.object
- rotate Adds rotation by given angle around given point to the list of transformations of the element.object
- scale Adds scale by given amount relative to given point to the list of transformations of the element.boolen
- stop Stops animation for given element.boolean
- toBack Moves the element so it is the furthest from the viewer’s eyes, behind other elements.boolean
- toFront Moves the element so it is the closest to the viewer’s eyes, on top of other elements.function
- touchcancel Adds event handler for touchcancel for the element.function
- touchend Adds event handler for touchend for the element.function
- touchmove Adds event handler for touchmove for the element.function
- touchstart Adds event handler for touchstart for the element.string
- transform or array Adds transformation to the element which is separate to other attributes, i.e. translation doesn’t change x or y of the rectange. The format of transformation string is similar to the path string syntax:"t100,100r30,100,100s2,2,100,100r45s1.5"object
- translate Adds translation by given amount to the list of transformations of the element.function
- update Adds event handler for update for the element.Extends Element & Container Elements
- Set Extends Element & Draws a circle
- Circle number
- x x coordinate of the centrenumber
- y y coordinate of the centrenumber
- r radiusExtends Element & Draws a ellipse
- Ellipse number
- x x coordinate of the centrenumber
- y y coordinate of the centrenumber
- rx horizontal radiusnumber
- ry vertical radiusExtends Element & Embeds an image into the surface
- Image string
- src URI of the source imagenumber
- x x coordinate of the centrenumber
- y y coordinate of the centrenumber
- width width of the imagenumber
- height height of the imageExtends Element & Creates a path element by given path data string
- Path string
- d path string in SVG formatExtends Element & Creates set of shapes to represent given font at given position with given size
- Print number
- x x position of the textnumber
- y y position of the textstring
- text text to printstring
- font-family family of font objectstring
- font-weight weight of font objectstring
- font-style style of font objectstring
- font-stretch stretch of font objectnumber
- font-size size of the font, default is 16string
- origin could be "baseline" or "middle", default is "middle"number
- letter-spacing number in range -1..1, default is 0Extends Element & Draws a circle
- Rect number
- x x coordinate of the top left cornernumber
- y y coordinate of the top left cornernumber
- width width of the rectnumber
- height height of the rectnumber
- r radius for rounded corners, default is 0Extends Element & Draws a text string & If you need line breaks, put “\n” in the string
- Text number
- x x coordinate positionnumber
- y y coordinate positionstring
- text The text string to drawExtends Path & Draws a line
- Line number
- x1 x coordinate of the start pointnumber
- y1 y coordinate of the start pointnumber
- x2 x coordinate of the end pointnumber
- y2 y coordinate of the end point
#### All Element Ref Function
- Paper
- getPaper function paper of the componentfunction
- Set
- getSet set of the componentfunction
- Element
- getElement element of the component
#### Raphael & Utils
- Raphael you can see http://dmitrybaranovskiy.github.io/raphael/reference.html#Raphaelfunction
- Utils
- createPaper create a paper by Raphael()function
- updatePaper update a paperfunction
- removePaper remove a paperfunction
- create create elements or a set by paper.xxxfunction
- createElement call create to create a elementfunction
- createSet call create to create a setfunction
- updateElement update elements or a set function
- removeSet remove a set from paper function
- removeElement remove a element from paper array
- papers all paper instancearray
- elements all elements or set of the only paper instancefunction` find parent of element by id
- findParentById
Email: liuhong1.happy@163.com