All Projects → dumptyd → Vue Css Donut Chart

dumptyd / Vue Css Donut Chart

Licence: mit
Lightweight Vue component for drawing pure CSS donut charts

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Css Donut Chart

AndroidTableauLibrary
AndroidTableauLibrary is an Android SDK library supports variety of analytic graphs which developers simply integrate on Android project. - by @sung2063
Stars: ✭ 53 (-49.04%)
Mutual labels:  pie-chart, progress-bar
Aachartcore Kotlin
📈📊⛰⛰⛰An elegant modern declarative data visualization chart framework for Android . Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types.极其精美而又强大的 Android 数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.
Stars: ✭ 332 (+219.23%)
Mutual labels:  chart, pie-chart
PieCharts
Easy to use and highly customizable pie charts library for iOS
Stars: ✭ 501 (+381.73%)
Mutual labels:  pie-chart, chart
React Fast Charts
Blazing Fast Charting Library in React with loading time less than 50ms
Stars: ✭ 113 (+8.65%)
Mutual labels:  chart, pie-chart
Jhchart
Stars: ✭ 593 (+470.19%)
Mutual labels:  chart, pie-chart
React D3 Components
D3 Components for React
Stars: ✭ 1,599 (+1437.5%)
Mutual labels:  chart, pie-chart
Anychart
AnyChart is a lightweight and robust JavaScript charting solution with great API and documentation. The chart types and unique features are numerous, the library works easily with any development stack.
Stars: ✭ 288 (+176.92%)
Mutual labels:  chart, pie-chart
Orcharts
饼状图、环形图、扇形图、曲线图、折线图
Stars: ✭ 125 (+20.19%)
Mutual labels:  chart, pie-chart
Piecharts
Easy to use and highly customizable pie charts library for iOS
Stars: ✭ 476 (+357.69%)
Mutual labels:  chart, pie-chart
Aachartkit
📈📊🚀🚀🚀An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的跨平台数据可视化图表框架,支持柱状图、条形图、折…
Stars: ✭ 4,358 (+4090.38%)
Mutual labels:  chart, pie-chart
StockView
股票相关控件(分时图、五日分时图、自选股迷你分时图、资金趋势图、盈亏额/盈亏率)- (曲线图、折线图)
Stars: ✭ 87 (-16.35%)
Mutual labels:  pie-chart, chart
Caroline
A simple Cairo Chart Library for GTK and Vala
Stars: ✭ 41 (-60.58%)
Mutual labels:  chart, pie-chart
Aachartcore
📈📊☕️☕️☕️An elegant modern declarative data visualization chart framework for Android. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types.极其精美而又强大的 Android 数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.
Stars: ✭ 424 (+307.69%)
Mutual labels:  chart, pie-chart
Dypiechartview
Animated Pie Chart using Custom CALayer.
Stars: ✭ 5 (-95.19%)
Mutual labels:  chart, pie-chart
Highcharts Chart
Polymer Element wrapper for highcharts library. Seamlessly create various types of charts from one element.
Stars: ✭ 97 (-6.73%)
Mutual labels:  chart, pie-chart
C3
📊 A D3-based reusable chart library
Stars: ✭ 9,163 (+8710.58%)
Mutual labels:  chart
Flamebarchart
一个炫酷的柱状图表。
Stars: ✭ 99 (-4.81%)
Mutual labels:  chart
React Charts
⚛️ Simple, immersive & interactive charts for React
Stars: ✭ 1,302 (+1151.92%)
Mutual labels:  chart
Stolon Chart
Kubernetes Helm chart to deploy HA Postgresql cluster based on Stolon
Stars: ✭ 90 (-13.46%)
Mutual labels:  chart
Chart.qml
Chart.qml like Chart.js
Stars: ✭ 100 (-3.85%)
Mutual labels:  chart

vue-css-donut-chart

Lightweight Vue component for drawing pure CSS donut charts

npm npm monthly downloads npm bundle size GitHub Actions status Coverage status Snyk Vulnerabilities for npm package

Live demo

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

Playground – https://jsfiddle.net/dumptyd/ujvypcd3/

Features

◾️ No external dependencies.

