Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not 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

 

 capture.PNG

 

 


・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

capture2.PNG

 

4 REPLIES 4
v-viig
Community Champion
Community Champion

We suggest to email pbircvsupport@microsoft.com

 

This email is supported by R expert.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Anonymous
Not applicable

I tried to email.

But No reply.

Please help me.

v-viig
Community Champion
Community Champion

Our R-script developer is on vacation. He will reply soon.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

v-viig
Community Champion
Community Champion

We investigated this issue. It seems you just need to add powerbi_rEnableShowTextForCJKLanguages = 1 at the beginning of your R-script.

 

To find out more please visit documentation: https://docs.microsoft.com/en-us/power-bi/visuals/service-r-visuals#known-limitations

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.