| | 353 | if self.options.axis.y.label: |
| | 354 | tickExtents = [cx.text_extents(unicode(tick[1]))[2:4] |
| | 355 | for tick in self.yticks] |
| | 356 | tickWidth = 0.0 |
| | 357 | if tickExtents: |
| | 358 | tickWidth = self.options.axis.tickSize + 4.0 |
| | 359 | tickExtents.sort() |
| | 360 | max_width, height = tickExtents[-1] |
| | 361 | if self.options.axis.y.rotate: |
| | 362 | radians = math.radians(self.options.axis.y.rotate) |
| | 363 | max_width = ( |
| | 364 | (max_width * math.cos(radians)) |
| | 365 | + (height * math.sin(radians)) ) |
| | 366 | tickWidth += max_width |
| | 367 | |
| | 368 | cx.new_path() |
| | 369 | label = unicode(self.options.axis.y.label) |
| | 370 | labelWidth, labelHeight = cx.text_extents(label)[2:4] |
| | 371 | x = self.area.x - tickWidth - 4.0 |
| | 372 | y = self.area.y + .5 * self.area.h + labelWidth / 2 |
| | 373 | cx.move_to(x, y) |
| | 374 | cx.select_font_face(self.options.axis.labelFont, |
| | 375 | cairo.FONT_SLANT_NORMAL, |
| | 376 | cairo.FONT_WEIGHT_BOLD) |
| | 377 | radians = math.radians(90) |
| | 378 | cx.rotate(-radians) |
| | 379 | cx.show_text(label) |
| | 380 | cx.rotate(radians) |
| | 381 | cx.select_font_face(self.options.axis.labelFont, |
| | 382 | cairo.FONT_SLANT_NORMAL, |
| | 383 | cairo.FONT_WEIGHT_NORMAL) |
| | 384 | |
| 357 | | cx.move_to(x - labelWidth / 2.0, |
| 358 | | y + self.options.axis.tickSize + 10) |
| 359 | | cx.show_text(label) |
| | 412 | if self.options.axis.x.rotate: |
| | 413 | radians = math.radians(self.options.axis.x.rotate) |
| | 414 | cx.move_to( |
| | 415 | x - (labelHeight * math.cos(radians)), |
| | 416 | y + self.options.axis.tickSize |
| | 417 | + (labelHeight * math.cos(radians)) |
| | 418 | + 2) |
| | 419 | cx.rotate(radians) |
| | 420 | cx.show_text(label) |
| | 421 | cx.rotate(-radians) |
| | 422 | else: |
| | 423 | cx.move_to(x - labelWidth / 2.0, |
| | 424 | y + self.options.axis.tickSize + labelHeight + 2) |
| | 425 | cx.show_text(label) |
| | 431 | if self.options.axis.x.label: |
| | 432 | tickExtents = [cx.text_extents(unicode(tick[1]))[2:4] |
| | 433 | for tick in self.xticks] |
| | 434 | tickHeight = 0.0 |
| | 435 | if tickExtents: |
| | 436 | tickHeight = self.options.axis.tickSize + 4.0 |
| | 437 | tickExtents.sort() |
| | 438 | max_width, height = tickExtents[-1] |
| | 439 | if self.options.axis.x.rotate: |
| | 440 | radians = math.radians(self.options.axis.x.rotate) |
| | 441 | height = ((max_width * math.sin(radians)) |
| | 442 | + (height * math.cos(radians)) ) |
| | 443 | tickHeight += height |
| | 444 | |
| | 445 | cx.new_path() |
| | 446 | label = unicode(self.options.axis.x.label) |
| | 447 | cx.select_font_face(self.options.axis.labelFont, |
| | 448 | cairo.FONT_SLANT_NORMAL, |
| | 449 | cairo.FONT_WEIGHT_BOLD) |
| | 450 | labelWidth, labelHeight = cx.text_extents(label)[2:4] |
| | 451 | x = self.area.x + self.area.w / 2.0 - labelWidth / 2.0 |
| | 452 | y = self.area.y + self.area.h + tickHeight + labelHeight + 4.0 |
| | 453 | cx.move_to(x, y) |
| | 454 | cx.show_text(label) |
| | 455 | cx.select_font_face(self.options.axis.labelFont, |
| | 456 | cairo.FONT_SLANT_NORMAL, |
| | 457 | cairo.FONT_WEIGHT_NORMAL) |
| | 458 | |