Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello,
has anyone encountered the problem where the visual looks significantly different than when compiled in R?
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.
This is my R-code, if anyone are interested:
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 %>%
mutate(Ferdig_Tid_Short = as.Date(Ferdig_Tid_Short),
MaskinNr = as.character(MaskinNr)) %>%
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)))))
) %>%
group_by(year,MaskinNr,MaskinGruppeNavn) %>%
summarise(
maskintimer = sum(Reell_Maskintid),
qyeartimer = as.numeric(max(last)-min(first))*24
) %>%
ungroup %>%
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 %>%
transmute(maskingruppe,
MaskinNr = MaskinNr) %>%
distinct() %>%
arrange(MaskinNr) %>%
group_by(maskingruppe) %>%
mutate(color = map_chr(1:length(maskingruppe),function(x)color_vec[x])) %>%
pull(color);
g = maskin %>%
filter(maskingruppe != 'Pakningslegging') %>%
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,')
####################################################
Solved! Go to Solution.
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?
Hi @Anonymous,
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 dataReductionAlgorithm is updated to declare your visual's data point limit (up to a maximum of 30,000).
If you haven't tried this, here's the relevant section of documentation that explains the default limit and how to configure your capabilities.json accordingly.
Hope this helps,
Daniel
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
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?
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 🤞
All the best,
Daniel
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
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 🙂
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |