{"id":89,"date":"2024-09-12T19:59:04","date_gmt":"2024-09-12T19:59:04","guid":{"rendered":"https:\/\/powerplatformsolutions.net\/?p=89"},"modified":"2025-10-12T14:48:16","modified_gmt":"2025-10-12T14:48:16","slug":"mastering-dynamic-svg-creating-by-building-radar-charts-from-collection","status":"publish","type":"post","link":"https:\/\/powerplatformsolutions.net\/?p=89","title":{"rendered":"Mastering dynamic SVG creating"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"alignright size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"279\" height=\"220\" src=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChart1.png\" alt=\"\" class=\"wp-image-90\"\/><\/figure><\/div>\n\n\n<p>We will do it by building radar chart from collection <\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-e81e3e2c75b808747edf5e9a5fd9e6de\" style=\"color:#f0e6e6\">I was recently challenged in one of my projects to build some radar charts dynamically from some data provided in a collection (we could say &#8220;table&#8221; but as we are in PowerApps environment we will be talking &#8220;collections&#8221; here) .<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-b26d4cde73c13b9c17a49db57caa7ff9\" style=\"color:#f0e6e6\">So we have a collection with 2 key values &#8211; score and title which we need convert into a pretty radar chart as on a picture on a right. I thought &#8211; peace of cake, just use one of the standard charts in PowerApps, but when I started looking in to it I realised that there is no radar chart in standard PA charts. <br><br>I know I could use Power BI, but for some reasons this project was to be PowerApps only. So I started googling and youtubing (apparently there is no such word as &#8220;youtubing&#8221; yet :\/ , but I still gona use it \ud83d\ude42  ) <br><br>   And thats what I came up with&#8230;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft size-full is-resized\"><img decoding=\"async\" width=\"186\" height=\"306\" src=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCollection.png\" alt=\"\" class=\"wp-image-94\" style=\"width:147px;height:auto\" srcset=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCollection.png 186w, https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCollection-182x300.png 182w\" sizes=\"(max-width: 186px) 100vw, 186px\" \/><\/figure><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-bfedc0fbed5ab65783cdad8d3d479ba3\" style=\"color:#f0e6e6\"><br>On a left are collection values we are going to build our chart from   <\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-ace030546c45b46feb64b1ead1462d2a\" style=\"color:#f0e6e6\">I was lucky to still remember something from school geometry lessons so I knew we can find point coordinates if we know the angle and distance. So each record in the collection would be a separate beam (lines going outside from the centre in our cobweb), each equal length equal angle from previous beam)  , and on this beam there will be a point with a distant from the centre dependant on the score. <\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-808ff43e80e0fffcd0a63de01a62af73\" style=\"color:#f0e6e6\">And to find those coordinates we will be using some Sin and Cos functions <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-019d2bc4c35b40ce47e40652d8c6bfea\" style=\"color:#f0e6e6\">First we need to find how many rows\/beams we have, and then find the angle between those beams<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1025\" height=\"68\" src=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode1.png\" alt=\"\" class=\"wp-image-95\" srcset=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode1.png 1025w, https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode1-300x20.png 300w, https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode1-768x51.png 768w\" sizes=\"(max-width: 1025px) 100vw, 1025px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-a438b76c387ad7ed58426fa225d78b5b\" style=\"color:#f0e6e6\">I find it easier to keep values, related to particular element, in one object, hence using Rc for that. I guess there is no need to explain what Count and Angle values are. Cntr &#8211; is a string of centre coordinates that will be used later. At the same time we create some blank collections for future use.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-566f9f14d17c69aadc27eb325fa9fbc4\" style=\"color:#f0e6e6\">And now &#8211; lets start creating some coordinates (you may not believe me, but I loved geometry when I was in school )  <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1016\" height=\"322\" src=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode2.png\" alt=\"\" class=\"wp-image-97\" srcset=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode2.png 1016w, https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode2-300x95.png 300w, https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode2-768x243.png 768w\" sizes=\"(max-width: 1016px) 100vw, 1016px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-f8aa8d360e17322228db205a1f15dc01\" style=\"color:#f0e6e6\">Ok, so we have now a collection with coordinates for beams endings (centre coordinates string we created in the beginning) <br>Lets build some SVG code <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1003\" height=\"147\" src=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode3.png\" alt=\"\" class=\"wp-image-99\" srcset=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode3.png 1003w, https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode3-300x44.png 300w, https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode3-768x113.png 768w\" sizes=\"(max-width: 1003px) 100vw, 1003px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-34dd77c8f3d04c1f316e139543a0dc95\" style=\"color:#f0e6e6\">And the last thing &#8211; combine all those string into SVG image code, that goes under Image properties of the Image element <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"805\" height=\"162\" src=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode4.png\" alt=\"\" class=\"wp-image-100\" srcset=\"https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode4.png 805w, https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode4-300x60.png 300w, https:\/\/powerplatformsolutions.net\/wp-content\/uploads\/2024\/09\/RadarChartCode4-768x155.png 768w\" sizes=\"(max-width: 805px) 100vw, 805px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-1ef57ddcac666e6287f8bc684915324d\" style=\"color:#f0e6e6\">Thats it, job done! Took me only 7 hours in total to build it \ud83d\ude42 <br>Yes, you can add more cobwebs (per each 20% etc), add more texts, change lines thickness, colours<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will do it by building radar chart from collection I was recently challenged in one of my projects to build some radar charts dynamically from some data provided in a collection (we could say &#8220;table&#8221; but as we are in PowerApps environment we will be talking &#8220;collections&#8221; here) . So we have a collection [&hellip;]<\/p>\n","protected":false},"author":85,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-powerapps"],"_links":{"self":[{"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=\/wp\/v2\/posts\/89"}],"collection":[{"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=\/wp\/v2\/users\/85"}],"replies":[{"embeddable":true,"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":13,"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":344,"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions\/344"}],"wp:attachment":[{"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/powerplatformsolutions.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}