Javascript 使用Highcharts创建具有角度的Highcharts>;=5.0.0和海图ng>;=1.0.0使用图表工厂
我想从5.0.0版之前的Highcharts和Highcharts ng 0.0.12版过渡到最新版本 我知道在图表对象以及highcharts ng在最新版本中的工作方式中有一些关键的更改。我一直在寻找一个关于如何使用这些最新版本设置Angular环境的示例,但是使用这些版本的资源似乎非常短缺 我希望你能帮我安排一下 我自己也尝试过许多更改,但我不断地遇到旧版本脚本没有遇到的错误。错误,例如:Javascript 使用Highcharts创建具有角度的Highcharts>;=5.0.0和海图ng>;=1.0.0使用图表工厂,javascript,angularjs,highcharts,highcharts-ng,Javascript,Angularjs,Highcharts,Highcharts Ng,我想从5.0.0版之前的Highcharts和Highcharts ng 0.0.12版过渡到最新版本 我知道在图表对象以及highcharts ng在最新版本中的工作方式中有一些关键的更改。我一直在寻找一个关于如何使用这些最新版本设置Angular环境的示例,但是使用这些版本的资源似乎非常短缺 我希望你能帮我安排一下 我自己也尝试过许多更改,但我不断地遇到旧版本脚本没有遇到的错误。错误,例如: “无法获取未定义或空引用的“series”属性 (多切克元) (http://localhost:5
“无法获取未定义或空引用的“series”属性
(多切克元)
(http://localhost:50262/app/vendorScripts/highcharts-ng.js:51:16)“
“无法设置未定义的属性'getChartObj'”(位于HighChartNGController.$onInit(highcharts ng.js:36))
“严格模式(ChartFactory)中不允许对属性进行多个定义”
“'use strict';
angular.module('portalDashboardApp')
.factory('ChartFactory', function () {
return {
getChartConfig: function () {
return {
options: {
chart: {
type: 'bar',
height: 400,
spacingTop: 30,
spacingBottom: 10,
spacingLeft: 10,
spacingRight: 50,
zoomType: 'x',
backgroundColor: false,
resetZoomButton: {
position: {
x: 0,
y: 40
}
}
},
credits: {
enabled: false
},
navigation: {
buttonOptions: {
y: -30
}
},
tooltip: {
formatter: function () {
return '<b>' + this.y + ' ' + this.series.name + '</b>';
}
},
plotOptions: {
column: {
stacking: ''
},
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
},
showInLegend: true
},
series: {
animation: true,
point: {
events: {
click: function () {
}
}
},
dataLabels: {
enabled: true,
format: ''
}
}
},
exporting: {
sourceWidth: 1600,
sourceHeight: 800,
// scale: 2 (default)
chartOptions: {
subtitle: null
},
buttons: {
contextButton: {
text: 'Export Chart'
}
}
}
},
title: {
text: false
},
xAxis: {
type: 'category'
},
yAxis: {
gridLineWidth: 1,
title: {
text: 'Count'
},
labels:
{
enabled: true,
format: '{value}'
}
},
legend: {
layout: 'vertical',
floating: true,
backgroundColor: '#FFFFFF',
align: 'right',
verticalAlign: 'top',
y: 60,
x: -60
},
series: [{}],
loading: false
};
}
};
});
function volumeGraphConfig(timeline_data, time_trend) {
$scope.VolumeGraphChartConfig = ChartFactory.getChartConfig();
$scope.VolumeGraphChartConfig.chart.type = 'column';
}
function populateVolumeData(timeline_data, time_trend) {
$scope.VolumeGraphChartConfig.xAxis.categories = timeline_data;
$scope.VolumeGraphChartConfig.series = [{
name: 'Twitter',
data: time_trend.Twitter,
color: twitterColor
}, {
name: 'Instagram',
data: time_trend.Instagram,
color: instagramColor
}, {
name: 'Youtube',
data: time_trend.Youtube,
color: youtubeColor
}];
$scope.VolumeGraphChartConfig.tooltip = {
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <strong>{point.y}</strong> mentions<br/>',
shared: false
};
}
<highchart id="FacebookVolume" config="volumeGraphChartConfig"></highchart>
这是我的图表工厂:
'use strict';
angular.module('portalDashboardApp')
.factory('ChartFactory', function () {
return {
getChartConfig: function () {
return {
options: {
chart: {
type: 'bar',
height: 400,
spacingTop: 30,
spacingBottom: 10,
spacingLeft: 10,
spacingRight: 50,
zoomType: 'x',
backgroundColor: false,
resetZoomButton: {
position: {
x: 0,
y: 40
}
}
},
credits: {
enabled: false
},
navigation: {
buttonOptions: {
y: -30
}
},
tooltip: {
formatter: function () {
return '<b>' + this.y + ' ' + this.series.name + '</b>';
}
},
plotOptions: {
column: {
stacking: ''
},
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
},
showInLegend: true
},
series: {
animation: true,
point: {
events: {
click: function () {
}
}
},
dataLabels: {
enabled: true,
format: ''
}
}
},
exporting: {
sourceWidth: 1600,
sourceHeight: 800,
// scale: 2 (default)
chartOptions: {
subtitle: null
},
buttons: {
contextButton: {
text: 'Export Chart'
}
}
}
},
title: {
text: false
},
xAxis: {
type: 'category'
},
yAxis: {
gridLineWidth: 1,
title: {
text: 'Count'
},
labels:
{
enabled: true,
format: '{value}'
}
},
legend: {
layout: 'vertical',
floating: true,
backgroundColor: '#FFFFFF',
align: 'right',
verticalAlign: 'top',
y: 60,
x: -60
},
series: [{}],
loading: false
};
}
};
});
function volumeGraphConfig(timeline_data, time_trend) {
$scope.VolumeGraphChartConfig = ChartFactory.getChartConfig();
$scope.VolumeGraphChartConfig.chart.type = 'column';
}
function populateVolumeData(timeline_data, time_trend) {
$scope.VolumeGraphChartConfig.xAxis.categories = timeline_data;
$scope.VolumeGraphChartConfig.series = [{
name: 'Twitter',
data: time_trend.Twitter,
color: twitterColor
}, {
name: 'Instagram',
data: time_trend.Instagram,
color: instagramColor
}, {
name: 'Youtube',
data: time_trend.Youtube,
color: youtubeColor
}];
$scope.VolumeGraphChartConfig.tooltip = {
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <strong>{point.y}</strong> mentions<br/>',
shared: false
};
}
<highchart id="FacebookVolume" config="volumeGraphChartConfig"></highchart>
“严格使用”;
角度。模块('portalDashboardApp')
.factory('ChartFactory',函数(){
返回{
getChartConfig:函数(){
返回{
选项:{
图表:{
类型:'bar',
身高:400,
间距:30,
间距底部:10,
间距:10,
间距:50,
zoomType:'x',
背景颜色:假,
重置ZoomButton:{
职位:{
x:0,,
y:40
}
}
},
学分:{
已启用:false
},
导航:{
按钮选项:{
y:-30
}
},
工具提示:{
格式化程序:函数(){
返回“”+this.y+“”+this.series.name+“”;
}
},
打印选项:{
专栏:{
堆叠:“”
},
馅饼:{
allowPointSelect:true,
光标:“指针”,
数据标签:{
启用:对,
},
showInLegend:对
},
系列:{
动画:没错,
要点:{
活动:{
单击:函数(){
}
}
},
数据标签:{
启用:对,
格式:“”
}
}
},
出口:{
震源宽度:1600,
资料来源高度:800,
//比例:2(默认值)
图表选项:{
字幕:空
},
按钮:{
上下文按钮:{
文本:“导出图表”
}
}
}
},
标题:{
文本:false
},
xAxis:{
类型:“类别”
},
亚克斯:{
网格线宽度:1,
标题:{
文本:“计数”
},
标签:
{
启用:对,
格式:“{value}”
}
},
图例:{
布局:“垂直”,
浮动:是的,
背景颜色:“#FFFFFF”,
对齐:“右”,
垂直排列:“顶部”,
y:60,
x:-60
},
系列:[{}],
加载:错误
};
}
};
});
这是我在角度控制器中创建图表的方法:
'use strict';
angular.module('portalDashboardApp')
.factory('ChartFactory', function () {
return {
getChartConfig: function () {
return {
options: {
chart: {
type: 'bar',
height: 400,
spacingTop: 30,
spacingBottom: 10,
spacingLeft: 10,
spacingRight: 50,
zoomType: 'x',
backgroundColor: false,
resetZoomButton: {
position: {
x: 0,
y: 40
}
}
},
credits: {
enabled: false
},
navigation: {
buttonOptions: {
y: -30
}
},
tooltip: {
formatter: function () {
return '<b>' + this.y + ' ' + this.series.name + '</b>';
}
},
plotOptions: {
column: {
stacking: ''
},
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
},
showInLegend: true
},
series: {
animation: true,
point: {
events: {
click: function () {
}
}
},
dataLabels: {
enabled: true,
format: ''
}
}
},
exporting: {
sourceWidth: 1600,
sourceHeight: 800,
// scale: 2 (default)
chartOptions: {
subtitle: null
},
buttons: {
contextButton: {
text: 'Export Chart'
}
}
}
},
title: {
text: false
},
xAxis: {
type: 'category'
},
yAxis: {
gridLineWidth: 1,
title: {
text: 'Count'
},
labels:
{
enabled: true,
format: '{value}'
}
},
legend: {
layout: 'vertical',
floating: true,
backgroundColor: '#FFFFFF',
align: 'right',
verticalAlign: 'top',
y: 60,
x: -60
},
series: [{}],
loading: false
};
}
};
});
function volumeGraphConfig(timeline_data, time_trend) {
$scope.VolumeGraphChartConfig = ChartFactory.getChartConfig();
$scope.VolumeGraphChartConfig.chart.type = 'column';
}
function populateVolumeData(timeline_data, time_trend) {
$scope.VolumeGraphChartConfig.xAxis.categories = timeline_data;
$scope.VolumeGraphChartConfig.series = [{
name: 'Twitter',
data: time_trend.Twitter,
color: twitterColor
}, {
name: 'Instagram',
data: time_trend.Instagram,
color: instagramColor
}, {
name: 'Youtube',
data: time_trend.Youtube,
color: youtubeColor
}];
$scope.VolumeGraphChartConfig.tooltip = {
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <strong>{point.y}</strong> mentions<br/>',
shared: false
};
}
<highchart id="FacebookVolume" config="volumeGraphChartConfig"></highchart>
'use strict';
angular.module('portalDashboardApp')
.factory('ChartFactory', function () {
return {
getChartConfig: function () {
return {
options: {
chart: {
type: 'bar',
height: 400,
spacingTop: 30,
spacingBottom: 10,
spacingLeft: 10,
spacingRight: 50,
zoomType: 'x',
backgroundColor: false,
resetZoomButton: {
position: {
x: 0,
y: 40
}
}
},
credits: {
enabled: false
},
navigation: {
buttonOptions: {
y: -30
}
},
tooltip: {
formatter: function () {
return '<b>' + this.y + ' ' + this.series.name + '</b>';
}
},
plotOptions: {
column: {
stacking: ''
},
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
},
showInLegend: true
},
series: {
animation: true,
point: {
events: {
click: function () {
}
}
},
dataLabels: {
enabled: true,
format: ''
}
}
},
exporting: {
sourceWidth: 1600,
sourceHeight: 800,
// scale: 2 (default)
chartOptions: {
subtitle: null
},
buttons: {
contextButton: {
text: 'Export Chart'
}
}
}
},
title: {
text: false
},
xAxis: {
type: 'category'
},
yAxis: {
gridLineWidth: 1,
title: {
text: 'Count'
},
labels:
{
enabled: true,
format: '{value}'
}
},
legend: {
layout: 'vertical',
floating: true,
backgroundColor: '#FFFFFF',
align: 'right',
verticalAlign: 'top',
y: 60,
x: -60
},
series: [{}],
loading: false
};
}
};
});
function volumeGraphConfig(timeline_data, time_trend) {
$scope.VolumeGraphChartConfig = ChartFactory.getChartConfig();
$scope.VolumeGraphChartConfig.chart.type = 'column';
}
function populateVolumeData(timeline_data, time_trend) {
$scope.VolumeGraphChartConfig.xAxis.categories = timeline_data;
$scope.VolumeGraphChartConfig.series = [{
name: 'Twitter',
data: time_trend.Twitter,
color: twitterColor
}, {
name: 'Instagram',
data: time_trend.Instagram,
color: instagramColor
}, {
name: 'Youtube',
data: time_trend.Youtube,
color: youtubeColor
}];
$scope.VolumeGraphChartConfig.tooltip = {
pointFormat: '<span style="color:{series.color}">{series.name}</span>: <strong>{point.y}</strong> mentions<br/>',
shared: false
};
}
<highchart id="FacebookVolume" config="volumeGraphChartConfig"></highchart>
函数volumeGraphConfig(时间线数据、时间趋势){
$scope.VolumeGraphChartConfig=ChartFactory.getChartConfig();
$scope.VolumeGraphChartConfig.chart.type='column';
}
函数populateVolumeData(时间线数据、时间趋势){
$scope.VolumeGraphChartConfig.xAxis.categories=timeline\u数据;
$scope.VolumeGraphChartConfig.series=[{
名称:“推特”,
数据:time_trend.Twitter,
颜色:twitterColor
}, {
名称:“Instagram”,
数据:time_trend.Instagram,
颜色:instagramColor
}, {
名称:“Youtube”,