Chart Pie

A pie chart is a circular statistical graphic that visually represents numerical proportions.
Overview API

Usage

Randomize

  <wc-button id="randomize">Randomize</wc-button>
  <br>

  <wc-chart-pie width="400" margin="20"></wc-chart-pie>


  <script>
    const chart = document.querySelector('wc-chart-pie');
    chart.label = "Browsers";
    chart.data = [
      { label: 'Firefox', name: 'firefox', value: 10, color: '#FF0000'},
      { label: 'Chrome', name: 'chrome', value: 20},
      { label: 'Microsoft Edge', name: 'microsoft', value: 30 },
      { label: 'Internet Explorer', name: 'ie', value: 40 },
      { label: 'MC Browser', name: 'mcb', value: 50 },
    ];

    function randomNumber(min, max) {
      return parseInt(Math.random() * (max - min) + min);
    }

    let count = 1;
    document.querySelector('#randomize').addEventListener('click', () => {
      chart.data = chart.data.map(d => ({ ...d, value: parseInt(Math.random() * 100) }));
      chart.width =  randomNumber(400, 600);
    });
  </script>

On this page

Sponsor

Properties

Events

Methods

CSS Custom Properties