javascript - 如何使用 Angular 和 ng2-google-charts 在谷歌图表工具中将 SVG 图像作为注释
问题描述
我想创建一个显示一些测量值并添加一些注释作为图标的组件。我将 Angular 与 ng2-google-charts 一起用于图表。在https://developers.google.com/chart/interactive/docs/customizing_tooltip_content#annotating-data上有一个列角色 annontationText 的示例,我想对 annontation 做同样的事情。
但是我无法将注释切换为 html。但是带有 annontationText 的示例的方式也不适合我。我不知道错误是否来自角度组件,或者我是否监督了某些事情。
import {Component, Input, OnInit} from '@angular/core';
@Component({
selector: 'app-measurement',
templateUrl: './measurement.component.html',
styleUrls: ['./measurement.component.css']
})
export class MeasurementComponent implements OnInit {
plot;
constructor() {}
ngOnInit() {
this.createPlot('Test');
}
createPlot(title) {
this.plot = {
chartType: 'LineChart',
options:
{
title: title,
height: '600px',
curveType: 'function',
hAxis: {title: 'x'},
vAxis: { title: 'y' }
},
dataTable: [
[ { 'id': 'x', 'label': 'x','type': 'number' },
{ 'id': 'y', 'label': 'y','type': 'number' },
{'id': 'icon', 'label': 'icon', 'type': 'string', 'role': 'annotation', p: {html: true}} ],
[0.0005, 1434,null],
[0.001, 1436,null],
[0.0015, 1435, '<img src="./assets/img/icon1.svg">'],
[0.002, 1429, '<img src="./assets/img/ic_bench.svg">'],
[0.0025, 1439, null]
[0.003, 1451, null],
]
};
}
}
但它不会显示图像,而只会显示 HTML 文本。
解决方案
推荐阅读
- asp.net - .NET 在存在 Owin 问题的现有项目依赖中安装 umbraco
- haskell - 使用带有反射的 Web 组件 HTML 标记
- flexbox - Bootstrap 4 - 正确显示带有文本和图标的项目列表
- google-apps-script - 有没有办法在 Google Docs 的 Google Apps 脚本中添加“复制到剪贴板”功能?
- java - SparkStreaming 2.3.1 java.lang.NoSuchMethodError: twitter4j.TwitterStream.addListener(Ltwitter4j/StreamListener;)V
- ios - 在 IOS 中计算哈希率
- javascript - 当我收到来自 socket.io 的响应时,我的反应组件没有呈现我的状态
- php - 用php执行一个shell脚本
- graph-algorithm - Does Prim's algorithm checks graph connectivity by itself?
- javascript - Javascript每个循环都有暂停而不是暂停