Bubweb
  • 🌟News and Releases
    • New Templates
  • 🚀HELP GUIDE
    • Hire me
    • Getting Started
      • New Responsive Properties
      • Stripe
      • Google Login
      • Charts
        • Area
        • Column
        • Pie
        • Dumbbell
        • Polar Area
      • PWA
  • 🎨Templates
    • OpenAI & Claude
      • AI Agent Tools: OpenAI & Claude
    • Stable Diffusion SaaS Image Generator
      • Getting Started
      • Styles & Config
    • OpenAI & DALL-E
      • OpenAI SaaS - Tools Generate
        • 0️⃣New Responsive Properties
        • 1️⃣Configure Role & ID attribute
        • 2️⃣Configure OpenAI & DALL-E
        • 3️⃣Configure Stripe
        • 4️⃣Deploy to Live
        • Styles
        • PWA
    • Ecommerce
      • Ecommerce PWA - Stripe
        • New Responsive Properties
        • Company Role
        • Styles
        • Google Login
        • Stripe
        • PWA
        • 👁️‍🗨️Preview
    • CRM
      • CRM & Dashboard PWA - Lite
    • Dashboard Starter Kit
      • Global
        • 1️⃣New Responsive Properties
        • 2️⃣Configure Role
        • 3️⃣Styles
        • 4️⃣Charts
        • 5️⃣PWA
    • Social Network
      • Social Network Hub
        • 1️⃣New Responsive Properties
        • 2️⃣Configure Role
        • 3️⃣Styles
        • 4️⃣PWA
  • 🔌PLUGINS
    • Jotform
      • Getting Started
    • Microsoft OneDrive
      • Getting Started
Powered by GitBook
On this page
  • Chart Pie
  • Example of a static pie chart
  1. HELP GUIDE
  2. Getting Started
  3. Charts

Pie

Setting up the chart

PreviousColumnNextDumbbell

Last updated 1 year ago

Chart Pie

Example of a static pie chart

All I did was make the hexadecimal colors and the chart list dynamic

<!DOCTYPE html>
<html>
  <head>
    <script>
      window.onload = function () {
        var options = {
          legend: {
            fontSize: "14px",
            fontWeight: 600,
            fontFamily: "Inter, sans-serif",
            show: true,
            position: "right",
            formatter: function (val, opts) {
              return (
                val +
                " <span style='color: #374151;'>$" +
                opts.w.globals.series[opts.seriesIndex]
                  .toString()
                  .replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ",") +
                "</span>"
              );
            },
            labels: {
              colors: "#9CA3AF",
              useSeriesColors: false
            },
            itemMargin: {
              horizontal: 6,
              vertical: 6
            }
          },
          tooltip: {
            enabled: true
          },
          plotOptions: {
            pie: {
              donut: {
                size: "60%",
                labels: {
                  show: true
                }
              },
              expandOnClick: true
            }
          },
          grid: {
            padding: {
              top: 0,
              right: 0,
              bottom: 0,
              left: 0
            }
          },
          colors: ["#F1416C", "#E5E7EB", "#4F46E5"],
          series: [7660, 2820, 45257],
          labels: ["Shoes", "Gaming", "Others"],
          chart: {
            type: "donut",
            height: "auto",
            width: 400,
            offsetX: 20,
            sparkline: {
              enabled: true
            }
          }
        };

        var chart = new ApexCharts(document.querySelector("#chart"), options);
        chart.render();
      };
    </script>
  </head>
  <body>
    <div id="chart" style="width: 95%;"></div>
    <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  </body>
</html>

Content to show per list item

Series

7660, 2820, 45257

Labels

"Shoes", "Gaming", "Others"
🚀