LineLayer (クラス)
public LineLayer {inherits StackableChartLayer}
パッケージ: CURL.GUI.CHARTS

線を使用してデータ系列をプロットする ChartLayer の実装。

説明

既定では、LineLayer は、PathShapeLineLayer.y-axis-data の各メンバごとに生成します。生成された ShapeLineLayer.series-shapes で見つかります。
Shape の外観と動作はいくつかの方法でカスタマイズできます。最も簡単な方法はオプションを使用することです。他のグラフ コンポーネントの場合と同様、Shape は、それがある場所またはその上のどこにでも非ローカル オプション セットを使用して制御することができます。たとえば、stroke-thickness を設定して、PathShapes の厚さを変更できます。
また、LineLayer.shape-factory を使用すれば、Shape の作成プロセスをオーバーライドすることもできます。これは非常に用途の広い手法です。これを使用すれば、個々の Shape のオプション値を変更したり、ShapeTooltip を提供したり、まったく種類の異なる Shape を一緒に生成したりさえできます。
これは、ChartLayer の標準実装の 1 つです。他の標準実装の一覧、および LayeredChart システムの詳細については、LayeredChart を参照してください。

注意事項

グラフへのその他のオブジェクトの追加については、ChartLayer を参照してください。

この例では、LineLayer レベルでの非ローカル オプションの使用法を示すとともに、追加の Shape を作成するための LineLayer.shape-factory の高度な使用法をヒント付きで示しています。

{import * from CURL.GUI.CHARTS}
{import * from CHARTS-DOC,
    location = "../docstring-support/gui/charts-doc.scurl"
}

{let chart:LayeredChart =
    {LayeredChart
        width = 15cm,
        height = 6cm,
        {LineLayer
            sample-records,
            "Age",
            "Points",
            x-axis-data = {ChartDataSeries sample-records, "Name"},
            stroke-thickness = 3pt,
            shape-factory =
                {proc
                    {layer:LineLayer,
                     points:{FastArray-of PointRecordPair},
                     series-index:int
                    }:Shape
                    
                    let constant stock-shape:Shape =
                        {LineLayer.default-shape-factory
                            layer,
                            points,
                            series-index
                        }
                    let constant fill-pattern:FillPattern =
                        {layer.get-fill-pattern-for-data-series series-index}

                    {for point in points do
                        {stock-shape.add
                            {RectangleShape
                                {GRect 3pt, 3pt, 3pt, 3pt},
                                translation = point.point,
                                rotation = 45deg,
                                color = {darker-fill-pattern fill-pattern},
                                border-width = 1.5pt,
                                border-color = FillPattern.silver,
                                tooltip =
                                    {Tooltip
                                        style = TooltipStyle.immediate,
                                        {value
                                            def fname =
                                                layer.y-axis-data[series-index].field.name
                                            {format "%s: %s = %g",
                                                point.record["Name"],
                                                fname,
                                                point.record[fname]
                                            }
                                        }
                                    }
                            }
                        }
                    }
                    {return stock-shape}
                }
        }
    }
}

{AntialiasedFrame chart}

コンストラクタ
default:新規の LineLayer を作成します。
コンストラクタ public {LineLayer.default
x-axis-data:#ChartDataSeries = null,
stacking-mode:ChartStackingMode = ChartStackingMode.none,
shape-factory:LineLayer.ShapeFactory = LineLayer.default-shape-factory,
border-color:any = FillPattern.black,
...
}

