如何将Highchart的字体系列更改为Bootstrap css默认字体系列

时间:2015-05-05 10:38:11

标签: css twitter-bootstrap fonts highcharts

我想在饼图中将标题数据标签工具提示的字体更改为Bootstrap默认默认字体(I&#39 ; m使用Highchart库来显示图表)。我怎么能改变这些?试图添加fontFamily,但它没有工作。

var chart = new Highcharts.Chart({
                    chart: {
                        renderTo: $(element).attr('id'),
                        backgroundColor: '#F8F8F8'
                    },
                    title: {
                        text: "Space Used by Users",
                        fontFamily: 'Helvetica'
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                format: '{point.name}: {point.sizeText}',
                                style: {
                                    fontSize: '11px'
                                }
                            },
                            showInLegend: true
                        }
                    },
                    credits: {
                        enabled: false
                    },
                    tooltip: {
                        pointFormat: '{series.name}: <b>{point.sizeText}</b>'
                    },
                    series: [{
                        type: 'pie',
                        data: [
                            {
                                name: 'Personal Usage',
                                y: scope.item.personalUsage,
                                sizeText: scope.item.personalUsageSizeText
                            },
                            {
                                name: 'Shared Usage',
                                y: scope.item.sharedUsage,
                                sizeText: scope.item.sharedUsageSizeText
                            }
                        ]
                    }]
                });

如何将字体更改为默认引导程序?

1 个答案:

答案 0 :(得分:23)

您只是设置图表标题的字体。以下代码为饼图全局设置字体。

function getChannelVideos(){
    // create an empty data array
    var video = [];

    // create the httpRequest 
    var xhr = Titanium.Network.createHTTPClient(); 

    xhr.open('GET','getVideoFeed.php?chid='+channelView.channelId); 


    // this method will be called when the request is complete
    xhr.onload = function() 
    { 

        // parse json coming from the server
        var json = JSON.parse(this.responseText);

        // if Channel Videos are returned
        if(json.channelVideos)
        {
            for (var i = 0; i < json.channelVideos.length; i++){

                var video = Ti.UI.createView({  // creates video view
                    width:'60%', // sets height
                    backgroundColor: 'transparent',
                });

                var videoThumb = Ti.UI.createImageView({  // creates thumb
                    image:json.channelVideos[i].vThumb, 
                    width:'100%', // sets height
                    top:150 + i*200, // positions from top
                    backgroundColor: '#000'
                });
                video.add(videoThumb);  // adds thumb to video view

                var videoTitle = Ti.UI.createLabel({  // creates label
                    text:json.channelVideos[i].vTitle,
                    font:{
                        fontSize:12
                    },
                    color:'#fff',
                    backgroundColor:'#000',
                    textAlign:'center',
                    width:'100%',
                    height:20,
                    top:140 + i*200, // positions from top
                });
                video.add(videoTitle);  // adds video title to video view

                var videoSpeaker = Ti.UI.createLabel({  // creates Label
                    text:json.channelVideos[i].vSpeaker,
                    font:{
                        fontSize:12
                    },
                    color:'#fff',
                    backgroundColor:'#000',
                    textAlign:'center',
                    width:'100%',
                    height:20,
                    top:295 + i*200, // positions from top
                });
                video.add(videoSpeaker);  // adds speaker name to video view

                var videoPlay = Ti.UI.createImageView({
                    image:'/images/light_play.png',
                    top:215 + i*200, // positions from top
                });

                video.add(videoPlay);  // adds playbutton to videoview

                chContentAreaView.add(video);  // adds video view to scrollview 

                var vId=json.channelVideos[i].vId;

                video.vId = vId;  // Here vId is custom property of video

                video.addEventListener('click', function(e){
                    alert(e.source.vId);
                    Ti.App.fireEvent('videoPlay',{
                        videoId:e.source.vId                        
                    });
                });

            }

        }
    };

    // this method will be called if there is an error 
    xhr.onerror = function(){
        alert(this.error + ': ' + this.statusText);
        return false;
    };

    // open the httpRequest 
    xhr.setRequestHeader("contentType","application/json; charset=utf-8");
    xhr.send();
}