Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for color axis #152

Open
hski-github opened this issue Dec 20, 2024 · 0 comments
Open

Add example for color axis #152

hski-github opened this issue Dec 20, 2024 · 0 comments

Comments

@hski-github
Copy link

For the section about color https://spotfiresoftware.github.io/spotfire-mods/docs/visualization-mods/using-the-api/mod-data-views/#using-the-spotfire-color-axis I would add an example to retrieve the color. In principle it is easy to use with row.color(), but with an example it is even more obvious.

I would also add the information, that marking automatically adjusts the color - if not deactivated in the settings of the visualization -, so no need to adjust opacity manually.

Example screenshot
image

Example

async function logDataView(dataView)
{
    // Print axes names
    const axes = await dataView.axes();
    console.log(axes.map(axis => axis.name).join(","));

    // Print the row values.
    const rows = await dataView.allRows();
    rows.forEach(row => {
        console.log(axes.map(axis => {
            if(axis.isCategorical){
                return row.categorical(axis.name).formattedValue()
            }
            return row.continuous(axis.name).value()
        }).join(",").concat(row.color().hexCode);

    });
}

Output

X,Y
Apples >> Spain,2500,#85CD4D
Apples >> USA,13500,#85CD4D
Oranges >> Spain,12000,#FC7F08
Oranges >> USA,19000,#FC7F08

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant