Catalog npm
Back to packageRELEASE DETAILS

1.1.4

npm

@0saw/vue-css-donut-chart

Lightweight Vue component for drawing pure CSS donut charts

chartcirclecssdonutprogresspure cssvue
Published18 Mar 2019
Direct dependencies8
Transitive dependenciesNot calculated

README

Current package documentation

vue-css-donut-chart

Lightweight Vue component for drawing pure CSS donut charts

Live demo

Live demo can be found on the project page - https://dumptyd.github.io/vue-css-donut-chart

Features

  • Pure CSS. Vue is only used for calculations.
  • No external dependencies
  • ~3KB min+gzipped JS and ~0.4KB min+gzipped CSS

Installation

1. Install via yarn or npm

yarn add vue-css-donut-chart

OR

npm install vue-css-donut-chart

2. Import and use vue-css-donut-chart

  • ES6
import Donut from 'vue-css-donut-chart';
import 'vue-css-donut-chart/dist/vcdonut.css';

Vue.use(Donut);

<link href="https://unpkg.com/vue-css-donut-chart/dist/vcdonut.css">
<script src="https://unpkg.com/vue-css-donut-chart"></script>
<script>
  Vue.use(vcdonut.default);
</script>

Usage

Basic usage

With sane defaults in place, basic usage is as simple as passing a sections array of objects with a value prop to vc-donut component.

<template>
  <vc-donut :sections="sections">50%</vc-donut>
</template>
<script>
  export default {
    data() {
      return {
        sections: [{ value: 25 }, { value: 25 }, { value: 25 }, { value: 25 }]
      };
    }
  };
</script>

Usage with all the available props

<template>
  <vc-donut
    background="white" foreground="grey"
    :size="200" unit="px" :thickness="30"
    has-legend legend-placement="top"
    :sections="sections" :total="100"
  >
    <h1>100%</h1>
  </vc-donut>
</template>
<script>
  export default {
    data() {
      return {
        sections: [
          { label: 'Red section' value: 25, color: 'red' },
          { label: 'Green section' value: 25, color: 'green' },
          { label: 'Blue section' value: 25, color: 'blue' }
        ]
      };
    }
  };
</script>

Props

size

  • type: Number
  • default: 250
  • Diameter of the donut. Can be any positive value.

unit

  • type: String
  • default: px
  • Unit to use for size. Can be any valid CSS unit. Use % to make the donut responsive.

thickness

  • type: Number
  • default: 20
  • Percentage thickness of the donut ring. Can be any positive value between 0-100.

text

  • type: String
  • Donut text. This can also be provided through the default slot.

background

  • type: String
  • default: #ffffff
  • Background color of the donut. In most cases, this should be the background color of the parent element.

foreground

  • type: String
  • default: #eeeeee
  • Foreground color of the donut. This is the color that is shown for empty regions of the donut ring.

total

  • type: Number
  • default: 100
  • Total for calculating the percentage for each section.

has-legend

  • type: Boolean
  • default: false
  • Specifies whether the donut should have a legend.

legend-placement

  • type: String
  • default: bottom
  • Specifies where the legend should be placed. Valid values are top, right, bottom and left.

sections

  • type: Array
  • default: []
  • An array of objects. Each object in the array represents one section. Every object must have a value property. Sum of all the sections' value should not exceed total, an error is thrown otherwise.
  • Object properties
    • value - Size of the section. Should be <= total.
    • color - Color of the section. vc-donut comes with 24 predefined colors, so this property is optional if you have <= 24 sections without the color property.
    • label - Name of this section. This is used in the legend as well as tooltip text.

Slots

default slot

If you want more control over text content of the chart, default slot can be used instead of the text prop.

legend

Slot for plugging in your own legend.


Contributing

License

Code released under MIT license.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 8

