theiviaxx / MilkChart

Graphing library for MooTools
56 stars 6 forks source link

Row Names on Bar type #2

Closed theiviaxx closed 14 years ago

theiviaxx commented 14 years ago

When using long row names, there is potential for the text to overlap the graph. this is easy to do in a Bar graph.

http://img707.imageshack.us/img707/8522/indexnr.png

CasperPas commented 14 years ago

I did a little change to the code from line 483:

Old code:

        this.ctx.textAlign = "center"
        this.ctx.fillText(this.rowNames[rowNameID], rowOrigin.x-(colWidth/2),rowOrigin.y-(this.rowPadding/2));

New code:

        this.ctx.textAlign = "center";
        textWidth = Math.ceil(this.ctx.measureText(this.rowNames[rowNameID]).width);
        this.ctx.fillText(this.rowNames[rowNameID], rowOrigin.x-((colWidth+textWidth)/2),rowOrigin.y-(this.rowPadding/2));

That might fix that issue (I tested with the demo code)

PS: is it missing ";" at the code?

        this.ctx.textAlign = "center"
theiviaxx commented 14 years ago

this has been implemented

theiviaxx commented 14 years ago

Forge updated