html - 如何从 Chart.js 更改 Angular 7/8 上的工具提示
问题描述
我在我的应用程序上使用 Angular 和 Chart.js(带有 ng2-charts)。使用条形图,默认情况下,当我单击列时,我会得到一个工具提示,如下所示:
我的条形图.component.html:
<div class="container chart-style">
<canvas baseChart
[datasets]="barChartData"
[labels]="barChartLabels"
[options]="barChartOptions"
[legend]="barChartLegend"
[chartType]="barChartType"
[options]="barChartTooltip"
style="height:20rem; width:100rem"
>
</canvas>
</div>
和 my-bar-chart.component.ts :
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-my-bar-chart',
templateUrl: './my-bar-chart.component.html',
styleUrls: ['./my-bar-chart.component.css']
})
export class MyBarChartComponent {
constructor() { }
public barChartOptions = {
scaleShowVerticalLines: true,
responsive: true,
maintainAspectRatio: false
};
public barChartLabels = ['One star', 'Two stars', 'Three stars', 'four stars', 'Five stars'];
public barChartType = 'bar';
public barChartLegend = true;
public barChartData = [
{data: [28, 39, 42, 19, 8],
label: 'amount',
backgroundColor: [
'rgba(54, 162, 235, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(54, 162, 235, 0.2)',
],
borderWidth: 0,
hoverBackgroundColor: 'rgba(221, 221, 221, 1)',
scaleStepWidth: 1,
pointHoverBorderColor: 'rgba(255,1,2, 1)',
}
];
public barChartTooltip = //I dont know
}
解决方案
推荐阅读
- c++ - c++ 自定义数组可在 Visual Studio 监视窗口中浏览
- objective-c - 从 Xcode 10 部署到运行 iOS 12 的 iPhone 时,应用程序立即崩溃
- sql - 将数据列拆分为命名文本文件的应用程序或方法?
- apache-spark - 为什么在使用 spark 的 mllib 的 MulticlassClassificationEvaluator 时,准确率和召回率得到相同的值?
- python-3.x - 从包含路径的列表创建嵌套字典
- android - 在 React Native 中找不到 intellij-core.jar
- javascript - 我的要求范围内的对象正在外部发生变异,但我正在克隆它
- android - 替换片段会导致单个框架布局的重叠问题
- java - 使用自定义比较器从自定义对象的 TreeSet 中获取子集
- scala - Spark SQL 结构化数据写入原子文件