11

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...

STF
  • 1,485
  • 3
  • 19
  • 36
Michael Blok
  • 221
  • 1
  • 4
  • 15

7 Answers7

14

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]

}]});
Samira
  • 196
  • 1
  • 3
12

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
    }],
}],

});

Khaan
  • 759
  • 7
  • 23
5

I think, this may be helpful:

In general, useHTML for all labels etc. is recommended.

Paweł Fus
  • 44,795
  • 3
  • 61
  • 77
3

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/

Nabi K.A.Z.
  • 9,887
  • 6
  • 59
  • 81
  • your example is not showing any label text except title.. i have the same problem but don't know how to remove this issue... https://jsfiddle.net/NabiKAZ/h4kv0t9v/4/ – Khaan May 20 '17 at 05:43
  • @MuhammadYasir seems this problem there is just on chrome. I work it. – Nabi K.A.Z. May 21 '17 at 06:18
  • some body has done for you.. please check it.. Just add useHTML: true to plot options of your chart https://jsfiddle.net/3me9h7k2/ – Khaan May 22 '17 at 08:00
  • @MuhammadYasir use `useHTML: true` appears another problem you can see here: http://aplud.com/ja9ak layers on another layes. – Nabi K.A.Z. May 22 '17 at 21:25
0

you can set direction ltr

Sample:

<div id="container" style="direction: ltr"></div>
BDL
  • 21,052
  • 22
  • 49
  • 55
mm33
  • 1
  • 1
0

In the options there is a property: "useHtml": true and if you need in the title you can add style: { direction: rtl } it works!

Racheli Frish
  • 211
  • 2
  • 4
0

only

title: {
    text: 'یک نمودار؟!',
    useHTML: true,
},
legend: {
    rtl: true,
},

will do the job for you.

Amir Rezvani
  • 1,262
  • 11
  • 34