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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rootchina
Regular Visitor

Cannot plot the R viz in PBI Desktop when the column named with Chinese characters (UTF-8)

 Hi  Power BI guru, 

 

Issue Description:

I find that there exists a language support issue when I try to plot a R visual in Power BI Desktop. It failes to plot the visual with error throwing out, however the visual could be generated in the R IDE with the same scripts. I have converted the file to UTF-8 and set locale option with Chinese region before run the R script. Could someone help me out? Thanks in advance. 

 

 

Software env:

Power BI Desktop Version: 2.48.4792.721 64-bit (July 2017)

Microsoft R Open R-3.4

Windows 10 Enterprise OS English (Chinese Font installed)

 

Code Executed:

library(showtext)
showtext.auto(enable = TRUE)
font.add('fang', 'simfang.ttf')
Sys.setlocale(,"CHS")
城市 <- dataset$城市
纳税 <- dataset$纳税
plot(城市,纳税,family = 'fang')

Successful visual present in R Studio:

 

RStudioviz.PNG

Error details in Power BI Desktop:

 

Feedback Type:
Frown (Error)

Timestamp:
2017-08-08T01:13:51.8636859Z

Local Time:
2017-08-08T09:13:51.8636859+08:00

Product Version:
2.48.4792.721 (PBIDesktop) (x64)

Release:
July 2017

IE Version:
11.1066.14393.0

OS Version:
Microsoft Windows NT 10.0.14393.0 (x64 en-US)

CLR Version:
4.6.2. or later [Release Number = 394802]

Workbook Package Info:
1* - en-US, Query Groups: 0, fastCombine: Disabled, runBackgroundAnalysis: True.

Peak Working Set:
432 MB

Private Memory:
295 MB

Peak Virtual Memory:
33.9 GB

Error Message:
R 脚本错误。
Loading required package: sysfonts
错误: unexpected symbol in:
"setwd(Sys.getenv('RScriptWrapperWorkingDirectory'))
graphics.off"
停止执行


User ID:
d120bad3-50cb-47cf-8ce3-c32368a4c52f

Session ID:
a48981d1-59d9-4b14-9c4b-a293b3c6b7a4

Telemetry Enabled:
True

Model Default Mode:
Import

Snapshot Trace Logs:
C:\Users\zhang.jialiang\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot1058448085.zip

Performance Trace Logs:
C:\Users\zhang.jialiang\AppData\Local\Microsoft\Power BI Desktop\PerformanceTraces.zip

Disabled Preview Features:
PBI_shapeMapVisualEnabled
PBI_EnableReportTheme
PBI_numericSlicerEnabled
PBI_SpanishLinguisticsEnabled
PBI_PbiServiceLiveConnect
PBI_daxTemplatesEnabled
CustomConnectors

Disabled DirectQuery Options:
PBI_DirectQuery_Unrestricted

Cloud:
GlobalCloud

活动 ID:
null

时间:
Tue Aug 08 2017 08:43:23 GMT+0800 (China Standard Time)

Client Error Code:
ServiceErrorToClientError

Error Details:
R 脚本错误。
Loading required package: sysfonts
错误: unexpected symbol in:
"setwd(Sys.getenv('RScriptWrapperWorkingDirectory'))
graphics.off"
停止执行


Stack Trace:
Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: R 脚本错误。
Loading required package: sysfonts
错误: unexpected symbol in:
"setwd(Sys.getenv('RScriptWrapperWorkingDirectory'))
graphics.off"
停止执行
---> Microsoft.PowerBI.Radio.RScriptRuntimeException: R 脚本错误。
Loading required package: sysfonts
错误: unexpected symbol in:
"setwd(Sys.getenv('RScriptWrapperWorkingDirectory'))
graphics.off"
停止执行

