Echarts

There are few options on how to include/import Echarts into your project.

Install from NPM

Install the Echarts Js library from command prompt from the root directory of the project:

npm install echarts --save

Import the helper function to manage the charts colors based on mode changes. It will take updated values from the root variables.

import useChartColors from '@hooks/useChartColors';

Below the example how to use the package and make it working ApexTree on any page.

HTML

<div class="card-body" x-data="basicBarApp">
    <div class="h-80" x-ref="basicBarChart" data-chart-colors="[bg-sky-500, bg-gray-200, bg-gray-800]" data-chart-dark-colors="[bg-sky-500, bg-dark-800, bg-dark-100]"></div>
</div>

<script src="assets/libs/echarts/echarts.js"></script>

JavaScript

import useChartColors from '@hooks/useChartColors';
import React from 'react';
import ReactEcharts from 'echarts-for-react';

interface barChartsProps {
    chartColors: string;
    chartDarkColors: string;
}

const BasicBarChart = ({ chartColors, chartDarkColors }: barChartsProps) => {
    // Pass both chartColors and chartDarkColors to the hook
    const chartsColor = useChartColors({ chartColors, chartDarkColors });

    var options = {
        xAxis: {
            type: 'category',
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
            type: 'value'
        },
        grid: {
            top: '5%',
            left: '5%',
            right: '0%',
            bottom: '6%',
        },
        color: chartsColor,
        series: [
            {
                data: [120, 200, 150, 80, 70, 110, 130],
                type: 'bar'
            }
        ]
    };
    return (
        <React.Fragment>
            <ReactEcharts option={options}  className="h-80" />
        </React.Fragment>
    );
}

export default BasicBarChart
Receive the latest updates directly in your inbox!

Be the first to know about new updates and exclusive discounts. No spam, just great offers!

How about

A Custom Project?

With over 7 years of experienced team, we specialize in delivering custom projects for startups, blue-chip companies, and government agencies. We have successfully completed over 250+ projects, providing tailored solutions that meet the unique needs of each client.

Hire Us
Domiex Admin & Dashboards
230+

Total Pages

5+

Layouts

11+

Application

We provide quick support withing one business day to all of our customers.

© Domiex Created & Crafted by SRBThemes.