谷歌图
谷歌图表 API 网络组件.
见: 文档
使用量
安装
npm i @google-web-components/google-chart
在 HTML 文件内
<html>
<head>
<script type="module">
import '@google-web-components/google-chart';
</script>
</head>
<body>
<google-chart data='[["Month", "Days"], ["Jan", 31]]'></google-chart>
</body>
</html>
在一个LitElement中
import {LitElement, html} from 'lit';
import {customElement} from 'lit/decorators.js';
import '@google-web-components/google-chart';
@customElement('new-element')
export class NewElement extends LitElement {
render() {
return html`
<google-chart data='[["Month", "Days"], ["Jan", 31]]'></google-chart>
`;
}
}
在多聚体3元素中
import {PolymerElement, html} from '@polymer/polymer';
import '@google-web-components/google-chart';
class NewElement extends PolymerElement {
static get template() {
return html`
<google-chart data='[["Month", "Days"], ["Jan", 31]]'></google-chart>
`;
}
}
customElements.define('new-element', NewElement);
更多使用实例
查看演示中的实例或尝试此实况 联合来文:本。 。 。 .
从 3.x 恢复
该组件已迁移到 LitElement , 现在使用 TypeScript 。 这种迁移带来了两个突破性的变化.
删除的多聚体特性 selection-changed 事件
特定多聚体 selection-changed 用于双向绑定的事件已被删除.
以往有两起观测图表选择变化的事件: google-chart-select 和多聚体产生的 selection-changed。 。 。 .
为了与其他事件保持一致(例如:. google-chart-ready),我们只保留 google-chart-select。 。 。 .
使用此特性的多聚体组件必须更新,以明确命名选择事件(细节) (中文(简体) ).
在下文的例子中,注意到增加了: ::google-chart-select。 。 。 .
- <google-chart selection="{{chartSelection}}"></google-chart>
+ <google-chart selection="{{chartSelection::google-chart-select}}"></google-chart>
使用 selection-changed 事件必须以类似方式更新:
- <google-chart .selection="${chartSelection}" @selection-changed="${reactToChartSelection}"></google-chart>
+ <google-chart .selection="${chartSelection}" @google-chart-select="${reactToChartSelection}"></google-chart>
删除 google-chart-loader 组件
其功能可以从 loader.js 模块 :
import {dataTable, load} from '@google-web-components/google-chart/loader.js';
或者您可以选择使用 google.visualization.ChartWrapper 直接( e)实例) (中文(简体) ).
捐款
本地测试和演示操作指令 :
安装
git clone https://github.com/GoogleWebComponents/google-chart.git
cd google-chart
npm install
本地运行演示
npm start
浏览器会自动打开 .
运行测试
npm test