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

echarts-adaptive-plugin

v0.0.4

Published

echarts-adaptive-plugin

Downloads

22

Readme

echarts-adaptive-plugin

npm-version node-version npm-downloads license

这是一个为 ECharts 图表提供自适应功能的插件。它可以监听一个元素的大小变化,并自动调整 ECharts 图表的大小,以确保图表在不同设备和屏幕尺寸下都能正常显示。

特性

  • 自适应调整:自动监听容器大小的变化,调整图表尺寸。
  • 灵活配置:支持自定义调整参数,以满足特定需求。
  • 简单易用:通过简单的配置即可实现图表的自适应功能。

安装

使用 npm 安装:

npm install echarts-adaptive-plugin

或者使用 yarn:

yarn add echarts-adaptive-plugin

使用方法

首先,确保你已经安装了 ECharts。

然后,你可以这样使用 echarts-adaptive-plugin

import * as echarts from 'echarts';
import { echartsAdaptive } from 'echarts-adaptive-plugin';

// 初始化 ECharts 实例
const echartsInstance = echarts.init(
  document.getElementById('your-chart-container')
);

// 获取需要监听大小变化的元素
const monitorContent = document.getElementById('your-chart-container');

// 确保 monitorContent 不为空
if (!monitorContent) {
  throw new Error(
    '监视内容的元素未找到,请确保元素ID正确且已经被加载到DOM中。'
  );
}

// 配置自适应插件
const destroyAdaptive = echartsAdaptive({
  echartsInstance,
  monitorContent: document.getElementById('your-chart-container'),
  handle: ({ echartsInstance, monitorContent }) => {
    // 可以在这里返回自定义的调整参数
    return {};
  }
});

// 当不再需要自适应功能时,可以调用返回的函数销毁监听
// destroyAdaptive();

API

echartsAdaptive(options)

options

  • echartsInstance: echarts.ECharts - ECharts 实例。
  • monitorContent: HTMLElement - 需要监听大小变化的元素。
  • handle?: (options: { echartsInstance: echarts.ECharts; monitorContent: HTMLElement; }) => object - 可选的处理函数,用于返回自定义的调整参数。

开发

  • 安装依赖:npm install
  • 文档服务:npm run dev
  • 构建项目:npm run build
  • 发布项目:npm run release

许可证

MIT License


Made with ❤️ by huyikai

希望这个插件能帮助你更轻松地实现 ECharts 图表的自适应布局!