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

@qcharts/core

v1.0.37

Published

QCharts 是一个基于 spritejs 封装的图表库,可以让用户以组件的形式组合出各种图表

Downloads

84

Readme

QCharts

特点

QCharts 是一个基于 spritejs 封装的图表库,它以数据驱动,将图表以最小组件进行拆分,具有高度全面灵活的属性配置方法,可对图表绘制过程中所有的点、线、面的大小、位置、填充颜色、描边颜色、描边线型、透明度等属性进行配置,配置方法简单易懂,语义清晰,无论如何复杂的图表,Qcharts 都能轻松胜任。 → 详细文档,Demo:Quickstart

安装

1.通过 npm 获取 QCharts,我们提供了 QCharts npm 包,通过下面的命令即可完成安装

npm install @qcharts/core --save
// 通过模块引入的方式使用CatCharts
import { Chart, Pie, Tooltip, Legend } from '@qcharts/core'

2.既可以下载脚本到本地,也可以通过 cdn 获取 QCharts;QCharts 依赖于 spritejs,需要先引入 spritejs。

<script src="https://unpkg.com/spritejs@3/dist/spritejs.min.js"></script>
<script src="https://unpkg.com/@qcharts/core@1/dist/index.js"></script>

开始使用

1.创建 div 图表容器,Qcharts 初始化 container 属性支持 id 选择器与 class 选择器

<div id="app"></div>

2.编写绘图代码

// 指定图表数据源
chart.source(data, {
  row: 'catgory', // 以catgory字段分组
  value: 'sales', // 以sales字段取值
  text: 'date' //  date为文本字段
})

// 创建折线对象
const line = new Line()
// 设置折线点的描边颜色为白色
line.style('point', { strokeColor: '#fff' })
// 创建提示框对象,格式化展示属性为:date scale
const tooltip = new Tooltip({
  formatter: function(data) {
    return `${data.date} ${data.sales}`
  }
})
// 创建底部坐标轴对象
const axisBottom = new Axis()
// 创建左侧坐标轴对象。隐藏轴体直线和刻度
const axisLeft = new Axis({ orient: 'left' }).style('axis', false).style('scale', false)
// 创建图例对象,设置位置以及图标和文本大小
const legend = new Legend({ align: ['center', 'bottom'] }).style('icon', { borderRadius: 10 }).style('text', { fontSize: 12 })
// 装载组件
chart.append([line, tooltip, axisBottom, axisLeft, legend])
// 渲染图表

一张折线图就绘制成功

在 React/Vue 中使用 Qcharts

基于 Qcharts 良好的组合性和扩展性,Qcharts 天然支持对 React 和 Vue 这两个常用框架的深度整合,在 React 环境下,我们推荐使用qcharts-react ,在 Vue 环境下,我们推荐使用 qcharts-vue。这两个产品都是基于 Qcharts 的封装,与 Qcharts 有着一致的开发体验,可以前往官网获取详细的使用说明和示例。当然,你可以自己动手封装成其他框架下的组件,在 Qcharts 下,这些封装成本非常低。