- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试为我们的图表创建一个插件,该插件在数据流系列中的最后一个数据上显示一个标记。该符号应仅显示在最新数据上。我在这里了解到我可以扩展原型(prototype)并创建我的图表 Here喜欢
(function (H) {
H.wrap(H.Chart.prototype, 'init', function(proceed) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
};
H.wrap(H.Chart.prototype, 'redraw', function(proceed, points) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
//Add my marker symbol here
});
}(Highcharts));
我测试了上面的两个事件,他们开始添加正确的时间。但是,我的观点是一个 bool 值,这不是我所期望的。我阅读了 api 文档 Here 但无法理解如何进行。如果有人有更好的例子或指导如何使用扩展并实现这一点,我们将不胜感激。我的数据是流式连续数据,需要仅在最新数据之上显示标记符号。
更新
谢谢楼主的回复。我们正在使用 react-highcharts,我注意到我无权访问图表加载事件。尽管如此,我注意到我可以按照说明扩展我的 H.Series 原型(prototype) Here并且我的事件会在每个新的刻度线油漆上触发。我现在将我的代码更新为
H.wrap(H.Series.prototype, 'drawGraph', function (proceed) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
const { chart } = this;
renderSpotIndicator(chart);
});
function renderSpotIndicator(chart){
const series = chart.series[0],
len = series.data.length - 1,
lastPoint = series.data[len];
if(lastPoint){
lastPoint.update({
marker: {
enabled: true
}
});
}
}
当我运行时,我注意到我的标记属性在我的 lastPoint 中不存在,因此它会抛出错误。我无法使用它。我被建议改为绘制标记。以下示例 Here .我将代码更改为
function renderSpotIndicator(chart){
const series = chart.series[0],
len = series.data.length - 1,
lastPoint = series.data[len];
if(lastPoint){
chart.renderer.circle(lastPoint.pointX, lastPoint.pointY, 5).attr({
fill: lastPoint.color,
padding: 10,
r: 5,
stroke: 'white',
'stroke-width': 1,
zIndex: 5
}).add();
}
}
上面也是抛出错误。当我检查时,我注意到自己圈出的属性在我的 lastPoint 上不可用。我的 lastPoint 返回正确,但我无法在特定点上设置标记,因为属性在 lastPoint 上不可用。先生,请提供任何帮助。
最佳答案
您可以编辑加载事件并提取系列的最后一个点。然后调用更新以显示标记。每次刷新图表(通过添加点)时,您都需要执行相同的步骤。提取最后一个点,更新标记(隐藏),添加点并显示最后一个标记。
var series = this.series[0],
len = series.data.length - 1,
lastPoint = series.data[len];
lastPoint.update({
marker: {
enabled: true
}
});
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = Math.random();
len = series.data.length - 1;
series.data[len].update({
marker: {
enabled: false
}
}, false);
series.addPoint([x, y], true, true);
len = series.data.length - 1;
series.data[len].update({
marker: {
enabled: true
}
}, true);
}, 1000);
关于javascript - 在 HighChart 的最新数据上显示 Marker 符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35983353/
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
ECharts是一个纯Javascript的图表库,可以流畅的运行在PC和移动设备上,兼容当前绝大部分浏览器,底层依赖轻量级的Canvas类库ZRender,提供直观、生动、可交互、可高度个性化定制
前言 提示:这里可以添加本文要记录的大概内容: 例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。 提示:以下是本篇文章正文
作为一名ios开发攻城狮,在苹果没有出arc(自动内存管理机制)时,我们几乎有一半的开发时间都耗费在这么管理内存上.后来苹果很人性的出了arc,虽然在很大程度上,帮助我们开发者节省了精力和时间.但是
如何反转Pandas中DataSeries的排序顺序,以便我按降序使用它们? 最佳答案 In [28]: s = pd.Series([20, 10, 30], ['c', 'a', 'b']) In
这个问题已经有答案了: 已关闭10 年前。 Possible Duplicate: Is jQuery $.browser Deprecated? 最新的 jQuery 库是否发生变化 $.brows
我正在开发一个 Intranet 项目,所以我无法复制/粘贴代码,所以希望我的描述和一些小片段会有所帮助。 我知道 MySQL 触发器无法做到这一点,但希望有一种干净的 JPA PrePersist(
这是数据集: 人员状态日期 埃里克 1 1/1/2015 埃里克 2 2/1/2015 埃里克 3 2015 年 3 月 1 日 约翰福音 1 3/1/2015 约翰福音 2 2015 年 2 月 1
现在我正在使用下面的查询按每篇文章的 auto_increment id 排序 mysql_query("SELECT * FROM articles ORDER BY id DESC"); 我想知道
已结束。此问题不符合 Stack Overflow guidelines .它目前不接受答案。 我们不允许提出有关书籍、工具、软件库等方面的建议的问题。您可以编辑问题,以便用事实和引用来回答它。 关闭
已结束。此问题不符合 Stack Overflow guidelines .它目前不接受答案。 我们不允许提出有关书籍、工具、软件库等方面的建议的问题。您可以编辑问题,以便用事实和引用来回答它。 关闭
现在我正在使用下面的查询按每篇文章的 auto_increment id 排序 mysql_query("SELECT * FROM articles ORDER BY id DESC"); 我想知道
在我们做文章的时候常用一些函数修改来实现自己的页面效果,例如,时间的自定义格式 我们常常需要乃至的,搜集了些有关时间格式的CODE,作大家为参考,希望对大家有些帮助 列表页list_article
我想将某些东西提交到 github 存储库,但我(显然)没有任何权利这样做。我对那个 repo 做了一个分支,提交了我的更改并提交了一个 pull-request。 现在,问题是过了一段时间其他人已经
我是 SQL 新手,所以现有的答案对我来说有点复杂。 我有三张 table : WORKER |id |name |date |... JOB |id |name |salary |accept AP
我正在自动从PowerPoint和Excel电子表格中生成PowerPoint报表。在粘贴表格之前,我已经完成了整个过程。 我使用PPApp.CommandBars.ExecuteMso ("Past
我们有 1 个 Kafka 主题和 1 个分区: 从 spring boot kafka 消费者那里看到一个相当奇怪的行为。 Spring kafka消费者在重新启动时总是从主题的开头开始消费。 我已
通过编程从iOS照片库获取最新照片是否有技巧? 我知道我可以按日期搜索,但是我必须每隔一微秒进行一次扫描,以便进行某种比较以准确地找到它。 有没有人做过这个或任何想法? 最佳答案 我之前采取的一种方法
我们上周将 Web 应用程序中的 Telerik Kendo 库从 V2015.2.902 升级到 V2016.1.112。从那时起,我们注意到使用 Kendo 的页面需要很长时间才能加载(30 秒到
我有两个表: STUDENT GRADES ---------- ---------- id id name person_id ad
我是一名优秀的程序员,十分优秀!