svg - customized bargraph's background in rapheal -


i new in svg , raphael javascript.

i creating bar graphs raphael.the bar graphs having "stripped" background. bar graphs being rendered in "path" of "svg".according me achieve exact , feel there 2 ways:

1)i have code path's background. or 2)i need provide background image should repeat through out path.

i not code first approach.

so,here second approach:

"r1" bar graph being created @ $("#first_graph"). want customize background of bar graph.to achieve selected path responsible graph section , setting background fron pattern.

script part:

r1.hbarchart(0, 0, 650, 90, [base_array_1, calc_array_1], {colors: ["#278bd1","#052f4d"],stacked: true}).hover(fin, fout);

$("#first_graph").find("path:odd").attr({ fill: "url(#image)",

});

pattern part.... declared @ html:

<svg id='pattern' xmlns="http://www.w3.org/2000/svg" version="1.1">  <defs>  <pattern id='image' width="1" height="1" viewbox="0 0 100 100" preserveaspectratio="none">  <image xlink:href="../images/sub_chart_blue_bg.png" width="100" height="100" preserveaspectratio="none"></image>         </pattern>       </defs>     </svg> 

now, problem ...iam facing(in second approach) that:

the image being stratched.

i request me providing 1 approch create stripped background of graph(path of svg).

here how can it. not sure why yours not work.

so answer question "can 1 me create "stripped background image" of path." @ demo

var p = raphael('notepad',500,500); var pad = p.path("m25.221,1.417h6.11c-0.865,0-1.566,0.702-1.566,1.566v25.313c0,0.865,0.701,1.565,1.566,1.565h19.111c0.865,0,1.565-0.7,1.565-1.565v2.984c26.787,2.119,26.087,1.417,25.221,1.417zm15.666,29.299c-0.346,0-0.626-0.279-0.626-0.625s0.281-0.627,0.626-0.627c0.346,0,0.627,0.281,0.627,0.627s16.012,29.299,15.666,29.299zm24.376,26.855c0,0.174-0.142,0.312-0.313,0.312h7.27c-0.173,0-0.313-0.142-0.313-0.312v4.3c0-0.173,0.14-0.313,0.313-0.313h16.792c0.172,0,0.312,0.14,0.312,0.313l24.376,26.855l24.376,26.855z");  pad.transform("t200,200"); pad.scale(10); pad.attr({fill:'url("http://www.zingerbug.com/backgrounds/background_images/gray_diagonal_stripes_seamless_background_pattern.jpg")'}); 

enter image description here

the image gets stretched because large or has big resolution. make close original, need resize image according path size, use background. think should fix problem.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -