Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Skrypt PHP tworzący grafy w języku SVG
makos
post 10.06.2007, 19:41:36
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 12.05.2007

Ostrzeżenie: (0%)
-----


Mam pytanko w jaki sposób zrobić odnisienie do współrzędnych cx i cy tak aby wartości były pobierane ze zmiennych $x=42 i $y=-236. W przyszłości wartości mają być pobierane z tablicy, ale już na samym początku mam problem. Jeśli zamiast cx="<?=$x;?>" wstawi się cx="42" tp wszystko działa normalnie ale bez odniesienia.
oto skrypt:
  1. <?php
  2. header("Content-type: image/svg-xml");
  3. echo '<?xml version="1.0" standalone="no"?>';
  4. ?>
  5.  
  6. <svg width="800" height="800">
  7. <g id="graph0" class="graph" transform="scale(1.33333 1.33333) rotate(0) translate(4 334)">
  8. <polygon style="fill:white;stroke:white;" points="-4,4 -4,-334 341,-334 341,4 -4,4"/>
  9.  
  10.  
  11. <script type="text/javascript"> <![CDATA[
  12. function zmien(id, atrybut, wartosc)
  13. {element = evt.getTarget().getOwnerDocument().getElementById(id);
  14. element.setAttribute(atrybut, wartosc);}
  15. ]]></script>
  16. />
  17.  
  18. <?php
  19. $x=42;
  20. $y=-236;
  21. ?>
  22.  
  23. <g>
  24. <ellipse id="w1" cx="<?=$x;?>" cy="-236" rx="20" ry="18"
  25. fill="yellow" stroke="green" stroke-width="0.04cm"
  26. onmouseover="zmien('w1','stroke','red');"
  27. onmouseout="zmien('w1','stroke','green');"
  28. />
  29. <a xlink:href="http://www.wp.pl" xlink:title="MK">
  30. <text text-anchor="middle" x="42" y="-236" 
  31. style="font:Arial; font-size:7.34pt; ">A</text>
  32. </a>
  33. <ellipse id="w2" cx="292" cy="-239" rx="20" ry="20"
  34. fill="yellow" stroke="green" stroke-width="0.04cm"
  35. onmouseover="zmien('w2','stroke','red');"
  36. onmouseout="zmien('w2','stroke','green');"
  37. />
  38. <a xlink:href="http://www.wp.pl" xlink:title="MK">
  39. <text text-anchor="middle" x="292" y="-236" 
  40. style="font:Arial; font-size:7.34pt; ">B</text>
  41. </a>
  42. </g>
  43.  
  44. <g id="edge1" class="edge">
  45. <path fill="green" stroke="green" stroke-width="1.5"
  46. d="M 62 -239 L 272 -239 z
  47. M 265 -241 L 265 -237 L 272 -239 z" transform="rotate(0 42 -239)"/>
  48. </g>
  49.  
  50. <g id="edge2" class="edge">
  51. <path fill="green" stroke="green" stroke-width="1.5"
  52. d="M 62 -239 L 272 -239 z
  53. M 265 -241 L 265 -237 L 272 -239 z" transform="rotate(90 42 -239)"/>
  54. </g>
  55. </svg>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
kubarek
post 10.06.2007, 20:45:18
Post #2





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 19.02.2007

Ostrzeżenie: (0%)
-----


a czy teraz się nie wyświetla
Cytat
...<ellipse id="w1" cx="42" cy="-236" rx="20" ry="18" ...
?
bo powinno


--------------------
// ...
Co nieco o mnie ;)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 09:46