Forum Discussion

AakashMarasini's avatar
AakashMarasini
Frequent Visitor
2 years ago
Solved

Max Min Limit setup in custom visual

Hi Developers! I am building a custom visual and added the Max Area height for x axis. Now i want to set the min and max value to it. I have tried putting those values in capabilities.json file an...
  • ewaghabi's avatar
    2 years ago

    I don't know if you already got it, but I managed to do it with something like this (in your settings.ts file):

    import powerbi from "powerbi-visuals-api";
    
    ...
    class MyMaxValidator implements powerbi.visuals.MaxValidator<number> {
       type: powerbi.visuals.ValidatorType.Max;
       value: number;
    
       constructor(max: number) {
           this.value = max;
       }
    }
    class MyMinValidator implements powerbi.visuals.MinValidator<number> {
       type: powerbi.visuals.ValidatorType.Min;
       value: number;
    
       constructor(min: number) {
           this.value = min;
       }
    }
    
    ...
    
    public maxAreaHeightX = new formattingSettings.Slider({
      name: "maxAreaHeightX",
      displayName: "Max Area Height",
      value: 20,
      options: { maxValue: new MyMaxValidator(30), minValue: new MyMinValidator(10) }    
    });