{"id":10269,"date":"2020-11-12T20:21:45","date_gmt":"2020-11-13T04:21:45","guid":{"rendered":"https:\/\/threecloud.wpengine.com\/post\/create-a-custom-visual-in-power-bi-with-react\/"},"modified":"2023-07-28T11:48:43","modified_gmt":"2023-07-28T18:48:43","slug":"create-a-custom-visual-in-power-bi-with-react","status":"publish","type":"post","link":"https:\/\/3cloudsolutions.com\/resources\/create-a-custom-visual-in-power-bi-with-react\/","title":{"rendered":"Create a Custom Visual in Power BI with React"},"content":{"rendered":"<p>Welcome to another edition of Azure Every Day! I\u2019m an App Development Consultant at 3Cloud and in this post I\u2019ll show you how to create a custom visual in Power BI with React.<br \/>\nWhen creating a custom visual in Power BI, you use the TypeScript language. You\u2019ll be fine with TypeScript if you are familiar with JavaScript. Once you\u2019ve created a custom visual from scratch, you can test and debug your visuals online using live reports, as well as package and deploy your visual to a production report. You can check out the Microsoft documentation about custom visuals at https:\/\/powerbi.microsoft.com\/en-us\/developers\/custom-visualization\/ to learn more.<br \/>\nI\u2019ll walk you through the process here, but also be sure to watch my video included at the end of this post.<br \/>\n\u2022 To get started, be sure you have node installed on your machine.<br \/>\n\u2022 Navigate to your project directory run the npm install command for Power BI visual tools. Once Power BI visual tools are installed, run pbiviz, new and then your project name.<br \/>\n\u2022 Next, run pbiviz start which will start your custom visualization in the local host.<br \/>\n\u2022 To debug your visualization, go to app.powerbi.com and create a new report (or use an existing one) and add the developer visual to the report.<br \/>\n\u2022 In order to add React elements to your custom visual, you\u2019ll need to install React and ReactDOM. Import React and ReactDOM into the visual.ts file or whatever file you will be using to render the HTML elements to the DOM.<br \/>\n\u2022 Create a React element within the visual.ts. Also create the DOM element and add an element to the DOM that is referenced by this element.<br \/>\n\u2022 Next, create the React component using React.createElement of the component name that you\u2019ve imported, then pass any props you would like in the second parameter of the React.createElement function.<br \/>\n\u2022 Finally, you can add the React element to the DOM by using ReactDOM.render and reference the React component that you built and the HTML element on the page that you would like to add the React element to.<br \/>\n\u2022 When you\u2019re finished building and debugging your project, you can set the project and author details in the pbiviz.json file.<br \/>\n\u2022 Run the pbiviz package command to generate a pbiviz file to import into your Power BI report.<br \/>\n\u2022 Now you can go into your report and import a visual from file. Select the visual and add the data you would like to add to your visual and configure the settings you had previously.<br \/>\n\u2022 Please check out my video for code detail on all the above steps.<\/p>\n<p>&nbsp;<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/OnQmuXTNJjc\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>This post walked you through the steps to create a custom visual in Power BI using React. I hope you\u2019ll give it a try.<\/p>\n<p>Need further help? Our expert team and solution offerings can help your business with any Azure product or service, including Managed Services offerings. Contact us at 888-8AZURE or sales@3cloudsolutions.com.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to another edition of Azure Every Day! I\u2019m an App Development Consultant at 3Cloud&mldr;<\/p>\n","protected":false},"author":21,"featured_media":10802,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[260],"tags":[273],"class_list":["post-10269","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-ai","tag-power-bi","topics-blog"],"acf":[],"_links":{"self":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/posts\/10269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/comments?post=10269"}],"version-history":[{"count":0,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/posts\/10269\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/media\/10802"}],"wp:attachment":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/media?parent=10269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/categories?post=10269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/tags?post=10269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}