# Waterfall

## Content



Waterfall series is a form of data visualization that helps in understanding the progressive effect of positive and negative values in FlexChart. Waterfall series can be used for analytical purposes, mainly for understanding or explaining the continuous transition in the value, which is subjected to increase or decrease.

This topic describes how to use Waterfall series in your FlexChart to represent the positives and negative values of an entity.

*   [Step 1: Create a Datasource for FlexChart](/componentone/docs/mvc/online-mvc-core/WorkingwithControls/FlexChart/Work-with-FlexChart/Series/WaterfallSeries#step-1-create-a-datasource-for-flexchart)
*   [Step 2: Add a FlexChart](/componentone/docs/mvc/online-mvc-core/WorkingwithControls/FlexChart/Work-with-FlexChart/Series/WaterfallSeries#step-2-add-a-flexchart)
*   [Step 3: Build and Run the Project](/componentone/docs/mvc/online-mvc-core/WorkingwithControls/FlexChart/Work-with-FlexChart/Series/WaterfallSeries#step-3-build-and-run-the-project)

The following image shows how FlexChart appears after completing the steps above:![](https://cdn.mescius.io/document-site-files/images/9b6a6cfe-b8e8-42e9-8a04-da6cb7762977/images/flexchartwaterfall.png)

### Step 1: Create a Datasource for FlexChart

1.  Add a new class to the folder **Models** (for example: `Waterfall.cs`). See [Adding controls](/componentone/docs/mvc/online-mvc-core/Adding-Controls) to know how to add a new model.
2.  Add the following code to the new model to define a class which will serve as a datasource for the FlexChart. **csharp**
    
    ```csharp
    public class Waterfall
        {
            public int WaterfallId { get; set; }
            public string Name { get; set; }
            public int Value { get; set; }
            public Waterfall()
            {
            }
            public Waterfall(string name, int value)
            {
                Name = name;
                Value = value;
            }
            public static List<Waterfall> GetData()
            {
                var names = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
                var data = new List<Waterfall>();
                for (int i = 0, len = names.Length; i < len; i++)
                {
                    data.Add(new Waterfall(names[i], (((i % 3) + 3) * 1000)));
                };
                return data;
            }
    }
    ```
    

### Step 2: Add a FlexChart

Complete the following steps to initialize a FlexChart.

**Add a new Controller**

1.  In the **Solution Explorer**, right click the folder **Controllers.**
2.  From the context menu, select **Add | Controller**. The **Add Scaffold** dialog appears.
3.  Complete the following steps in the **Add Scaffold** dialog:
    1.  Select **Empty MVC Controller** template.
    2.  Set name of the controller (for example: `FlexChartController`).
    3.  Click **Add**.
4.  Include the MVC references as shown below.
    
    ```csharp
    using C1.Web.Mvc;
    using C1.Web.Mvc.Serializition;
    using C1.Web.Mvc.Chart;
    ```
    
5.  Replace the method Index() with the following method.
    
    ```csharp
    public ActionResult Index()
            {
                return View(Waterfall.GetData());
            }
    ```
    

**Add a View for the Controller**

1.  From the **Solution Explorer**, expand the folder **Controllers** and double click the `FlexChartController.`
2.  Place the cursor inside the method `Index()`.
3.  Right click and select **Add View**. The **Add View** dialog appears.
4.  In the **Add View** dialog, verify that the view name is **Index** and View engine is **Razor (CSHTML).**
5.  Click **Add**. A view is added for the controller.
    
    ```razor
    @{
        var waterfallStyle = new WaterfallStyles();
        waterfallStyle.ConnectorLines = new SVGStyle { Stroke = "#339", StrokeDasharray = "5 5" };
    }
    <c1-flex-chart id="flexchart" binding="Value" binding-x="Name" height="300px">
        <c1-items-source source-collection="Model" />
        <c1-flex-chart-waterfall styles="waterfallStyle" relative-data="false" connector-lines="true" />
    </c1-flex-chart>
    ```
    

### Step 3: Build and Run the Project

1.  Click **Build | Build Solution** to build the project.
2.  Press **F5** to run the project. 
	> type=note
	> Append the folder name and view name to the generated URL (for example: http://localhost:1234/**FlexChart/Index**) in the address bar of the browser to see the view.