GithubHelp home page GithubHelp logo

Comments (3)

spatney avatar spatney commented on June 19, 2024

capabilities were always meant to be static, and not instance specific (thus the reason for them being in a static variable). Changing them at run time can produce undesired behavior during dataview transform since the Power BI clients expect them to be static.

We do want to allow custom visuals in the future to customize their query at runtime (change dataview mappings & roles). Could you give me an example of when you want to dynamically change dataview objects?

from powerbi-visuals-tools.

samississipi avatar samississipi commented on June 19, 2024

Thanks for reply!

I didn't mean to change dataview objects dynamically but to generate dataview object descriptors at runtime according to my settings or some other states to be persisted.

here's the example I mentioned in the last post:

class SettingService {

    // register type of visual setting
    public register(settingType);

    // convert registered settings to pbi dataview object descriptors
    public getRequiredObject(): { [objectName: string]: DataViewObjectDescriptor };

    // other possible functions
    public save(setting);
    public load(settingType);
    ...
}

// decorator defines how to map setting to dataview object
@mapToPbiObject({objectName: "layout"})
class LayoutSetting {

    // decorator defines how to map setting option to dataview object property
    @mapToPbiProperty({propertyName: "overflow",default: "scroll"})
    public overflow: string;

    @mapToPbiProperty({propertyName: "minWidth",default: 20})
    public minWidth: number;
}

var settingService: SettingService;
settingService.register(LayoutSetting);

export class MyVisual implements IVisual {

    public static capabilities: VisualCapabilities = {

        // define data roles, dataview mappings and etc.
        ...

        // define dataview objects
        // generate required dataview object descriptors according to registered settings.
        objects: settingService.getRequiredObject();
    }
}

there's similar requirement for other (inner) fields of capabilities such as conditions field of DataViewMapping (which is the element type of dataViewMappings field).
for example, I currently work on a visual with multiple roles, for which I have to decide all valid combinations of the count of fields assigned to each role, and then generate a set of conditions at runtime. and the result set could be change at each update of business logic. it's really bad for me to offline calculate these conditions each time I update the logic.

conclusion

although capabilities must be defined before visual initializing and be immutable in the whole lifetime of the visual, that doesn't mean capabilities must be designed as static. it could be dynamically generated before the visual initializing just as traditional (two) approaches do, and this could benefit us with extra flexibility.

from powerbi-visuals-tools.

AleksSavelev avatar AleksSavelev commented on June 19, 2024

Closing this issue since the new version of powerbi-visuals-api allows you to implement settings dynamically

from powerbi-visuals-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.