Forum Discussion

a_novice's avatar
a_novice
Frequent Visitor
9 years ago
Solved

Error: Custom Visual

Hello! When coding a custom barchart for powerbi I get an error with a d3 typing. I had errors with other d3 typings when following the microsoft instructional video on youtube, but I have figured o...
  • v-viig's avatar
    v-viig
    9 years ago

    I suppose that you might use these code:

    private svg: d3.Selection<d3.BaseType, any, HTMLElement, any>;
    private barChartContainer: d3.Selection<d3.BaseType, any, any, any>;
    private barContainer: d3.Selection<d3.BaseType, any, any, any>;
    private xAxis: d3.Selection<d3.BaseType, any, any, any>;
    let svg = this.svg = d3.select<SVGElement, any>(options.element as any)
    this.svg.attr({
        width: width,
        height: height
    } as any);
    bars.attr({
        width: xScale.rangeBand(),
        height: d => height - yScale(<number>d.value),
        y: d => yScale(<number>d.value),
        x: d => xScale(d.category),
        fill: d => d.color,
        'fill-opacity': viewModel.settings.generalView.opacity / 100
    });

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]