Movatterモバイル変換


[0]ホーム

URL:


  • Overview
  • View Specification
  • Data / Datasets
  • Transform
  • Mark
  • Encoding
  • Projection
  • View Composition
  • Parameter
  • Config

  • Property Types
  • Tooltip
  • Invalid Data
  • Line

    Edit this page
    {  "data": ... ,  "mark": "line",  "encoding": ... ,  ...}

    Theline mark represents the data points stored in a field with a line connecting all of these points. Line marks are commonly used to depict trajectories or change over time. Unlike most other marks that represent one data element per mark, one line mark represents multiple data element as a single line, akin toarea andtrail.

    Note: For line segments that connect (x,y) positions to (x2,y2) positions, please userule marks. For continuous lines with varying size, please usetrail marks.

    Documentation Overview

    Line Mark Properties

    // Single View Specification{  ...  "mark": {    "type": "line",    ...  },  "encoding": ... ,  ...}

    An line mark definition can contain anystandard mark properties and the following line interpolation and point overlay properties:

    PropertyTypeDescription
    orientString

    The orientation of a non-stacked bar, tick, area, and line charts. The value is either horizontal (default) or vertical.

    • For bar, rule and tick, this determines whether the size of the bar and tick should be applied to x or y dimension.
    • For area, this property determines the orient property of the Vega output.
    • For line and trail marks, this property determines the sort order of the points in the line ifconfig.sortLineBy is not specified. For stacked charts, this is always determined by the orientation of the stack; therefore explicitly specified value will be ignored.
    interpolateString |ExprRef

    The line interpolation method to use for line and area marks. One of the following:

    • "linear": piecewise linear segments, as in a polyline.
    • "linear-closed": close the linear segments to form a polygon.
    • "step": alternate between horizontal and vertical segments, as in a step function.
    • "step-before": alternate between vertical and horizontal segments, as in a step function.
    • "step-after": alternate between horizontal and vertical segments, as in a step function.
    • "basis": a B-spline, with control point duplication on the ends.
    • "basis-open": an open B-spline; may not intersect the start or end.
    • "basis-closed": a closed B-spline, as in a loop.
    • "cardinal": a Cardinal spline, with control point duplication on the ends.
    • "cardinal-open": an open Cardinal spline; may not intersect the start or end, but will intersect other control points.
    • "cardinal-closed": a closed Cardinal spline, as in a loop.
    • "bundle": equivalent to basis, except the tension parameter is used to straighten the spline.
    • "monotone": cubic interpolation that preserves monotonicity in y.
    tensionNumber |ExprRef

    Depending on the interpolation type, sets the tension parameter (for line and area marks).

    pointBoolean | Object | String

    A flag for overlaying points on top of line or area marks, or an object defining the properties of the overlayed points.

    • If this property is"transparent", transparent points will be used (for enhancing tooltips and selections).

    • If this property is an empty object ({}) ortrue, filled points with default properties will be used.

    • If this property isfalse, no points would be automatically added to line or area marks.

    Default value:false.

    Examples

    Line Chart

    Usingline with one temporal or ordinal field (typically onx) and another quantitative field (typically ony) produces a simple line chart with a single line.

    We can add create multiple lines by grouping along different attributes, such ascolor ordetail.

    Multi-series Colored Line Chart

    Adding a field to amark property channel such ascolor groups data points into different series, producing a multi-series colored line chart.

    We can use text marks andargmax to add labels to each line instead of using legends. Note that here we hide one of the line to avoid collision.

    We can further applyselection to highlight a certain line on hover.

    Multi-series Line Chart with Varying Dashes

    Adding a field tostrokeDash also produces a multi-series line chart.

    We can also use line grouping to create a line chart that has multiple parts with varying styles.

    Multi-series Line Chart with the Detail Channel

    To group lines by a field without mapping the field to any visual properties, we can map the field to thedetail channel to create a multi-series line chart with the same color.

    The same method can be used to group lines for a ranged dot plot.

    Line Chart with Point Markers

    By setting thepoint property of the mark definition totrue or an object defining a property of the overlaying point marks, we can overlay point markers on top of line.

    This is equivalent to adding another layer of filled point marks.

    Note that the overlay point marks haveopacity = 1 by default (instead of semi-transparent like normal point marks).

    Here we create stroked points by setting their\"filled\" tofalse and theirfill to\"white\".

    Line Chart with Invalid Values

    By default, data points with invalid x- or y-values (null orNaN) will cause break in the lines.

    Note that individual points without connecting points will still be invisible by default.

    To show individual points without connecting points, you may setstrokeCap to"square":

    or overlay it with marker points:

    Connected Scatter Plot (Line Chart with Custom Path)

    As shown in previous example, the line’s path (order of points in the line) is determined by data values on the temporal/ordinal field by default. However, a field can be mapped to theorder channel for determining a custom path.

    For example, to show a pattern of data change over time between gasoline price and average miles driven per capita we useorder channel to sort the points in the line by time field (year). In this example, we also use thepoint property to overlay point marks over the line marks to highlight each data point.

    Line interpolation

    Theinterpolate property of amark definition can be used to change line interpolation method. For example, we can setinterpolate to"monotone".

    We can also setinterpolate to"step-after" to create a step-chart.

    For the list of all supportedinterpolate properties, please see theline mark properties section.

    Geo Line

    By mapping geographic coordinate data tolongitude andlatitude channels of a correspondingprojection, we can draw lines through geographic points.

    Line Config

    // Top-level View Specification{  ...  "config": {    "line": ...,    ...  }}

    Theline property of the top-levelconfig object sets the default properties for all line marks. Ifmark property encoding channels are specified for marks, these config values will be overridden.

    The line config can contain anyline mark properties (excepttype,style, andclip).


[8]ページ先頭

©2009-2025 Movatter.jp