プロパティ
series-shapes:この LineLayer のプロットを表す Shape を含む配列。
フィールド public constant LineLayer.series-shapes:{Array-of Shape} ={new {Array-of Shape}}
shape-factory:この LineLayer 内の各プロット Shape を生成するために使用されるファクトリ プロシージャ。
アクセサ public LineLayer.shape-factory:LineLayer.ShapeFactory
セッター public LineLayer.shape-factory:LineLayer.ShapeFactory
symbols-at-data-points?:オプションで、各データ ポイントにシンボルを表示します。
ローカル オプション public LineLayer.symbols-at-data-points?:bool =false
プロパティ 継承 StackableChartLayer: generate-y-axes?, stacking-mode
プロパティ 継承 ChartLayer: chart, color-associations, legend-enabled?, legend-entry-factory, style-element, x-axis-data, y-axis-data
プロパティ 継承 Shape: as-Shape, border-color, color, draw-operation, graphical-parent, option-parent, possibly-displayed?, selection-context, shape-parent, shape-selectable, stroke-thickness, transformation, visible?
プロパティ 継承 ShapeContainerBase: as-ShapeRoot, shape-children
プロパティ 継承 Visual: _style-element, clonable-class?, completely-clonable-children?, cursor, data-source, display-context, dragee, font-size, has-key-focus?, input-method-enabled?, input-method-keyboard-mode, name, options, style-class, style-manager, style-options, test-child?, test-description, test-name, test-parent?, test-type-name, test-visible?, tooltip, user-data, visual-parent
プロパティ 継承 DataBindingTarget: data-binding-context, data-bindings
プロパティ 継承 EventTarget: event-handlers
プロパティ 継承 OptionListInterface: option-register-proc, options-present-here, registered-option-keys

クラス変数と定数
ShapeFactory:LineLayer Shape 要素の生成に使用されるファクトリー プロシージャの Type。これは、オプション LineLayer.shape-factory の型です。
public constant LineLayer.ShapeFactory:ProcType ={proc-type {layer:LineLayer, points:{FastArray-of PointRecordPair}, series-index:int }:Shape }

クラス プロシージャ
default-shape-factory:LineLayer.shape-factory の既定値。
public {LineLayer.default-shape-factory
layer:LineLayer,
points:{FastArray-of PointRecordPair},
series-index:int
}:Shape

