Ticket #5: rotate-x.patch

File rotate-x.patch, 1.6 kB (added by jae@…, 4 years ago)

Patch to add rotate to options.axis.x

  • chart.py

     
    1717 
    1818import copy 
    1919import cairo 
     20import math 
    2021 
    2122from pycha.color import (defaultColorscheme, getColorscheme, hex2rgb, 
    2223                         DEFAULT_COLOR) 
     
    349350                    cx.line_to(x, y + self.options.axis.tickSize) 
    350351                    cx.close_path() 
    351352                    cx.stroke() 
     353                    cx.fill() 
    352354 
     355                    cx.new_path() 
    353356                    label = unicode(tick[1]) 
    354357                    extents = cx.text_extents(label) 
    355358                    labelWidth = extents[2] 
    356359                    labelHeight = extents[3] 
    357                     cx.move_to(x - labelWidth / 2.0, 
     360                    if self.options.axis.x.rotate: 
     361                        cx.move_to(x, y + self.options.axis.tickSize + 10) 
     362                        degrees = self.options.axis.x.rotate 
     363                        cx.rotate(degrees*math.pi/180.) 
     364                        cx.show_text(label) 
     365                        cx.rotate(-degrees*math.pi/180.) 
     366                    else: 
     367                        cx.move_to(x - labelWidth / 2.0, 
    358368                               y + self.options.axis.tickSize + 10) 
    359                     cx.show_text(label) 
     369                        cx.show_text(label) 
    360370                    return label 
    361371                for tick in self.xticks: 
    362372                    drawXLabel(tick) 
     
    456466            tickCount=10, 
    457467            tickPrecision=1, 
    458468            range=None, 
     469            rotate=None, 
    459470        ), 
    460471        y=Option( 
    461472            hide=False,