cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
rakeshkamble1
Frequent Visitor

How to create datalabels in custom power bi visual?

How to use DataLabelManager class to create datalabels in custom power bi visual?

7 REPLIES 7
v-janeyg-msft
Community Support
Community Support

Hi, @rakeshkamble1 

 

Here is the usage of 'DataLabelManager':powerbi-visuals-utils-chartutils/data-label-manager.md at master · microsoft/powerbi-visuals-utils-c...

The DataLabelManager helps to create and maintain labels. It arranges label elements using the anchor point or rectangle. Collisions between elements can be automatically detected and as a result elements can be repositioned or get hidden.

 

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Dear Janey,

 

Thank you for your response. I have followed the code but unable to understand how I can show customized data labels on bar chart. Tis article only shows how to get the datalabel, but I would require more info on how we can display the datalabels on bar chart.

Hi, @rakeshkamble1 

 

Here are some references:

Objects and properties of Power BI visuals in Power BI embedded analytics for better embedded BI ins...

Build a bar chart in Power BI embedded analytics for better embedded BI insights - Power BI | Micros...

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Dear Janey,

 

Thank you once again for your reply.

I would require an example where datalabels should be shown on bar chart using custom visual. I have already created one bar chart, but not able to understand how to incorporate DataLabels and Legends into it.

 

If I could get any code reference then it's highly helpful.

Hi, @rakeshkamble1 

You can domnload a sample here.

GitHub - microsoft/PowerBI-visuals-sampleBarChart: Bar Chart Custom Visual for tutorial.

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Dear Janey,

 

Thank you for sharing the information.

I have issue with below line of code while adding legend data.

 

interface ViewModel{
    dataPointsDatapoint[];
    legendDataLegendData;
    dataLabelsDataLabelEnabledDataPoint;
};

 

let legendData : LegendData = {
            dataPoints: [],
            title: "Testing"
        }
        legendData.dataPoints.push({
            label: "Legend Test",
            color: "blue",
            selected: false,
            identity: null
        });
        this.legend.drawLegend(this.viewModel.legendDataoptions.viewport); --Issue here in customVisualsHost.bundle.min.js file 

 

Can you please let me know where i'm doing wrong parameter insertion?

Hi, @rakeshkamble1 

 

Can you share a screenshot of the error message?

You can also try e-mail contact:  pbicvsupport@microsoft.com  They are professional.

Best Regards

Janey Guo

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors