npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@guoliim/react-echarts

v0.0.13

Published

react hook & typyscript to wrapper echarts

Downloads

153

Readme

react-echarts

a react wrapper component for echarts which steal ideal from echarts-for-react by react hook & typescript.

Install

use npm

npm install @guoliim/react-echarts

use yarn

yarn add @guoliim/react-echarts

Usage

import React from 'react'
import echarts from 'echarts'
import Charts from '@guoliim/react-echarts'

<Chart
    echarts={echarts}
    data={
        option, /* option to render in echarts */
    }
/>

API

echarts

  • description

    Required, echarts module include version 3.x or 4.x

  • type

    --

  • example

    echarts

className

  • description

    Optional, css class name to style charts, especially block-size

  • type

    string

  • example

    classNameToStyleChart

data

  • description

    Required, include three part

    • option: required, data & params that echarts to be merged to generate and render in chart

    • opts: optional, include notMerge, lazyUpdate, silent to modify echarts instance merge & update & silent behavior

    • on: optional, bind event on echarts instance

    mode detail can be found in official doc

  • type

        {
            data: Object,
            opts?: {
                notMerge?: boolean,
                lazyUpdate?: boolean,
                silent?: boolean
            },
            on?: {
                event: string
                handler: (params: unknown) => unknown
            }[]
        }
  • default / example

    • default: lazyUpdate value is true

    • example:

          {
              option: {
                  xAxis: {
                      type: 'category',
                      data: ['Mon', 'Mon', 'Tue', 'Tue', 'Tue', 'Tue', 'Tue']
                  },
                  yAxis: {
                      type: 'value'
                  },
                  series: [{
                      data: [820, 932, 901, 934, 1290, 1330, 1320],
                      type: 'line'
                  }]
              },
              on: [
                  {
                      event: 'click',
                      handler: handlerTest,
                  },
              ],
          }

opts

  • description

    Optional, option to modify init echarts instance

  • type

        {
            devicePixelRatio?: number
            renderer?: string
            width?: number | string
            height?: number | string
        }
  • default / example

    • default: { rerender: 'svg' }

    • example:

          {
              devicePixelRatio: 15,
              renderer: 'canvas',
              width: 300,
              height: 300,
          }

theme

  • description

    Optional, Theme to be applied. This can be a configuring object of a theme, or a theme name registered through echarts.registerTheme.

  • type

    Object

  • example

    --

disableLoading

  • description

    Optional, when echarts loading, show the loading mask

  • type

    boolean

  • example

    false

onLoading

  • description

    Optional, then function to set how the loading mask showing

  • type

    (echarts: ECharts) => unknown

  • example

        const showLoading = (chart) => {
            chart.clear()
            chart.showLoading({
                text: '努力加载中',
                color: '#333',
                textColor: '#333',
                maskColor: 'transparent'
            })
        }

onEchartsReady

  • description

    Optional, the handle when echarts instance settled successfully

  • type

    (echarts: ECharts) => unknown

  • example

        (echarts) => {
            console.log('ready', echarts)
        }

Echarts API

echarts option & params & api can found in official doc

Example

    import React from 'react'
    import echarts from 'echarts'
    import styled from '@emotion/styled'

    import Chart from '../src'

    export default {
        title: 'Charts',
        component: Chart,
    }

    const LineChart = styled(Chart)`
        block-size: 200px;
    `

    export const LineCharts = () => {

        const handlerTest = React.useCallback((params) => {console.log('click', params)}, [])
        const showLoading = React.useCallback((chart) => {
            chart.clear()
            chart.showLoading({
            text: '努力加载中',
            color: '#333',
            textColor: '#333',
            maskColor: 'transparent'
            })
        }, [])

        const chartData = {
            option: {
                xAxis: {
                    type: 'category',
                    data: ['Mon', 'Mon', 'Tue', 'Tue', 'Tue', 'Tue', 'Tue']
                },
                yAxis: {
                    type: 'value'
                },
                series: [{
                    data: [820, 932, 901, 934, 1290, 1330, 1320],
                    type: 'line'
                }]
            },
            on: [
                {
                    event: 'click',
                    handler: handlerTest,
                },
            ],
        }

        return (
            <LineChart
                echarts={echarts}
                data={chartData}
                onLoading={showLoading}
                onEchartsReady={(echarts) => {
                    console.log('ready', echarts)
                }}
        />
        )
    }

RoadMap

License

MIT@guoliim

To-do

    • [x] add types/index.d.ts support
    • [x] add eslint / typescript lint
    • [x] add prettier
    • [x] add test
    • [x] add doc
    • [x] add example for local
    • [ ] add example for online
    • [ ] add publish script for npm registry & github pkg registry
    • [ ] promote test coverage