Git Product home page Git Product logo

react-echarts's Introduction

Hi, I'm Hugo πŸ‘‹

Tech Lead at @Vitruve

Hi, I'm Hugo. Most folks know me as hugocxl online. I'am a software craftsman passionate about software design and crafting digital products.

πŸ’» Projects

  • Terai - πŸŒπŸš€ Next-gen i18n framework
  • React to Image - πŸ“Έ Hooks for converting your React components to images
  • React ECharts - 🐳 ECharts for React
  • Typescript Library Starter - πŸ’Ž A template for crafting Typescript libraries
  • hugocxl.me - ⚑️ My site built with Next.js, PandaCSS, Notion, and Vercel
  • Software Design Essentials - πŸ›οΈ TLDR for Software Design
  • dotfiles - πŸ”‹ Your dotfiles are how you personalize your system. These are mine
  • Serika - 🎨 Serika Theme for Visual Studio Code
  • Haramosh - 🎨 Haramosh Theme for Visual Studio Code

⭐️ Radar

I keep myself up-to-date with the latest trends, innovations, and breakthroughs in the dynamic world of software development, check my stars.

πŸ“« Connect

Reach me at @hugocxl or [email protected]

react-echarts's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar hugocxl avatar maximeoger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-echarts's Issues

Animation still reset each time data is changed

Hello, thanks for making this working again!

I faced same issue which is mentioned below as resolved in v1.0.4

          Fixed in `v1.0.4`, thanks to @brandanking-decently contribution.

Originally posted by @hugocxl in #20 (comment)

So I have this version, still each data change cause my barchart to disappear and raise from zero instead of smoothly sliding bars up and down to new values.

Here is my way of doing things, please help

import { EChart } from '@kbox-labs/react-echarts';
import {
  BarChart,
} from 'echarts/charts';
import {
  GridComponent,
  TooltipComponent,
  TitleComponent,
} from 'echarts/components';
import {
  CanvasRenderer,
} from 'echarts/renderers';

import merge from 'lodash/merge';
import map from 'lodash/map';
import { shadedColors } from './color/colors';

const defaultStyle = { height: '', width: '100%' };
const defaultOptions = {
  grid: [
    {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
      containLabel: true,
    },
  ],
  color: map(shadedColors.slice(1), 0),
};

export default function Echarts({
  option = {}, style = {}, ...props
}) {
  const p = merge({}, props, defaultOptions, option);

  return (
    <EChart
      use={[
        BarChart,
        GridComponent,
        TooltipComponent,
        TitleComponent,
        CanvasRenderer,
      ]}
      renderer="canvas"
      lazyUpdate
      notMerge {/* adding/removing notMerge has no effect */}
      theme="theme_name"
      style={{ ...defaultStyle, ...style }}
      {...p}
    />
  );
}

Using narrowed type for props

Description

The use prop is a really good wrapper to reduce bundle size: https://hugocxl.github.io/react-echarts/docs/bundle-size
However, wondering if we have a way (e.g. generic) that can narrow down the prop type to those modules we included only?
https://echarts.apache.org/handbook/en/basics/import#creating-an-option-type-in-typescript just like in the official docs

Problem Statement/Justification

For better type-checking in case of using in-exist props

Proposed Solution or API

Maybe generic?

Alternatives

No response

Additional Information

No response

Data transition animation issue

Description

Looking at the official data transition example: https://echarts.apache.org/handbook/en/how-to/animation/transition
It looks really smooth and fancy, however, within this library, this is broken: https://stackblitz.com/edit/vitejs-vite-bcghqm?file=src%2FApp.tsx

Why invoke .clear() on option change?

echartsInstance.clear()

This line is definitely which breaks this in the first place. If the instance is cleared, there's no way ECharts can diff the options, hence animation won't be applied. And what's even worse, the entry animation will be played everytime option changes.
If it's intend to avoid memory leak, we should just clear it when component unmount by return value of empty-dependency-array useEffect

