Loading ...
Sorry, an error occurred while loading the content.

66285Re: [svg-developers] Database and SVG file

Expand Messages
  • yannick.bochatay@...
    Nov 14, 2013
      Here's a short example of a svg file. Colors change after calling a server-side script. No library needed.

      <?xml version="1.0" encoding="utf-8"?>
      <svg width="500" height="100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <path id="country_1" d="M0,100 L100,0 L200,100"/>
      <path id="country_2" d="M100,0 L200,100 L300,0"/>
      <path id="country_3" d="M200,100 L300,0 L400,100"/>
      (function() {

      var req = new XMLHttpRequest();

      req.open('GET', 'yourScript.php', true);

      req.onreadystatechange = function (e) {

      if (req.readyState != 4) return;
      if (req.status != 200) { window.alert("error"); return; }

      var obj = JSON.parse(req.responseText),

      for (id in obj) {

      shape = document.getElementById(id);

      value = obj[id];

      switch (true) {
      case (value < 5) : color = "green"; break;
      case (value < 10) : color = "orange"; break;
      default : color = "red"; break;




      All you need is to write "yourScript.php" (php or any server-side language) which queries the database and produces json format like :

      "country_1" : 3,
      "country_2" : 8,
      "country_3" : 12

      Hope it will help.

      ----- Mail original -----
      De: "flyfishac" <flyfishac@...>
      À: svg-developers@yahoogroups.com
      Envoyé: Mercredi 13 Novembre 2013 15:27:55
      Objet: [svg-developers] Database and SVG file

      I'm wondering if anyone can make suggestions on learning how to manipulate an SVG file with a database or if anyone has a simple example with source files.

      I'm a salesman whose territory consists of 3 states. Within those states are counties. As sales begin to increase per county, the Fill Color of that county is edited by me via Inkscape. It would be nice to drive those colors via database and not have to alter the SVG file every time I make a large sale.

      * This can be a very powerful tool for organizations who want to better understand their territories in real time and visualize growth patterns over a period of time.

      I really want to learn how to do this!

    • Show all 3 messages in this topic