tick-label-factory (非ローカル オプションの定義)
public tick-label-factory:TickLabelFactory ={proc {axis:ChartAxis, tick:ChartTick, tick-rotation:Angle}:any {return {axis.generate-tick-label tick, tick-rotation}} }
パッケージ: CURL.GUI.CHARTS

ChartAxis の目盛りラベルを作成するために使用されるファクトリ プロシージャを定義するオプション。

説明

ChartAxis.generate-tick-label を呼び出して、既定の軸ラベルを作成し、結果を変更すると便利です。
このオプションは axis-label と似ており、プロシージャ内で同じタイプのほとんどを返すことができることに注意してください。ただし、tick-label-factory そのものは常に プロシージャです。
このオプションは、一般的に ChartAxis そのものについてではなく、LayeredChart のメンバについて設定されます。それは、軸が再生成される場合にも、オプション設定が残るようにするためです。この例については、次を参照してください。軸の生成および関連概念については、LayeredChart も参照してください。
パラメータについては、TickLabelFactory を参照してください。

注意事項

ラベルが生成されると、そのラベルの変換 (回転とスケール以外) が ChartLabelGroup によって設定されます。ラベルに対して文字列以外のものを返す場合は、そのオブジェクトの原点に注意する必要があります。原点は、目盛りが示す方向の axis-label-group-spacing で示されたオフセットの目盛りに位置付けられるように配置されます。生成する形状を位置付ける際には、その形状が正しく配置されるように注意する必要があります。
halign および valign をサポートするオブジェクト (TextShape など) の場合は、以下の設定を使用することをお勧めします。
軸位置 (ChartTick.axis-position を参照)推奨する halign (または horigin)推奨する valign (または vorigin)
AxisPosition.left"right""center"
AxisPosition.right"left""center"
AxisPosition.top"center""bottom"
AxisPosition.bottom"center""top"
(ChartAxis.get-tick-label-alignment は値を算出します。)
Shape の場合は、この表に示したガイドラインに従ってください。たとえば、左の軸に対して RectangleShape を生成する場合は、四角形の右端を (0m, 0m) 中心に位置付けるのが一般的です。
垂直軸の軸ラベルは回転されますが、目盛りラベルは回転されないので、上記の推奨事項は axis-label の場合とは異なります。


例: 目盛りラベル ファクトリの使用
{import * from CURL.GUI.CHARTS}
{import * from CHARTS-DOC,
    location = "../docstring-support/gui/charts-doc.scurl"
}

{let chart:LayeredChart =
    {LayeredChart
        width = 15cm,
        height = 7cm,
        bottom-axis-parent =
            {ShapeGroup
                || Override for just the bottom axis:
                tick-label-rotation = 0deg,
                tick-label-auto-stagger? = false,
                tick-label-factory =
                    {proc {axis:ChartAxis, tick:ChartTick, tick-rotation:Angle}:any
                        {if tick.value == null then
                            {return null}
                        }
                        let (halign:String, valign:String) =
                            {axis.get-tick-label-alignment tick-rotation}
                        let shape:TextShape =
                            {TextShape
                                || Put the origin at the left edge of the
                                || shape for rotation.
                                halign = halign,
                                valign = valign,
                                color = "black",
                                {format "%s", tick.value}
                            }
                        let bounds:GRect = {shape.get-own-bounds}
                        {bounds.grow 3pt}
                        {return
                            {RectangleShape
                                bounds,
                                color = "lightsteelblue",
                                border-color = "steelblue",
                                border-width = 1px,
                                rotation = tick-rotation,
                                shape
                            }
                        }
                        {return shape}
                    }
            },
        {LineLayer
            sample-records,
            "Age",
            "Points",
            x-axis-data = {ChartDataSeries sample-records, "Name"}
        }
    }
}

{AntialiasedFrame chart}

{text tick-label-rotation (on bottom axis only):}
{TextField
    value = "0deg",
    width = 3cm,
    {on ValueFinished at tf:TextField do
        set chart.bottom-axis-parent.tick-label-rotation =
            {evaluate tf.value} asa Angle
    }
}