Maybe, passing down property: undefined is different from not passing that property in ECharts options

Since you are restructuring everything then pass down to setOptions(), this may have some weird behaviour on how ECharts handles data and diff them. At least this is true in some of ESLint rules, that passing undefined is different from not passing.

I've tried to remove .clear() call and remove everything except series when passing to setOptions(),


then the example above works, but unfortunately I can't edit node_modules folder in stackblitz.

Link to Reproduction

https://stackblitz.com/edit/vitejs-vite-bcghqm?file=src%2FApp.tsx

Steps to reproduce

No response

JS Framework

React TS

Version

latest

Browser

Chrome 121

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

No response

Console complaining `use()` of unused components

Description

Just a normal bar chart used, and use has been specified, however the console still reporting lots of unused use cases.
Worrying about this since that in dev mode it may accidentally let something run without specifying in use, hence will break in production if those are not imported in prod.
image

Link to Reproduction

https://stackblitz.com/edit/vitejs-vite-ea2tby?file=src%2FApp.tsx,src%2FECharts.tsx&terminal=dev

Steps to reproduce

Visit the reprod link

JS Framework

React TS

Version

latest

Browser

Chrome 121

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

No response

Chart connect

Subject

connect method

Description

Hi. From the documentation is not so clear for me how to connect charts. For example I have this implementation and Chart component used multiple times. How can I connect it ? I know theres a method 'connect' in echarts for group.

`
import { Box } from '@mui/material';
import { EChart } from '@kbox-labs/react-echarts'
import { forwardRef } from 'react';

const Chart = forwardRef(function Chart(props, ref) {
const { options } = props;

return (
    <Box>
        <EChart {...options} ref={ref}
            style={{ height: '360px', width: '100%' }}
            renderer={'svg'}
            group="group1"
            notMerge={true}
            lazyUpdate={true}
        />
    </Box>
);

});

export default Chart;
`

Missing type declaration files

Description

import { EChart } from '@hcorta/react-echarts';

This will give me an error Could not find a declaration file for module xxx.

Link to Reproduction

n/a

Steps to reproduce

  1. Install this package in your project:
npm i @hcorta/react-echarts
  1. Use this package in your tsx file.

JS Framework

React (TS)

Version

2.0.0

Browser

No response

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

No response

How to use registerMap

Subject

component

Description

Reading the docs there's nothing about "registering" a map with geoJSON data.

The same by reading the code.

May I ask you if this is possible and how? Tnx.

Error on installing with npm

I was trying to install this ECharts library via npm but I'm getting this error on installation process:

npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "^>=15.0.0": Tags may not have any characters that encodeURIComponent encodes.

Hopefully it's a quick fix!

Error when using in Next.js: Unexpected token 'export'

Description

When I added react-echarts to my Next.js 14 project using the pages router, I get the following error message when calling a page that imports an EChart component:

 β¨― /Users/M305642/dev/mtrust/mtrust-portal/node_modules/.pnpm/[email protected]/node_modules/echarts/core.js:20
export * from 'echarts/lib/export/core.js';
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:77:18)
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1340:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at mod.require (/Users/M305642/dev/mtrust/mtrust-portal/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:64:28)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/Users/M305642/dev/mtrust/mtrust-portal/node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@kbox-labs/react-echarts/dist/index.js:41:19)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19) {
  page: '/project/651feaa07bf885750abf7b68/metering'
}

Link to Reproduction

https://github.com/renet/next-echarts-repro

Steps to reproduce

  1. Checkout
  2. run pnpm i
  3. run pnpm dev
  4. Open http://localhost:3000
  5. See error message

JS Framework

Next.js / React TS

Version

1.0.3

Browser

Safari

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

The sandbox did not work, throwing an pnpm-specific error, but it works just fine locally with a clean pnpm install. The error does not occur, when the app router is used.

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.