PlotSet LogoPlotSet

How to Create an Interactive SVG

A step by step walkthrough for turning an SVG drawing into a clickable diagram with popups or a text panel in PlotSet.

约 10 分钟

You will end up with a drawing whose parts open an explanation when a reader clicks or hovers over them.

Expect about ten minutes. Most of it goes on checking that each id in your data matches an element in the drawing.

你需要的数据

One row per clickable part, with the id of an element in the SVG and the text to show for it.

示例 CSV
idheadingsubheadingcontentlink
steam-wandSteam wandFroths milkAngle the tip just below the surface.
porta-filterPortafilterHolds the coffeeLock it in a quarter turn.
drip-trayDrip trayCatches spillsEmpty it every day.
power-buttonPowerSwitches the machine onWait two minutes to warm up.
备注

The id must match the id, class, name or aria-label of an element in the SVG, ignoring case.

Only the id is required. The heading falls back to the id if left blank.

A category column can recolour the matched parts and build a legend.

A reveal column names an element that stays hidden until its row is selected.

操作步骤

PlotSet 中从空白模板到完成图表的具体点击路径。

  1. 01

    Open the Interactive SVG template

    From the PlotSet dashboard, start a new project and choose Interactive SVG from the Other category. It loads with an espresso machine and five numbered parts.

    PlotSet 的模板选择界面:左侧是图表分类列表,中间展开 Bar Charts 分类的模板网格,Bar Chart 模板卡片上显示「Select」按钮。
    每份指南都从这里开始:先选分类,再选模板,不管你要做哪种图表,用的都是同一个网格。
  2. 02

    Add your drawing

    Open the SVG tab and give a URL or paste your SVG markup. Choose how the drawing fits, sizes and aligns inside the chart.

  3. 03

    Add your data

    Import a CSV or .xlsx file, paste rows from a spreadsheet, or connect a Google Sheet. Each row is one part of the drawing.

    PlotSet 编辑器的数据视图:表格中 Name、Value、Region 三列填着加拿大各省的数据,旁边的「Data」面板提供 CSV 上传、「Magic Import」和 Google Sheet 同步。
    这里的数据视图取自一个条形图项目。你可以上传 CSV、用「Magic Import」从图片里提取数字,或同步 Google Sheet,每种图表类型的面板都一样。
  4. 04

    Bind the columns

    Choose the id column, then the heading, subheading and content columns. Add a category or a link column if you have them.

    PlotSet 数据面板中高亮的列绑定:「Label/time」对应 A 列,「Values」对应 B 列,「Filter/color」对应 C 列,下方是「Auto Binding」按钮。
    绑定决定哪一列作标签、哪一列提供数值、哪一列决定颜色。「Auto Binding」(自动绑定)会根据表头推测,所以要核对一遍,别想当然。
  5. 05

    Choose click or hover

    In the Interaction tab, pick the trigger, how unselected parts fade, and whether a click follows the row's link.

    PlotSet 编辑器停在「Preview」标签页:画布上是做好的 Interactive SVG,右侧的设置面板用红框标出。
    Interactive SVG 的「Preview」标签页。所有样式设置都在红框标出的这个面板里,每个设置各自占一个标签页:外观、标题、脚注,以及这种图表类型特有的选项。
  6. 06

    Pick a popup or a panel

    The Popup content and Text panel tabs set where the details appear and how they are styled.

  7. 07

    Check it on a phone

    The Mobile tab sets whether readers see the drawing, the text or both below a set width.

  8. 08

    Publish and embed

    Publish for a live chart and copy the embed code from the Share dialog. Click every part once before you share it.

    PlotSet 编辑器工具栏中高亮的「Share」按钮,紧挨着「Export」按钮。
    点「Share」,完成的图表就会变成一个公开链接和一段嵌入代码。

从已加载示例数据的 Interactive SVG 模板开始,再替换成你自己的数据。

打开模板

发布、嵌入或导出

最后一段路对每种图表都一样:「Share」(分享)把图表变成一个在线的公开链接和一段嵌入代码,「Export」(导出)把它输出成静态文件。

Share:公开链接与嵌入代码

打开嵌入代码和公开链接的开关,图表就发布出去了。链接可以放心发给任何人;嵌入代码以 iframe 的形式放进任意页面,悬停提示和交互效果都会保留。之后修改了图表,点「Recreate」就能把改动同步到链接和嵌入代码两边。

PlotSet 编辑器工具栏中高亮的「Share」按钮,紧挨着「Export」按钮。
点「Share」,完成的图表就会变成一个公开链接和一段嵌入代码。
PlotSet 的「Share」对话框:用于启用嵌入代码和公开链接的开关,「Link」「Embed」「Facebook」「Reddit」「Twitter」「LinkedIn」「Email」几个按钮,以及带「Copy」按钮的图表公开链接。
打开嵌入代码和公开链接的开关,然后复制链接或取用 iframe。之后再修改图表,点「Recreate」就能把改动同步给所有已拿到链接的人。

Export:SVG、PNG 或 JPG

「Export」会按你需要的尺寸输出一份静态副本。SVG 放到多大都清晰,还能在设计工具里继续编辑;幻灯片和文档用 PNG 或 JPG 最稳妥。想让图片在高分屏上够锐利,关键就是那个倍数设置。

PlotSet 编辑器工具栏中高亮的「Export」按钮。
要做成幻灯片或报告里的静态文件,就走「Export」这条路。
PlotSet 的「Export chart」对话框:倍数选择器设为 2x,宽高输入框填的是 1000 和 600,展开的格式菜单里列出 SVG、PNG 和 JPG。
SVG 放到多大都清晰,还能在设计工具里继续编辑;做幻灯片用 PNG 或 JPG 最稳妥。导出前先设好倍数,图片在高分屏上才够锐利。

Interactive SVG 的样式提示

Name your layers

Give each part of the drawing a clear id in your design tool before you export the SVG.

Keep text short

Two or three lines per part read well in a popup and fit the panel.

Number the parts

Markers with numbers show readers where to click and give the text an order.

Dim what is not covered

Fading the parts with no row keeps the eye on what is interactive.

制作 Interactive SVG 时的常见错误

A part does not respond

Its id does not match an element in the SVG. Compare the spelling with the layer name.

The drawing does not load

The URL is blocked or missing cross-origin headers. Paste the markup instead.

The panel text is cut off

The panel does not scroll. Shorten the text or switch to popups.

Nothing happens on a phone

Hover does not exist on touch screens. Switch the trigger to click.

深入了解 Interactive SVG

不确定 Interactive SVG 是否是正确选择?查看它是什么、何时使用以及何时不使用。

关于 Interactive SVG

Interactive SVG:常见问题

Yes. Export it as SVG with the layer names kept as ids, then paste the markup or link to it.

现在制作你的 Interactive SVG

免费开始,300+ 模板任选。无需信用卡。