ng2高线图中的仪表图



我正试图找到/解决如何使用ng2 highcharts实现仪表。

我一直在研究折线图和条形图是如何在angular2-seed-ng2-highcharts项目中实现的https://github.com/Bigous/angular2-seed-ng2-highcharts并认为这将是一个简单的问题,将图表选项修改为类似于:

chart: {
type: 'gauge',
plotBackgroundColor: null,
plotBackgroundImage: null,
plotBorderWidth: 0,
plotShadow: false
},
title: {
text: 'Speedometer'
},
pane: {
startAngle: -150,
endAngle: 150,
background: [{
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#FFF'],
[1, '#333']
]
},
borderWidth: 0,
outerRadius: '109%'
}, {
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#333'],
[1, '#FFF']
]
},
borderWidth: 1,
outerRadius: '107%'
}, {
// default background
}, {
backgroundColor: '#DDD',
borderWidth: 0,
outerRadius: '105%',
innerRadius: '103%'
}]
},
// the value axis
yAxis: {
min: 0,
max: 200,
minorTickInterval: 'auto',
minorTickWidth: 1,
minorTickLength: 10,
minorTickPosition: 'inside',
minorTickColor: '#666',
tickPixelInterval: 30,
tickWidth: 2,
tickPosition: 'inside',
tickLength: 10,
tickColor: '#666',
labels: {
step: 2,
rotation: 'auto'
},
title: {
text: 'km/h'
},
plotBands: [{
from: 0,
to: 120,
color: '#55BF3B' // green
}, {
from: 120,
to: 160,
color: '#DDDF0D' // yellow
}, {
from: 160,
to: 200,
color: '#DF5353' // red
}]
},
series: [{
name: 'Speed',
data: [80],
tooltip: {
valueSuffix: ' km/h'
}
}]

模板引用它:

<td width="50%">
<div [ng2-highcharts]="chartGauge" class="graph"></div>
</td>

图表没有呈现,这些错误我目前无法解释:

