当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

ng-apexcharts

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 管炳
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Angular wrapper for ApexCharts to build interactive visualizations in Angular 7+.

Examples

More than 80+ examples of all the chart types with sample codes can be found on the Angular Demos page of the website. Here's a basic line chart example built in codesandbox.

Download and Installation

  1. Install using npm:
npm install apexcharts ng-apexcharts --save
  1. Open angular.json and under scripts add:
"scripts": [
  "node_modules/apexcharts/dist/apexcharts.min.js"
]
  1. Add ng-apexcharts-module to imports
import { NgApexchartsModule } from "ng-apexcharts";

...

imports: [
  BrowserModule,
  FormsModule,
  ReactiveFormsModule,
  NgApexchartsModule,
  ...
]

Usage

In any component you can use the chart using:

<apx-chart [series]="series" [chart]="chart" [title]="title"></apx-chart>

You need to provide at least the series and chart attribute to make sure thechart can get created.

You can also use any other attribute from the following options.

Options

All options of the chart can be inserted using the attributes.This is a list of all available attributes:

@Input() chart: ApexChart;
@Input() annotations: ApexAnnotations;
@Input() colors: string[];
@Input() dataLabels: ApexDataLabels;
@Input() series: ApexAxisChartSeries | ApexNonAxisChartSeries;
@Input() stroke: ApexStroke;
@Input() labels: string[];
@Input() legend: ApexLegend;
@Input() fill: ApexFill;
@Input() tooltip: ApexTooltip;
@Input() plotOptions: ApexPlotOptions;
@Input() responsive: ApexResponsive[];
@Input() xaxis: ApexXAxis;
@Input() yaxis: ApexYAxis | ApexYAxis[];
@Input() grid: ApexGrid;
@Input() states: ApexStates;
@Input() title: ApexTitleSubtitle;
@Input() subtitle: ApexTitleSubtitle;
@Input() theme: ApexTheme;

You can visit the docs to read more about all the options listed above.

Updating the chart

Changing the attributes will automatically call the relevant update methods of ApexCharts and re-render it.

Calling core ApexCharts methods

You don't actually need to call updateSeries() or updateOptions() manually. Changing the props will automatically update the chart. But, in certain cases you may need to call these methods, so here's the reference.

Method Description
updateSeries Allows you to update the series array overriding the existing one
updateOptions Allows you to update the configuration object
toggleSeries Allows you to toggle the visibility of series programatically. Useful when you have custom legend.
appendData Allows you to append new data to the series array.
addText The addText() method can be used to draw text after chart is rendered.
addXaxisAnnotation Draw x-axis annotations after chart is rendered.
addYaxisAnnotation Draw y-axis annotations after chart is rendered.
addPointAnnotation Draw point (xy) annotations after chart is rendered.

All the methods are proxied through the component so that you dont need to access the DOM by yourself.

Just reference the component as a ViewChild in your Component by using:

@ViewChild('chartObj') chart: ChartComponent;

and changing the template to this:

<apx-chart #chartObj></apx-chart>

Now you're able to call methods from your Component.

this.chart.toggleSeries("series-1");

How to call the methods of ApexCharts without referencing the chart component?

Sometimes, you may want to call methods of the core ApexCharts library from some other place, and you can do so on this.$apexcharts global variable directly. You need to target the chart by chart.id while calling this method

Example

window.ApexCharts.exec("ng-chart-example", "updateSeries", [
  {
    data: [40, 55, 65, 11, 23, 44, 54, 33]
  }
]);

In the above method, ng-chart-example is the ID of chart, updateSeries is the name of the method you want to call and the third parameter is the new Series you want to update.

More info on the .exec() method can be found here

All other methods of ApexCharts can be called the same way.

Turning off auto update of the series

With the attribute autoUpdateSeries you can control if the chart component should call the updateSeries function automatically if the series attribute is changed. It is set to true by default, but in a mixed/combo chart, set this attribute to false if you are using and changing the type property in your series. This only has the effect that the whole chart rerenders even if only the series changes.

Supporting ApexCharts

ApexCharts is an open source project.
You can help by becoming a sponsor on Patreon or doing a one time donation on PayPal

Become a Patron

License

ng-ApexCharts is released under MIT license. You are free to use, modify and distribute this software, as long as the copyright header is left intact.

Submitted by

Special thanks to Morris Janatzek for contributing to ApexCharts project by creating this angular wrapper.

  • 为什么有的是ng-app就行?为什么ng-app="自定义的模块"? 简单理解: ng-app有一个默认的模块。 ng-app=“自定义的模块” 是一个使用了自定义的模块,该自定义的模块继承了 那个初始的默认的模块,可以调用初始的默认的模块的方法。 如果有多个ng-app,如何加载? 答:默认是加载第一个,而且只加载第一个。 点击打开链接

  • 原文:https://docs.angularjs.org/api/ng/directive/ngApp ngApp指令可以用于自动引导AngularJs应用程序。ngApp指令指定了应用程序的根节点位置,通常放在页面的根节点附近,例如在<body>或者<html>节点上。 当使用ngApp的时候要注意一下几点: 1. 每个html文档只能自动加载一个AngularJS应用程序。文档中的第一个ng

  • <html> <head> <meta charset="UTF-8" /> <title>https://www.runoob.com/highcharts/highcharts-tutorial.html</title> <script src="jquery.min.js"></script> <script src="highcharts.js"></script> <script src

  • target.selectionStart 表示光标位置 <textarea [(ngModel)]="value" (keyup)="getCaretPosWithEvent($event)"></textarea> getCaretPosWithEvent (event: { target: any; }) { const target = event.target; if

 相关资料
  • 问题内容: 我试图了解和/ 之间的区别,但对我来说它们看起来相同。 我应该记住使用一个或另一个来区别吗? 问题答案: ngIf 该指令根据表达式 删除或重新创建 DOM树的一部分。如果赋值为的表达式的计算结果为假值,则将元素从DOM中删除,否则将元素的克隆重新插入DOM中。 删除元素时,使用它的作用域将被销毁,并在恢复该元素时创建一个新的作用域。在内部创建的作用域使用原型继承从其父作用域继承。 如

  • 问题内容: 任何人都可以为该JSFiddle提供正确的方法: JsFiddle链接 我正在尝试通过.class&#ID更改元素的类。 提前致谢 感谢tymeJV,新的JSFiddle: 解 问题答案: 正确的方法是根据切换变量使用,请考虑: CSS: JS: HTML: 通过根据变量(“ toggle”)是否为或分配引用的类(在上面为“红色”)来工作。

  • 问题内容: 我了解这一点,并会影响在元素上设置的类,并控制是否将元素呈现为DOM的一部分。 有没有对选择的准则在/ 或反之亦然? 问题答案: 取决于您的用例,但总结不同之处: 将从DOM中删除元素。这意味着您所有的处理程序或所有附加到这些元素的内容都将丢失。例如,如果将单击处理程序绑定到子元素之一,则将其评估为false时,将从DOM中删除该元素,并且即使稍后将其评估为true并显示该元素,您的单

  • NG Bootstrap 是基于 Angular(非 Angular.js)开发的 Bootstrap CSS 框架的指令集。 原生开发 专为Bootstrap 4 开发的Angular组件,开发了符合Angular生态系统的API,没有使用任何第三方Javascript库来实现,全都是纯粹的原生Javascript。 Boostrap的JS插件 支持全部Boostrap自带的Javascript

  • Mogwai ERDesigner NG是一个实体关系建模工具类似于ERWin。它设计成让数据库建模变得尽可能简易并为整个开发过程提供支持,从数据库设计到模式 (schema)和代码生成。此外ERDesigner还提供一个灵活的插件体系,从而可以通过安装新的插件来扩展该工具的功能。ERDesigner提 供的功能包括: *.能够使用一个强大和易于使用的图形编辑来设计数据库模型。 *.能够依据ER图

  • ng-inspector 是Chrome和Safari的浏览器扩展程序,它显示一个检查器面板,该面板实时显示当前页面中的AngularJS作用域层次结构,以及哪些控制器或指令与哪个作用域相关联。 将鼠标悬停在检查器中的范围上将突出显示该范围附加到的DOM元素。单击模型将console.log该模型的内容。 该扩展程序在带有AngularJS徽标的地址栏旁边添加了一个按钮,用于打开和关闭窗格。