我很难让angular-google-chart生成一个带有两个y轴刻度的图表。我已经尝试了许多在线的例子,直接使用谷歌图表,但没有运气。我已经包含了我认为是一个简单的例子。这段代码在一个控制器中。下面是我的代码:
(function () {
'use strict';
angular
.module('core')
.controller('DashboardErrorRatesController', DashboardErrorRatesController);
DashboardErrorRatesController.$inject = ['$rootScope', '$scope', '$state', '$timeout', '$interval', 'Authentication', 'locale', 'Common', 'Query', 'googleJsapiUrl'];
function DashboardErrorRatesController($rootScope, $scope, $state, $timeout, $interval, Authentication, locale, Common, Query, googleJsapiUrl) {
$scope.myChartObject = {
type: 'LineChart',
displayed: false,
chartArea: { left: 100, top: 100, width: 400, height: 450 },
data: {
cols: [
{
id: 'issues',
label: 'Issues per Week',
type: 'string'
},
{
id: 'pct_people',
label: '% of People',
type: 'number'
},
{
id: 'avg_excallations',
label: 'Average Escallations',
type: 'number'
}
],
rows: [
{ 'c': [{ 'v': '0' }, { 'v': 0.39 }, { 'v': 0 }] },
{ 'c': [{ 'v': '1' }, { 'v': 0.17 }, { 'v': 31.063636363636363 }] },
{ 'c': [{ 'v': '2' }, { 'v': 0.12 }, { 'v': 30.46086956521739 }] },
{ 'c': [{ 'v': '3' }, { 'v': 0.09 }, { 'v': 49.612360674157316 }] },
{ 'c': [{ 'v': '4' }, { 'v': 0.06 }, { 'v': 26.975 }] },
{ 'c': [{ 'v': '5' }, { 'v': 0.04 }, { 'v': 32.82588235294117 }] },
{ 'c': [{ 'v': '6' }, { 'v': 0.03 }, { 'v': 25.413886666666667 }] },
{ 'c': [{ 'v': '7' }, { 'v': 0.03 }, { 'v': 35.716933333333344 }] },
{ 'c': [{ 'v': '8' }, { 'v': 0.02 }, { 'v': 11.689516129032258 }] },
{ 'c': [{ 'v': '9' }, { 'v': 0.01 }, { 'v': 10.20833125 }] },
{ 'c': [{ 'v': '10' }, { 'v': 0.01 }, { 'v': 29.311111111111114 }] },
{ 'c': [{ 'v': '10+' }, { 'v': 0.05 }, { 'v': 24.697815555555554 }] }
],
options: {
title: 'Something',
isStacked: false,
width: 300,
height: 600,
vAxis: {
0: {
title: '% of People',
format: '#%'
},
1: {
title: 'Average Escallations',
format: '#,###.##'
}
},
hAxis: {
title: 'Issues per Week'
},
seriesType: 'bars',
series: {
0: { targetAxisIndex: 0 },
1: { targetAxisIndex: 1 }
}
},
formatters: {}
}
};
}
}());我认为这应该会生成一个包含两个轴的图表,但事实并非如此。它几乎就像angular- google -chart库(0.1.0)使用的是旧版本的google图表一样,但我无法理解这一点。
下面是html:
<div google-chart chart="myChartObject"></div>发布于 2017-03-27 02:19:55
我想通了!我将类型从“LineChart”更改为“ComboChart”。哇,那花了很长时间。我讨厌这种情况发生。
https://stackoverflow.com/questions/43023623
复制相似问题