简体   繁体   English

如何动态将元素添加到Roassal RTGrapher实例?

[英]How do I dynamically add elements to the Roassal RTGrapher instance?

Object subclass: #MultiData
    instanceVariableNames: 'b'
    classVariableNames: ''
    package: 'CFR-Extensions'

initialize
    b := RTGrapher new.

    b add: (self makeD: #('hello' 1 2 1)).
    b add: (self makeD: #('test' 1 2 11)).

    b

makeD: first
    | d |
    d := RTVerticalMultipleData new.
    d barShape color: Color blue.
    points := OrderedCollection new.
    points add: first.
    d points: points.
    d addMetric: #second.
    d addMetric: #third.
    d addMetric: #fourth.

    "Rotated text"
    d barChartWithBarTitle: #first rotation: -30.
    ^d

The above is essentially the Several metrics per data point example from the Roassal book factored into two methods. 以上本质上是Roassal书中的“ Several metrics per data pointSeveral metrics per data point 示例 ,将其分为两种方法。 Rather than just visualizing a static dataset I've been looking into ways of trying to add data as the program runs. 我一直在研究尝试在程序运行时添加数据的方法,而不仅仅是可视化静态数据集。 I want to visualize the trace of the parameters for a tabular RL agent. 我想可视化表格RL代理的参数跟踪。

What happens when I display the graph in the inspector is that only the latest element shows up as a chart. 当我在检查器中显示图形时,会发生的事情是只有最新的元素显示为图表。 There is some overlaying in the labels though that should not be there. 标签中有一些覆盖层,但不应覆盖。

Originally I wanted to do something like pass an OrderedCollection of points, but the way RTVerticalMultipleData compiles them into Trachel elements makes such a scheme invalid, so I've thought to batch the data instead before adding it as an element. 最初我想做一些类似的事情,例如传递点的OrderedCollection ,但是RTVerticalMultipleData将它们编译成Trachel元素的方式使这种方案无效,因此我考虑过在添加数据作为元素之前对数据进行批处理。

The fact that the above does not work strikes me as a bug. 上面的方法不起作用的事实令我感到不满意。 Apart from fixing this, I am wondering if there is a better way to visualize dynamic data? 除了解决此问题,我想知道是否有更好的方法来可视化动态数据?

I don't know roassal enough to answer to your problem, but for dynamic visualizations, Pharo also has the Telescope project. 我不了解如何解决您的问题,但对于动态可视化,Pharo还提供了Telescope项目。 ( https://github.com/TelescopeSt/Telescope ) https://github.com/TelescopeSt/Telescope

Currently, Telescope only works with Seaside via web visualization (With the Cytoscape connector: https://github.com/TelescopeSt/TelescopeCytoscape ). 目前,Telescope仅通过Web可视化与Seaside一起使用(使用Cytoscape连接器: https : //github.com/TelescopeSt/TelescopeCytoscape )。 See a demo at: https://demos.ferlicot.fr/TelescopeDemo 观看演示: https//demos.ferlicot.fr/TelescopeDemo

I don't know if web visualizations are fine with you but I share just in case. 我不知道Web可视化是否适合您,但我以防万一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM