-
| Error Rendering SVG with Node.js Using @observablehq/plotSummaryI encountered an issue when attempting to render an SVG using  Reproduction StepsThe following simple code works as expected, generating a valid base64-encoded PNG image from an SVG: import sharp from "sharp";
import * as Plot from "@observablehq/plot";
import { JSDOM } from "jsdom";
const data = [
  { a: 1, b: 10 },
  { a: 2, b: 20 },
  { a: 3, b: 30 },
];
const plot = Plot.plot({
  document: new JSDOM().window.document,
  marks: [Plot.dot(data, { x: "a", y: "b", fill: "green" })],
});
const sharpOut = await sharp(Buffer.from(plot.outerHTML, "utf-8"))
  .png()
  .toBuffer();
const base64Image = sharpOut.toString("base64");
console.log(base64Image);However, when attempting to render a more complex SVG that includes projections and geospatial data, the code fails with the following error: Here is the code that causes the issue: import sharp from "sharp";
import * as d3 from "d3";
import * as Plot from "@observablehq/plot";
import { JSDOM } from "jsdom";
const country_outline = {
  type: "Feature",
  id: "250",
  properties: { name: "France" },
  geometry: {
    type: "MultiPolygon",
    coordinates: [[[[-51.658716587165856, 4.155807753115468], [-52.24912249122491, 3.241826107316186], [-52.555125551255514, 2.503870556263422]]]],
  },
};
const country_railway_stations = {
  type: "FeatureCollection",
  features: [
    { type: "Feature", properties: { name: "Paris", id: "1" }, geometry: { type: "Point", coordinates: [2.3522219, 48.856614] } },
    { type: "Feature", properties: { name: "Lyon", id: "2" }, geometry: { type: "Point", coordinates: [4.835659, 45.764043] } },
    { type: "Feature", properties: { name: "Marseille", id: "3" }, geometry: { type: "Point", coordinates: [5.36978, 43.296482] } },
    { type: "Feature", properties: { name: "Toulouse", id: "4" }, geometry: { type: "Point", coordinates: [1.444209, 43.604652] } },
    { type: "Feature", properties: { name: "Nice", id: "5" }, geometry: { type: "Point", coordinates: [7.265592, 43.710173] } },
  ],
};
const x_middle = 4;
const y_middle = 51;
const zoom = 4;
const plot = Plot.plot({
  document: new JSDOM("").window.document,
  projection: {
    type: d3.geoAzimuthalEquidistant,
    domain: d3.geoCircle().center([x_middle, y_middle]).radius(zoom)(),
  },
  color: { scheme: "PuBu" },
  marks: [
    Plot.geo(country_outline),
    Plot.dot(country_railway_stations.features, {
      x: (d) => d.geometry.coordinates[0],
      y: (d) => d.geometry.coordinates[1],
      channels: { name: "name" },
      tip: true,
    }),
  ],
});
plot.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/2000/svg");
plot.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
const sharpOut = await sharp(Buffer.from(plot.outerHTML, "utf-8"))
  .png()
  .toBuffer();
const base64Image = sharpOut.toString("base64");
console.log(base64Image);Expected BehaviorAccording to the documentation and my own notebook, the code should render an SVG that includes the projected geographical data, which can then be converted to a PNG using  Actual BehaviorThe code throws a  Environment
 Please let me know if any additional details are needed, or if there's a workaround or fix that can be applied. | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
| The workaround is probably to remove  | 
Beta Was this translation helpful? Give feedback.
The workaround is probably to remove
tip: true?