Coder Social home page Coder Social logo

echarts-tsx's Introduction

echarts-tsx

The simplest React wrapper for Apache ECharts with Hooks and TypeScript.

使用 hooks 和 ts 简易封装的 echarts 组件。

🚀🚀🚀 支持 ts、自动根据元素宽高 resize、按需引入 🚀🚀🚀

Props

{
  option: EChartOption; // 配置项
  resize?: boolean; // 是否resize,默认为true
  // 👇以下三个是setoption的选项,见https://echarts.apache.org/v4/zh/api.html#echartsInstance.setOption
  notMerge?: boolean;
  lazyUpdate?: boolean;
  silent?: boolean;
}

Export

// default 组件
// 👇type
ChartRef; // ref的类型,包含echart实例
ECharts; //echart实例的类型
EChartOption; // 配置项类型

Quick Start

install

npm install echarts-tsx

import component & import charts and components you need

import Echarts, { ChartRef, EChartOption } from "echarts-tsx";

import "echarts/lib/chart/line";
import "echarts/lib/component/tooltip";

init option and ref and use component

const [option, setOption] = useRef<EChartOption>(null);
const DOM = useRef<chartRef>(null);

// you can fetch data and use setOption to update chart
// you can use DOM.current.echart to use Instance,example👇
useEffect(()=>{
  DOM.current.echart.on('click',()=>{
    // ...
  })
},[])

<Echarts ref={DOM} option={option} />;

echarts-tsx's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.