メソッド
get-data-series-from-shape:Shape に関連した ChartDataSeries を決定します (ある場合)。
public {LineLayer.get-data-series-from-shape
shape:Shape
}:#ChartDataSeries
set-data-series-visibility:ChartLayer.y-axis-data の個々のメンバの表示を制御します。
public {LineLayer.set-data-series-visibility
data-series-index:int,
visible?:bool
}:void
update-layout:この ChartLayer の内部レイアウトを更新します。
public {LineLayer.update-layout}:void
メソッド 継承 StackableChartLayer: append-data-series, compute-data-min-max, get-data-mapping, get-inverse-data-mapping
メソッド 継承 ChartLayer: append-color-association, create-legend-entries, detach, draw, get-data-series-visibility, get-fill-pattern-for-data-series, get-nearest-record-in-data, get-own-bounds, get-record-at-point, get-record-count, handle-observer-message, maybe-create-x-axis, maybe-create-y-axis-for-series, non-keyword-init-arg, note-color-associations-changed, note-y-axis-data-array-changed, remove-color-association, remove-data-series, self-contains-point?, self-intersects-polygon?
メソッド 継承 Shape: apply-rotation, apply-scale, apply-transformation, apply-translation, apply-translation-in-parent, constrain-own-layout-bounds, constrain-shape-layout-bounds, contains-point?, find-graphical-ancestor, fire-crossing-event, fire-in-child, get-display-context, get-down-orientation-in-shape-parent, get-graphical-root, get-gui-path, get-gui-path-to-child, get-local-device-pixel-size, get-origin-in-graphical-ancestor, get-origin-in-root, get-origin-in-shape-parent, get-origin-in-shape-root, get-own-bounds-in-shape-root, get-own-layout-bounds, get-right-orientation-in-shape-parent, get-shape-bounds, get-shape-bounds-in-shape-root, get-shape-layout-bounds, get-top-left-in-ancestor, get-transformation-to-shape-root, keyword-init-arg, option-change-notify, overdraw-for-selection, quantize-line-thickness, request-draw, request-draw-self, reset-transformation, set-rotation, set-scale, set-transformation, set-translation-in-parent, to-Graphic, transform-from-display-coordinates, transform-from-graphical-root-coordinates, transform-point-from-shape-root, transform-point-to-shape-root, transform-to-display-coordinates, transform-to-graphical-root-coordinates, transform-vector-from-shape-root, transform-vector-to-shape-root, transformation-changed, transformation-changing
メソッド 継承 Observer: observe, stop-observing
メソッド 継承 ShapeContainerBase: add, clear, clone-children, draw-shape-child, draw-shape-children, get-all-children-at-point, get-child-at-point, get-leaf-at-point, get-shape-root, note-attached, note-detaching, notify-option-children, on-drag-enter, on-pointer-enter, on-pointer-envelope-event, register-options, remove, set-shape-index, set-shape-index-after, set-shape-index-before, shape-container-fire-inferior-crossing-event, shape-container-handle-crossing, shape-container-pick-child, shape-container-pointer-enter-occurred, shape-container-pointer-leave-occurred
メソッド 継承 Visual: add-from-init-args, animate, change-cursor, clonable-appearance?, clone-appearance, clone-appearance-helper, find-test-children, get-focus-manager, get-layout-context, get-test-parent, get-test-property, get-text, get-view, maybe-fire-attach-event, maybe-fire-detach-event, note-caret-position, on-drag-leave, on-pointer-leave, pop-cursor, prepare-test-object, prepare-test-parent, push-cursor, quantize-width, refresh-style-options, release-key-focus, request-key-focus, scroll-to-include, test-record, test-run, xy-offset-to
メソッド 継承 GraphicOptions: any-to-Distance
メソッド 継承 GuiEventTarget: handle-delegate-event, handle-event, on-action, on-cancel-mode, on-command-changed, on-commit, on-composition-change-event, on-composition-result-event, on-context-menu-event, on-current-record-change-request, on-current-record-changed, on-destroy-notify, on-destroy-requested, on-drag-over, on-drag-pointer, on-drag-started, on-drop, on-end-composition-event, on-focus-event, on-focus-in, on-focus-out, on-gesture, on-gesture-begin, on-gesture-end, on-gesture-magnify, on-gesture-pan, on-gesture-rotate, on-gesture-swipe, on-gesture-tap, on-gesture-touch, on-grab-release, on-gui-event, on-input-method-event, on-inspection, on-key-event, on-key-press, on-pointer-button, on-pointer-crossing, on-pointer-event, on-pointer-motion, on-pointer-press, on-pointer-release, on-pointer-scroll, on-raw-key-event, on-raw-key-press, on-raw-key-release, on-reset, on-selectable-added, on-selectable-removed, on-selection-changed, on-selection-context-activated, on-selection-context-deactivated, on-selection-event, on-start-composition-event, on-start-event, on-stop-event, on-view-activate, on-view-deactivate, on-window-close, remove-event-handlers-for-event-class
メソッド 継承 DataBindingTarget: add-data-binding, get-data-binding, refresh-data-binding, remove-data-binding, unset-property, update-data-binding, validate-data-binding
メソッド 継承 EventTarget: accepts-event-class?, add-event-handler, event-handler-present?, remove-event-handler, verify-event
メソッド 継承 OptionListInterface: add-option, add-style-option, change-option-parent-notify, clone-options, get-option, get-option-by-name, local-add-notify, local-remove-notify, name-to-option-key, new-option-item, option-changed, option-lookup, option-lookup-here, option-propagate-notify, option-set?, propagate-option-change, remove-option, remove-style-option, remove-styles, set-option-by-name, set-style-option-by-name, unset-option-by-name, unset-style-option-by-name
メソッド 継承 BasicEventTarget: enqueue-event
メソッド 継承 InitRestArgParser: process-rest-args
メソッド 継承 Object: object-describe, object-describe-for-debugging, object-serialize



コンストラクタ詳細
default (コンストラクタ)
public {LineLayer.default
x-axis-data:#ChartDataSeries = null,
stacking-mode:ChartStackingMode = ChartStackingMode.none,
shape-factory:LineLayer.ShapeFactory = LineLayer.default-shape-factory,
border-color:any = FillPattern.black,
...
}

