3 Star 15 Fork 2

小为 / G2Plot-QRCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

G2Plot-QRCode

G2Plot-QRCode: plugin based on G2Plot v2. LIVE DEMO, CodeSandbox.

npm Version npm License

image

Install

$ npm i --save g2plot-qrcode

Usage

  • render
import { G2Plot } from '@antv/g2plot';
import { adaptor, defaultOptions } from 'g2plot-qrcode';

const qr = new G2Plot('container', {
  // 二维码文本
  data: 'Hello, g2plot qrcode!',
  // 间距
  padding: 8,
  // 宽高
  width: 120,
  height: 120,
  // 背景前景颜色
  backgroundColor: 'white',
  foregroundColor: 'black',
  typeNumber: 0,
  correctLevel: 'H', // L M H Q
  // 样式自定义
  pixelStyle: (pixelData) => ({}),
}, adaptor, defaultOptions);

qr.render();
  • update
qr.update({
  data: 'hello world!',
});

Configure

export interface QRCodeOptions {
  /** qrcode 的内容文本 */
  readonly data: string;
  /** 边框间距,默认 8px */
  readonly padding?: number;
  /** 二维码大小宽高,默认都是 120px */
  readonly width: string;
  readonly height: string;
  /** 二维码 correctLevel,默认 H */
  readonly correctLevel?: 'L' | 'M' | 'Q' | 'H';
  /** 二维码 typeNumber,默认 0 */
  readonly typeNumber?: any;
  // readonly effect?: 'fusion' | 'round' | 'rect';
  /** 二维码前景色,默认 black */
  readonly foregroundColor?: string;
  /** 二维码背景色,默认 white */
  readonly backgroundColor?: string;
  /** 二维码的 icon 中心图标,默认无 */
  readonly icon?: {
    readonly image: string; // 图片
    readonly width?: number; // 图片宽高
    readonly height?: number;
  };
  /** 单元格样式,默认无 */
  readonly pixelStyle?: (pixelData: PixelData) => object;
}

License

MIT@hustcc.

MIT License Copyright (c) 2019 hustcc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Draw a QRCode with G2Plot. 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/hustcc/G2Plot-QRCode.git
git@gitee.com:hustcc/G2Plot-QRCode.git
hustcc
G2Plot-QRCode
G2Plot-QRCode
master

搜索帮助