Arjunsos / simile-widgets

Automatically exported from code.google.com/p/simile-widgets
0 stars 0 forks source link

TIMEPLOT: DefaultTimeGeometry.paint never writes out the gridColor to the grid-label's style #79

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Simple fix:

Timeplot.DefaultTimeGeometry.prototype.paint = function() {
    if (this._canvas) {
        var unit = this._unit;
        var ctx = this._canvas.getContext('2d');

        var gradient = ctx.createLinearGradient(0,0,0,this._canvas.height);

        ctx.strokeStyle = gradient;
        ctx.lineWidth = this._gridLineWidth;
        ctx.lineJoin = 'miter';

        // paint grid
        if (this._gridColor) {
            gradient.addColorStop(0, this._gridColor.toString());
            gradient.addColorStop(1, "rgba(255,255,255,0.9)");

            for (var i = 0; i < this._grid.length; i++) {
                var tick = this._grid[i];
                var x = Math.floor(tick.x) + 0.5;
                if (this._axisLabelsPlacement == "top") {
                    var div = this._timeplot.putText(this._id + "-" + i,
tick.label,"timeplot-grid-label",{
                        left: x + 4,
                        top: -4, // BUGFIX
                        color: this._gridColor.toHexString(), // BUGFIX
                        visibility: "hidden"
                    });
                } else if (this._axisLabelsPlacement == "bottom") {
                    var div = this._timeplot.putText(this._id + "-" + i,
tick.label, "timeplot-grid-label",{
                        left: x + 4,
                        bottom: 2,
                        color: this._gridColor.toHexString(), // BUGFIX
                        visibility: "hidden"
                    });
                }
                if (x + div.clientWidth < this._canvas.width + 10) {
                    div.style.visibility = "visible"; // avoid the labels
that would overflow
                }

                // draw separator
                ctx.beginPath();
                ctx.moveTo(x,0);
                ctx.lineTo(x,this._canvas.height);
                ctx.stroke();
            }
        }

        // paint axis
        gradient.addColorStop(0, this._axisColor.toString());
        gradient.addColorStop(1, "rgba(255,255,255,0.5)");

        ctx.lineWidth = 1;
        gradient.addColorStop(0, this._axisColor.toString());

        ctx.beginPath();
        ctx.moveTo(0,0);
        ctx.lineTo(this._canvas.width,0);
        ctx.stroke();
    }
};

Index: geometry.js
===================================================================
--- geometry.js (revision 9214)
+++ geometry.js (working copy)
@@ -534,12 +532,14 @@
                         var div = this._timeplot.putText(this._id + "-" +
i, tick.label,"timeplot-grid-label",{
                             left: x + 4,
                             top: 2,
+ color: this._gridColor.toHexString(),
                             visibility: "hidden"
                         });
                     } else if (this._axisLabelsPlacement == "bottom") {
                         var div = this._timeplot.putText(this._id + "-" +
i, tick.label, "timeplot-grid-label",{
                             left: x + 4,
                             bottom: 2,
+ color: this._gridColor.toHexString(),
                             visibility: "hidden"
                         });
                     }

[Submitted by Jon-Carlos Rivera on simile.mit.edu]

Original issue reported on code.google.com by stefano.mazzocchi@gmail.com on 25 Mar 2009 at 5:52

GoogleCodeExporter commented 8 years ago

Original comment by stefano.mazzocchi@gmail.com on 25 Mar 2009 at 6:42

GoogleCodeExporter commented 8 years ago

Original comment by stefano.mazzocchi@gmail.com on 25 Mar 2009 at 7:09