home.social

#svg — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #svg, aggregated by home.social.

  1. Years ago I cribbed this from a creative dev whose work I liked

    It uses canvas and js mouse events. I wish it were possible in CSS (or with SVG) or something close to it.

    (I'm working on a platform which is quite limited so we are trying to think of ways to circumvent some of the constraints)

    jsfiddle.net/lharby/ysLgcp8q/

    #JavaScript #Canvas #CSS #SVG

  2. Years ago I cribbed this from a creative dev whose work I liked

    It uses canvas and js mouse events. I wish it were possible in CSS (or with SVG) or something close to it.

    (I'm working on a platform which is quite limited so we are trying to think of ways to circumvent some of the constraints)

    jsfiddle.net/lharby/ysLgcp8q/

    #JavaScript #Canvas #CSS #SVG

  3. Years ago I cribbed this from a creative dev whose work I liked

    It uses canvas and js mouse events. I wish it were possible in CSS (or with SVG) or something close to it.

    (I'm working on a platform which is quite limited so we are trying to think of ways to circumvent some of the constraints)

    jsfiddle.net/lharby/ysLgcp8q/

    #JavaScript #Canvas #CSS #SVG

  4. Years ago I cribbed this from a creative dev whose work I liked

    It uses canvas and js mouse events. I wish it were possible in CSS (or with SVG) or something close to it.

    (I'm working on a platform which is quite limited so we are trying to think of ways to circumvent some of the constraints)

    jsfiddle.net/lharby/ysLgcp8q/

    #JavaScript #Canvas #CSS #SVG

  5. @metaphil ich habe ne eigene Version als svg erstellt. Bedient euch. Könnt die auch gerne ändern, hab ich nur schnell hingerotzt :D

    You're welcome.

    saikinc.dnshome.de/s/GenKINein

    #ki #ai #aislop #aufkleber #svg

  6. Simplest sliced text with absolutely no duplication - not in the markup, not in any pseudos. This means it's contenteditable without requiring JS!

    Live demo on @codepen: codepen.io/thebabydino/pen/VYK

    #CSS #SVG #filter #svgFilter #code #web #dev #webDev #webDevelopment #coding #frontend #textEffect #textEffects

  7. Simplest sliced text with absolutely no duplication - not in the markup, not in any pseudos. This means it's contenteditable without requiring JS!

    Live demo on @codepen: codepen.io/thebabydino/pen/VYK

    #CSS #SVG #filter #svgFilter #code #web #dev #webDev #webDevelopment #coding #frontend #textEffect #textEffects

  8. Simplest sliced text with absolutely no duplication - not in the markup, not in any pseudos. This means it's contenteditable without requiring JS!

    Live demo on @codepen: codepen.io/thebabydino/pen/VYK

    #CSS #SVG #filter #svgFilter #code #web #dev #webDev #webDevelopment #coding #frontend #textEffect #textEffects

  9. Simplest sliced text with absolutely no duplication - not in the markup, not in any pseudos. This means it's contenteditable without requiring JS!

    Live demo on @codepen: codepen.io/thebabydino/pen/VYK

    #CSS #SVG #filter #svgFilter #code #web #dev #webDev #webDevelopment #coding #frontend #textEffect #textEffects

  10. Simplest sliced text with absolutely no duplication - not in the markup, not in any pseudos. This means it's contenteditable without requiring JS!

    Live demo on @codepen: codepen.io/thebabydino/pen/VYK

    #CSS #SVG #filter #svgFilter #code #web #dev #webDev #webDevelopment #coding #frontend #textEffect #textEffects

  11. Ok, probably you already know it, but I just found a slick little web app that allows you to download an SVG logo of any brand. From time to time I need something like that, and this one is good.

    svgl.app

    #logo #svg

  12. Weekend project: tinkering with OKLCH, CSS custom properties, SVG, and colour theory to generate harmonious accent colours from a single source of truth (inline custom property). Very happy to see this picked by CodePen. It gave me a welcome, unexpected boost 😍

    codepen.io/damianwalsh/pen/myO

    #webdev #css #svg

  13. Wochenrückblick, Ausgabe 142 (2026-20)

    Themen:

    ✈️ Honeycomb Bravo endlich komplett in X-Plane integriert

    🏡 Der Garten ist kurz vor Dschungel-Status

    🗺️ Bikerouter-Änderungen: Bugfixes und zwei neue Features

    🔨 Ich war handwerklich aktiv

    🔧 Werkzeug-Neuzugänge in der Werkstatt

    🐚 CLI-Tool der Woche: svgo

    🔊 In dieser Woche gehört: Marie Claire b2b Max Muth

    #Wochenrückblick #XPlane #Honeycomb #HoneycombBravo #Garten #Bikerouter #Handwerk #Werkzeug #Werkstatt #SVGOMG #SVG #svgo #cli #CliToolDerWoche #Techno

    https://www.marcusjaschen.de/blog/2026/2026-20/

  14. Wochenrückblick, Ausgabe 142 (2026-20)

    Themen:

    ✈️ Honeycomb Bravo endlich komplett in X-Plane integriert

    🏡 Der Garten ist kurz vor Dschungel-Status

    🗺️ Bikerouter-Änderungen: Bugfixes und zwei neue Features

    🔨 Ich war handwerklich aktiv

    🔧 Werkzeug-Neuzugänge in der Werkstatt

    🐚 CLI-Tool der Woche: svgo

    🔊 In dieser Woche gehört: Marie Claire b2b Max Muth

    #Wochenrückblick #XPlane #Honeycomb #HoneycombBravo #Garten #Bikerouter #Handwerk #Werkzeug #Werkstatt #SVGOMG #SVG #svgo #cli #CliToolDerWoche #Techno

    https://www.marcusjaschen.de/blog/2026/2026-20/

  15. Wochenrückblick, Ausgabe 142 (2026-20)

    Themen:

    ✈️ Honeycomb Bravo endlich komplett in X-Plane integriert

    🏡 Der Garten ist kurz vor Dschungel-Status

    🗺️ Bikerouter-Änderungen: Bugfixes und zwei neue Features

    🔨 Ich war handwerklich aktiv

    🔧 Werkzeug-Neuzugänge in der Werkstatt

    🐚 CLI-Tool der Woche: svgo

    🔊 In dieser Woche gehört: Marie Claire b2b Max Muth

    #Wochenrückblick #XPlane #Honeycomb #HoneycombBravo #Garten #Bikerouter #Handwerk #Werkzeug #Werkstatt #SVGOMG #SVG #svgo #cli #CliToolDerWoche #Techno

    https://www.marcusjaschen.de/blog/2026/2026-20/

  16. Wochenrückblick, Ausgabe 142 (2026-20)

    Themen:

    ✈️ Honeycomb Bravo endlich komplett in X-Plane integriert

    🏡 Der Garten ist kurz vor Dschungel-Status

    🗺️ Bikerouter-Änderungen: Bugfixes und zwei neue Features

    🔨 Ich war handwerklich aktiv

    🔧 Werkzeug-Neuzugänge in der Werkstatt

    🐚 CLI-Tool der Woche: svgo

    🔊 In dieser Woche gehört: Marie Claire b2b Max Muth

    #Wochenrückblick #XPlane #Honeycomb #HoneycombBravo #Garten #Bikerouter #Handwerk #Werkzeug #Werkstatt #SVGOMG #SVG #svgo #cli #CliToolDerWoche #Techno

    https://www.marcusjaschen.de/blog/2026/2026-20/

  17. Wochenrückblick, Ausgabe 142 (2026-20)

    Themen:

    ✈️ Honeycomb Bravo endlich komplett in X-Plane integriert

    🏡 Der Garten ist kurz vor Dschungel-Status

    🗺️ Bikerouter-Änderungen: Bugfixes und zwei neue Features

    🔨 Ich war handwerklich aktiv

    🔧 Werkzeug-Neuzugänge in der Werkstatt

    🐚 CLI-Tool der Woche: svgo

    🔊 In dieser Woche gehört: Marie Claire b2b Max Muth

    #Wochenrückblick #XPlane #Honeycomb #HoneycombBravo #Garten #Bikerouter #Handwerk #Werkzeug #Werkstatt #SVGOMG #SVG #svgo #cli #CliToolDerWoche #Techno

    https://www.marcusjaschen.de/blog/2026/2026-20/

  18. I wanted to make this #CSS animation as path commands that animate from super sharp curves to perfect circle, using trigonometry, but… this #SVG works, too, across all browsers: codepen.io/chriskirknielsen/pe

    Warning: may contain a magic number.

  19. I wanted to make this #CSS animation as path commands that animate from super sharp curves to perfect circle, using trigonometry, but… this #SVG works, too, across all browsers: codepen.io/chriskirknielsen/pe

    Warning: may contain a magic number.

  20. I wanted to make this #CSS animation as path commands that animate from super sharp curves to perfect circle, using trigonometry, but… this #SVG works, too, across all browsers: codepen.io/chriskirknielsen/pe

    Warning: may contain a magic number.

  21. I wanted to make this #CSS animation as path commands that animate from super sharp curves to perfect circle, using trigonometry, but… this #SVG works, too, across all browsers: codepen.io/chriskirknielsen/pe

    Warning: may contain a magic number.

  22. I wanted to make this #CSS animation as path commands that animate from super sharp curves to perfect circle, using trigonometry, but… this #SVG works, too, across all browsers: codepen.io/chriskirknielsen/pe

    Warning: may contain a magic number.

  23. Does anyone know of some tool or website to convert a or file into a pretty graphic? Maybe an ?

    I don't wanna use to do that for me haha. I just went on my first bike ride around the city and wanna share some cool stats

  24. Does anyone know of some tool or website to convert a #GPX or #KMZ file into a pretty graphic? Maybe an #SVG?

    I don't wanna use #Strava to do that for me haha. I just went on my first bike ride around the city and wanna share some cool stats

    #Cycling #BikeCommuting #Bicycle

  25. Does anyone know of some tool or website to convert a #GPX or #KMZ file into a pretty graphic? Maybe an #SVG?

    I don't wanna use #Strava to do that for me haha. I just went on my first bike ride around the city and wanna share some cool stats

    #Cycling #BikeCommuting #Bicycle

  26. Does anyone know of some tool or website to convert a #GPX or #KMZ file into a pretty graphic? Maybe an #SVG?

    I don't wanna use #Strava to do that for me haha. I just went on my first bike ride around the city and wanna share some cool stats

    #Cycling #BikeCommuting #Bicycle

  27. Does anyone know of some tool or website to convert a #GPX or #KMZ file into a pretty graphic? Maybe an #SVG?

    I don't wanna use #Strava to do that for me haha. I just went on my first bike ride around the city and wanna share some cool stats

    #Cycling #BikeCommuting #Bicycle

  28. I’m trying to make simple vector shapes look handmade, using filter primitives that add imperfections (grain, wobble, rough edges, scatter, noise). Can anyone recommend good, easy-to-follow resources for working with inline SVG on the web?

    #lazyweb #webdev #SVG

  29. I’m trying to make simple vector shapes look handmade, using filter primitives that add imperfections (grain, wobble, rough edges, scatter, noise). Can anyone recommend good, easy-to-follow resources for working with inline SVG on the web?

    #lazyweb #webdev #SVG

  30. @lkundrak It's and . I created the base image in , added an <animate> nodes using the XML editor (and some supporting groups to select a reference point for rotation), and then re-opened it in a text editor to comfortably edit the <animate>s.

  31. @lkundrak It's #SVG and #SMIL. I created the base image in #Inkscape , added an <animate> nodes using the XML editor (and some supporting groups to select a reference point for rotation), and then re-opened it in a text editor to comfortably edit the <animate>s.

  32. @lkundrak It's #SVG and #SMIL. I created the base image in #Inkscape , added an <animate> nodes using the XML editor (and some supporting groups to select a reference point for rotation), and then re-opened it in a text editor to comfortably edit the <animate>s.

  33. @lkundrak It's #SVG and #SMIL. I created the base image in #Inkscape , added an <animate> nodes using the XML editor (and some supporting groups to select a reference point for rotation), and then re-opened it in a text editor to comfortably edit the <animate>s.

  34. @lkundrak It's #SVG and #SMIL. I created the base image in #Inkscape , added an <animate> nodes using the XML editor (and some supporting groups to select a reference point for rotation), and then re-opened it in a text editor to comfortably edit the <animate>s.

  35. There isn't an element per slice. It's just one element for all slices going up on hover and then back down.

    #CSS #SVG #filter

  36. 🆕 blog! “Stupidly Simple SVG Sparklines”

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg…

    👀 Read more: shkspr.mobi/blog/2026/05/stupi

    #svg #tutorial

  37. 🆕 blog! “Stupidly Simple SVG Sparklines”

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg…

    👀 Read more: shkspr.mobi/blog/2026/05/stupi

    #svg #tutorial

  38. 🆕 blog! “Stupidly Simple SVG Sparklines”

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg…

    👀 Read more: shkspr.mobi/blog/2026/05/stupi

    #svg #tutorial

  39. 🆕 blog! “Stupidly Simple SVG Sparklines”

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg…

    👀 Read more: shkspr.mobi/blog/2026/05/stupi

    #svg #tutorial

  40. 🆕 blog! “Stupidly Simple SVG Sparklines”

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg…

    👀 Read more: shkspr.mobi/blog/2026/05/stupi

    #svg #tutorial

  41. Stupidly Simple SVG Sparklines

    shkspr.mobi/blog/2026/05/stupi

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 124">
        <polyline fill="none" stroke="#0074D955" stroke-width="3" 
            points="12,48 83,84 154,79 226,90 297,79 369,65 440,78 512,80 583,88 654,12 726,56 797,92 869,93 940,97 1012,106"></polyline>
    </svg>
    

    The SVG co-ordinate system has position 0,0 at the top left. Most graphics formats are like that. That's fine for our x value - but it means higher y values will appear lower on the graph.

    Getting the x co-ordinate of each data point is easy. Take the width of the SVG image and divide it by the number of data-points.

    The y co-ordinate is harder. The algorithm is:

    1. Find the height of the SVG.
    2. Find the maximum value in the data.
    3. Find the minimum value in the data.
    4. Divide the maximum value by the height of the graph.
    5. For each data point, either:
      • To have the lowest value at the bottom of the graph, subtract the minimum from the value, then multiply by the ratio in (4).
      • Or, to retain the gap between zero and the lowest value, multiply the value by the ratio in (4).
    6. The y co-ordinate is calculated by subtracting the value in (5) from the height in (1).

    Here's some code showing how it works. I've added a little padding to the inside of the graph - you'll see why later:

    //  Max and min of views.
    $max_views = max( $svg_views_data );
    $min_views = min( $svg_views_data );
    $svg_data_length = sizeof( $svg_dates_data ) - 1;
    
    //  SVG details for scaling.
    $svg_padding = 12;
    $svg_width_graph  = 1000;
    $svg_width  = $svg_width_graph + ( $svg_padding * 2 );
    $svg_height_graph = 100;
    $svg_height = $svg_height_graph + ( $svg_padding * 2 );
    
    //  Calculate where each point should be.
    $x_per = $svg_width_graph / ( $svg_data_length );
    $y_per = $svg_height_graph / $max_views;
    
    //  Loop through the data.
    foreach ( $svg_views_data as $index=>$views ) {
        //  X is from the left.
        $x_pos = intval( $x_per * $index ) + $svg_padding;
        //  Y is from the top.
        $y_pos = $svg_height - intval( $y_per * $views ) - $svg_padding;
    
        //  Add a point to the line.
        $polyline_points .= "{$x_pos},{$y_pos}\n";
    }
    
    echo <<< SVG
    <svg xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 $svg_width $svg_height" class="chart">
        <polyline
            fill="none"
            stroke="#F00"
            stroke-width="3"
            points="{$polyline_points}"/>
    </svg>
    SVG;
    

    Suppose someone suggests stupidly simple sparklines suffer seriously so someone should supplement statistics several circles?

    Using the same co-ordinates, we can place an SVG circle on top of the point. Give it a "title" attribute and you have a little bit of interactivity.

    <circle cx="12" cy="48" r="5" fill="#0074D955"><title>4,707 Views</title></circle>
    

    Here's how it looks (view source to understand how it is constructed).

    4,707 2025-09-012,051 2025-09-022,444 2025-09-031,627 2025-09-042,450 2025-09-053,453 2025-09-062,491 2025-09-072,326 2025-09-081,754 2025-09-097,268 2025-09-104,113 2025-09-111,503 2025-09-121,394 2025-09-131,108 2025-09-14533 2025-09-15

    Hover over any of those little circles and you'll see some pop-up text giving you information about that datapoint.

    …that's it! If you have an array of data points, you can easily create a graph with no graphing library, no plugins, no 3rd party dependencies. Just super simple SVG.

    #svg #tutorial
  42. Stupidly Simple SVG Sparklines

    shkspr.mobi/blog/2026/05/stupi

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 124">
        <polyline fill="none" stroke="#0074D955" stroke-width="3" 
            points="12,48 83,84 154,79 226,90 297,79 369,65 440,78 512,80 583,88 654,12 726,56 797,92 869,93 940,97 1012,106"></polyline>
    </svg>
    

    The SVG co-ordinate system has position 0,0 at the top left. Most graphics formats are like that. That's fine for our x value - but it means higher y values will appear lower on the graph.

    Getting the x co-ordinate of each data point is easy. Take the width of the SVG image and divide it by the number of data-points.

    The y co-ordinate is harder. The algorithm is:

    1. Find the height of the SVG.
    2. Find the maximum value in the data.
    3. Find the minimum value in the data.
    4. Divide the maximum value by the height of the graph.
    5. For each data point, either:
      • To have the lowest value at the bottom of the graph, subtract the minimum from the value, then multiply by the ratio in (4).
      • Or, to retain the gap between zero and the lowest value, multiply the value by the ratio in (4).
    6. The y co-ordinate is calculated by subtracting the value in (5) from the height in (1).

    Here's some code showing how it works. I've added a little padding to the inside of the graph - you'll see why later:

    //  Max and min of views.
    $max_views = max( $svg_views_data );
    $min_views = min( $svg_views_data );
    $svg_data_length = sizeof( $svg_dates_data ) - 1;
    
    //  SVG details for scaling.
    $svg_padding = 12;
    $svg_width_graph  = 1000;
    $svg_width  = $svg_width_graph + ( $svg_padding * 2 );
    $svg_height_graph = 100;
    $svg_height = $svg_height_graph + ( $svg_padding * 2 );
    
    //  Calculate where each point should be.
    $x_per = $svg_width_graph / ( $svg_data_length );
    $y_per = $svg_height_graph / $max_views;
    
    //  Loop through the data.
    foreach ( $svg_views_data as $index=>$views ) {
        //  X is from the left.
        $x_pos = intval( $x_per * $index ) + $svg_padding;
        //  Y is from the top.
        $y_pos = $svg_height - intval( $y_per * $views ) - $svg_padding;
    
        //  Add a point to the line.
        $polyline_points .= "{$x_pos},{$y_pos}\n";
    }
    
    echo <<< SVG
    <svg xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 $svg_width $svg_height" class="chart">
        <polyline
            fill="none"
            stroke="#F00"
            stroke-width="3"
            points="{$polyline_points}"/>
    </svg>
    SVG;
    

    Suppose someone suggests stupidly simple sparklines suffer seriously so someone should supplement statistics several circles?

    Using the same co-ordinates, we can place an SVG circle on top of the point. Give it a "title" attribute and you have a little bit of interactivity.

    <circle cx="12" cy="48" r="5" fill="#0074D955"><title>4,707 Views</title></circle>
    

    Here's how it looks (view source to understand how it is constructed).

    4,707 2025-09-012,051 2025-09-022,444 2025-09-031,627 2025-09-042,450 2025-09-053,453 2025-09-062,491 2025-09-072,326 2025-09-081,754 2025-09-097,268 2025-09-104,113 2025-09-111,503 2025-09-121,394 2025-09-131,108 2025-09-14533 2025-09-15

    Hover over any of those little circles and you'll see some pop-up text giving you information about that datapoint.

    …that's it! If you have an array of data points, you can easily create a graph with no graphing library, no plugins, no 3rd party dependencies. Just super simple SVG.

    #svg #tutorial
  43. Stupidly Simple SVG Sparklines

    shkspr.mobi/blog/2026/05/stupi

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 124">
        <polyline fill="none" stroke="#0074D955" stroke-width="3" 
            points="12,48 83,84 154,79 226,90 297,79 369,65 440,78 512,80 583,88 654,12 726,56 797,92 869,93 940,97 1012,106"></polyline>
    </svg>
    

    The SVG co-ordinate system has position 0,0 at the top left. Most graphics formats are like that. That's fine for our x value - but it means higher y values will appear lower on the graph.

    Getting the x co-ordinate of each data point is easy. Take the width of the SVG image and divide it by the number of data-points.

    The y co-ordinate is harder. The algorithm is:

    1. Find the height of the SVG.
    2. Find the maximum value in the data.
    3. Find the minimum value in the data.
    4. Divide the maximum value by the height of the graph.
    5. For each data point, either:
      • To have the lowest value at the bottom of the graph, subtract the minimum from the value, then multiply by the ratio in (4).
      • Or, to retain the gap between zero and the lowest value, multiply the value by the ratio in (4).
    6. The y co-ordinate is calculated by subtracting the value in (5) from the height in (1).

    Here's some code showing how it works. I've added a little padding to the inside of the graph - you'll see why later:

    //  Max and min of views.
    $max_views = max( $svg_views_data );
    $min_views = min( $svg_views_data );
    $svg_data_length = sizeof( $svg_dates_data ) - 1;
    
    //  SVG details for scaling.
    $svg_padding = 12;
    $svg_width_graph  = 1000;
    $svg_width  = $svg_width_graph + ( $svg_padding * 2 );
    $svg_height_graph = 100;
    $svg_height = $svg_height_graph + ( $svg_padding * 2 );
    
    //  Calculate where each point should be.
    $x_per = $svg_width_graph / ( $svg_data_length );
    $y_per = $svg_height_graph / $max_views;
    
    //  Loop through the data.
    foreach ( $svg_views_data as $index=>$views ) {
        //  X is from the left.
        $x_pos = intval( $x_per * $index ) + $svg_padding;
        //  Y is from the top.
        $y_pos = $svg_height - intval( $y_per * $views ) - $svg_padding;
    
        //  Add a point to the line.
        $polyline_points .= "{$x_pos},{$y_pos}\n";
    }
    
    echo <<< SVG
    <svg xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 $svg_width $svg_height" class="chart">
        <polyline
            fill="none"
            stroke="#F00"
            stroke-width="3"
            points="{$polyline_points}"/>
    </svg>
    SVG;
    

    Suppose someone suggests stupidly simple sparklines suffer seriously so someone should supplement statistics several circles?

    Using the same co-ordinates, we can place an SVG circle on top of the point. Give it a "title" attribute and you have a little bit of interactivity.

    <circle cx="12" cy="48" r="5" fill="#0074D955"><title>4,707 Views</title></circle>
    

    Here's how it looks (view source to understand how it is constructed).

    4,707 2025-09-012,051 2025-09-022,444 2025-09-031,627 2025-09-042,450 2025-09-053,453 2025-09-062,491 2025-09-072,326 2025-09-081,754 2025-09-097,268 2025-09-104,113 2025-09-111,503 2025-09-121,394 2025-09-131,108 2025-09-14533 2025-09-15

    Hover over any of those little circles and you'll see some pop-up text giving you information about that datapoint.

    …that's it! If you have an array of data points, you can easily create a graph with no graphing library, no plugins, no 3rd party dependencies. Just super simple SVG.

    #svg #tutorial
  44. Stupidly Simple SVG Sparklines

    shkspr.mobi/blog/2026/05/stupi

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 124">
        <polyline fill="none" stroke="#0074D955" stroke-width="3" 
            points="12,48 83,84 154,79 226,90 297,79 369,65 440,78 512,80 583,88 654,12 726,56 797,92 869,93 940,97 1012,106"></polyline>
    </svg>
    

    The SVG co-ordinate system has position 0,0 at the top left. Most graphics formats are like that. That's fine for our x value - but it means higher y values will appear lower on the graph.

    Getting the x co-ordinate of each data point is easy. Take the width of the SVG image and divide it by the number of data-points.

    The y co-ordinate is harder. The algorithm is:

    1. Find the height of the SVG.
    2. Find the maximum value in the data.
    3. Find the minimum value in the data.
    4. Divide the maximum value by the height of the graph.
    5. For each data point, either:
      • To have the lowest value at the bottom of the graph, subtract the minimum from the value, then multiply by the ratio in (4).
      • Or, to retain the gap between zero and the lowest value, multiply the value by the ratio in (4).
    6. The y co-ordinate is calculated by subtracting the value in (5) from the height in (1).

    Here's some code showing how it works. I've added a little padding to the inside of the graph - you'll see why later:

    //  Max and min of views.
    $max_views = max( $svg_views_data );
    $min_views = min( $svg_views_data );
    $svg_data_length = sizeof( $svg_dates_data ) - 1;
    
    //  SVG details for scaling.
    $svg_padding = 12;
    $svg_width_graph  = 1000;
    $svg_width  = $svg_width_graph + ( $svg_padding * 2 );
    $svg_height_graph = 100;
    $svg_height = $svg_height_graph + ( $svg_padding * 2 );
    
    //  Calculate where each point should be.
    $x_per = $svg_width_graph / ( $svg_data_length );
    $y_per = $svg_height_graph / $max_views;
    
    //  Loop through the data.
    foreach ( $svg_views_data as $index=>$views ) {
        //  X is from the left.
        $x_pos = intval( $x_per * $index ) + $svg_padding;
        //  Y is from the top.
        $y_pos = $svg_height - intval( $y_per * $views ) - $svg_padding;
    
        //  Add a point to the line.
        $polyline_points .= "{$x_pos},{$y_pos}\n";
    }
    
    echo <<< SVG
    <svg xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 $svg_width $svg_height" class="chart">
        <polyline
            fill="none"
            stroke="#F00"
            stroke-width="3"
            points="{$polyline_points}"/>
    </svg>
    SVG;
    

    Suppose someone suggests stupidly simple sparklines suffer seriously so someone should supplement statistics several circles?

    Using the same co-ordinates, we can place an SVG circle on top of the point. Give it a "title" attribute and you have a little bit of interactivity.

    <circle cx="12" cy="48" r="5" fill="#0074D955"><title>4,707 Views</title></circle>
    

    Here's how it looks (view source to understand how it is constructed).

    4,707 2025-09-012,051 2025-09-022,444 2025-09-031,627 2025-09-042,450 2025-09-053,453 2025-09-062,491 2025-09-072,326 2025-09-081,754 2025-09-097,268 2025-09-104,113 2025-09-111,503 2025-09-121,394 2025-09-131,108 2025-09-14533 2025-09-15

    Hover over any of those little circles and you'll see some pop-up text giving you information about that datapoint.

    …that's it! If you have an array of data points, you can easily create a graph with no graphing library, no plugins, no 3rd party dependencies. Just super simple SVG.

    #svg #tutorial
  45. Stupidly Simple SVG Sparklines

    shkspr.mobi/blog/2026/05/stupi

    A sparkline is a little line-graph with no axes or other unnecessary details. They're useful for getting quick understanding of what the data is showing.

    They're also really easy to create programmatically.

    This uses the SVG "polyline" which takes a list of x,y co-ordinate pairs. But can you spot the small problem?

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 124">
        <polyline fill="none" stroke="#0074D955" stroke-width="3" 
            points="12,48 83,84 154,79 226,90 297,79 369,65 440,78 512,80 583,88 654,12 726,56 797,92 869,93 940,97 1012,106"></polyline>
    </svg>
    

    The SVG co-ordinate system has position 0,0 at the top left. Most graphics formats are like that. That's fine for our x value - but it means higher y values will appear lower on the graph.

    Getting the x co-ordinate of each data point is easy. Take the width of the SVG image and divide it by the number of data-points.

    The y co-ordinate is harder. The algorithm is:

    1. Find the height of the SVG.
    2. Find the maximum value in the data.
    3. Find the minimum value in the data.
    4. Divide the maximum value by the height of the graph.
    5. For each data point, either:
      • To have the lowest value at the bottom of the graph, subtract the minimum from the value, then multiply by the ratio in (4).
      • Or, to retain the gap between zero and the lowest value, multiply the value by the ratio in (4).
    6. The y co-ordinate is calculated by subtracting the value in (5) from the height in (1).

    Here's some code showing how it works. I've added a little padding to the inside of the graph - you'll see why later:

    //  Max and min of views.
    $max_views = max( $svg_views_data );
    $min_views = min( $svg_views_data );
    $svg_data_length = sizeof( $svg_dates_data ) - 1;
    
    //  SVG details for scaling.
    $svg_padding = 12;
    $svg_width_graph  = 1000;
    $svg_width  = $svg_width_graph + ( $svg_padding * 2 );
    $svg_height_graph = 100;
    $svg_height = $svg_height_graph + ( $svg_padding * 2 );
    
    //  Calculate where each point should be.
    $x_per = $svg_width_graph / ( $svg_data_length );
    $y_per = $svg_height_graph / $max_views;
    
    //  Loop through the data.
    foreach ( $svg_views_data as $index=>$views ) {
        //  X is from the left.
        $x_pos = intval( $x_per * $index ) + $svg_padding;
        //  Y is from the top.
        $y_pos = $svg_height - intval( $y_per * $views ) - $svg_padding;
    
        //  Add a point to the line.
        $polyline_points .= "{$x_pos},{$y_pos}\n";
    }
    
    echo <<< SVG
    <svg xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 $svg_width $svg_height" class="chart">
        <polyline
            fill="none"
            stroke="#F00"
            stroke-width="3"
            points="{$polyline_points}"/>
    </svg>
    SVG;
    

    Suppose someone suggests stupidly simple sparklines suffer seriously so someone should supplement statistics several circles?

    Using the same co-ordinates, we can place an SVG circle on top of the point. Give it a "title" attribute and you have a little bit of interactivity.

    <circle cx="12" cy="48" r="5" fill="#0074D955"><title>4,707 Views</title></circle>
    

    Here's how it looks (view source to understand how it is constructed).

    4,707 2025-09-012,051 2025-09-022,444 2025-09-031,627 2025-09-042,450 2025-09-053,453 2025-09-062,491 2025-09-072,326 2025-09-081,754 2025-09-097,268 2025-09-104,113 2025-09-111,503 2025-09-121,394 2025-09-131,108 2025-09-14533 2025-09-15

    Hover over any of those little circles and you'll see some pop-up text giving you information about that datapoint.

    …that's it! If you have an array of data points, you can easily create a graph with no graphing library, no plugins, no 3rd party dependencies. Just super simple SVG.

    #svg #tutorial