热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

长长度字符串未在图表中正确显示-Longlengthstringisnotdisplayingcorrectlyinthechart

Inthejavascriptcodeunderthefunctionhighcharts.chartihavegiventhejsoncodeasxAxis:{ca

In the Javascript code under the function highcharts.chart i have given the json code as xAxis: { categories:["jasrajsinghbediisthebest"]} .The string jasrajsinghbediisthebest is not appearing correctly in the chart due to its large length . I want that the chart should display long strings.I dont want to change the size of the div ,it should remain at 400px.

在函数highcharts.chart下的Javascript代码中,我将json代码作为xAxis:{categories:[“jasrajsinghbediisthebest”]}。字符串jasrajsinghbediisthebest由于其较长的长度而未在图表中正确显示。我想图表应该显示长字符串。我不想改变div的大小,它应该保持在400px。

js code:

$(function () {
// Set up the chart
var chart = new Highcharts.Chart({
    xAxis: {
    //  xAxis data format :["x","y","z"]
        categories:["jasrajsinghbediisthebest"]
    },
    chart: {
        renderTo: 'container',
        type: 'column',
        margin: 75,
        options3d: {
            enabled: true,
            alpha: 15,
            beta: 15,
            depth: 50,
            viewDistance: 25
        }
    },
    title: {
        text: 'Chart rotation demo'
    },
    subtitle: {
        text: 'Test options by dragging the sliders below'
    },
    plotOptions: {
        column: {
            depth: 25
        }
    },
    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]
});
function showValues() {
    $('#R0-value').html(chart.options.chart.options3d.alpha);
    $('#R1-value').html(chart.options.chart.options3d.beta);
}

// Activate the sliders
$('#R0').on('change', function () {
    chart.options.chart.options3d.alpha = this.value;
    showValues();
    chart.redraw(false);
});
$('#R1').on('change', function () {
    chart.options.chart.options3d.beta = this.value;
    showValues();
    chart.redraw(false);
});

showValues();
});

html code:





Alpha Angle
Beta Angle

css code:

#container, #sliders {
    min-width: 310px; 
    max-width: 800px;
    margin: 0 auto;
}
#container {
    height: 400px; 
}

2 个解决方案

#1


0  

use overflow none in your labels :

在标签中使用overflow none:

labels: { 
align: 'left',  
style: { 
    textOverflow:'none', 
    whiteSpace: 'nowrap' 
  } 
 }

#2


0  

You need to set width of label and then set useHTML as true. Last step is apply CSS styles.

您需要设置label的宽度,然后将useHTML设置为true。最后一步是应用CSS样式。

xAxis: {
        //  xAxis data format :["x","y","z"]
        categories: ["jasrajsinghbediisthebest"],
        labels: {
            useHTML:true,
            style: {
            }
        }
    },

CSS

.highcharts-xaxis-labels span {
    word-break:break-all!important;
    white-space: normal!important;
}

Example: http://jsfiddle.net/ta2pLb3v/1/


推荐阅读
author-avatar
丨火云邪神丨
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有