famedoro
famedoro

Reputation: 1241

JavaFX 1.x to JavaFX2 Chart Logarithm

I've looking for an example for having Log scale, I've found something here:

http://blog.dooapp.com/javafx-chart-api-and-logarithmic-scale-tag-ja

and here:

https://forums.oracle.com/forums/thread.jspa?threadID=2420118&stqc=true

but it is written in JavaScript: is there anyone so kind to rewrite these 2 methods in JavaFX 2.x?

var logUpperBound: Number = bind Math.log10(upperBound);
var logLowerBound: Number = bind Math.log10(lowerBound);

override public function getDisplayPosition(arg0: Object): Number {
    def delta = logUpperBound - logLowerBound;
    def deltaV = Math.log10((arg0 as Number)) - logLowerBound;
    if (orientationVertical) {
        return (1 -((deltaV) / delta)) * height;
    } else {
        return ((deltaV) / delta) * width;
    }
}

override protected function updateTickMarks(): Void {
    if (tickMarks.size() == 0) {
        for (i in [0..Math.log10(upperBound)-1], j in [1..9]) {
            var v = j * Math.pow(10, i);
            insert CustomTickMark {
                customLabel: "{%6.0f v}"
                customPosition: getDisplayPosition(v)
                customValue: v
            } into tickMarks;
        }

    }
}

I can't use these methods since I do not know JavaScript.

Upvotes: 0

Views: 309

Answers (1)

kevins
kevins

Reputation: 46

You could find my article on how to do it here:

http://blog.dooapp.com

Kévin

Upvotes: 1

Related Questions