◾️ Small size footprint. npm bundle size

◾️ High test coverage. Coverage status

◾️ Performs automatic font size recalculation as the size of the donut changes.

◾️ Supports responsive donut and pie charts.

Table of Contents

Installation

Install via yarn or npm

yarn add vue-css-donut-chart

OR

npm install vue-css-donut-chart

Registering vue-css-donut-chart

◾️ ES6

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

Vue.use(Donut);

◾️ In-browser using CDNs

Using unpkg
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/vcdonut.css">
<script src="https://unpkg.com/[email protected]"></script>
<script>
  Vue.use(vcdonut.default);
</script>
Using jsDelivr
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vcdonut.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vcdonut.umd.min.js"></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 with objects containing a value property. This will create a donut with 2 sections that take up 25% each.

<template>
  <vc-donut :sections="sections">Basic donut</vc-donut>
</template>
<script>
  export default {
    data() {
      return {
        sections: [{ 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"
    :start-angle="0" :auto-adjust-text-size="true"
    @section-click="handleSectionClick">
    <h1>75%</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' }
        ]
      };
    },
    methods: {
      handleSectionClick(section, event) {
        console.log(`${section.label} clicked.`);
      }
    }
  };
</script>

For brevity, only the section-click event is demonstrated in the above example. You can use all the other section-* events the same way.

Using the component as a pie chart

Making the component look like a pie chart is as simple as setting the thickness to 100.

<template>
  <vc-donut
    :sections="[{ value: 35 }, { value: 15 }, { value: 15 }, { value: 35 }]"
    :thickness="100">
  </vc-donut>
</template>

Note: setting thickness to 100 will completely hide the diagram's text or slot content. The content will still be present in the DOM, however it won't be visible for obvious reasons.

API

Props

Prop Type Required Default Description
size Number No 250 Diameter of the donut. Can be any positive value.
unit String No 'px' Unit to use for size. Can be any valid CSS unit. Use % to make the donut responsive.
thickness Number No 20 Percent thickness of the donut ring relative to size. Can be any positive value between 0-100 (inclusive). Set this to 0 to draw a pie chart instead.
text String No Text to show in the middle of the donut. This can also be provided through the default slot.
background String No '#ffffff' Background color of the donut. In most cases, this should be the background color of the parent element.
foreground String No '#eeeeee' Foreground color of the donut. This is the color that is shown for empty region of the donut ring.
start-angle Number No 0 Angle measure in degrees where the first section should start.
total Number No 100 Total for calculating the percentage for each section.
has-legend Boolean No false Whether the donut should have a legend.
legend-placement String No 'bottom' Where the legend should be placed. Valid values are top, right, bottom and left. Doesn't have an effect if has-legend is not true.
auto-adjust-text-size Boolean No true Whether the font-size of the donut content is calculated automatically to fit the available space.
sections Array No [] An array of objects. Each object in the array represents a section.
section.value Number Yes Value of the section. The component determines what percent of the donut should be taken by a section based on this value and the total prop. Sum of all the sections' value should not exceed total, an error is thrown otherwise.
section.color String Read description Read description Color of the section. The component comes with 24 predefined colors, so this property is optional if you have <= 24 sections without the color property.
section.label String No 'Section <section number>' Name of the section. This is used in the legend as well as the tooltip text of the section.

Events

All the section-* listeners are called with the section object on which the event occurred and the native Event object as arguments respectively. Consider adding a custom property (eg: name) to the section objects to uniquely identify them.

Event Parameter Description
section-click section, event Emitted when a section is clicked.
section-mouseenter section, event Emitted when the mouseenter event occurs on a section.
section-mouseleave section, event Emitted when the mouseleave event occurs on a section.
section-mouseover section, event Emitted when the mouseover event occurs on a section.
section-mouseout section, event Emitted when the mouseout event occurs on a section.
section-mousemove section, event Emitted when the mousemove event occurs on a section.

Slots

Slot Description
default slot If you want more control over the content of the chart, default slot can be used instead of the text prop.
legend Slot for plugging in your own legend.

Contributing

Issueshttps://github.com/dumptyd/vue-css-donut-chart/issues

License

Code released under MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].