angular2.js?1460493363215:23083原始异常:错误:Highcharts错误#17:www.Highcharts.com/errors/17BrowserDomAdapter.logError@angular2.js?1460493363215:23083ExceptionHandler.call@angular2.js?1460493363215:1194(匿名函数)@angular2.js?1460493363215:12591NgZone_notifyOnError@angular2.js?1460493363215:13515collection_1.StringMapWrapper.merge.orror@angular2.js?1460493363215:13419Zone.run@angular2-polyfills.js?1460493363213:1247(匿名函数)@angular2.js?1460493363215:13438NgZone.run@angular2.js?1460493363215:13400(匿名函数)@angular2.js?1460493363215:12690schedulerFn@angular2.js?1460493363215:12934tryCatcher@Rx.js?1460493363214:31Subscriber.next@Rx.js?1460493363214:9500主题_下一个@Rx.js?1460493363214:9999Subject.next@Rx.js?1460493363214:9963EventEmitter.emit@angular2.js?1460493363215:12915(匿名函数)@angular2.js?1460493363215:13331Zone.run@angular2-polyfills.js?1460493363213:1243中区_notifyOnTurnDone@angular2.js?1460493363215:13330(匿名函数)@angular2.js?1460493363215:13445zoneBoundFn@angular2-polyfills.js?1460493363213:1220lib$es6$承诺$asap$$flush@angular2-polyfills.js?1460493363213:262angular2.js?1460493363215:23083原始STACKTRACE:BrowserDomAdapter.logError@angular2.js?1460493363215:23083ExceptionHandler.call@angular2.js?1460493363215:1197(匿名函数)@angular2.js?1460493363215:12591NgZone_notifyOnError@angular2.js?1460493363215:13515collection_1.StringMapWrapper.merge.orror@angular2.js?1460493363215:13419Zone.run@angular2-polyfills.js?1460493363213:1247(匿名函数)@angular2.js?1460493363215:13438NgZone.run@angular2.js?1460493363215:13400(匿名函数)@angular2.js?1460493363215:12690schedulerFn@angular2.js?1460493363215:12934tryCatcher@Rx.js?1460493363214:31Subscriber.next@Rx.js?1460493363214:9500主题_下一个@Rx.js?1460493363214:9999Subject.next@Rx.js?1460493363214:9963EventEmitter.emit@angular2.js?1460493363215:12915(匿名函数)@angular2.js?1460493363215:13331Zone.run@angular2-polyfills.js?1460493363213:1243中区_notifyOnTurnDone@angular2.js?1460493363215:13330(匿名函数)@angular2.js?1460493363215:13445zoneBoundFn@angular2-polyfills.js?1460493363213:1220lib$es6$承诺$asap$$flush@angular2-polyfills.js?1460493363213:262angular2.js?1460493363215:23083错误:Highcharts错误#17:www.Highcharts.com/errors/s7错误(本机)在ea(http://localhost:5556/node_modules/highcharts/highstock.js?1460493363216:8:256)位于Object.Ca.initSeries(http://localhost:5556/node_modules/highcharts/highstock.js?1460493363216:213:1)在http://localhost:5556/node_modules/highcharts/highstock.js?1460493363216:235:42在Array.forEach(本地)在Array.forEach(http://localhost:5556/node_modules/es6-shim/es6-shim.js?1460493363213:1107:14)在n(http://localhost:5556/node_modules/highcharts/highstock.js?1460493363216:26:295)在Object.Ca.firstRender(http://localhost:5556/node_modules/highcharts/highstock.js?1460493363216:235:13)在Object.Ca.init(http://localhost:5556/node_modules/highcharts/highstock.js?1460493363216:212:415)在对象处。(http://localhost:5556/node_modules/highcharts/highstock.js?1460493363216:400:355)BrowserDomAdapter.log angular2.js错误?1460493363215:23083ExceptionHandler.call@angular2.js?1460493363215:1198(匿名函数)@angular2.js?1460493363215:12591NgZone_notifyOnError@angular2.js?1460493363215:13515collection_1.StringMapWrapper.merge.orror@angular2.js?1460493363215:13419Zone.run@angular2-polyfills.js?1460493363213:1247(匿名函数)@angular2.js?1460493363215:13438NgZone.run@angular2.js?1460493363215:13400(匿名函数)@angular2.js?1460493363215:12690schedulerFn@angular2.js?1460493363215:12934ryCatcher@Rx.js?1460493363214:31Subscriber.next@Rx.js?1460493363214:9500主题_下一个@Rx.js?1460493363214:9999Subject.next@Rx.js?1460493363214:9963EventEmitter.emit@angular2.js?1460493363215:12915(匿名函数)@angular2.js?1460493363215:13331Zone.run@angular2-polyfills.js?1460493363213:1243中区_notifyOnTurnDone@angular2.js?1460493363215:13330(匿名函数)@angular2.js?1460493363215:13445zoneBoundFn@angular2-polyfills.js?1460493363213:1220lib$es6$承诺$asap$$flush@angular2-polyfills.js?1460493363213:262angular2.js?1460493363215:23083错误上下文:BrowserDomAdapter.logError@angular2.js?1460493363215:23083ExceptionHandler.call@angular2.js?1460493363215:1201(匿名函数)@angular2.js?1460493363215:12591NgZone_notifyOnError@angular2.js?1460493363215:13515collection_1.StringMapWrapper.merge.orror@angular2.js?1460493363215:13419Zone.run@angular2-polyfills.js?1460493363213:1247(匿名函数)@angular2.js?1460493363215:13438NgZone.run@angular2.js?1460493363215:13400(匿名函数)@angular2.js?1460493363215:12690schedulerFn@angular2.js?1460493363215:12934tryCatcher@Rx.js?1460493363214:31Subscriber.next@Rx.js?1460493363214:9500主题_下一个@Rx.js?1460493363214:9999Subject.next@Rx.js?1460493363214:9963EventEmitter.emit@angular2.js?1460493363215:12915(匿名函数)@angular2.js?1460493363215:13331Zone.run@angular2-polyfills.js?1460493363213:1243中区_notifyOnTurnDone@angular2.js?1460493363215:13330(匿名函数)@angular2.js?1460493363215:13445zoneBoundFn@angular2-polyfills.js?1460493363213:1220lib$es6$承诺$asap$$flush@angular2-polyfills.js?1460493363213:262angular2.js?1460493363215:23083_Context{element:div.graph,componentElement:home,Context:HomeCmp,locals:Object,injector:injector…}BrowserDomAdapter.logError@angular2.js?1460493363215:23083ExceptionHandler.call@angular2.js?1460493363215:1202(匿名函数)@angular2.js?1460493363215:12591NgZone_notifyOnError@angular2.js?1460493363215:13515collection_1.StringMapWrapper.merge.orror@angular2.js?1460493363215:13419Zone.run@angular2-polyfills.js?1460493363213:1247(匿名函数)@angular2.js?1460493363215:13438NgZone.run@angular2.js?1460493363215:13400(匿名函数)@angular2.js?1460493363215:12690schedulerFn@angular2.js?1460493363215:12934tryCatcher@Rx.js?1460493363214:31Subscriber.next@Rx.js?1460493363214:9500主题_下一个@Rx.js?1460493363214:9999Subject.next@Rx.js?1460493363214:9963EventEmitter.emit@angular2.js?1460493363215:12915(匿名函数)@angular2.js?1460493363215:13331Zone.run@angular2-polyfills.js?1460493363213:1243中区_notifyOnTurnDone@angular2.js?1460493363215:13330(匿名函数)@angular2.js?1460493363215:13445zoneBoundFn@angular2-polyfills.js?1460493363213:1220lib$es6$承诺$asap$$flush@angular2-polyfills.js?1460493363213:262

该量表需要highchartsmore库,我在index.html中添加了以下行,它解决了上述问题。

<script src="../node_modules/highcharts/highcharts.js"></script>
<script src="../node_modules/highcharts/highcharts-more.js"></script>

图表现在呈现。

最新更新