# Predictive Line

A forecasting or predictive line chart consists of a basic trend line for all data up until the current date/time, along with a forecast line showing predicted changes beyond the current date/time.

## The Method To Use <a href="#the-method-to-use.1" id="the-method-to-use.1"></a>

The method is `s.plt.predictive_line()`.

It must contain the following input variables:

```python
order: int
x: str
data: Union[str, DataFrame, List[Dict]]
```

Accepts the following input variables as optional:

```python
y: Optional[Union[List[str], str]]
min_value_mark: Optional[str] 
max_value_mark: Optional[str]
color_mark: str
data: Union[List[str], DataFrame, List[Dict]]
x_axis_name: Optional[str] 
y_axis_name: Optional[str]
title: Optional[str] 
rows_size: Optional[int] 
cols_size: Optional[int]
padding: Optional[List[int]] 
show_values: Optional[List[str]]
option_modifications: Optional[Dict]
variant: Optional[str]
```

## Examples <a href="#examples.1" id="examples.1"></a>

### 1. Default Configuration <a href="#id-1-default-configuration" id="id-1-default-configuration"></a>

```python
data = [
    {'date': dt.date(2021, 1, 1), 'x': 4, 'y': 5},
    {'date': dt.date(2021, 1, 2), 'x': 7, 'y': 6},
    {'date': dt.date(2021, 1, 3), 'x': 4, 'y': 7},
    {'date': dt.date(2021, 1, 4), 'x': 9, 'y': 8},
    {'date': dt.date(2021, 1, 5), 'x': 3, 'y': 9},
]

s.plt.predictive_line(
    data=data, x='date', order=0,
    min_value_mark=3, max_value_mark=4,
    rows_size=2, cols_size=12,
)
```

![Predictive line chart with default configuration](https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2F0rgbTEQMHFClDEPAi3q8%2FLine%20Predictive.png?alt=media\&token=dbe4a4ee-fc55-482e-a40b-662ceeed18a4)

### 2. Customization And Context <a href="#id-2.-title-axes-names-legend" id="id-2.-title-axes-names-legend"></a>

It is possible to personalize the **title** of the chart, **name** of each axis, the **legend, size** and add **padding.** One example could be obtained using:

```python
data = [
    {'date': dt.date(2021, 1, 1), 'gas': 4, 'oil': 5},
    {'date': dt.date(2021, 1, 2), 'gas': 7, 'oil': 6},
    {'date': dt.date(2021, 1, 3), 'gas': 4, 'oil': 7},
    {'date': dt.date(2021, 1, 4), 'gas': 9, 'oil': 5},
    {'date': dt.date(2021, 1, 5), 'gas': 3, 'oil': 9},
    {'date': dt.date(2021, 1, 6), 'gas': 6, 'oil': 5},
    {'date': dt.date(2021, 1, 7), 'gas': 8, 'oil': 6},
]

s.plt.predictive_line(
    data=data, x='date', order=0,
    min_value_mark=3, max_value_mark=4,
    rows_size=2, cols_size=12, padding='0,0,0,1',
    title='Fossil price evolution - first days 2021.'
)
```

![The predictive line chart is completely personalized. Note the space before the component with padding='0,0,0,1'.](https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2F7P6NKQuJSPrXWIkflhd5%2FLine%20Predictive%20Configured.png?alt=media\&token=05af47ca-25eb-4535-8491-817889ce2ef3)

## Variants

By setting the parameter `variant` to the following values the appearance of the chart can be changed:

{% tabs %}
{% tab title="Clean" %}

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2F91H2QLdfHplg4zKRd3Gj%2Fimatge.png?alt=media&#x26;token=fb888fbb-6d07-451b-819a-87e9db7ace7b" alt=""><figcaption><p>variant = "clean"</p></figcaption></figure>
{% endtab %}

{% tab title="Minimal" %}

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FOKMqaySBMo99TJn2YkEF%2Fimatge.png?alt=media&#x26;token=068857b3-63d5-4260-99c2-7311eaaff15d" alt=""><figcaption><p>variant = "minimal"</p></figcaption></figure>
{% endtab %}
{% endtabs %}

##

{% hint style="info" %}

## Featured Content

[changing-the-menu-path](https://docs.shimoku.com/dev/building-web-app/menu/changing-the-menu-path "mention")\
The `menu_path` can be modified.<br>

[using-the-grid](https://docs.shimoku.com/dev/building-web-app/grid/using-the-grid "mention")

It is possible to use any number of rows.
{% endhint %}
