Class: ScaleModel

core.ScaleModel

Class representing a model for generating a scale. This model computes the position of tick lines between two points. The precision is determined automatically.

The model items are dictionary objects of the form { position, value } with position being a position between 0.0 and 1.0 and value being a value between begin and end.

Example of a simple scale display using a core.Repeater:

Box {
    id: scale

    fill: true

    ScaleModel {
        id: scaleModel

        begin: 0.0
        end: 60.0
        maxTicks: 50
    }

    Repeater {
        model: scaleModel

        delegate: template Box {
            position: "free"
            y: modelData.value.position * scale.bboxHeight
            width: 30
            height: 1
            color: "black"
        }
    }
}

new core.ScaleModel ()

Properties:
Name Type Description
begin number

(default: 0) The beginning point of the scale. This value may be greater than end for flipping the direction.

end number

(default: 100) The ending point of the scale. This value may be less than begin for flipping the direction.

maxTicks number

(default: 10) The maximum amount of tick lines. If this maximum would be exceeded, the precision is decreased instead.

precision number

[readonly] The current precision, i.e. the number of digits required after the decimal point for representing the tick values.

Extends

Methods

valueToPosition (v)number

Returns the position of the given value on the scale. The position is a value between 0.0 and 1.0.

Name Type Description
v number

The value.

Returns:
Type Description
number The position of the value.