【发布时间】:2019-09-18 16:18:07
【问题描述】:
我有带有相关分数的图像流到我的应用程序。随着分数的到来,我使用 ng2-charts 将它们绘制在折线图上。
我想自定义图表上的工具提示,以显示它附带的图像的较小预览。我已经四处搜寻,但无法弄清楚如何将自定义 html 注入工具提示,或者是否可以在不创建自定义图表的情况下进行。
任何关于这是否可行以及如何实现的建议将不胜感激。
这是在 Ionic 4 和 angular 6 中,我的模块版本是:
- “ng2-charts”:“^2.2.2”,
- "chart.js": "^2.8.0",
不确定这对我的问题是否必要,但这是我到目前为止设置图表的方式。
- 降价
<ion-content padding>
<div class="row" style="display: block;">
<div class="col-md-6">
<div style="display: block;">
<canvas baseChart width="1200" height="600"
[datasets]="lineChartData"
[labels]="lineChartLabels"
[options]="lineChartOptions"
[colors]="lineChartColors"
[legend]="lineChartLegend"
[chartType]="lineChartType"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)"></canvas>
</div>
</div>
</div>
</ion-content>
- 初始化图表
// Initializing Chart settings
public lineChartLegend:boolean = true;
public lineChartType:string = 'line';
public lineChartData:ChartDataSets[] = [{ data: this.scoreArr, label: 'Image Scores' }];
public lineChartLabels:Label[] = [];
public lineChartOptions: (ChartOptions & { annotation: any }) = {
responsive: true,
scales: {
// We use this empty structure as a placeholder for dynamic theming.
xAxes: [{}],
yAxes: [
{
id: 'y-axis-0',
position: 'left',
}
]
},
annotation: {
annotations: [
{
type: 'line',
mode: 'vertical',
scaleID: 'x-axis-0',
value: 'March',
borderColor: 'orange',
borderWidth: 2,
label: {
enabled: true,
fontColor: 'orange',
content: 'LineAnno'
}
},
],
}
};
public lineChartColors:Color[] = [
{ // dark grey
backgroundColor: 'rgba(77,83,96,0.2)',
borderColor: 'rgba(77,83,96,1)',
pointBackgroundColor: 'rgba(77,83,96,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(77,83,96,1)'
}
];
【问题讨论】:
标签: html angular6 chart.js ionic4 ng2-charts