Progressive pie, donut, bar and line charts

Overview

Peity

Build Status

Peity (sounds like deity) is a jQuery plugin that converts an element's content into a mini <svg> pie, donut, line or bar chart.

Basic Usage

HTML

<span class="pie">3/5</span>
<span class="donut">5,2,3</span>
<span class="line">3,5,1,6,2</span>
<span class="bar">2,5,3,6,2,1</span>

JavaScript (jQuery)

$(".pie").peity("pie");
$(".donut").peity("donut");
$(".line").peity("line");
$(".bar").peity("bar");

Docs

More detailed usage can be found at benpickles.github.io/peity.

Development

Run the automated visual regression tests with:

make test

Run a filtered set of tests with:

ARGS="--grep bar" make test

To manually view all test cases run:

make server

And hit http://localhost:8080/.

Release

Update the version string in jquery.peity.js, run make release, and follow the instructions.

Copyright

Copyright 2009-2020 Ben Pickles. See LICENCE for details.

Comments
  • Requests: Line Graph Baseline & Pie Chart Hole

    Requests: Line Graph Baseline & Pie Chart Hole

    opened by ghost 10
  • Automatically apply data attributes

    Automatically apply data attributes

    When users define data-colour, data-diameter etc. (with those after the 'data-' prefix matching properties of defaults), apply them automatically instead of requiring writing custom functions.

    opened by buunguyen 10
  • It would be nice if

    It would be nice if "width" could take a percentage value

    I'm trying to have the line chart span 100% of it's parent and when I pass '100%' in the width parameter of the line type, the plugin doesn't draw anything.

    Thanks.

    opened by nicjohnson 9
  • Tooltips

    Tooltips

    Any chance you could add tooltips (by default) to some types of peity chart (e.g. pie) or even all of them, so that the real underlying value (e.g. 17/23) can be viewed as well as the visual rendering?

    opened by MarcusJT 7
  • innerHTML to Span

    innerHTML to Span

    Hi, I'm having a problem running the Peity Charts using innerHtml.

    if a use an alert to show the content of the Span I can see perflecty all the values inserted into the Span tag using innerHTML but it doesn't show the line bar graph. If a place all the values manually into the Span Tag I can see the graph just fine.

    `

    `

    I have a function below the code above that has this code:

    var test = "5,3,9,6,5,9,7,3,5,2,5,3,9,6,5,9,7,3,5,2"; document.getElementById("spanPeity").innerHTML = test; alert("content of span spanPeity= " + document.getElementById("spanPeity").innerHTML);

    Could you please tell what's wrong in the code.

    Thanks so much in advance.

    opened by Jonathan-Developer 6
  • Added IE < 9 support with excanvas

    Added IE < 9 support with excanvas

    Great plugin, thanks for creating it! I had a use-case recently that required support for IE < 9 using excanvas. This pull request adds support for excanvas + IE7/8.

    IE 8 required adding the canvas element to a container that had no "P" tags (I used body but only if excanvas is loaded). Also IE 8 standards requires calling initElement again after any non-canvas changes are made (such as height/width) while IE7 must call it before any changes--yeah very ghetto.

    I had to change jQuery code in prepareCanvas function to plain JS to make excanvas happy as well.

    Maybe it will help someone else stuck writing for archaic organizations. Thanks again.

    Tested on Chrome (Mac), IE 7/8/9 (Windows 7).

    opened by jeff-mccoy 5
  • v0.6.0 vs. v1.1.2: canvas no longer child of element on which peity is called?

    v0.6.0 vs. v1.1.2: canvas no longer child of element on which peity is called?

    Please correct me if I'm wrong but it appears that v0.6.0 vs. v1.1.2 renders the element as a child vs. a sibling, respectively, of the element containing the chart values.

    Being a previous sibling makes it much harder/impossible to style the canvas with CSS: http://stackoverflow.com/questions/1817792/css-previous-sibling-selector

    v.0.6.0: http://imgur.com/H2rwfs9

    v.1.1.2: http://imgur.com/joUXesR

    opened by tim-peterson 5
  • bar chart zero (

    bar chart zero ("0") value height

    For the bar charts, is there a way to assign some small bar height to values of "0"?

    I prefer the way Github does it with their 52-week participation graphs and not just to have empty space.

    opened by tim-peterson 5
  • Multiple colors on BarChart

    Multiple colors on BarChart

    Hi, I'm trying to set different colors for each bar on my bar chart. I use Peity to show small graph with 2 bars on for a periode n and the other for perdiode n-1 so i need to have 2 differents colors for each of my bars.

    I haven't find a way to do so.

    Thanks.

    opened by Ghriim 5
  • Expose an item's value on bar and pie slice SVG nodes

    Expose an item's value on bar and pie slice SVG nodes

    The intention is that this can drive tooltips, for example: https://jsbin.com/vufayan/edit?html,js,output

    • Addresses #2.
    • Fixes #9.
    • Addresses #29.
    • Fixes #55.
    • Fixes #71.
    • Closes #84.
    opened by benpickles 4
  • Adding composer.json and submitting to packagist

    Adding composer.json and submitting to packagist

    Would you consider adding a composer.json file so that this library can be included in a composer based PHP project easily?

    If wanted I can create the composer file and submit a pull request.

    Currently there is a clone of the repo in packagist (https://packagist.org/packages/grimmlink/peity) but it would be best to include your repo rather than someones clone

    Thanks

    opened by chewett 4
  • Add ability to use CSS classes on SVG charts

    Add ability to use CSS classes on SVG charts

    Hey,

    I was wondering if it was possible to replace this:

    <span data-peity='{ "fill": ["red", "#eeeeee"],    "innerRadius": 10, "radius": 40 }'>1/7</span>
    

    With perhaps this:

    <span data-peity='{ "class": "my-class",    "innerRadius": 10, "radius": 40 }'>1/7</span>
    .. or
    <span data-peity='{ "class": ["my-class", "my-class2"],    "innerRadius": 10, "radius": 40 }'>1/7</span>
    

    This way I can move all my colors etc. to other systems, like SASS.

    I checked the code, and it seems like there explicitly isn't a way to add attributes to the rendered SVG elements, so I can't even workaround it :). Also, I noted that SVG is optional, so of course classes wouldn't work if Peity fell back to canvas rendering.. but I'm willing to lose that support :).

    Mike.

    opened by LordMike 2
  • Required Two different color in Line chart

    Required Two different color in Line chart

    Hi, I expect two different color in line chart. For instance, If the line goes up it should be Green. If the line goes down it should be Red. Is it possible in line chart? If possible kindly explain how to do

    Thanks

    opened by shajahan86 1
  • data-value not working with

    data-value not working with "bar"

    Hey, I wanted to try out the latest data-value attribute, but I can't figure why it isn't working: My attempts:

    <span class="bar" data-value="9,8,9,10,9,9,7,8,7,9">9,8,9,10,9,9,7,8,7,9</span>
    <span class="bar" data-value="123">9,8,9,10,9,9,7,8,7,9</span>
    

    JS part

    $(".bar").peity("bar", {
            height: 36,
            fill: ['rgba(100,100,100,0.85)'],
            width: 65,
            padding: 0.2
        });
    

    Not sure what I'm not doing ok, can you give me an example when you have time?

    opened by gamebak 0
  • Change data-value to label

    Change data-value to label

    If using tooltips to display data-value on mouseOver, there is a need to show a label or context (i.e., "324.9 MB" vs "324987634").

    opened by jackvalko 0
  • Further custom styling

    Further custom styling

    Hey!

    Firstly, thanks for a great and simple to use plugin.

    Is it possible to apply a gradient to a line graph and to have each data point have a circle of some sort?

    Thanks.

    opened by harrynewsome 0
