简体   繁体   English

在 Spotfire Mods 中,作为阅读器的一部分,我可以确定数据视图中发生了什么变化吗?

[英]In Spotfire Mods can I determine what has changed in the dataview as part of the reader?

I was able to successfully implement the monitoring for changes in the dataview overall, and any mod properties as described in this answer for my D3 network chart mod in Spotfire.我能够成功地监控整个数据视图中的变化,以及此答案中描述的任何 mod 属性,用于我在 Spotfire 中的 D3 网络图表 mod。 It works really well.它真的很好用。

However, in a D3 network chart there is simulation running and you only want this simulation to restart when the actual data rendered changes, is there a way to check within the dataView object for more detailed changes.但是,在 D3 网络图中,正在运行模拟,并且您只希望在呈现的实际数据发生更改时重新启动此模拟,有没有办法在 dataView object 中检查更详细的更改。 For example, if the axis expression changes for the Color By or Size by column I don't need to rerun the network simulation and simply update the color or size of a node, or even when some marking is applied to the network chart (which also affects the dataView).例如,如果 Color By 或 Size by 列的轴表达式发生变化,我不需要重新运行网络模拟并简单地更新节点的颜色或大小,甚至当某些标记应用于网络图表时(其中也影响数据视图)。 However, if my data columns change, I want the network to rerun the simulation.但是,如果我的数据列发生变化,我希望网络重新运行模拟。

Another example use case is if filtering has been applied, we may want to update the network only if a large amount of data has been filtered out.另一个示例用例是,如果已应用过滤,我们可能只想在过滤掉大量数据时才更新网络。

Is there any methods in the API I could use to check these more detailed changes in the DataView passed into reader? API 中是否有任何方法可以用来检查传递给阅读器的 DataView 中的这些更详细的更改?

My reader looks like this:我的读者看起来像这样:

/**
 * Create the read function.
 */
const reader = readerWithChangeChecker(
    mod.createReader(
        mod.visualization.data(),
        mod.windowSize(),
        mod.property("network_strength"),
        mod.property("display_labels"),
        mod.property("network_type"),
        mod.property("apply_color")
    )
);

and I have an updateNetwork function in async render function which subscribes to the reader.我有一个 updateNetwork function 在异步渲染 function 订阅读者。 I then have some simple logic checks which are passed to the updateNetwork chart function:然后我进行了一些简单的逻辑检查,这些检查将传递给 updateNetwork 图表 function:

// check what has changed
let data_requires_update = false;
let simulation_requires_update = false;
let window_requires_update = false;
let rendering_requires_update = false;

if (reader.hasValueChanged(dataView)) {
    data_requires_update = true;
    simulation_requires_update = true;
}

if (
    reader.hasValueChanged(network_strength) ||
    reader.hasValueChanged(network_type)
) {
    simulation_requires_update = true;
}

if (reader.hasValueChanged(windowSize)) {
    window_requires_update = true;
}

if (
    reader.hasValueChanged(display_labels) ||
    reader.hasValueChanged(apply_color)
) {
    rendering_requires_update = true;
}

// trigger loading network
updateNetwork(
    data_requires_update,
    simulation_requires_update,
    window_requires_update,
    rendering_requires_update
);

So I am looking to add more detail to dataView check so I can detect axes changes, main data table changes, and whether filtering has happened.所以我希望为 dataView 检查添加更多细节,以便我可以检测轴更改、主数据表更改以及是否发生过滤。 Is this possible?这可能吗?

The dataview in Spotfire Mods can be invalidated and replaced due to many different reasons; Spotfire Mods 中的数据视图可能因多种原因而失效和替换; new axis expressions, changed data table, changed marking or filtering, new streaming data or refreshed/replaced data tables or even modified document properties if those are used in an axis expression.新的轴表达式、更改的数据表、更改的标记或过滤、新的流数据或刷新/替换的数据表,甚至修改文档属性(如果这些属性用于轴表达式)。

It is therefor not always possible to get detailed information as to what of these caused a new data view to be calculated, but you can subscribe to changes in the axis expressions, thereby forcing a refreshed simulation at least when the user changes any of the important axis expressions.因此,并非总是可以获得关于哪些因素导致计算新数据视图的详细信息,但您可以订阅轴表达式的更改,从而至少在用户更改任何重要的数据时强制刷新模拟轴表达式。

In your situation adding all axes but ColorBy and SizeBy may bring you closer to your goal.在您的情况下,添加除 ColorBy 和 SizeBy 之外的所有轴可能会让您更接近目标。 If you get a new dataview but no new axes, then you could try to update the visualization without refreshing the simulation using d3.如果你得到一个新的数据视图但没有新的轴,那么你可以尝试更新可视化而不使用 d3 刷新模拟。 If the change was for example only marking, color or size no new simulation pass should be needed.例如,如果更改只是标记、颜色或尺寸,则不需要新的模拟通道。 In order to identify the nodes and connections in your visualization you should use the key property of the hierarchy leaf node.为了识别可视化中的节点和连接,您应该使用层次结构叶节点的key属性。

If the reason for the new dataview was for example filtering or new data (streaming or refreshed data table), you will instead have a set d3 enter/exit DOM elements.如果新数据视图的原因是例如过滤或新数据(流式传输或刷新数据表),您将拥有一个 set d3 enter/exit DOM 元素。 If those sets are relatively small it might be ok to not refresh the simulation?如果这些集合相对较小,不刷新模拟可能可以吗?

But also bear in mind that the measures defining the connection strength could have new values even if that axis expression is unchanged.但也请记住,即使该轴表达式未更改,定义连接强度的度量也可能具有新值。 So it may be hard to know for sure that an update is ok.因此,可能很难确定更新是否正常。 A manual refresh simulation button might be the easiest way out of that unless you want to compare the entire data views to come up with a way to determine whether to update or refresh it entirely.手动刷新模拟按钮可能是最简单的方法,除非您想比较整个数据视图以想出一种方法来确定是更新还是完全刷新它。

The conclusion is that most information needed to determine whether to update the current visualization or to re-run the entire layout pass is available via the API, but to make a great responsive Mod reuires some knowledge about what is being visualized.结论是,确定是更新当前可视化还是重新运行整个布局过程所需的大多数信息都可以通过 API 获得,但要制作一个出色的响应式 Mod 需要了解正在可视化的内容。

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

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