# ChartJS

The [ChartJS ](http://www.chartjs.org)extension component uses the excellent ChartJS widget to render amazing charts in real time. Please note that this extension is still under development and some advanced options are not yet available. Nevertheless, it’s quite an extension!

![](/files/o5gSqc6ptC7HGcq2jaqf)

{% embed url="<https://github.com/iceteagroup/wisej-extensions/tree/master/Wisej.Web.Ext.ChartJS>" %}
ChartJS Source Code
{% endembed %}

## Features

The **ChartJS** Extension includes the following chart types:

* Line
* Bar
* HorizontalBar
* Radar
* PolarArea
* Pie
* Doughnut
* Bubble
* Scatter

## How to Use

The **ChartJS** extension can be added to a Wisej.NET project using NuGet Package Manager.

{% embed url="<https://www.nuget.org/packages/Wisej-3-ChartJS>" %}

You can configure your instance by setting Chart specific *Options*.

For example, you can disable the tooltip using Options:

{% tabs %}
{% tab title="C#" %}
{% code overflow="wrap" %}

```csharp
chartJS1.Options.Tooltips = new Wisej.Web.Ext.ChartJS.OptionsTooltips { Enabled = false };
```

{% endcode %}
{% endtab %}

{% tab title="VB.NET" %}
{% code overflow="wrap" %}

```vb
ChartJS1.Options.Tooltips = New Wisej.Web.Ext.ChartJS.OptionsTooltips With {.Enabled = False}
```

{% endcode %}
{% endtab %}
{% endtabs %}

You can set the minimum and maximum values on the Y axis using Options:

{% tabs %}
{% tab title="C#" %}
{% code overflow="wrap" %}

```csharp
chartJS1.Options.Scales.yAxes = new[]
{
    new OptionScalesAxesY { Ticks = new OptionsScalesTicks { Min = 1, Max = 100 } }
};
```

{% endcode %}
{% endtab %}

{% tab title="VB.NET" %}
{% code overflow="wrap" %}

```vb
chartJS1.Options.Scales.yAxes = {
    New OptionScalesAxesY With {
        .Ticks = New OptionsScalesTicks With {
            .Min = 1,
            .Max = 100
        }
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

Data is provided in *DataSets*.

### Code sample

The code snippet below:

{% tabs %}
{% tab title="C#" %}

```csharp
var data = new object[10];            
Random random = new Random();
for (int i = 0; i < 10; i++)
{
        data[i] = new Point(i, random.Next(10));
}
DataSet ds = chartJS1.DataSets.Add("ds1");
ds.Data = data;
ds.BackgroundColor = Color.Red;
```

{% endtab %}

{% tab title="VB.NET" %}

```vb
Dim data(9) As Object
Dim random As New Random()
For i As Integer = 0 To 9
    data(i) = New Point(i, random.Next(10))
Next

Dim ds = ChartJS1.DataSets.Add("ds1")
ds.Data = data
ds.BackgroundColor = Color.Red
```

{% endtab %}
{% endtabs %}

Creates the following chart:

![](/files/-Mic8FpE2Vx467lcV-tE)

{% hint style="warning" %}
Make sure to set the labels of the chart either in the [Designer](https://docs.wisej.com/docs/concepts/designer) or via code. If there are no labels, the points on the graph will not be shown.
{% endhint %}

You can add labels to the X axis like so:

{% tabs %}
{% tab title="C#" %}
{% code overflow="wrap" %}

```csharp
// Numeric labels
this.chartJS1.Labels = new string[] {"1","2","3","4"};

// Day of the week labels
this.chartJS1.Labels = new string[] {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
```

{% endcode %}
{% endtab %}

{% tab title="VB.NET" %}
{% code overflow="wrap" %}

```vbnet
'Numeric labels
Me.ChartJS1.Labels = New String() {"1", "2", "3", "4"}

'Day of the week labels
Me.ChartJS1.Labels = New String() {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
Find more information in our **ChartJS** example in [C#](https://github.com/iceteagroup/wisej-examples/tree/2.2/ChartJS) or in [VB.NET](https://github.com/iceteagroup/wisej-examples-vb/tree/main/ChartJS).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/extensions/extensions/chartjs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