Owner
Ben Pickles
Listener of Zappa • Writer of Ruby and JavaScript • Creator of https://github.com/benpickles/peity • Leader of thought
Ben Pickles
Resize image in browser with high quality and high speed

pica - high quality image resize in browser Resize images in browser without pixelation and reasonably fast. Autoselect the best of available technolo

Nodeca 3.2k Dec 27, 2022
null 3.9k Dec 30, 2022
Unite Gallery - Responsive jQuery Image and Video Gallery Plugin. Aim to be the best gallery on the web on it's kind. See demo here:

##Unite Gallery - Responsive jQuery Gallery Plugin Product Link: unitegallery.net This gallery has commercial versions for: WordPress , Joomla! , Pres

Max Valiano 531 Oct 24, 2022
A light wight javascript image viewing plugin with smooth animation and 0 dependence

A light wight javascript image viewing plugin with smooth animation and 0 dependence

null 50 Nov 12, 2022
ASP.NET Core image gallery with Marten, ImageSharp, and HTMX

Image Gallery This sample uses the following core technologies to deliver an image gallery experience: ASP.NET Core Marten ImageSharp.Web HTMX This al

Khalid Abuhakmeh 11 Feb 9, 2022
Picdit - Photo Editor is a web application created using HTML, CSS, PHP and JavaScript

