A corporation manager and dashboard for EVE Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

48 lines
1.5 KiB

  1. $(function() {
  2. $("#map").html("<p>Loading map data...</p>");
  3. $.getJSON( "map/data.json", function(data) {
  4. $("#map").empty();
  5. var svg = d3.select("#map").append("svg")
  6. .attr("width", 1000)
  7. .attr("height", 1000); // TODO: dynamic
  8. var xmin = Infinity, xmax = -Infinity,
  9. ymin = Infinity, ymax = -Infinity;
  10. for (var sid in data["galaxy"]) {
  11. var system = data["galaxy"][sid];
  12. var x = system["coords"][0];
  13. var y = system["coords"][2];
  14. if (x < xmin) xmin = x;
  15. if (x > xmax) xmax = x;
  16. if (y < ymin) ymin = y;
  17. if (y > ymax) ymax = y;
  18. }
  19. var width = xmax - xmin;
  20. var height = ymax - ymin;
  21. var scale = 1000;
  22. svg.attr("viewBox", "0 0 " + scale + " " + scale);
  23. svg.selectAll("circle")
  24. .data(Object.values(data["galaxy"]))
  25. .enter()
  26. .append("circle")
  27. .attr("cx", (d) => {
  28. var x = d["coords"][0];
  29. return (x - xmin) / width * scale;
  30. })
  31. .attr("cy", (d) => {
  32. var y = d["coords"][2];
  33. return (y - ymin) / height * scale;
  34. })
  35. .attr("r", 1)
  36. .attr("class", (d) => {
  37. var sec = d["security"];
  38. var klass = sec < 0.05 ? "null" :
  39. Number(sec).toFixed(1).replace(".", "_");
  40. return "system sec-" + klass;
  41. });
  42. });
  43. });