at Microsoft.PowerBI.Radio.RScriptWrapper.RunScript(String originalScript, Int32 timeoutMs)
at Microsoft.PowerBI.Client.Windows.R.RScriptHandler.GenerateVisual(ScriptHandlerOptions options)
--- End of inner exception stack trace ---
at Microsoft.PowerBI.Client.Windows.R.RScriptHandler.GenerateVisual(ScriptHandlerOptions options)
at Microsoft.PowerBI.ExploreServiceCommon.ScriptVisualCommandFlow.RunInternal(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
at Microsoft.PowerBI.ExploreServiceCommon.ScriptVisualCommandFlow.Run(Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
at Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.TransformDataShapeResult(QueryCommand transformCommand, String dataShapeId, SemanticQueryDataShapeCommand command, Stream dataShapeResultStream, QueryBindingDescriptor& bindingDescriptor)
at Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.ProcessAndWriteDataQuery(IQueryResultDataWriter queryResultDataWriter, DataShapeGenerationContext dsqGenContext, EntityDataModel model, DataQuery query, ServiceErrorStatusCode& serviceErrorStatusCode)
at Microsoft.PowerBI.ExploreHost.SemanticQuery.ExecuteSemanticQueryFlow.ProcessAndWriteSemanticQueryCommands(IQueryResultsWriter queryResultsWriter, ExecuteSemanticQueryRequest request, IConceptualSchema conceptualSchema, EntityDataModel model)

DPI Scale:
100%

Supported Services:
Power BI

Formulas:


section Section1;

shared dataset = let
源 = R.Execute("`dataset` = read.csv('C:\\Users\\zhang.jialiang\\Desktop\\NewO365Useradd\\test1.csv', encoding = ""UTF-8"", check.names = FALSE, header = TRUE, blank.lines.skip = FALSE);"),
dataset1 = 源{[Name="dataset"]}[Value]
in
dataset1;

RvizErr.PNG

 

Data source CSV file:

姓名,工号,省份,城市,地址,街道,邮政编码,利润,纳税,时间
Jared,10025,浙江,杭州,杭州市西湖区,文三路,310000,2800000,560000,2017年2月
Allen,10020,北京,北京,北京市朝阳区,长安街,100000,3200000,640000,2017年3月
Carl,10012,广东,广州,广州市天河区,五山路,510000,3600000,720000,2017年4月
Butter,10017,陕西,西安,西安市雁塔区,长安南路,710000,2400000,480000,2017年5月
Steven,10088,上海,上海,上海市徐汇区,华山路,200000,3000000,600000,2017年6月
Kelvin,10056,新疆,乌鲁木齐,乌鲁木齐市天山区,跃进街,830000,2200000,440000,2017年7月

Where Big Data Meets the Cloud.
3 REPLIES 3
Anonymous
Not applicable

I am having the exact same issue. Power BI would throw error when there are Chinese characters in the code, even if I changed the locale and set powerbi_rEnableShowTextForCJKLanguages = 1.

@rootchina  Have you found a solution to this yet?

 

Sys.setlocale(category = "LC_ALL", locale = "cht")
library(showtext)
powerbi_rEnableShowTextForCJKLanguages = 1

v-sihou-msft
Employee
Employee

@rootchina

 

I directly drag 城市 and 纳税 column into R visual. Then your script works and the chinese characters are displayed properly. 

 

library(showtext)
showtext.auto(enable = TRUE)
Sys.setlocale("LC_ALL","CHS")
plot(dataset)

 

34.PNG

 

Regards,

Hi Simon, 

 

Thanks for your solution which could avoid calling variables when using plot(dataset) ,  sometimes we have to use the varibles if we need to plot a accurate shapes with with defined parameters.

 

Assign the column header with Chinese characters to the variables, like what i describled in the question. 

 

library(showtext)
showtext.auto(enable = TRUE)
font.add('fang', 'simfang.ttf')
Sys.setlocale(,"CHS")
城市 <- dataset$城市
纳税 <- dataset$纳税
plot(城市,纳税,family = 'fang')

 

Due to the Chinese parse, the scripts fails to executed thought it works in R studio. 

 

Where Big Data Meets the Cloud.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.