# BranchGraphColumn

Show branch graph.

# Constructor Properties

Property Description Default
start set the moving direction by setting the beggining point. 'top' or 'bottom' 'bottom'
cache set true when caching the calculation result of the branch structure. Please call clearCache(grid) when deleting the cahced 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'
<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