@abcum/ember-charts 中文文档教程

发布于 5年前 浏览 31 项目主页 更新于 3年前

ember-charts

用于在 Ember.js 应用程序中处理图表、时间线和网络的插件。

Usage

Installation

ember install @abcum/ember-charts

Introduction

ember-charts 插件为 wo 添加了功能 使用 chart.js 图表、vis.js 时间线和网络,实现分析数据、时间序列数据、事件数据和网络图形数据的复杂和高级可视化。

Examples

Charts

创建一个基本图表。 图表类型可以是以下之一:饼图线< /a>,雷达气泡甜甜圈极地区域

{{chart-view type='bar' data=data}}
export default Ember.Controller.extend({
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, 3, 5, 2, 3],
        }]
    }
})

并指定基本折线图的自定义选项。

{{chart-view type='line' data=data options=options}}
export default Ember.Controller.extend({
    options: {
        legend: {
            display: true,
            labels: {
                fontColor: 'rgb(255, 99, 132)'
            }
        }
    }
})

有关配置选项的详细信息,请查看 Chart.js 文档 页面。

Timelines

创建一个基本的事件时间表。

{{#timeline-view as |t|}}
    {{t.item type='point' start=start content="Visited 'Home' page"}}
    {{t.item type='point' start=start content="Visited 'About Us' page"}}
{{/timeline-view}}

并指定对时间轴事件的操作。

{{#timeline-view on-timechange=(action 'timechange') as |t|}}
    {{t.item type='point' start=start content="Visited 'Home' page" on-select=(action 'select')}}
    {{t.item type='point' start=start content="Visited 'About Us' page" on-select=(action 'select')}}
{{/timeline-view}}

并为时间线指定自定义选项。 查看 Vis.js 文档了解详细的配置选项。

{{#timeline-view options=options as |t|}}
    ...
{{/timeline-view}}
import vis from 'vis.js';

export default Ember.Controller.extend({
    options: {
        start: vis.moment().subtract(6, 'months').format(),
        end: vis.moment().add(6, 'week').format(),
        width: '100%',
        height: '100%',
        align: 'left',
        orientation: 'top',
        showCurrentTime: true,
        autoResize: true,
        selectable: false,
        editable: false,
        zoomMin: 3600000,
        zoomMax: 31560000000,
    }
})
Timeline events

这些动作属性可以在时间轴上设置。

AttributeDescription
on-clickCalled when the user clicks on the timeline.
on-dblclickCalled when the user double-clicks on the timeline.
on-contextmenuCalled when the user right-clicks on the timeline.
on-timechangeCalled when the user is moving the timeline range.
on-timechangedCalled once when the user has finished moving the timeline range.
on-rangechangeCalled when the user is dragging the custom time bar.
on-rangechangedCalled once when the user has finished dragging the custom time bar.
Timeline item events

可以在时间线项目上设置这些动作属性。

AttributeDescription
on-clickCalled when the user clicks on an item.
on-dblclickCalled when the user double-clicks on an item.
on-contextmenuCalled when the user right-clicks on an item.
on-mouseoverCalled when the user moves the mouse over an item.
on-mouseoutCalled when the user moves the mouse away from an item.
on-selectCalled when the user selects an item.

Networks

创建一个基本的图形网络。

{{#network-view as |n|}}
    {{n.node id='a' label="Alexander"}}
    {{n.node id='m' label="Marcus"}}
    {{n.node id='j' label="Jonathan"}}
    {{n.edge from='a' to='j' label="likes"}}
{{/network-view}}

并指定对网络节点/边缘的操作。

{{#network-view on-zoom=(action 'zoom') as |n|}}
    {{n.node id='a' label="Alexander" on-select=(action 'select')}}
    {{n.node id='m' label="Marcus" on-select=(action 'select')}}
    {{n.node id='j' label="Jonathan" on-select=(action 'select')}}
    {{n.edge from='a' to='j' label="likes" on-select=(action 'select')}}
{{/network-view}}

并为网络指定自定义选项。 查看 Vis.js 文档了解详细的配置选项。

{{#network-view options=options as |n|}}
    ...
{{/network-view}}
import vis from 'vis.js';

export default Ember.Controller.extend({
    options: {
        autoResize: true,
        width: '100%',
        height: '100%',
        interaction: {
            zoomView: false,
        },
        nodes: {
            shape: 'box',
            scaling: {
                min: 10,
                max: 30
            },
            font: {
                size: 12,
                face: 'Helvetica'
            },
        },
        edges: {
            scaling: {
                min: 5,
                max: 15,
            },
            font: {
                size: 10,
                face: 'Helvetica',
            },
        },
        physics: {
            stabilization: true,
            solver: 'repulsion',
            barnesHut: {
                damping: 0.5,
                avoidOverlap: 1,
            }
        },
    }
})
Network events

这些动作属性可以在网络上设置。

AttributeDescription
on-zoomCalled when the user changes the zoom level of the network
on-clickCalled when the user clicks on the network.
on-dblclickCalled when the user double-clicks on the network.
on-contextmenuCalled when the user right-clicks on the network.
Network node/edge events

这些动作属性可以在网络节点或网络边缘上设置。

AttributeDescription
on-clickCalled when the user clicks on an node or edge.
on-dblclickCalled when the user double-clicks on an node or edge.
on-contextmenuCalled when the user right-clicks on an node or edge.
on-selectCalled when the user selects an node or edge.

Development

  • make install (install bower and ember-cli dependencies)
  • make upgrade (upgrade ember-cli to the specified version)
  • make tests (run all tests defined in the package)

ember-charts

An addon for working with charts, timelines, and networks in an Ember.js app.

Usage

Installation

ember install @abcum/ember-charts

Introduction

The ember-charts addon adds functionality for working with chart.js charts, and vis.js timeline and networks, enabling complex and advanced visualisation of analytical data, time-series data, event-data, and networked graph data.

Examples

Charts

Create a basic chart. The chart type can be one of: pie, bar, line, radar, bubble, doughnut, polarArea.

{{chart-view type='bar' data=data}}
export default Ember.Controller.extend({
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, 3, 5, 2, 3],
        }]
    }
})

And specify custom options a basic line chart.

{{chart-view type='line' data=data options=options}}
export default Ember.Controller.extend({
    options: {
        legend: {
            display: true,
            labels: {
                fontColor: 'rgb(255, 99, 132)'
            }
        }
    }
})

For detailed information on configuration options, look at the Chart.js documentation pages.

Timelines

Create a basic event timeline.

{{#timeline-view as |t|}}
    {{t.item type='point' start=start content="Visited 'Home' page"}}
    {{t.item type='point' start=start content="Visited 'About Us' page"}}
{{/timeline-view}}

And specify actions on timeline events.

{{#timeline-view on-timechange=(action 'timechange') as |t|}}
    {{t.item type='point' start=start content="Visited 'Home' page" on-select=(action 'select')}}
    {{t.item type='point' start=start content="Visited 'About Us' page" on-select=(action 'select')}}
{{/timeline-view}}

And specify custom options for the timeline. View the Vis.js documentation for detailed configuration options.

{{#timeline-view options=options as |t|}}
    ...
{{/timeline-view}}
import vis from 'vis.js';

export default Ember.Controller.extend({
    options: {
        start: vis.moment().subtract(6, 'months').format(),
        end: vis.moment().add(6, 'week').format(),
        width: '100%',
        height: '100%',
        align: 'left',
        orientation: 'top',
        showCurrentTime: true,
        autoResize: true,
        selectable: false,
        editable: false,
        zoomMin: 3600000,
        zoomMax: 31560000000,
    }
})
Timeline events

These action attributes are able to be set on a timeline.

AttributeDescription
on-clickCalled when the user clicks on the timeline.
on-dblclickCalled when the user double-clicks on the timeline.
on-contextmenuCalled when the user right-clicks on the timeline.
on-timechangeCalled when the user is moving the timeline range.
on-timechangedCalled once when the user has finished moving the timeline range.
on-rangechangeCalled when the user is dragging the custom time bar.
on-rangechangedCalled once when the user has finished dragging the custom time bar.
Timeline item events

These action attributes are able to be set on a timeline item.

AttributeDescription
on-clickCalled when the user clicks on an item.
on-dblclickCalled when the user double-clicks on an item.
on-contextmenuCalled when the user right-clicks on an item.
on-mouseoverCalled when the user moves the mouse over an item.
on-mouseoutCalled when the user moves the mouse away from an item.
on-selectCalled when the user selects an item.

Networks

Create a basic graph network.

{{#network-view as |n|}}
    {{n.node id='a' label="Alexander"}}
    {{n.node id='m' label="Marcus"}}
    {{n.node id='j' label="Jonathan"}}
    {{n.edge from='a' to='j' label="likes"}}
{{/network-view}}

And specify actions on network nodes / edges.

{{#network-view on-zoom=(action 'zoom') as |n|}}
    {{n.node id='a' label="Alexander" on-select=(action 'select')}}
    {{n.node id='m' label="Marcus" on-select=(action 'select')}}
    {{n.node id='j' label="Jonathan" on-select=(action 'select')}}
    {{n.edge from='a' to='j' label="likes" on-select=(action 'select')}}
{{/network-view}}

And specify custom options for the network. View the Vis.js documentation for detailed configuration options.

{{#network-view options=options as |n|}}
    ...
{{/network-view}}
import vis from 'vis.js';

export default Ember.Controller.extend({
    options: {
        autoResize: true,
        width: '100%',
        height: '100%',
        interaction: {
            zoomView: false,
        },
        nodes: {
            shape: 'box',
            scaling: {
                min: 10,
                max: 30
            },
            font: {
                size: 12,
                face: 'Helvetica'
            },
        },
        edges: {
            scaling: {
                min: 5,
                max: 15,
            },
            font: {
                size: 10,
                face: 'Helvetica',
            },
        },
        physics: {
            stabilization: true,
            solver: 'repulsion',
            barnesHut: {
                damping: 0.5,
                avoidOverlap: 1,
            }
        },
    }
})
Network events

These action attributes are able to be set on a network.

AttributeDescription
on-zoomCalled when the user changes the zoom level of the network
on-clickCalled when the user clicks on the network.
on-dblclickCalled when the user double-clicks on the network.
on-contextmenuCalled when the user right-clicks on the network.
Network node/edge events

These action attributes are able to be set on a network node, or network edge.

AttributeDescription
on-clickCalled when the user clicks on an node or edge.
on-dblclickCalled when the user double-clicks on an node or edge.
on-contextmenuCalled when the user right-clicks on an node or edge.
on-selectCalled when the user selects an node or edge.

Development

  • make install (install bower and ember-cli dependencies)
  • make upgrade (upgrade ember-cli to the specified version)
  • make tests (run all tests defined in the package)
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文