Reputation: 1651
In my highcharts-angular application need to be display chart context menu as show in below image.
I have gone through this https://www.highcharts.com/demo/pie-basic example but this whole code in JavaScript & jQuery. But here I need same functionality in highcharts-angular.
My sample code is here: https://stackblitz.com/edit/angular-s6h17i.
Upvotes: 1
Views: 3062
Reputation: 467
According to this documentation in npmjs.com one should add these lines to appropriate component for download context button get appeared:
import * as Highcharts from 'highcharts';
import HC_exporting from 'highcharts/modules/exporting';
HC_exporting(Highcharts);
Upvotes: 2
Reputation: 7372
Highcharts context menu requires to import and initialize exporting
and export-data
modules:
import * as HighchartsExporting from "highcharts/modules/exporting";
import * as HighchartsExportData from "highcharts/modules/export-data";
HighchartsExporting(Highcharts);
HighchartsExportData(Highcharts);
Your 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() {}
}
Demo: https://codesandbox.io/s/2z2y2n07w0
Upvotes: 4