0

我正在尝试构建这样的图表: 图1 使用 vaadin-charts 为 angular2,除了现在我有两种颜色,因为我正在比较两个不同的来源。我的月份显示正确,但我不知道如何将月份分类为季度。

图2

https://vaadin.com/docs/-/part/charts/webcomponents-api/charts-configuration.html#charts.configuration.axes.categories

这是我到目前为止所得到的:

<vaadin-column-chart>
    <chart-title>Distributions</chart-title>
    <x-axis>
        <categories>Jan, Feb, Mar, Apr, May, Jun</categories>
    </x-axis>
    <y-axis>
      <title>Value</title>
    </y-axis>
    <data-series name="exponential" [data]="exponential">
    </data-series>

    <data-series name="incremental" [data]="incremental">
    </data-series>
  </vaadin-column-chart>
4

1 回答 1

0

使用Highcharts-Chart你可以这样做:

/* ==================================================||
 These can all be data-binded in a polymer app
 Example: <highcharts-chart id='chart' type="column" title="Distributions" x-axis="[[xAxisConfig]]" data="[[multiSeriesData]]" plot-options="[[joinedBarsConfig]]" y-label="Value" legend></highcharts-chart>
|| ==================================================*/

//Bind Data
chart.data = [
  {name: 'exponential', data: [1,2,4,8,16]},
  {name: 'incremental', data: [0,1,2,3,4], color: '#ec6464'},
]

//Bind PlotOptions for thin, connected bars
chart.plotOptions = {column: {
  pointPadding: 0,
  borderWidth: 0,
}}

//Make x-axis categorical
chart.xAxis = {categories: ["Jan","Feb","Mar","Apr","May","Jun"]}
<base href="https://user-content-dot-custom-elements.appspot.com/avdaredevil/highcharts-chart/v2.0.1/highcharts-chart/">
<link rel="import" href="highcharts-chart.html">

<highcharts-chart id='chart' type="column" title="Distributions" y-label="Value" legend></highcharts-chart>

单击运行代码片段以查看图表!

而已!这里有更多关于实时数据的例子。这是组件页面

于 2017-03-03T21:28:18.070 回答