Native requirements
8 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
vue
Environment
{
  "local_name": "vue",
  "alias": false,
  "peer_metadata": null
}
^2.5.17runtime
dev
Environment
{
  "local_name": "dev",
  "alias": false,
  "peer_metadata": null
}
^0.1.3development
@vue/cli-plugin-babel
Environment
{
  "local_name": "@vue/cli-plugin-babel",
  "alias": false,
  "peer_metadata": null
}
^3.0.3development
@vue/cli-plugin-eslint
Environment
{
  "local_name": "@vue/cli-plugin-eslint",
  "alias": false,
  "peer_metadata": null
}
^3.0.3development
@vue/cli-service
Environment
{
  "local_name": "@vue/cli-service",
  "alias": false,
  "peer_metadata": null
}
^3.0.3development
vue-template-compiler
Environment
{
  "local_name": "vue-template-compiler",
  "alias": false,
  "peer_metadata": null
}
^2.5.17development
eslint-config-airbnb-base
Environment
{
  "local_name": "eslint-config-airbnb-base",
  "alias": false,
  "peer_metadata": null
}
^13.1.0development
eslint-plugin-import
Environment
{
  "local_name": "eslint-plugin-import",
  "alias": false,
  "peer_metadata": null
}
^2.14.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-I4224n4xFV5IWR0uTZT6lpxeb+zZNDAyiTJkIJddeV3c5pThfakq7ObmGDAZZTmSA437DbR+Zz21Y54bEnUTZg==",
  "shasum": "93ccae1cbc622b264bf0a3028fe9cd64a3ff2146",
  "tarball": "https://registry.npmjs.org/@0saw/vue-css-donut-chart/-/vue-css-donut-chart-1.1.4.tgz",
  "fileCount": 24,
  "unpackedSize": 421485,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcj1TmCRA9TVsSAnZWagAAEeYQAI7NDJ98fogIMpdwEYvu\nZvF/9XYqsWlLeGZVvimDVVdMpTk5beUXQ81fFhBBpIuiBpJkJik97BXrft7/\n6dGqLKt2yIo2+3zhc5RwXo1VyH7U/g5lDICW4zi0z7KlJcQMX9oT8zyUGqQL\nXzbladjGpqWQhoJs4EFg4vmvT/17nM41uC3jxlzvJQkAdw6Nnk2g17PGoN5v\nQ/qeBWH2ThMdK19uvwzg+khHHHRynoWLlpQMAEINskGRWiMc9Hy+OQnNwOTs\ngxM53srTJuB1IVnqeHMOZkP/8id9Yi+ZkOyrNDklSNkEL2DfDhM4i02SA8ls\nPlwWPqrIx2lzRQQD1seT10cZLHD3fZgO7bWbR0xJ7H+G0ZA327I9Wok3DqCT\nTuvtGvp4ZGM3WvOs3/WlmE1qwDmuoFYOe4H1vv1avNcqVLFx6mg5/G2WpgI+\nhmw5EF+WKoc43gpknvAKg2etl4/X+DdH2roNkHghuvtaQ7uqiZxBJygqUPwA\nrTeNTy5peLoMYSmDTFSuVpSd1FKcwml5rjt3lrATpFJEP9aq+bXK28On6Y6r\noJLr6HXIt/4bs44R7Q1u42Y9psHTbWg4WR7/6Q/Wu4xBUFHg/OHOhCab1bmQ\nTFFG+uM/JBZr+HJVZdWbhB9H8L7DKP0JrNdRi8ORWkpFEl8ni8Zg6trMMC5v\nu3kl\r\n=0FLy\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCICufqByOo76SEBC3fwxVLQ5b9mEmMh1RWpeAD+AqcMlpAiBns0/Oa223+1wlRbNlC9Tar5SZpPJaxMZfPlIkE7gTUQ=="
    }
  ]
}

Repository

PENDING
0saw/vue-css-donut-chart

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:15 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:9cfc3fa791857b06bddaa54ba2e5398f4a1badc9309a5832d86ca2e778e53014

Other collected versions

1.1.518 Mar1.1.318 Mar1.1.218 Mar1.1.118 Mar1.1.018 Mar1.0.218 MarView all collected versions →