third party plugins

Tailwind CSS Apex charts

Charts are visual tools that simplify complex data sets, making information more accessible. They include line, bar, and pie charts for specific trends.

Below are the comprehensively outlined steps you can follow to seamlessly integrate Apexcharts JS with FlyonUI.

  • 1
    Step 1: Install Required Packages

    Install apexcharts and lodash via npm. The lodash library is required by certain JavaScript helpers for ApexCharts, so ensure both packages are installed.

    npm i apexcharts lodash

  • 2
    Step 2: Include ApexCharts JavaScript and CSS

    Add the required ApexCharts CSS and JS files to your page in the following locations:

    <head>
      <link rel="stylesheet" href="../path/to/apexcharts/apexcharts.css" />
    </head>
    <body>
      <script src="../path/to/lodash/lodash.js"></script>
      <script src="../path/to/apexcharts/dist/apexcharts.js"></script>
    </body>

    Note: A CDN link won't work here because we need to modify the default Vendor CSS to fit FlyonUI's design.


  • 3
    Step 3: Add the ApexCharts Helper JavaScript

    Include the apexcharts-helpers.js script file after the apexcharts.js. Since this helper script uses Tailwind CSS classes, copy it into your project's js folder and reference it in your tailwind.config.js to ensure the required classes are generated.

    <script src="../path/to/apexcharts-helper.js"></script>

  • 4
    Step 4: Update Tailwind Configuration

    Include the path to the vendor and helper JS files in the content section of your Tailwind configuration file. Additionally, set vendors="true" in the FlyonUI config to ensure the override CSS is generated:

    module.exports = {
      content: [
        '../path/to/apexcharts/**/*.js', // Include all relevant JS files from ApexCharts
        '../path/to/apexcharts-helper.js', // Include helper JS file with tooltip functions and initialization code
      ],
      flyonui: {
        vendors: true // Enable vendor-specific CSS generation
      }
    }

  • 5
    Step 5: Basic Usage

    Use the method below to create an ApexCharts instance. This method contains all necessary settings, specifications, and styles for the chart.

    buildChart('#id', mode => ({ /* Chart details */ }))

The example below demonstrates how to use a single area chart with Helper.js.

Helper.js offers four different tooltip designs and includes an auto-init function, eliminating the need for manual initialization. However, if you prefer, you can remove the Helper.js file and use the default Apex chart initialization. Below is an example, but keep in mind that you will need to enable the vendor option in the config file for CSS generation.

The following example demonstrates the usage of a multiple area charts.

The following example demonstrates the usage of a multiple area charts with comparison tooltip.

The following example demonstrates the usage of a multiple area charts with alternative comparison tooltip.

The following example demonstrates the usage of a curved area charts.

The following example demonstrates the usage of a Column chart.

The following example demonstrates the usage of a multiple column charts.

The following example demonstrates the usage of a single line chart.

The following example demonstrates the usage of a multiple line charts.

The following example demonstrates the usage of a Curved line charts.

The following example demonstrates the usage of a Horizontal bar chart.

The following example demonstrates the usage of a doughnut chart.

The following example demonstrates the usage of a bubble chart.

The following example demonstrates the usage of a pie chart.

The following example demonstrates the usage of a radial bar chart.

The following example demonstrates the usage of a radar chart.

The following example demonstrates the usage of a small sized sparkline charts.