# Aligning Zero with Multiple Axes in the Chart

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC Chart</td>
 </tr>
 <tr>
  <td>Progress Telerik UI for ASP.NET MVC version</td>
  <td>Created with the 2022.3.1109 version</td>
 </tr>
</table>

## Description

I have a Telerik UI for ASP.NET MVC Chart with multiple axes. One has negative values and the other does not. How can I configure the zero on the two axes to be aligned and how can I show the negative values on one axis as well?

## Solution

1. Update both the [`.Min()`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/chartnumericaxisbuilder#minsystemdouble) and [`.Max()`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/chartnumericaxisbuilder#maxsystemdouble) configuration methods for the value axes so they include both positive and negative values.
2. To handle the zero values within a particular value axis, pass a function along with the current value as an argument through the [`.Template()`](https://www.telerik.com/aspnet-mvc/documentation/api/kendo.mvc.ui.fluent/chartaxislabelsbuilder#templatesystemstring) configuration option for its labels.
3. Within the function, make an assertion for any negative values with the help of the function's argument. Based on the evaluation, either return an empty result or that of the value.

```Razor Index.cshtml   
    @(Html.Kendo().Chart(Model)
        .Name("chart")
        .Title("Hybrid car mileage report")
        .Legend(legend => legend
            .Position(ChartLegendPosition.Top)
        )
        .Series(series =>
        {
              series
                .Column(model => model.Value, categoryExpression: model => model.Date)
                .Labels(l => l.Visible(true));

              series
                .Line(new double[] { -7.8, 6.2, 5.9, 7.4, 5.6})
                .Name("l/100 km")
                .Color("#4e4141")
                .Axis("l100km"); 
        })
        .CategoryAxis(axis => axis
            .Date()
            .BaseUnit(ChartAxisBaseUnit.Days)
            // Align the first two value axes to the left
            // and the last two to the right.
            //
            // Right alignment is done by specifying a
            // crossing value greater than or equal to
            // the number of categories.
            .AxisCrossingValue(0, 0, 15,15)
        )
         .ValueAxis(axis => axis
            .Numeric()
            .Max(3)
            .Min(-3)
            .Labels(l => l.Template("#=onlyPositive(data)#"))
            .Line(line => line.Visible(true))
        )
        .ValueAxis(axis => axis
          .Numeric()
          .Min(-10)
          .Max(10)
          .MajorUnit(1)
          .Labels(l => l.Template("#=onlyPositive(data)#"))
          .Line(line => line.Visible(true))
        )
          .ValueAxis(axis => axis
          .Numeric()
          .Min(-60)
          .Max(60)
          .Labels(l => l.Template("#=onlyPositive(data)#"))
          .Line(line => line.Visible(true))
        )
         .ValueAxis(axis => axis
          .Numeric("l100km")
          .Line(line => line.Visible(true))
        )
    )
```

```JS script.js
    <script>
        function onlyPositive(e) {
            console.log(e.value);
            if (e.value < 0) {
                return '';
            }

            return e.value;
        }
    </script>
```

For the complete implementation of the suggested approach, refer to the [Telerik REPL example on aligning zero values with multiple axes within the ASP.NET MVC Chart](https://netcorerepl.telerik.com/QcvbQlbq50VLHjf500).

## More ASP.NET MVC Chart Resources

* [ASP.NET MVC Chart Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/charts/overview)

* [ASP.NET MVC Chart Demos](https://demos.telerik.com/aspnet-mvc/charts/index)

* [ASP.NET MVC Chart Product Page](https://www.telerik.com/aspnet-mvc/charts)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Telerik REPL: Align Zero with Multiple Axes in the Chart](https://netcorerepl.telerik.com/QcvbQlbq50VLHjf500)
* [Client-Side API Reference of the Chart for ASP.NET MVC](https://www.telerik.com/kendo-jquery-ui/documentation/api/dataviz/ui/chart)
* [Server-Side API Reference of the Chart for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/chart)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
