new Bars(oChart)
The Bars object holds a collection of Bar objects. The Bar objects define the look and feel for bars in the chart's area. The Chart.Bars method gets the control's bars. The Chart.Bar method gets the bar giving its index, name or reference. The Bars type defines all predefined bars within the control, and allows adding new bars to the control. The Add, Remove and Clear methods allow managing the bars within the control. The AddBar method adds a new item-bar to a specific item, while Bars.Add method adds a new type of bar.
Parameters:
| Name | Type | Description |
|---|---|---|
oChart |
Chart | Specifies the control's chart as an object of Chart type. |
Members
(readonly) Count :number
The Count property gets the count of bars(types of bars) within the collection. The Add, Remove, Clear methods may change the count of bars within the collection. The Count property is read-only and is equivalent to the GetCount() method. The Bars.Item method gets the bar giving its index, name, shortcut or reference, as an object of Bar type. The Item and Count can be used to enumerate all type of bars.
Type:
- number
Example
The following statements are equivalents:
oGantt.Chart.Bars.GetCount(), count of bars(types of bars) within the collection
oGantt.Chart.Bars.Count, count of bars(types of bars) within the collection
where oGantt is an object of Gantt type
Count
Methods
Add(oBarOptions) → {Bar}
The Add() method adds a new type of bar to the control, and returns the reference to the newly created bar, as an object of Bar type. The name of the bar-type to add/request can be specified as a string expression, or as a field of an object of BarOptions type. The Add() method returns the reference to the newly created bar, as an object of Bar type. If a bar with the same name already exists, the Add() method returns the reference to the existing bar without creating a new one. If the name of the bar to add includes the '%' character, it defines a bar of percent-type ("A%B"). A bar of percent-type displays and handles inner progress-bar, according with the bar's "percent" option. The Remove method removes a bar from the collection. The Clear method removes all bars of the control. The ClearBars() method clears all bars of the item. The Copy() method copies a Bar object and returns a reference to the newly created object, as an object of Bar type.
Parameters:
| Name | Type | Description |
|---|---|---|
oBarOptions |
object | Indicates the name of the bar-type to add/request (as a string), or an object of BarOptions type, that defines the options of the bar-type to add.
If the name(parameter or option) includes the '%' character, it defines a bar of percent-type ("A%B").
A bar of percent-type displays and handles inner progress-bar, according with the bar's "percent" option.
The A of "A%B" format can be:By default, the control defines the following bar-names/types:
|
Returns:
Returns an object of Bar type being requested/created.
- Type
- Bar
Example
oGantt.Chart.Bars.Add({name: "R", shape: "red"}), creates a new type of bar called "R" that will be shown as solid-red
oGantt.Chart.Bars.Add("Task%Progress"), defines a "Task" bar of percent-type, so it displays the bar's "percent" value using the "Progress" shape
oGantt.Chart.Bars.Add("Summary%Task"), defines a "Summary" bar of percent-type, so it displays the bar's "percent" value using another "Task" shape
oGantt.Chart.Bars.Add("Task%red"), defines a "Task" bar of percent-type, so it displays the bar's "percent" value using the "red" color
oGantt.Chart.Bars.Add("Task%Button"), defines a "Task" bar of percent-type, so it displays the bar's "percent" value using the "Button" already-defined shape
oGantt.Chart.Bars.Add('Summary%{"fillColor": "rgba(0,0,0,0.5)", "client": "[,y+2*height/3+3,,height/3]", "primitive": "round"}'), defines a "Summary" bar of percent-type, so it displays the bar's "percent" value using a predefined shape
where oGantt is a object of Gantt type
Add
Clear()
The Clear() method removes all bars of the control. The Remove(name) method does not remove item-bars that use the removed bar-type. Instead, those item-bars will no longer have a type-bar associated with them. If an item-bar does not have a type-bar associated with it, it will be drawn using the control's unknown-shape, as defined by Chart.unkS() method. The ClearBars() method clears all bars of the item.
Example
oGantt.Chart.Bars.Clear(), removes all bars of the control
Clear
Copy(name, newName) → {Bar}
The Copy() method copies a Bar object and returns a reference to the newly created object, as an object of Bar type. The Add method adds a new type of bar to the control, and returns the reference to the newly created bar, as an object of Bar type. The name of the bar-type to add/request can be specified as a string expression, or as a field of an object of BarOptions type. The Add() method returns the reference to the newly created bar, as an object of Bar type. If a bar with the same name already exists, the Add() method returns the reference to the existing bar without creating a new one. If the name of the bar to add includes the '%' character, it defines a bar of percent-type ("A%B"). A bar of percent-type displays and handles inner progress-bar, according with the bar's "percent" option. The Remove method removes a bar from the collection. The Clear method removes all bars of the control. The ClearBars() method clears all bars of the item.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Specifies the name/shortcut name of the bar to be copied. |
newName |
string | Indicates the name of the bar to be created as a copy. |
Returns:
Returns an object of Bar type that holds the newly created object
- Type
- Bar
Example
oGantt.Chart.Bars.Copy("Task", "R"), creates a new type of bar called "R" as a copy of "Task" bar, so the "R" bar will be shown similar to "Task" bar
Copy
Item(name, includeShortcutopt) → {Bar}
The Item() method gets the bar giving its index, name, shortcut or reference, as an object of Bar type. The Count property gets the count of bars(types of bars) within the collection. The Item and Count can be used to enumerate all type of bars. The Item(name) method is equivalent with the Chart.Bar(name)method. By default, the control defines the following bar-names/types:
- "Task"
- "Split"
- "Progress"
- "Milestone"
- "Summary"
- "Project Summary"
- "Deadline"
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
any | The name parameter could be any of the following:
|
|
includeShortcut |
boolean |
<optional> |
Specifies whether the bar is searched for its shortcut as well (defaults to false). |
Returns:
Returns null(the bar is not found), or an object of Bar type, if the bars collection contains the giving name.
- Type
- Bar
Example
The following statements are equivalents:
oGantt.Bar("Task") {Bar}
oGantt.Chart.Bar("Task") {Bar}
oGantt.Chart.Bars.Item("Task") {Bar}
and returns the "Task" bar
where oGantt is an object of Gantt type
Item
Remove(name)
The Remove() method removes a bar from the collection. The Remove(name) method does not remove item-bars that use the removed bar-type. Instead, those item-bars will no longer have a type-bar associated with them. If an item-bar does not have a type-bar associated with it, it will be drawn using the control's unknown-shape, as defined by Chart.unkS() method. The Clear method removes all bars of the control. The ClearBars() method clears all bars of the item.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
any | The name parameter could be any of the following:
|
Example
The following statements are equivalents:
oGantt.Chart.Bars.Remove("Task"), removes the "Task" bar from the control
oGantt.Chart.Bars.Remove(0), removes the first bar from the control
oGantt.Chart.Bars.Remove(oGantt.Chart.Bar("Task")), removes the "Task" bar from the control
where oGantt is an object of Gantt type
Remove
RemoveRange(range)
The RemoveRange() method removes multiple-bars at once. The range parameter could be a bar, an array of [{Bar}] type, or exontrol.Arr. The RemoveRange(name) method does not remove item-bars that use the removed bar-type. Instead, those item-bars will no longer have a type-bar associated with them. If an item-bar does not have a type-bar associated with it, it will be drawn using the control's unknown-shape, as defined by Chart.unkS() method. The Clear method removes all bars of the control. The ClearBars() method clears all bars of the item.
Parameters:
| Name | Type | Description |
|---|---|---|
range |
any | Indicates a bar, an array of [{Bar}] type, or exontrol.Arr. |
Example
oGantt.Chart.Bars.RemoveRange([oGantt.Chart.Bar("Task"), oGantt.Chart.Bar("Progress")]), removes the "Task" and "Progress" bars from the control
RemoveRange