新規の LineLayer を作成します。

x-axis-data: ChartLayer.x-axis-data の初期値。この値は、指定されると、LayeredChart での自動 X 軸生成を変更するために使用されます。
stacking-mode: このグラフの初期 ChartStackingModeChartStackingMode.none 以外のスタッキング モードでは許可されるデータの型に制約が生じることに注意してください。詳細については、LineLayer.stacking-mode を参照してください。
shape-factory: LineLayer.shape-factory の初期値。このプロシージャは、プロットする Shape の作成を制御します。LineLayer.ShapeFactory も参照してください。
border-color: この ChartLayer での Shape.border-color オプションの初期値。
...: データ系列、オプション、および他の項目の初期化の値。詳細については、ChartLayer.default を参照してください。

例については、LineLayer を参照してください。



プロパティ詳細
series-shapes (フィールド)
public constant LineLayer.series-shapes:{Array-of Shape} ={new {Array-of Shape}}

この LineLayer のプロットを表す Shape を含む配列。

説明

この配列には、LineLayer.y-axis-data 内のChartDataSeries ごとに 1 つの要素が入ります。これらは、LineLayer.shape-factory によって返されたオブジェクトであり、Shape が生成される方法を変更するために使用できます。
この配列は、単なるインスペクション用で、変更はできません。要素の順序を変更したり、要素を追加または削除したりしないでください。また、その内容は、グラフのレイアウト処理が行われるたびに変更されます。そのため、レイアウト処理が行われて初めてその内容が有効になります。EventHandlerChartLayoutChanged に対して使用し、これらの値が変更された時点で通知を受け取ることができます。
この配列内の Shape オブジェクトの変更は許可されます。ただし、一般的に LineLayer.shape-factory にファクトリー プロシージャを提供して同じことを行うほうがはるかに容易です。レイアウトが変更された時点や形状の更新が必要となる時点を考慮する必要がないので、この手法をお勧めします。


shape-factory (アクセサ)
アクセサ public LineLayer.shape-factory:LineLayer.ShapeFactory
セッター public LineLayer.shape-factory:LineLayer.ShapeFactory

この LineLayer 内の各プロット Shape を生成するために使用されるファクトリ プロシージャ。

説明

独自のプロシージャを提供して、プロットの実行方法を変更できます。このプロシージャは、データ系列ごとに 1 回呼び出されます。(これは、他のほとんどの形状ファクトリーとは対照的です。これらの場合、通常、データ ポイントごとに 1 回呼び出されます。)引数の 1 つは、系列の各データ ポイントの項目を含む配列です。プロシージャの引数については、LineLayer.ShapeFactory を参照してください。
形状ファクトリを変更することは、オプション設定が十分でない場合に、プロットの外観を変更するためには、望ましいメソッドです。たとえば、LineLayer.series-shapes の内容を変更することは望ましい方法です。形状が再生成される場合は常にファクトリーが必ず呼び出されることが 1 つの理由です。一方、このようにしないと、独自にそれを追跡する必要があります。
既定の形状ファクトリーは LineLayer.default-shape-factory です。一般的な方法では、ファクトリー プロシージャを定義して、既定のファクトリーを呼び出してから、結果を変更します。たとえば、Visual.tooltip などのオプションを変更できます。ただし、この手法を用いて系列の色を変更することはお勧めできません。グラフの凡例ではこの変更が表示されないためです。代わりに、Chart.color-palette または ChartLayer.color-associations を使用してください。


{import * from CURL.GUI.CHARTS}
{import * from CHARTS-DOC,
    location = "../docstring-support/gui/charts-doc.scurl"
}

