Skip to content

Formatting of values when working with multiple values #17

Description

@goforthanddie

Hi there,

thanks for providing this helpful library!

When using multiple values in a slot of type cont, it seems that the first value always defines the format of the caption of all the following values. For example, if I add a currency first and a quantity second, reading the caption for the quantity yields the quantity formatted as a currency and vice versa. Is it possible to obtain the correctly formatted values?

image
In this example "Einnahmen" is a currency and "Menge" is a quantity and both captions are formatted as a currency. When switching the order, thus having "Menge" first and "Einnahmen" second, both are formatted as a quantity.

Thanks for looking into this!

Samy

Minimal working example:
vizdef.xml:

<visualizationDefinition version="3.1" xmlns="http://www.ibm.com/xmlns/prod/ba/vipr/vizBundle/vizdef.3">
    <slots>
        <slot name="categories" caption="Categories" type="cat" optional="false" />
        <slot name="values" caption="Values" type="cont" optional="false" />
    </slots>
    <dataSets>
        <dataSet name="data">
            <ref slot="categories" />
            <ref slot="values" />
        </dataSet>
    </dataSets>
</visualizationDefinition>

Main.ts:

import {RenderBase} from "@businessanalytics/customvis-lib";

// data column indices
const CATEGORIES = 0, VALUES = 1;

export default class extends RenderBase {
    protected create(_node: HTMLElement): HTMLElement {
        return _node;
    }

    protected update(_info): void {
        const rows = _info.data ? _info.data.rows : [];

        for (let i = 0; i < rows.length; i++) {
            console.log(rows[i].caption(CATEGORIES));
            console.log(rows[i].caption(VALUES));
            console.log(rows[i].value(VALUES));
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions