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

techarts

v1.0.6

Published

An out of the box Taro component for ECharts

Downloads

38

Readme

techarts

开箱即用的 Taro2 echarts 组件,不需要配置任何 "copy". 据有以下特性:

  • 支持多种使用方式。
  • 支持自定义构建的 echarts
  • 支持导出图片

如果你觉得解决了你的问题,并节省了时间,请在 github 上给我一个小星星 ^_^

安装

// 注意必须要加版本号,因为最新版本兼容了 Taro3 不兼容Taro2
npm install techarts@^1.0.5

使用

import EChart from 'techarts';
// 自定义构建的echarts
import * as echarts from './echarts';

// 基本用法
<EChart echarts={echarts} option={option} />;
// 通过组件实例设置数据
<EChart
  ref={(node) => {
    this.chart = node;
  }}
  echarts={echarts}
/>;
this.chart.setOption({...});
// 自定义初始化
<EChart echarts={echarts} onInit={this.onInit} />;

onInit = (canvas, width, height, dpr) => {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height,
    devicePixelRatio: dpr,
  });
  canvas.setChart(chart);
  chart.setOption(this.state.option);
  // this.chart = chart; // 通过chart也可以setOption
  // chart.on('click', e => {})
  // chat.on('selectchanged', e => {})
  return chart; // 必须return
};
// 以上三种用法可以结合使用

参数

| 参数名称 | 解释 | 默认值 | 是否必填 | | ------------ | -------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- | | echarts | echarts 对象。建议去官网自定义构建;注意不要勾选“代码压缩”,可下载后自行压缩。 | - | Y | | option | 参数同echart option | - | Y | | canvasId | cancas-id 兼容低基础库版本(<2.9.0)时需要 | - | N | | disableTouch | 是否禁用手势 | false | N | | lazyLoad | 需要拿到组件实例手动 init 的时候请传递 true | false | N | | style | 样式 | - | N | | onInit | 需要自定义 echarts init 时使用(可用此方式给 echarts 绑定事件) | - | N |

实例 API

| API 名称 | 参数 | 回调参数 | | -------------------- | ---------------------------------------------------------------------------------------------------- | --------- | | init | callback | 同 onInit | | setOption | echart option | - | | canvasToTempFilePath | 同小程序 | 同小程序 | | getCanvasId | 获取容器 id | - |

示例

参照项目 demo 目录

注意事项

  • Taro H5 本地开发时样式加载延时,导致 echarts 初始化宽高读取错误。build 之后正常
  • canvasToTempFilePath h5 未实现定制宽高位置等功能

License

MIT@elvinzhu