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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@albertluo213/chart-editor

v1.0.4

Published

Professional chart editor component for Cube Chart

Readme

@cube-chart/editor

完整的图表编辑器组件,提供可视化图表配置能力。

特性

  • ✏️ 可视化编辑界面
  • 🔧 丰富的配置选项(数据源、样式、交互等)
  • 💾 配置导入导出
  • 🔌 易于集成,支持 Vanilla JS 和 React
  • 📊 实时预览
  • 🎨 主题定制

安装

npm install @cube-chart/editor

快速开始

Vanilla JavaScript

import { ChartEditor } from '@cube-chart/editor';
import '@cube-chart/editor/style.css';

const editor = new ChartEditor({
  container: '#editor-container',
  mode: 'full', // 'full' | 'simple'
  config: {
    type: 'line',
    data: {
      values: []
    }
  },
  apiConfig: {
    baseURL: 'https://api.example.com',
    endpoints: {
      dataSources: '/api/datasources',
      save: '/api/charts'
    }
  }
});

// 监听配置变化
editor.on('configChanged', (config) => {
  console.log('配置已更新', config);
});

// 保存配置
editor.on('save', async (config) => {
  await saveChart(config);
});

// 获取当前配置
const config = editor.getConfig();

// 销毁
editor.destroy();

React

import { ChartEditor } from '@cube-chart/editor/react';
import '@cube-chart/editor/style.css';

function App() {
  const handleConfigChange = (config) => {
    console.log('配置变化', config);
  };

  const handleSave = async (config) => {
    await saveChart(config);
  };

  return (
    <ChartEditor
      mode="full"
      config={{
        type: 'line',
        data: { values: [] }
      }}
      apiConfig={{
        baseURL: 'https://api.example.com'
      }}
      onConfigChange={handleConfigChange}
      onSave={handleSave}
    />
  );
}

API 文档

ChartEditor

构造函数选项

interface ChartEditorOptions {
  container: string | HTMLElement;  // 容器元素或选择器
  mode?: 'full' | 'simple';         // 编辑器模式
  config?: ChartConfig;              // 初始图表配置
  apiConfig?: APIConfig;             // API 配置
  theme?: string;                    // 主题
  locale?: string;                   // 语言
}

方法

  • getConfig(): 获取当前配置
  • setConfig(config): 设置配置
  • validate(): 验证配置
  • reset(): 重置配置
  • destroy(): 销毁编辑器

事件

editor.on('configChanged', (config) => {});
editor.on('save', (config) => {});
editor.on('cancel', () => {});
editor.on('error', (error) => {});

编辑器模式

Full Mode (完整模式)

提供完整的编辑功能:

  • 数据源配置
  • 图表类型选择
  • 样式定制
  • 交互配置
  • 高级选项

Simple Mode (简单模式)

提供简化的编辑界面:

  • 基础图表类型
  • 简单数据配置
  • 预设样式

配置示例

const config = {
  type: 'line',
  data: {
    values: [
      { date: '2024-01', sales: 100 },
      { date: '2024-02', sales: 150 }
    ]
  },
  xField: 'date',
  yField: 'sales',
  title: '销售趋势',
  theme: 'light',
  legend: {
    visible: true,
    position: 'right'
  },
  tooltip: {
    visible: true
  }
};

License

MIT