Highcharts does not support rtl be default. When placing rtl texts like hebrew/arabic the text is completely destroyed, making it sometimes unreadable. How do I configure HighCharts to support RTL?
I am using the dotnetHighCharts if it helps...
Highcharts does not support rtl be default. When placing rtl texts like hebrew/arabic the text is completely destroyed, making it sometimes unreadable. How do I configure HighCharts to support RTL?
I am using the dotnetHighCharts if it helps...
try this code: Demo
var chart = new Highcharts.Chart({
chart: {
style:{
direction: 'rtl'
},
renderTo: 'container',
type: 'column'
},
xAxis: {
categories: [
' تست a',
'حسن',
'كريم',
'محمود'
],
reversed: true
},
yAxis: {
labels: {
useHTML: true,
format: '{value} متر مربع'
},
title: {
text: 'الاسم الأول',
useHTML: true
},
},
title: {
text: 'تست a',
useHTML: true
},
legend: {
useHTML: true
},
tooltip: {
useHTML: true
},
series: [{
name: 'تست',
data: [10000,30000,20000,40000]
}]});
Just add useHTML: true
to plot options of your chart.
See demo here jsfiddle.net/3me9h7k2
or
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'pie'
},
title: {
text: 'یک نمودار؟!',
useHTML: true, //bug fixed `IE9` and `EDGE`
style: {
fontSize: '20px',
fontFamily: 'tahoma',
direction: 'rtl',
},
},
tooltip: {
useHTML: true,
style: {
fontSize: '20px',
fontFamily: 'tahoma',
direction: 'rtl',
},
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
y: -5, //Optional
format: '\u202B' + '{point.name}', // \u202B is RLE char for RTL support
style: {
fontSize: '15px',
fontFamily: 'tahoma',
textShadow: false, //bug fixed IE9 and EDGE
},
useHTML: true,
},
//showInLegend: true,
},
},
series: [{
name: 'برند',
colorByPoint: true,
data: [{
name: 'اینترنت اکسپلورر؟!',
y: 56.33
}, {
name: 'کروم؟!',
y: 24.03,
}, {
name: 'فایرفکس؟!',
y: 10.38
}, {
name: 'سفاری؟!',
y: 4.77
}, {
name: 'اوپرا؟!',
y: 0.91
}, {
name: 'دیگر؟!',
y: 0.2
}],
}],
});
I think, this may be helpful:
In general, useHTML for all labels etc. is recommended.
You can use of a RLE
(Start of right-to-left embedding) control character in text. be like this:
format: '\u202B' + '{point.name}'
Sample code:
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'pie'
},
title: {
text: 'یک نمودار؟!',
useHTML: true, //bug fixed `IE9` and `EDGE`
style: {
fontSize: '20px',
fontFamily: 'tahoma',
direction: 'rtl',
},
},
tooltip: {
useHTML: true,
style: {
fontSize: '20px',
fontFamily: 'tahoma',
direction: 'rtl',
},
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
y: -5, //Optional
format: '\u202B' + '{point.name}', // \u202B is RLE char for RTL support
style: {
fontSize: '15px',
fontFamily: 'tahoma',
textShadow: false, //bug fixed IE9 and EDGE
},
},
},
},
series: [{
name: 'برند',
colorByPoint: true,
data: [{
name: 'اینترنت اکسپلورر؟!',
y: 56.33
}, {
name: 'کروم؟!',
y: 24.03,
}, {
name: 'فایرفکس؟!',
y: 10.38
}, {
name: 'سفاری؟!',
y: 4.77
}, {
name: 'اوپرا؟!',
y: 0.91
}, {
name: 'دیگر؟!',
y: 0.2
}],
}],
});
Completed code see in here online: https://jsfiddle.net/NabiKAZ/h4kv0t9v/4/
In the options there is a property: "useHtml": true and if you need in the title you can add style: { direction: rtl } it works!
only
title: {
text: 'یک نمودار؟!',
useHTML: true,
},
legend: {
rtl: true,
},
will do the job for you.