{let chart:LayeredChart =
    {LayeredChart
        width = 15cm,
        height = 6cm,
        legend-location = "right",
        {LineLayer
            sample-records,
            "Age",
            "Points",
            x-axis-data = {ChartDataSeries sample-records, "Name"},
            shape-factory =
                {proc
                    {layer:LineLayer,
                     points:{FastArray-of PointRecordPair},
                     series-index:int
                    }:Shape
                    let constant fill-pattern:FillPattern =
                        {layer.get-fill-pattern-for-data-series series-index}
                    let constant group:ShapeGroup =
                        {ShapeGroup
                            arrow-body-width = 2px,
                            arrow-head-width = 8px,
                            arrow-head-length = 12px,
                            arrow-head-style = ArrowStyle.solid,
                            arrow-tail-style = ArrowStyle.none,
                            font-size = 8pt
                        }
                    {for point key idx in points do
                        {if idx < points.size - 1 then
                            {group.add
                                {ArrowShape
                                    point.point,
                                    points[idx + 1].point,
                                    color = fill-pattern,
                                    {EllipseShape
                                        {GRect 5pt, 5pt, 5pt, 5pt},
                                        translation = point.point,
                                        color = {lighter-fill-pattern fill-pattern},
                                        {TextShape
                                            {value
                                                def fname =
                                                    layer.y-axis-data[series-index].field.name
                                                {format "%.2g", point.record[fname]}
                                            },
                                            color = FillPattern.black,
                                            valign = "center"
                                        }
                                    }
                                }
                            }
                        }
                    }
                    {return group}
                }
        }
    }
}

{AntialiasedFrame chart}


symbols-at-data-points? (ローカル オプション)
public LineLayer.symbols-at-data-points?:bool =false

オプションで、各データ ポイントにシンボルを表示します。

説明

このプロパティが true の場合は、シンボルが各データ ポイントに作成、表示されます。この結果は ScatterLayerLineLayer の結合結果と事実上同じですが、より便利です。


例: LineLayer.symbols-at-data-points? の使用
{import * from CURL.GUI.CHARTS}
{import * from CHARTS-DOC,
    location = "../docstring-support/gui/charts-doc.scurl"
}

{let chart:LayeredChart =
    {LayeredChart
        width = 12cm,
        height = 8cm,
        {LineLayer
            sample-records,
            "Age",
            "Points",
            x-axis-data = {ChartDataSeries sample-records, "Name"},
            symbols-at-data-points? = true
        }
    }
}

{value chart}

{CheckButton
    label = "symbols-at-data-points?",
    value = true,
    {on ValueFinished at cb:CheckButton do
        let layer:LineLayer = chart.layers[0] asa LineLayer
        set layer.symbols-at-data-points? = cb.value
    }
}



クラス変数と定数の詳細
ShapeFactory (クラス定数)
public constant LineLayer.ShapeFactory:ProcType ={proc-type {layer:LineLayer, points:{FastArray-of PointRecordPair}, series-index:int }:Shape }

LineLayer Shape 要素の生成に使用されるファクトリー プロシージャの Type。これは、オプション LineLayer.shape-factory の型です。

layer: Shape 生成が実行される LineLayer
points: 表示する各ポイントを記述する PointRecordPair オブジェクトの配列。各要素は、位置、レコード、およびレコード インデックスを含みます。これらは X 軸に沿って昇順に並べ替えられます (これは、LayeredChart.flipped? の値に応じて、X 座標の増大または Y 座標の減少に対応します)。
series-index: layer.y-axis-data へのインデックスによって表わされたプロットされる ChartDataSeries

戻り値

LineLayer に追加される Shape (通常は PathShape)。具体的には、この値は LineLayer.series-shapes のメンバになります。

説明

このタイプの詳細およびその使用例については、LineLayer.shape-factory を参照してください。



クラス プロシージャ詳細
default-shape-factory (クラスプロシージャ)
public {LineLayer.default-shape-factory
layer:LineLayer,
points:{FastArray-of PointRecordPair},
series-index:int
}:Shape

LineLayer.shape-factory の既定値。

