Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HighCharts to support RTL

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

like image 304
Michael Blok Avatar asked Feb 19 '13 13:02

Michael Blok


2 Answers

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]

}]});
like image 132
Samira Avatar answered Sep 19 '22 14:09

Samira


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

});

like image 37
Khaan Avatar answered Sep 19 '22 14:09

Khaan