首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在highcharts x轴和y轴标题上以下标和上标的形式显示内容

在highcharts x轴和y轴标题上以下标和上标的形式显示内容
EN

Stack Overflow用户
提问于 2013-08-26 14:50:09
回答 2查看 2.6K关注 0票数 5

我正在使用我的应用程序的highcharts来显示数学计算和电气术语,所以我需要在highcharts上显示电气术语,Xaxis标题和Yaxis标题的上标和下标的形式我已经尝试过任何方法,但我没有得到任何soln html sub和sup标签不工作,请给我任何适当的解决方案。

EN

回答 2

Stack Overflow用户

发布于 2013-08-26 15:10:25

考虑使用

代码语言:javascript
复制
...
//some options
title: {
   useHTML: true,
   text: "<sub>sub</sub>normal<sup>sup</sup>"
}
//other options
...
票数 11
EN

Stack Overflow用户

发布于 2015-09-09 21:47:04

这就是如何在图表标题、轴标签、图例标签和数据标签上使用useHTML属性-

代码语言:javascript
复制
$(function () {
    $('#container').highcharts({
		chart: {
            type: 'column'
        },
        credits : {
            enabled : false
        },
        title: {
            text: 'Chart Title<sup>1</sup>',
            useHTML : true,
        },
        xAxis: {
			categories: [ 'label1','label2','label3<sup>4</sup>','label4'],
            title:{
                enabled: false
            },						
            labels: {
                useHTML : true,
                title: {
                    enabled: false
                }         
            },
        },
        yAxis: {
            title: {
                enabled: false
            },
            labels: {
                useHTML : true,
                formatter:function(){
                    if(this.value != 10){
                        return this.value;
                    }else{
                        return this.value + '<sup> 2</sup>';
                    }					
                }								
            }						
        },
        legend: {
            useHTML : true,
            borderWidth: 0,
            labelFormatter:function(){
                if(this.name != 'legend1'){
                    return this.name;
                }else{
                    return this.name + '<sup> 5</sup>';
                }					
            }	
        },
        plotOptions: {
            column: {
                dataLabels: {
                    enabled: true,
                    useHTML : true,
                    y:-1,
                    formatter:function(){
                        if(this.y != 0){
                            if(this.y > 8 && this.y < 10){
                                return this.y + '<sup> 3</sup>';
                            }else{
                                return this.y;
                            }

                        }else{
                            return null;
                        }					
                    }				
                }						
            }			
        },		
        series: [{ 
            data: [{ 
                y: 14.913
            }, { 
                y: 8.281
            }, { 
                y: 3.592
            }, { 
                y: 3.017
            }], 
            showInLegend: false,
        },{
            name: 'legend1',
            color: 'rgb(14,178,89)'      
        },{
            name: 'legend2',
            color: 'rgb(100,100,9)'      
        }]
    });
});
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; max-width: 800px; margin: 0 auto"></div>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18438210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档