g2-single-bar 单一柱状图 - 图1 This article has not been translated, hope that your can PR to translated it. Help us!g2-single-bar 单一柱状图 - 图2

g2-single-bar 单一柱状图

单一柱状图更适合在列表中展示简单的区间数据,简洁的表现方式可以很好的减少大数据量的视觉展现压力。

  1. import { G2SingleBarModule } from '@delon/chart/single-bar';

代码演示

g2-single-bar 单一柱状图 - 图3

基础

基础用法。

  1. import { Component, ViewEncapsulation } from '@angular/core';
  2. @Component({
  3. selector: 'chart-single-bar-basic',
  4. template: `
  5. <nz-table [nzData]="list" [nzShowPagination]="false">
  6. <thead>
  7. <tr>
  8. <th>序号</th>
  9. <th nzWidth="350px">服务调用次数</th>
  10. <th nzWidth="350px">数据有负值</th>
  11. </tr>
  12. </thead>
  13. <tbody>
  14. <tr *ngFor="let i of list; let idx = index">
  15. <td>{{ idx + 1 }}</td>
  16. <td>
  17. <g2-single-bar height="24" [value]="i.value"></g2-single-bar>
  18. </td>
  19. <td>
  20. <g2-single-bar height="60" [value]="i.other" min="-100" line></g2-single-bar>
  21. </td>
  22. </tr>
  23. </tbody>
  24. </nz-table>
  25. `,
  26. styles: [
  27. `
  28. :host ::ng-deep .ant-table tbody > tr > td {
  29. padding: 0;
  30. }
  31. `,
  32. ],
  33. encapsulation: ViewEncapsulation.Emulated,
  34. })
  35. export class ChartSingleBarBasicComponent {
  36. list = new Array(5).fill({}).map(() => ({
  37. id: Math.floor(Math.random() * 10000),
  38. value: Math.floor(Math.random() * 100),
  39. other: Math.floor(Math.random() * 100) > 50 ? Math.floor(Math.random() * 100) : -Math.floor(Math.random() * 100),
  40. }));
  41. }

API

g2-single-bar

参数说明类型默认值
[delay]延迟渲染,单位:毫秒number0
[plusColor]图表颜色string#40a9ff
[minusColor]负值图表颜色string#ff4d4f
[height]图表高度number60
[barSize]柱状高度number30
[min]最大值,若小于0表示显示负值number0
[max]最小值number100
[padding]图表内部间距any0
[value]number0
[format]显示值格式(value: number) => string-
[textStyle]显示值样式any{ fontSize: 12, color: ‘#595959’ }
[theme]定制图表主题string | LooseObject-