<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: RHTML custom visual, data loss results in misleading plot in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2955134#M40188</link>
    <description>&lt;P&gt;Unfortunately R isn't really my wheelhouse, so I can't offer anything to help on that side of things; just that the capabilities are usually a common sticking point for data being limited in the visual's data view. Hopefully someone else may be able to clarify that part for you &lt;span class="lia-unicode-emoji" title=":crossed_fingers:"&gt;🤞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;All the best,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2022 23:14:36 GMT</pubDate>
    <dc:creator>dm-p</dc:creator>
    <dc:date>2022-12-07T23:14:36Z</dc:date>
    <item>
      <title>RHTML custom visual, data loss results in misleading plot</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2954549#M40181</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;has anyone encountered the problem where the visual looks significantly different than when compiled in R?&lt;/P&gt;&lt;P&gt;My output clearly missed out on alot of data, as many bars are missing from the column plot. Data consists of less than 2000 obs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my R-code, if anyone are interested:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;source('./r_files/flatten_HTML.r')

############### Library Declarations ###############
libraryRequireInstall("ggplot2");
libraryRequireInstall("plotly")
libraryRequireInstall("tidyverse")
libraryRequireInstall("scales")
libraryRequireInstall("lubridate")


################### Actual code ####################
# Prep maskin data --------------------------------------------------------
maskin = Values %&amp;gt;%
  mutate(Ferdig_Tid_Short = as.Date(Ferdig_Tid_Short),
         MaskinNr = as.character(MaskinNr)) %&amp;gt;% 
  mutate(
    year = year(Ferdig_Tid_Short),
    first = floor_date(x = today(),'year',),
    last = as.Date(ifelse(year(today())==year,
                          as.character(today()),
                          as.character((ceiling_date(x = today(),'year',)-days(1)))))
  ) %&amp;gt;%
  group_by(year,MaskinNr,MaskinGruppeNavn) %&amp;gt;% 
  summarise(
    maskintimer = sum(Reell_Maskintid),
    qyeartimer = as.numeric(max(last)-min(first))*24
  ) %&amp;gt;% 
  ungroup %&amp;gt;% 
  transmute(
    year = factor(year),
    MaskinNr = factor(MaskinNr, levels = unique(sort(as.numeric(Values$MaskinNr)))),
    maskingruppe = factor(MaskinGruppeNavn,
                          levels = c('65-90 tonn','120-400 tonn',
                                     '420-600 tonn',
                                     '1000-1500 tonn',
                                     'Pakningslegging')),
    diff = round(maskintimer/qyeartimer,3)
  );


# Lag plot ----------------------------------------------------------------
color_vec = c('#60D9BA','#287878','#01A001','#CFF06D','#00FF51','#FFFF00','#FF8000');


colors = maskin %&amp;gt;% 
  transmute(maskingruppe,
            MaskinNr = MaskinNr) %&amp;gt;%
  distinct() %&amp;gt;%
  arrange(MaskinNr) %&amp;gt;% 
  group_by(maskingruppe) %&amp;gt;% 
  mutate(color = map_chr(1:length(maskingruppe),function(x)color_vec[x])) %&amp;gt;% 
  pull(color);

g = maskin %&amp;gt;%
  filter(maskingruppe != 'Pakningslegging') %&amp;gt;% 
  ggplot(aes(year,diff,fill = MaskinNr)) +
  geom_col(position = position_dodge()) +
  facet_wrap(~maskingruppe) +
  theme_bw() +
  theme(plot.background = element_rect(fill = '#e7f0f0', color = '#e7f0f0'),
        legend.position="none") +
  xlab('') +
  ylab('') +
  scale_y_continuous (labels = scales::percent) +
  scale_fill_manual(values=colors);
####################################################

############# Create and save widget ###############
p = ggplotly(g);
internalSaveWidget(p, 'out.html');
####################################################

################ Reduce paddings ###################
ReadFullFileReplaceString('out.html', 'out.html', ',"padding":[0-9]*,', ',"padding":0,')
####################################################&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 16:10:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2954549#M40181</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-07T16:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: RHTML custom visual, data loss results in misleading plot</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2954935#M40184</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I don't do much with R, but with custom visuals in-general, they will cap at 1,000 data points by default unless the &lt;FONT face="courier new,courier"&gt;dataReductionAlgorithm&lt;/FONT&gt; is updated to declare your visual's data point limit (up to a maximum of 30,000).&lt;/P&gt;
&lt;P&gt;If you haven't tried this, &lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/dataview-mappings#data-reduction-algorithm" target="_self"&gt;here's the relevant section of documentation&lt;/A&gt; that explains the default limit and how to configure your &lt;FONT face="courier new,courier"&gt;capabilities.json&lt;/FONT&gt; accordingly.&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 19:56:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2954935#M40184</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2022-12-07T19:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: RHTML custom visual, data loss results in misleading plot</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2955036#M40186</link>
      <description>&lt;P&gt;This would definitively be a part of the problem, thanks for letting me know! Unfortuneately, it didn't fix the issue. For example, if i restrict the data (PBI filter) to a year with few observations, it is still wrong (even after updating top "count":30000). I'm assuming there is some R function that isn't supported in R?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 21:24:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2955036#M40186</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-07T21:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: RHTML custom visual, data loss results in misleading plot</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2955134#M40188</link>
      <description>&lt;P&gt;Unfortunately R isn't really my wheelhouse, so I can't offer anything to help on that side of things; just that the capabilities are usually a common sticking point for data being limited in the visual's data view. Hopefully someone else may be able to clarify that part for you &lt;span class="lia-unicode-emoji" title=":crossed_fingers:"&gt;🤞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;All the best,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 23:14:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2955134#M40188</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2022-12-07T23:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: RHTML custom visual, data loss results in misleading plot</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2967928#M40307</link>
      <description>&lt;P&gt;Turned out that I forgot to select "sum machine hours" as an aggregation option in Power BI... (my fault). However, your proposal would still be a problem in the next step, thank you for making me aware of it! Power BI is way more fun when you can actually make your own visuals &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 12:14:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/RHTML-custom-visual-data-loss-results-in-misleading-plot/m-p/2967928#M40307</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-14T12:14:05Z</dc:date>
    </item>
  </channel>
</rss>

