Issue
I have able to download the chart. I am trouble downloading both chart and table in highchart. Im gone through many solution I didn't got any solution in ANGULAR.
Html File :
<ion-content>
<div [chart]="chart"></div>
<div>
<table id="datatable" class="table">
<thead>
<tr>
<th></th>
<th>Jane</th>
<th>John</th>
</tr>
</thead>
<tbody>
<tr>
<th>Apples</th>
<td>3</td>
<td>4</td>
</tr>
<tr>
<th>Pears</th>
<td>2</td>
<td>0</td>
</tr>
<tr>
<th>Plums</th>
<td>5</td>
<td>11</td>
</tr>
<tr>
<th>Bananas</th>
<td>1</td>
<td>1</td>
</tr>
<tr>
<th>Oranges</th>
<td>2</td>
<td>4</td>
</tr>
</tbody>
</table>
<br />
<button (click)="test()">
download chart
</button>
</div>
</ion-content>
TS File :
import { Component, OnInit, ViewChild } from "@angular/core";
import * as Highcharts from "highcharts";
import { Chart } from "angular-highcharts";
const Exporting = require("highcharts/modules/exporting");
@Component({
selector: "app-line",
templateUrl: "./line.page.html",
styleUrls: ["./line.page.scss"],
})
export class LinePage implements OnInit {
@ViewChild("lineChart", { static: false }) lineChart: any;
chart: Chart;
Highcharts = Highcharts;
constructor() {
this.chart = new Chart({
data: {
table: "datatable",
},
chart: {
type: "column",
},
title: {
text: "Data extracted from a HTML table in the page",
},
yAxis: {
allowDecimals: false,
title: {
text: "Units",
},
},
tooltip: {
formatter: function () {
return (
"<b>" +
this.series.name +
"</b><br/>" +
this.point.y +
" " +
this.point.name.toLowerCase()
);
},
},
});
}
test = () => {
console.log(this.Highcharts.charts);
this.Highcharts.charts["0"].exportChart({
type: "image/jpeg",
filename: "line-chart",
});
};
ngOnInit() {}
}
Module File :
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { FormsModule } from "@angular/forms";
import { IonicModule } from "@ionic/angular";
import { LinePageRoutingModule } from "./line-routing.module";
import { LinePage } from "./line.page";
import { ChartModule, HIGHCHARTS_MODULES } from "angular-highcharts";
import * as more from "highcharts/highcharts-more.src";
import * as exporting from "highcharts/modules/exporting.src";
import * as heatChart from "highcharts/modules/heatmap";
import * as heatChartsrc from "highcharts/modules/heatmap.src";
import * as chartdata from "highcharts/modules/data";
import * as chartdatasrc from "highcharts/modules/data.src";
import * as boostcanvace from "highcharts/modules/boost-canvas";
import * as boostcanvacesrc from "highcharts/modules/boost-canvas.src";
import * as boost from "highcharts/modules/boost";
import * as boostsrc from "highcharts/modules/boost.src";
import * as access from "highcharts/modules/accessibility";
import * as accesssrc from "highcharts/modules/accessibility.src";
@NgModule({
providers: [
{
provide: HIGHCHARTS_MODULES,
useFactory: () => [
heatChart,
heatChartsrc,
more,
exporting,
chartdata,
chartdatasrc,
boostcanvace,
boostcanvacesrc,
boost,
boostsrc,
access,
accesssrc,
],
},
],
imports: [
CommonModule,
FormsModule,
IonicModule,
ChartModule,
LinePageRoutingModule,
],
declarations: [LinePage],
})
export class LinePageModule {}
Above I display my all project code.
So you can better understand. I am gone through the below comment but the angular is not in that solution.
Solution
This problem was resolved on version 12.0.0 from angular-highcharts.
Answered By - Carlos Henrique
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.