From b67b868cd8cab33adef1cc2967a3ad7566bbed18 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Tue, 1 Jan 2013 15:04:13 -0500 Subject: [PATCH] Add axisLineColor and axisLineWidth to the per-axis configurable options. --- experimental/palette/options.js | 8 ++++---- plugins/axes.js | 20 +++++++++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/experimental/palette/options.js b/experimental/palette/options.js index d627adf..1a3b231 100644 --- a/experimental/palette/options.js +++ b/experimental/palette/options.js @@ -77,19 +77,19 @@ var opts = { }, axisLabelWidth : { type : "int", - // scope : [ "x", "y", "y2" ] + // scope : [ "global", "x", "y", "y2" ] }, axisLineColor : { type : "string", - // scope : [ "x", "y", "y2" ] + scope : [ "global", "x", "y", "y2" ] }, axisLineWidth : { type : "int", - // scope : [ "x", "y", "y2" ] + scope : [ "global", "x", "y", "y2" ] }, axisTickSize : { type : "int", - // scope : [ "x", "y", "y2" ] + // scope : [ "global", "x", "y", "y2" ] }, clickCallback : { type : "function(e, x, points)" diff --git a/plugins/axes.js b/plugins/axes.js index 2e1834c..3c0b015 100644 --- a/plugins/axes.js +++ b/plugins/axes.js @@ -9,12 +9,20 @@ Dygraph.Plugins.Axes = (function() { "use strict"; /* - Bits of jankiness: - Direct layout access - Direct area access - Should include calculation of ticks, not just the drawing. +Options left to make axis-friendly. + ('axisTickSize') + ('drawAxesAtZero') + ('xAxisHeight') + +These too. What is the difference between axisLablelWidth and {x,y}AxisLabelWidth? + ('axisLabelWidth') + ('xAxisLabelWidth') + ('yAxisLabelWidth') */ /** @@ -145,8 +153,6 @@ axes.prototype.willDrawChart = function(e) { // axis lines context.save(); - context.strokeStyle = g.getOption('axisLineColor'); - context.lineWidth = g.getOption('axisLineWidth'); var layout = g.layout_; var area = e.dygraph.plotter_.area; @@ -220,6 +226,10 @@ axes.prototype.willDrawChart = function(e) { } else { axisX = halfUp(area.x); } + + context.strokeStyle = g.getOptionForAxis('axisLineColor', 'y'); + context.lineWidth = g.getOptionForAxis('axisLineWidth', 'y'); + context.beginPath(); context.moveTo(axisX, halfDown(area.y)); context.lineTo(axisX, halfDown(area.y + area.h)); @@ -228,6 +238,8 @@ axes.prototype.willDrawChart = function(e) { // if there's a secondary y-axis, draw a vertical line for that, too. if (g.numAxes() == 2) { + context.strokeStyle = g.getOptionForAxis('axisLineColor', 'y2'); + context.lineWidth = g.getOptionForAxis('axisLineWidth', 'y2'); context.beginPath(); context.moveTo(halfDown(area.x + area.w), halfDown(area.y)); context.lineTo(halfDown(area.x + area.w), halfDown(area.y + area.h)); @@ -272,6 +284,8 @@ axes.prototype.willDrawChart = function(e) { } } + context.strokeStyle = g.getOptionForAxis('axisLineColor', 'x'); + context.lineWidth = g.getOptionForAxis('axisLineWidth', 'x'); context.beginPath(); var axisY; if (g.getOption('drawAxesAtZero')) { -- 2.7.4