Highcharts yaxis标签切断/溢出

时间:2017-02-10 13:54:12

标签: highcharts

请看下面的图表 http://jsfiddle.net/klodoma/5d24xt39/

如您所见,YAxis标签在顶部被切断,它们未正确对齐。

有什么想法吗?

import pandas as pd

# Part 1, Building the dataframe.

df = pd.DataFrame({
                   'Visitor_ID':[1,2,3],
                   '2010'      :[4,3,10],
                   '2011'      :[3,0,6],
                   '2012'      :[6,7,3],
                   '2013'      :[0,3,0]    
                   })

df.set_index("Visitor_ID", inplace=True)

# Part 2, preparing the required variables.

def dictionary (max_visitors):
    dictionary={}
    for x in range(max_visitors):
        dictionary["number_{}".format(x)] = []
#    print(dictionary)
    return dictionary

# Part 3, Figuring out if the customer returned.             

def compare_yearly_visits(current_year, next_year):    
    index = 1 
    years = df.columns
    for x in df[current_year]: 
#        print (df[years][current_year][index], 'this year.')
#        print (df[years][next_year][index], 'Next year.')
        how_many_visits = df[years][current_year][index] 
        did_he_return   = df[years][next_year][index]

        if did_he_return > 0: 
            # If the visitor returned, add to a bunch of formats:
            returned_at_all.append([how_many_visits, True])
            times_returned.append([how_many_visits, did_he_return])
            dictionary["number_{}".format(x)].append(True)
        else: 
            ## If the visitor did not return, add to a bunch of formats:
            returned_at_all.append([how_many_visits, False])
            dictionary["number_{}".format(x)].append(False)

        index = index +1 

# Part 4, The actual program:
highest_amount_of_visits = 11 # should be done automatically, max(visits)?        
relevant_years = len(df.columns) -1
times_returned = []
returned_at_all = []

dictionary = dictionary(highest_amount_of_visits)
for column in range(relevant_years):  
#   print (dictionary)
    this_year = df.columns[column]
    next_year = df.columns[column+1]
    compare_yearly_visits(this_year, next_year)
    print ("cumulative dictionary up to:", this_year,"\n", dictionary)

enter image description here

1 个答案:

答案 0 :(得分:2)

fontSize的参数应该是字符串,例如'12px'

如果您使用浮动标题指定如此大的字体大小,请添加一些上边距,例如字体大小的一半。

 "chart": {
    marginTop: 25,
  ...

"yAxis": [{
  "opposite": false,
    "labels": {
      "enabled": true,
      "style": {
        "color": "#d9d9d9",
        "fontSize": '45px',
      }
    },
    "title": {
      "text": "",
    }
  }],

示例:http://jsfiddle.net/t1ehqzv0/