Picdit - Photo Editor is a web application created using HTML, CSS, PHP and JavaScript with the help VS Code and Microsoft Azure to develop the final project application outcome.

Darin Joshua D 3 Mar 31, 2022
Codecs lets you use read, write, edit, and analyze images.

Codecs Codecs lets you use read, write, edit, and analyze images. npm install @astropub/codecs Usage import * as fs from 'node:fs/promises' import * a

Astro Community 8 Oct 10, 2022
Progressive pie, donut, bar and line charts

Peity Peity (sounds like deity) is a jQuery plugin that converts an element's content into a mini <svg> pie, donut, line or bar chart. Basic Usage HTM

Ben Pickles 4.2k Jan 1, 2023
A Javascript library to export svg charts from the DOM and download them as an SVG file, PDF, or raster image (JPEG, PNG) format. Can be done all in client-side.

svg-exportJS An easy-to-use client-side Javascript library to export SVG graphics from web pages and download them as an SVG file, PDF, or raster imag

null 23 Oct 5, 2022
Want to preserve your loved one's voices for eternity? Narrate anything using the a voice imprint that can be made in as little as 10 minutes of audio samples. Easy as pie.

Want to preserve your loved one's voices for eternity? Narrate anything using the a voice imprint that can be made in as little as 10 minutes of audio samples. Easy as pie.

Ari 15 Nov 29, 2022
This plugin for Chart.js that makes your bar chart to 100% stacked bar chart.

chartjs-plugin-stacked100 This plugin for Chart.js that makes your bar chart to 100% stacked bar chart. Requires Chart.js 3.x. Demo: https://y-takey.g

y-take 106 Jan 3, 2023
Smoothie Charts: smooooooth JavaScript charts for realtime streaming data

Smoothie Charts is a really small charting library designed for live streaming data. I built it to reduce the headaches I was getting from watching ch

Joe Walnes 2.2k Dec 13, 2022
ln-charts parses the output of bos accounting commands into various charts for your Lightning Node.

ln-charts ln-charts parses the output of bos accounting commands into various charts for your Lightning Node. It runs on Angular, JS, HTML, CSS, ngx-c

Steven Ellis 21 Dec 18, 2022
TChart.js - simple and configurable Bar and Line Chart library in Javascript

TChart.js Simple and configurable Bar and Line Chart library in Javascript Description TChart.js is a canvas-based simple Javascript Bar and Line Char

null 4 Mar 3, 2021
Simple, responsive, modern SVG Charts with zero dependencies

Frappe Charts GitHub-inspired modern, intuitive and responsive charts with zero dependencies Explore Demos » Edit at CodePen » Contents Installation U

Frappe 14.6k Jan 4, 2023
📊 Interactive JavaScript Charts built on SVG

A modern JavaScript charting library to build interactive charts and visualizations with simple API. Our Partner ApexCharts is now a partner of Fusion

ApexCharts 12.1k Jan 3, 2023
The slides in this slideshow wobble as they move. The effect is based on Sergey Valiukh's Dribbble shot and was made using Snap.svg and morphing SVG paths.

Wobbly Slideshow Effect The slides in this slideshow wobble as they move. The effect is based on Sergey Valiukh's Dribbble shot and was made using Sna

Codrops 112 Jul 27, 2022
Create beautiful charts with one line of JavaScript

Chartkick.js Create beautiful charts with one line of JavaScript See it in action Supports Chart.js, Google Charts, and Highcharts Also available for

Andrew Kane 1.2k Jan 2, 2023
Create beautiful JavaScript charts with one line of React

React Chartkick Create beautiful JavaScript charts with one line of React See it in action Supports Chart.js, Google Charts, and Highcharts Quick Star

Andrew Kane 1.2k Dec 28, 2022
Create beautiful JavaScript charts with one line of Ruby

Chartkick Create beautiful JavaScript charts with one line of Ruby. No more fighting with charting libraries! See it in action Chartkick 4.0 was recen

Andrew Kane 6.1k Jan 8, 2023