# BranchGraphColumn

Show branch graph.

# Constructor Properties

Property Description Default
start Set the moving direction by setting the beginning point. 'top' or 'bottom' 'bottom'
cache Set true when caching the calculation result of the branch structure. Please call clearCache(grid) when deleting the cached data. false

# Style Properties

Property Description Default
branchColors Set the function which returns the color of branch you want to use. arguments: (branch name, index) the function which returns following colors in turn. '#979797','#008fb5','#f1c109'
margin Set the margin of side. 4
circleSize Set the size of point which express commit. 16
branchLineWidth Set the width of branch lines. 4
mergeStyle Set the way to express the merge line. 'bezier' or 'straight' 'bezier'

# Data Format

The value provided from each record through the field must be an object or an array of it in the following format.

# Branch Command

This is the command to create a new branch.
It is an object with the following properties:

Property Description
command (Required) Sets "branch", which indicates what command the object is directing.
branch Set the value of the branch name to operate on.
branch.to (Required) Set the name of the new branch to be created. Set branch to a string has the same effect.
branch.from Set the branch name to be branched from.

# Commit Command

This is the command to commit a branch.
It is an object with the following properties:

Property Description
command (Required) Sets "commit", which indicates what command the object is directing.
branch (Required) Set the value of the branch name to operate on.

# Merge Command

This is the command to merge a branch into a branch.
It is an object with the following properties:

Property Description
command (Required) Sets "merge", which indicates what command the object is directing.
branch (Required) Set the value of the branch name to operate on.
branch.to (Required) Sets the name of the branch that will be merged.
branch.from (Required) Sets the name of the branch you want to merge from.

# Tag Command

This is the command to create a tag.
It is an object with the following properties:

Property Description
command (Required) Sets "tag", which indicates what command the object is directing.
branch (Required) Set the value of the branch name to operate on.
tag (Required) Set the name of the new tag to be created.

# Instance Methods

# clearCache(grid)

Clear the cache.

Parameter Description
grid It should be given an instance of a grid.

# Example

<div class="sample1 demo-grid large"></div>
1
const grid = new cheetahGrid.ListGrid({
  parentElement: document.querySelector(".sample1"),
  header: [
    {
      field: (rec) => rec,
      caption: "BranchGraph",
      width: 200,
      columnType: new cheetahGrid.columns.type.BranchGraphColumn({
        start: "top", // Specify the start and indicate the direction to proceed. 'top' or 'bottom'. default 'bottom'
        cache: false, // cache enable. default false
      }),
    },
    {
      field(rec) {
        return `${JSON.stringify(rec)},`;
      },
      caption: "command",
      width: 1000,
    },
  ],
  frozenColCount: 1,
});
grid.records = [
  [
    // new branch 'mastar'
    {
      command: "branch",
      branch: "mastar",
    },
    // and commit 'mastar' branch
    {
      command: "commit",
      branch: "mastar",
    },
  ],
  [
    // commit 'mastar' branch
    {
      command: "commit",
      branch: "mastar",
    },
  ],
  [
    // new branch 'develop'. from 'mastar'
    {
      command: "branch",
      branch: {
        from: "mastar",
        to: "develop",
      },
    },
  ],
  [
    // commit 'develop' branch
    {
      command: "commit",
      branch: "develop",
    },
  ],
  [
    // merge 'develop' branch into 'master' branch
    {
      command: "merge",
      branch: {
        from: "develop",
        to: "mastar",
      },
    },
    // and tag with v.0.0.1
    {
      command: "tag",
      branch: "mastar",
      tag: "v1.0.0",
    },
  ],
  [
    null, // not doing
  ],
  //-------------------------
  [
    {
      command: "branch",
      branch: {
        from: "develop",
        to: "develop2",
      },
    },
    {
      command: "commit",
      branch: "develop2",
    },
  ],
  [
    {
      command: "branch",
      branch: {
        from: "develop",
        to: "develop3",
      },
    },
    {
      command: "commit",
      branch: "develop3",
    },
    {
      command: "merge",
      branch: {
        from: "develop2",
        to: "mastar",
      },
    },
  ],
  [
    {
      command: "commit",
      branch: "develop2",
    },
  ],
  [
    {
      command: "branch",
      branch: {
        from: "develop2",
        to: "develop4",
      },
    },
    {
      command: "commit",
      branch: "develop4",
    },
    {
      command: "branch",
      branch: {
        from: "develop2",
        to: "develop5",
      },
    },
    {
      command: "commit",
      branch: "develop5",
    },
  ],
  [
    {
      command: "commit",
      branch: "develop2",
    },
  ],
  [
    {
      command: "tag",
      branch: "mastar",
      tag: "v1.1.0",
    },
    {
      command: "commit",
      branch: "mastar",
    },
    {
      command: "commit",
      branch: "develop4",
    },
  ],
  {
    command: "commit",
    branch: "develop3",
  },
];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
Last Updated: 10/23/2024, 6:31:33 AM