Forum Discussion
Anonymous
7 years agoNot applicable
How can I resolve garbled characters in Custom Visuals?
I made custom visuals with R script.
But I can not display japanese. japanese language was garbled.
I realize that the characters were convert from Latin-1 to UTF-8.
How can I resolve it?
・InputData
・Rscript
source('./r_files/flatten_HTML.r')
############### Library Declarations ###############
targetPackages <- c('plotly','dplyr')
newPackages <- targetPackages[!(targetPackages %in% installed.packages()[,"Package"])]
if(length(newPackages)) install.packages(newPackages, repos = "http://cran.us.r-project.org")
libraryRequireInstall("plotly");
libraryRequireInstall("dplyr");
####################################################
############ User Parameters #########
# Set of parameters from GUI
MaxAlartLine = 200
if(exists("alartSetting_MaxAlartLine")){
MaxAlartLine = alartSetting_MaxAlartLine
}
MinAlartLine = 200
if(exists("alartSetting_MinAlartLine")){
MinAlartLine = alartSetting_MinAlartLine
}
MaxWarningLine = 100
if(exists("alartSetting_MaxWarningLine")){
MaxWarningLine = alartSetting_MaxWarningLine
}
MinWarningLine = -100
if(exists("alartSetting_MinWarningLine")){
MinWarningLine = alartSetting_MinWarningLine
}
AlartColor = '#0010c9'
if(exists("alartSetting_AlartColor")){
AlartColor = alartSetting_AlartColor
}
WarningColor = '#0010c9'
if(exists("alartSetting_WarningColor")){
WarningColor = alartSetting_WarningColor
}
ColorOn = TRUE
if(exists("alartSetting_ColorOn")){
ColorOn = alartSetting_ColorOn
}
####################################################
################### Actual code ####################
#HeaderSetting
headerValues <- list();
for (i in (0:ncol(Values))) {
tmpname <- names(Values)[i]
headerValues[i] <- tmpname
}
headerValues <- append(headerValues, "<b>Items</b>", after = 0)
#count
MaxAlartCountdata <- Values %>% dplyr::filter(Values[1] >= MaxAlartLine) %>% dplyr::summarise(cnt=n())
MaxWarningCountdata <- Values %>% dplyr::filter(Values[1] >= MaxWarningLine) %>% dplyr::summarise(cnt=n())
MinWarningCountdata <- Values %>% dplyr::filter(Values[1] <= MinWarningLine) %>% dplyr::summarise(cnt=n())
MinAlartCountdata <- Values %>% dplyr::filter(Values[1] <= MinAlartLine) %>% dplyr::summarise(cnt=n())
#CellSetting
cellValues <- list(
c('TotalCount','MaxAlartCount','MaxWarningCount','MinWarningCount','MinAlartCount'),
c(nrow(Values),MaxAlartCountdata[1,1],MaxWarningCountdata[1,1],MinWarningCountdata[1,1],MinAlartCountdata[1,1]))
#CellColorSetting
colorvec <- c('white')
if (ColorOn == TRUE){
if (MaxAlartCountdata[1,1] == 0) colorvec <- c(colorvec, 'white') else colorvec <- c(colorvec, AlartColor)
if (MaxWarningCountdata[1,1] == 0) colorvec <- c(colorvec, 'white') else colorvec <- c(colorvec, WarningColor)
if (MinWarningCountdata[1,1] == 0) colorvec <- c(colorvec, 'white') else colorvec <- c(colorvec, WarningColor)
if (MinAlartCountdata[1,1] == 0) colorvec <- c(colorvec, 'white') else colorvec <- c(colorvec, AlartColor)
}
#Plot
p <- plot_ly(
type = 'table',
header = list(
values = headerValues,
align = rep('center', ncol(Values) + 1),
line = list(width = 1, color = 'black'),
fill = list(color = 'white'),
font = list(family = "Arial", size = 14, color = "black")
),
cells = list(
values = c(cellValues),
align = rep('center', ncol(Values) + 1),
line = list(color = "black", width = 1),
fill = list(color = c('white',list(colorvec))),
font = list(family = "Arial", size = 12, color = c("black"))
));
#output
internalSaveWidget(p, 'out.html');
####################################################
・Result
4 Replies
- v-viigCommunity Champion
We suggest to email [email protected]
This email is supported by R expert.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- AnonymousNot applicable
I tried to email.
But No reply.
Please help me.
- v-viigCommunity Champion
Our R-script developer is on vacation. He will reply soon.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals