Code Monkey home page Code Monkey logo

component's Introduction

@antv/component

Visualization components for AntV, based on G which is a flexible rendering engine for visualization.

build Coverage Status npm Version npm Download npm License

✨ Features

  • Rich - Contains 20+ Visualization components, for AntV G2, G6, L7.
  • Powerful - Each component has powerful abilities and flexible scalability.
  • Well Design - Continuous optimization and iteration.
  • Powerful Renderer - Based on the powerful renderer G, we can render the components using Canvas, SVG or WebGL with same code.

📦 Installation

$ npm install @antv/component
$ yarn add @antv/component

🔨 Getting Started

import { Canvas } from '@antv/g';
import { Renderer } from '@antv/g-canvas';
import { Button } from '@antv/component';

// 1. New a canvas.
const canvas = new Canvas({
  container: 'container',
  width: 600,
  height: 600,
  renderer: new Renderer(),
});

// 2. Create a button with configure.
const button = new Button({
  /* ... */
});

// 3. Append into G canvas.
canvas.appendChild(button);

// 4. Render.
canvas.render();

📎 Documents

📮 Contribution

$ git clone [email protected]:antvis/component.git

$ cd component

$ npm install

$ npm run dev

Then send a pull request on GitHub.

📄 License

MIT@AntV.

component's People

Contributors

aarebecca avatar ai-qing-hai avatar connono avatar dengfuping avatar dxq613 avatar elaine1234 avatar eve-sama avatar hustcc avatar jounqin avatar keeplz avatar kuldeepkeshwar avatar leannechn avatar lessmost avatar leungwensen avatar lxfu1 avatar michael-land avatar paleface001 avatar pearlwang1106 avatar pearmini avatar rainy-25ghz avatar runtus avatar sersishen avatar simaq avatar visiky avatar xiaoiver avatar xile611 avatar yanyan-wang avatar yanyuanfe avatar yp0413150120 avatar zhangjunjie-loki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

component's Issues

[5.0] interface 改为可选

G2 会引用 types 下的一些类型定义,但是在 G2 层,这些类型定义中的配置都是可选的,所以希望 component 层可以改一下~~~

比如 :

image

[Feature Request] 增加对tooltip item替换内容进行html转义的选项

当前tooltip组件在对itemTpl中的占位符(如{name})进行替换时,并不会对替换内容进行转义
这在绝大多数情况下不会造成影响,还提供了更高的定制自由度
然而逻辑上,这一行为确实与其他组件乃至tooltip自身的标题是不一致的(而且文档中没有说明),甚至有可能成为安全隐患
图片
因此我认为在TooltipCfg中增加htmlEscape选项不但有必要,如果不考虑兼容性甚至应该是默认开启的

仓库治理

请给这个 repo 一个稍微详细一点的 Description。【开头补一个一句话说明】

稍微细化一下 README,说一下这个 repo 是干什么的、大概被哪里依赖。

(如果是已经废弃的项目需要清理)

[5.0] marker.spacing 不生效

传入的 items 是这个:

[
      { id: 'sold', name: 'sold', value: 'sold', marker: { symbol: 'circle', spacing: 100, style: { fill: 'red' } } },
      { id: 'buy', name: 'buy', value: 'buy', marker: { symbol: 'square', spacing: 100, style: { fill: 'blue' } } }
    ]

然后 component.get('items') 获得的也是对的。

image

但是绘制出来不对:

image

关于titleOffset的适应问题

  • Link:
  • Platform:
  • Mini Showcase(like screenshots):

关于坐标轴,line 类型 的 titleOffset的几点问题。

  1. 由于在 https://github.com/antvis/component/blob/master/src/axis/base.js 92行代码中,给title 中的 offset 设置了默认值。与 https://github.com/antvis/component/blob/master/src/axis/line.js
    中的 renderTitle 函数,107行代码逻辑矛盾,只有手动设置offset 为null 才进入此逻辑。

  2. https://github.com/antvis/component/blob/master/src/axis/line.js 中 109 行 labelsGroup 为 null,正确属性对象应该为:labelRenderer

 const labelRenderer = self.get('labelRenderer');
      if (labelRenderer) {
        const labelLength = self.getMaxLabelWidth(labelRenderer);
        const labelOffset = self.get('label').offset || self.get('_labelOffset');
        titleOffset += labelLength + labelOffset;
  }
  1. offset相对于轴线的偏移量的灵活性不足。 因为Y轴坐标轴的label数据变大的情况下,预先设置的offset值不满足的情况下会导致遮盖。个人建议:

offset 是否可以考虑是相对于坐标轴label文本的偏移量,如果在label有旋转角度的情况下,根据坐标轴项量 / 旋转角度 / label文本最大宽度 / fontSize等条件 可以计算 label文本的实际宽度。

真心希望尽快修复 1,2问题。等待上线中。。

Tooltip: htmlContent 配置会导致报错

  • Link:
  • Platform:
  • Mini Showcase(like screenshots):
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height">
    <title>散点图</title>
    <style>::-webkit-scrollbar{display:none;}html,body{overflow:hidden;height:100%;margin:0;}</style>
</head>
<body>
<div id="mountNode"></div>
<script>/*Fixing iframe window.innerHeight 0 issue in Safari*/document.body.clientHeight;</script>
<script src="https://gw.alipayobjects.com/os/antv/pkg/_antv.g2-3.3.2/dist/g2.min.js"></script>
<script src="https://gw.alipayobjects.com/os/antv/pkg/_antv.data-set-0.9.6/dist/data-set.min.js"></script>
<script src="https://gw.alipayobjects.com/os/antv/assets/lib/jquery-3.2.1.min.js"></script>
<script>
$.getJSON('/assets/data/scatter.json', function(data) {
  var chart = new G2.Chart({
    container: 'mountNode',
    forceFit: true,
    height: window.innerHeight
  });
  // 数据格式: [{"gender":"female","height":161.2,"weight":51.6}]
  chart.source(data);

    chart.tooltip({
      showTitle: false,
      crosshairs: {
        type: 'cross'
      },
      htmlContent: (title, items) => {
        // debugger;
        let container =
          '<div class="g2-tooltip" style="visibility: visible;position: absolute;border: 1px solid #efefef;'
          + 'color:#000;padding: 5px 15px;opacity: 0.8; background: white; "transition":top 200ms, left 200ms; ">'
          // + '<div class="g2-tooltip-title" style="margin-bottom: 4px;"></div>'
          // + `${title}`
          + '<ul class="g2-tooltip-list"></ul>';
        items.forEach((item, index) => {
          const color = item.color;
          container += '<li style="list-style:none;">'
            + '<p>' + item.name + '</p>'
            + '</li>';
        });
        container += '</div>';
        return container;
      },
    });
  chart.point().position('height*weight').size(4).shape('circle').opacity(0.65).tooltip('gender*height*weight', function(gender, height, weight) {
    return {
      name: gender,
      value: height + '(cm), ' + weight + '(kg)'
    };
  });
  chart.render();
});
</script>
</body>
</html>

[5.0] component 动画支持

在上层 G2 中,提供了四种动画类型:

  1. appear 初始化入场动画
  2. enter 数据更新后,新增元素的入场动画
  3. update 更新动画
  4. leave 出场(销毁)动画

组件中默认参与动画的元素:

  1. Axis
    a. ticks
    b. labels
    c. grid
    她们将参与:enter,update 和 leave 动画,初始化入场时(appear)不执行
  2. Annotation
    参与 appear, enter, update 和 leave

所以需要组件层支持:以上四种动画的配置:

interface AnimateBaseCfg {
  /** 动画缓动函数 */
  readonly easing?: string;
  /** 动画执行函数 */
  readonly animation?: string;
  /** 动画执行时间 */
  readonly duration?: number;
  /** 动画延迟时间 */
  readonly delay?: number;
  /** 动画执行结束后的回调函数 */
  readonly callback?: () => any;
}

interface AnimateOption {
  appear?: AnimateBaseCfg | false | null;
  enter?: AnimateBaseCfg | false | null;
  update?: AnimateBaseCfg | false | null;
  leave?: AnimateBaseCfg | false | null;
}


chart.axis('fieldName', {
  animate:  AnimateOption
});

bug

catPageHtml.js下的
_renderFlipPage函数获取legendWrapper 时有问题,
页面有多个图表时,document.getElementsByClassName(CONTAINER_CLASS)[0]会获取错误
是不是应该改为 const legendWrapper = this.get('legendWrapper')

怎么获取axis中label的最大高度及最大宽度

由于图表padding设置为auto时,滚动条、轴标题和轴文本等并不能自适应,所以想要手动计算padding值达到自适应效果。
由于后台返回值不同,所以padding值不能写固定值。

有没有办法获取到x轴label占的最大高度和y轴label的最大宽度?

[5.0] annotation

  • arc 传入的是 center、radius、startAngle、endAngle,只能用于 polar 下面吗?
  • image 使用 start、end 定位,用户传入那里是 x y width height,确定这样的吧?
  • line 中的 text.position 处理逻辑是 Controller 中做,还是 Component 中做?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.