Segments and Arrows


Here, we discuss segments and arrows, two connected types of graph objects that differ from lines in a few important ways.

Segments

Let’s start with a basic segment, shown below:

layout: OneGraph: graph: objects: - Segment: a: [2,2] b: [8,7] label: text: x location: 0.8

A segment is defined by a point a (the beginning of the segment) and point b (the end of the segment). Of note, it can also be labelled with text that shows up at a location specific by its length along the segment. In other words, in the example above. the 0.8 for location means that the text will show up 8/10ths of the way along the segment. When we add draggability to segments, this is useful because the placement of the text will adjust as the segment changes.

As with other graph objects, you can customize your segments in numerous ways:

layout: OneGraph: graph: objects: - Segment: a: [2,8] b: [9,1] color: grey strokeWidth: 4 lineStyle: dotted label: text: "\\text{This is a segment.}" location: 0.8

Arrows

Arrows are similar to segments, but include one or two pointers on the ends, as shown below:

layout: OneGraph: graph: objects: - Arrow: begin: [3,5] end: [5,7] color: blue

Notice that, unlike segments, arrows use begin and end as their coordinate attributes. Now let’s look at a more customized arrow:

layout: OneGraph: graph: objects: - Arrow: begin: [3,5] end: [5,7] color: blue trim: 0.1 double: true - Point: coordinates: [5,7]

A few things to note about the more complex arrow:

KGJS
KineticGraphs.org
Getting Started

About the Project

Authoring Sandbox

Graphs & Layouts

Layouts

Sidebars

Graphs

Trees

3D Graphs

Graph Objects

Styling Graph Objects

Points

Lines

Curves

Contours

Shapes and Areas

Segments and Arrows

Angles and Angle Markers

User Interactions

Parameters

Calculations

Dragging

Economics

Econ Schema

Supply and Demand

Consumer Optimization

Exchange