X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=plugins%2Faxes.js;h=e74f289973b8c14f5fc7359c2bfa000a2ab0db40;hb=7e1d5659d49ea4407f4e351852c275aa3fcc9f86;hp=40b826c99550e29c6b73270f2d8b93e2e6f7c2e9;hpb=48dc3815c2cd342aab3d47978b5351e2ce5bcf43;p=dygraphs.git diff --git a/plugins/axes.js b/plugins/axes.js index 40b826c..e74f289 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') */ /** @@ -49,6 +57,9 @@ axes.prototype.layout = function(e) { if (g.getOption('drawXAxis')) { var h; + // NOTE: I think this is probably broken now, since g.getOption() now + // hits the dictionary. (That is, g.getOption('xAxisHeight') now always + // has a value.) if (g.getOption('xAxisHeight')) { h = g.getOption('xAxisHeight'); } else { @@ -106,7 +117,7 @@ axes.prototype.willDrawChart = function(e) { position: "absolute", fontSize: g.getOptionForAxis('axisLabelFontSize', axis) + "px", zIndex: 10, - color: g.getOption('axisLabelColor'), + color: g.getOptionForAxis('axisLabelColor', axis), width: g.getOption('axisLabelWidth') + "px", // height: g.getOptionForAxis('axisLabelFontSize', 'x') + 2 + "px", lineHeight: "normal", // Something other than "normal" line-height screws up label positioning. @@ -122,7 +133,7 @@ axes.prototype.willDrawChart = function(e) { var makeDiv = function(txt, axis, prec_axis) { /* - * This seems to be called with the following three sets of axis/perc_axis: + * This seems to be called with the following three sets of axis/prec_axis: * x: undefined * y: y1 * y: y2 @@ -145,8 +156,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 +229,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 +241,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 +287,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')) {