Jump to content

How to get repeated data from Axis or Hierarchy?


Henry Heberle

Recommended Posts

I'm trying to get data that can be repeated to create a distribution graphic. I have a table like this in Spotfire:

a | 10

a | 10

a | 15

b | 20

or:

a: [10, 10, 15]

b: [20]

however, when trying to get the table, I always get only values that are not repeated, so I get a table like this in the Mod:

a | 10

a | 15

b | 20

Running this function would ignore the duplicates:

async function logViaHierarchy(dataView: DataView) { const xHierarchy = await dataView.hierarchy("Categorical"); const root = await xHierarchy!.root(); log(root, "-------");  function log(node: any, indent: any) { console.log(indent + node.formattedValue()); indent += " "; if (node.children) { node.children.forEach((node: any) => log(node, indent)); } else { node.rows().forEach((row: any) => console.log( indent + row.continuous("Continuous").value() ) ); } } }

What am I missing?

Link to comment
Share on other sites

Hello Henry

a DataView is a view or the data a visualization. In other words, is a subset or view of the data based on filtering, marking and the axis aggregations. Even if your continuous axis on the mod manifest can allows non aggregating measures (allowNonAggregatingMeasures=true), you will still end up with unique values because of the nature of the DataView and its hierarchy method.

If you want to plot all nodes, you need to have a unique identifier on another axis. Try adding a categorical axis on your mod-manifest.json and use the rowid() expression or a column that can identify each row.

Link to comment
Share on other sites

Thanks for the reply!

Can I hide this rowID column from the user, so that my distribution plot works like Spotfire's box plot (only X and Y axes)? For users it's important to keep consistency but if I need 3 axes, that's a different logic for the same type of visualization.

Link to comment
Share on other sites

Hello Henry

I can't find a way, but I I asked this Mods related question on the GitHub Spotfire-mods discussion board in where they replied that you can hide the axis from the user by changing the mod manifest file under the dataViewDefinition.axes:

"legendItem": {"defaultVisibility": "hidden"}

Here is an example

{ "name": "Identifier", "mode": "categorical", "placement": "none", "legendItem": {"defaultVisibility": "hidden","title": ""}, "propertyControl": {"title": "","visibility": "hidden"}},

In order to see the changes, you need to create a new instance of the mod because refreshing the Mod Manifest does not work for this purpose. To create a new visualization mod instance during development, go to Tools > Development > Create visualization mod...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...