# GC.Spread.Sheets.GanttSheet.TaskbarStyleRule

## Content

# Class: TaskbarStyleRule

[Sheets](../modules/GC.Spread.Sheets).[GanttSheet](../modules/GC.Spread.Sheets.GanttSheet).TaskbarStyleRule

## Table of contents

### Constructors

- [constructor](GC.Spread.Sheets.GanttSheet.TaskbarStyleRule#constructor)

### Properties

- [name](GC.Spread.Sheets.GanttSheet.TaskbarStyleRule#name)
- [style](GC.Spread.Sheets.GanttSheet.TaskbarStyleRule#style)

### Methods

- [getFromDate](GC.Spread.Sheets.GanttSheet.TaskbarStyleRule#getfromdate)
- [getToDate](GC.Spread.Sheets.GanttSheet.TaskbarStyleRule#gettodate)
- [match](GC.Spread.Sheets.GanttSheet.TaskbarStyleRule#match)

## Constructors

### <a id="constructor" name="constructor"></a> constructor

• **new TaskbarStyleRule**()

Creates a task bar style rule with the specified name.

**`classdesc`** Represents a task bar style rule for project. Could extend from this class and implement a customized rule.

**`example`**
```
 class MyProgressRule extends TaskbarStyleRule {
     constructor() {
         super("My Progress");
         this.style = {
             taskbarStyle: {
                 middleColor: "#3B87D4",
                 middleShape: "RectangleMiddle",
                 middlePattern: "solidFill",
             }
         };
     }
     match(task: Task): boolean {
         return task.complete > 0;
     }
     getFromDate(task: Task) {
         return task.startDisplayed;
     }
     getToDate(task: Task) {
         return task.completeThrough;
     }
 }
```

## Properties

### <a id="name" name="name"></a> name

• **name**: `string`

Gets the name of this rule.

___

### <a id="style" name="style"></a> style

• **style**: [`TaskStyle`](../modules/GC.Spread.Sheets.GanttSheet#taskstyle)

Gets or sets the style for all task bars this rule matched.

## Methods

### <a id="getfromdate" name="getfromdate"></a> getFromDate

▸ **getFromDate**(`task`): `Date`

Gets the date that indicates the start of the task bar for the specified task.
By default it returns task.startDisplayed. Override this method in your customized rule and returns the result.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `task` | [`Task`](GC.Spread.Sheets.GanttSheet.Task) | A matched task for this rule. |

#### Returns

`Date`

A date value indicates the start of the task bar for the specified task.

___

### <a id="gettodate" name="gettodate"></a> getToDate

▸ **getToDate**(`task`): `Date`

Gets the date that indicates the end of the task bar for the specified task.
By default it returns task.finishDisplayed. Override this method in your customized rule and returns the result.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `task` | [`Task`](GC.Spread.Sheets.GanttSheet.Task) | A matched task for this rule. |

#### Returns

`Date`

A date value indicates the end of the task bar for the specified task.

___

### <a id="match" name="match"></a> match

▸ **match**(`task`): `boolean`

Determines the task bar defined by this rule matches the specified task or not.
Override this method in your customized rule and returns the result.

**`abstract`**

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `task` | [`Task`](GC.Spread.Sheets.GanttSheet.Task) | The task to check. |

#### Returns

`boolean`

true if the task is matched and will show the task bar of this rule; otherwise false.
