有人可以帮我吗,实际上在我的highcharts-angle应用程序中,需要显示图表上下文菜单,如下图所示。
我已经看过这个https://www.highcharts.com/demo/pie-basic示例,但是javascript和Jquery中的整个代码。但是在这里,我需要在highcharts-angle中使用相同的功能。请在https://stackblitz.com/edit/angular-s6h17i此处找到我的示例代码,并分享您的建议。提前致谢。
答案 0 :(得分:2)
Highcharts上下文菜单需要导入和初始化exporting
和export-data
模块:
import * as HighchartsExporting from "highcharts/modules/exporting";
import * as HighchartsExportData from "highcharts/modules/export-data";
HighchartsExporting(Highcharts);
HighchartsExportData(Highcharts);
您的app.component.ts:
import { Component, OnInit } from "@angular/core";
import * as Highcharts from "highcharts";
import * as HighchartsExporting from "highcharts/modules/exporting";
import * as HighchartsExportData from "highcharts/modules/export-data";
HighchartsExporting(Highcharts);
HighchartsExportData(Highcharts);
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent implements OnInit {
Highcharts = Highcharts;
chartOptions = {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: "pie"
},
title: {
text: "Browser market shares in January, 2018"
},
tooltip: {
pointFormat: "{series.name}: <b>{point.percentage:.1f}%</b>"
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: "pointer",
dataLabels: {
enabled: true,
format: "<b>{point.name}</b>: {point.percentage:.1f} %"
},
showInLegend: true
}
},
credits: {
enabled: false
},
series: [
{
name: "Brands",
colorByPoint: true,
data: [
{
name: "Chrome",
y: 61.41,
sliced: true,
selected: true
},
{
name: "Internet Explorer",
y: 11.84
},
{
name: "Firefox",
y: 10.85
},
{
name: "Edge",
y: 4.67
},
{
name: "Safari",
y: 4.18
},
{
name: "Sogou Explorer",
y: 1.64
},
{
name: "Opera",
y: 1.6
},
{
name: "QQ",
y: 1.2
},
{
name: "Other",
y: 2.61
}
]
}
]
};
ngOnInit() {}
}
答案 1 :(得分:0)
根据this documentation in npmjs.com,应将这些行添加到适当的组件中,以便出现下载上下文按钮:
import * as Highcharts from 'highcharts';
import HC_exporting from 'highcharts/modules/exporting';
HC_exporting(Highcharts);
希望这会有所帮助。