<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Chart · Tools</title><link>https://tools.eknath.dev/tags/chart/</link><description>Chart updates from Tools</description><language>en-us</language><atom:link href="https://tools.eknath.dev/tags/chart/index.xml" rel="self" type="application/rss+xml"/><lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate><item><title>Pie chart from a few numbers</title><link>https://tools.eknath.dev/tools/pie-chart/</link><guid isPermaLink="true">https://tools.eknath.dev/tools/pie-chart/</guid><category>tool</category><category>planning</category><category>chart</category><description>Turn a few numbers into a pie chart with shares and a legend, from a link.</description><content:encoded><![CDATA[<h2 id="what-this-is-for">What this is for</h2>
<p><strong>Use it</strong> when you want to see how a total splits into parts, for example todos by state.</p>
<p><strong>Skip it</strong> when you need exact values on many categories; use a table.</p>
<p>The page is filled in from its address, so a person or an AI model can build the link and you only have to open it.</p>
<h2 id="link-to-a-filled-in-view">Link to a filled-in view</h2>
<p>Put the values in the address after <code>#</code>. The part after <code>#</code> stays in your browser and is never sent to a server, so it is the right place for private data. <code>?</code> works too. Two links to the same example:</p>
<ul class="ex-links">
  <li><span class="ex-text"><strong>Result only</strong><span>large, for a report or a screenshot</span></span>
  <a class="article-action" href="https://tools.eknath.dev/tools/pie-chart/#title=Todos&#43;by&#43;state&amp;data=Done%3D5%0APending%3D3%0ABlocked%3D1&amp;mode=present">Open ↗</a>
  <button type="button" class="ex-copy" data-copy-url="/tools/pie-chart/#title=Todos&#43;by&#43;state&amp;data=Done%3D5%0APending%3D3%0ABlocked%3D1&amp;mode=present" aria-label="Copy the link: result only" title="Copy link"><svg viewBox="0 0 24 24" aria-hidden="true" class="ex-copy-icon"><rect x="9" y="9" width="11" height="11" rx="2.5"/><path d="M5.5 15H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v.5"/></svg><svg viewBox="0 0 24 24" aria-hidden="true" class="ex-copy-done"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg></button></li>
  <li><span class="ex-text"><strong>Editable tool</strong><span>change the values and watch the result</span></span>
  <a class="article-action" href="https://tools.eknath.dev/tools/pie-chart/#title=Todos&#43;by&#43;state&amp;data=Done%3D5%0APending%3D3%0ABlocked%3D1">Open ↗</a>
  <button type="button" class="ex-copy" data-copy-url="/tools/pie-chart/#title=Todos&#43;by&#43;state&amp;data=Done%3D5%0APending%3D3%0ABlocked%3D1" aria-label="Copy the link: editable tool" title="Copy link"><svg viewBox="0 0 24 24" aria-hidden="true" class="ex-copy-icon"><rect x="9" y="9" width="11" height="11" rx="2.5"/><path d="M5.5 15H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v.5"/></svg><svg viewBox="0 0 24 24" aria-hidden="true" class="ex-copy-done"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg></button></li>
</ul>

<p>Add <code>mode=present</code> to any link to show only the result.</p>
<table>
  <thead>
      <tr>
          <th>Parameter</th>
          <th>What it is</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>data</code></td>
          <td>Values: one name=number per line, or separated by commas. For example: Done=5, Pending=3, Blocked=1. Percent signs and spaces are fine. Write 1000, or use one value per line, for thousands.</td>
      </tr>
  </tbody>
</table>
<p>Without JavaScript, the <code>data</code> value in the link is the table: each <code>name=number</code> pair is one slice, and its share is its number divided by the total.</p>
<h3 id="optional-text">Optional text</h3>
<p>Every tool also accepts five optional text parameters. Leave any of them out and nothing is drawn for it, so there is no empty heading or gap.</p>
<table>
  <thead>
      <tr>
          <th>Parameter</th>
          <th>What it is</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>title</code></td>
          <td>A heading above the result.</td>
      </tr>
      <tr>
          <td><code>description</code></td>
          <td>One or two sentences on what the result shows.</td>
      </tr>
      <tr>
          <td><code>summary</code></td>
          <td>A headline for people. Left out, the tool writes its own.</td>
      </tr>
      <tr>
          <td><code>legend</code></td>
          <td>How to read it, for example &ldquo;Blue is done&rdquo;.</td>
      </tr>
      <tr>
          <td><code>note</code></td>
          <td>A footnote: a source, a date or a caveat.</td>
      </tr>
  </tbody>
</table>
<p>Text is cut to a sensible length (100 to 300 characters) and shown as plain text, so markup in it is never run.</p>
<h2 id="for-agents">For agents</h2>
<p>Build the link above with your own values and give it to the user. Or run the logic without a browser:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>node cli.mjs pie-chart <span style="color:#e6db74">&#39;{&#34;data&#34;: &#34;Done=5, Pending=3, Blocked=1&#34;}&#39;</span>
</span></span></code></pre></div><p>The result is JSON: <code>ok</code>, <code>summary</code>, <code>matches</code> (a list of <code>{id, label, detail}</code>) and <code>view</code>, the data the page draws. A value that cannot be used gives <code>ok: false</code> and a <code>summary</code> that says what to fix. Every example in the data file is checked by <code>npm test</code>.</p>
<h2 id="related">Related</h2>
<ul>
<li><a href="https://tools.eknath.dev/">Tools home</a>: all the tools, and the registry that lists their parameters.</li>
</ul>
]]></content:encoded></item></channel></rss>