layer: Shape 生成が実行される LineLayer
points: 表示する各ポイントを記述する PointRecordPair オブジェクトの配列。各要素は、位置、レコード、およびレコード インデックスを含みます。これらは X 軸に沿って昇順に並べ替えられます (これは、LayeredChart.flipped? の値に応じて、X 座標の増大または Y 座標の減少に対応します)。
series-index: layer.y-axis-data へのインデックスによって表わされたプロットされる ChartDataSeries

戻り値

points を表す PathShape

説明

このプロシージャは、points から Path を作成します。次に、LineLayer.get-fill-pattern-for-data-series を使用して形状の色を提供し、この Path から PathShape を作成します。
このプロシージャは、形状を最初から作成するのではなく、既存の形状を変更したい場合に限り、独自の形状ファクトリー プロシージャから呼び出すのが一般的です。この例については、LineLayer を参照してください。



メソッド詳細
get-data-series-from-shape (メソッド)
public {LineLayer.get-data-series-from-shape
shape:Shape
}:#ChartDataSeries

Shape に関連した ChartDataSeries を決定します (ある場合)。

shape: 検索する Shape

説明

ChartLayer.y-axis-data の要素を表すために、Shape がこの ChartLayer によって生成された場合は、このメソッドでその要素が判別され、該当するデータ系列が返されます。その他の場合は、null を返します。
ChartLayer をサブクラス化しようとする場合は、このメソッドを実装する必要があります。これは通常、生成された Shape のセットを追跡し、渡される Shape が既知の Shape のメンバであるかどうかを決定することにより実行されます。


set-data-series-visibility (メソッド)
public {LineLayer.set-data-series-visibility
data-series-index:int,
visible?:bool
}:void

ChartLayer.y-axis-data の個々のメンバの表示を制御します。

data-series-index: 変更するデータ系列で、ChartLayer.y-axis-data へのインデックスとして表わされます。
visible?: data-series-index によって参照されるデータ系列が表示されない場合は、false です。

説明

これは、凡例メンバや既存の系列の色を変更せずにデータの可視性を制御する場合に役立ちます。この実装は ChartLayer サブクラスによって実行されます。標準グラフ レイヤは Shape.visible? を使用して可視性を制御します。独自のサブクラス内でこのメソッドを実装する場合、必ずスーパークラスの実装を呼び出す必要があります。


例: ChartLayer.set-data-series-visibility の使用
{import * from CURL.GUI.CHARTS}
{import * from CHARTS-DOC,
    location = "../docstring-support/gui/charts-doc.scurl"
}

{let chart:LayeredChart =
    {LayeredChart
        width = 12cm,
        height = 6cm,
        {LineLayer
            sample-records,
            "Age",
            "Points",
            "Height",
            x-axis-data = {ChartDataSeries sample-records, "Name"},
            symbols-at-data-points? = true
        }
    }
}

{value chart}

{CheckButton
    label = "Show Age?",
    value = true,
    {on ValueFinished at cb:CheckButton do
        let layer:ChartLayer = chart.layers[0]
        {layer.set-data-series-visibility 0, cb.value}
    }
}

{CheckButton
    label = "Show Points?",
    value = true,
    {on ValueFinished at cb:CheckButton do
        let layer:ChartLayer = chart.layers[0]
        {layer.set-data-series-visibility 1, cb.value}
    }
}

{CheckButton
    label = "Show Height?",
    value = true,
    {on ValueFinished at cb:CheckButton do
        let layer:ChartLayer = chart.layers[0]
        {layer.set-data-series-visibility 2, cb.value}
    }
}


update-layout (メソッド)
public {LineLayer.update-layout}:void

この ChartLayer の内部レイアウトを更新します。

説明

これは LayeredChart.update-layout から呼び出されます。ChartLayer の実装では、このメソッドを使用して、プロット形状が再生成され、レイヤに追加されます。ChartLayer をサブクラス化しようとする場合、データを表すためにさまざまな Shape を作成し、ChartLayer.add を使用してレイヤに追加するためには、このメソッドをオーバーライドする必要があります。