更改字体日期

时间:2019-03-27 09:20:34

标签: javascript highcharts

如何从高库存图表的工具提示(以红色突出显示)中增加字体?

enter image description here

1 个答案:

答案 0 :(得分:1)

使用tooltip:headerFormat会起作用

    tooltip: {
      headerFormat: '<span style="font-size:18px">{point.x:%A, %b %e, %Y}</span>'
    }

$(document).ready(function(){
    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function (data)    {
        // Create the chart
        
        var dataObject = {
            rangeSelector: {
                selected: 1,
                inputEnabled: $('#container').width() > 480
            },
            
            title: {
                text: 'AAPL Stock Price'
            },
            
            series: [{
                name: 'AAPL',
                data: data,
                tooltip: {
                    valueDecimals: 2
                }
            }],
            tooltip: {
            headerFormat: '<span style="font-size:18px">{point.x:%A, %b %e, %Y}</span>'
    },
            chart: {
                renderTo: 'container'
            }
        };
        
        var chart = new Highcharts.StockChart(dataObject);   
        //var chart = $('#container').highcharts('StockChart', dataObject);
    });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>

<div id="container" style="height: 400px; min-width: 310px"></div>