Chart Data

Performance !!!

Bar and Column Charts

Line and Area Charts

Pie and Funnel Charts

Scatter and Bubble Charts

Radar and Polar Charts

Financial Charts

Gantt Charts

Combinational Charts

Dynamic Charts

Working with Chart Axes

Chart Features

Customizing Chart

Client-Side Events


jqChart for ASP.NET MVC comes with a large number of predefined language packs and settings for almost all popular languages. They are located in the installation package, in the /js/i18n folder. Language packs are in the form of javascript files, containing definitions for all strings in the chart that can be localized.

In order to use a particular language pack, you need to include the javascript language pack to the head of your page, after the jQuery library reference (since language packs depend on jQuery) and after referencing the jqChart javascript file.

<script src="../js/jquery.min.js" type="text/javascript"></script>
<script src="../js/jquery.jqChart.min.js" type="text/javascript"></script>
<script src="../js/i18n/chart.locale-xx.js" type="text/javascript"></script>

For detailed implementation, please take a look at the Aspx, Razor and Controller code tabs.
 
<%@ Page  Language="C#"  Inherits="System.Web.Mvc.ViewPage<IEnumerable<SamplesBrowser.Models.DateTimeXAxisChartData>>" %>

<%@ Import Namespace="JQChart.Web.Mvc" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>    
    <link rel="stylesheet" type="text/css" href="~/Content/jquery.jqChart.css" />
    <link rel="stylesheet" type="text/css" href="~/Content/jquery.jqRangeSlider.css" />
    <link rel="stylesheet" type="text/css" href="~/Content/themes/le-frog/jquery-ui-1.8.20.css" />
    <script src="<%: Url.Content("~/Scripts/jquery-1.11.1.min.js") %>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/jquery.mousewheel.js") %>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/jquery.jqChart.min.js") %>" type="text/javascript"></script>    
    <script src="<%: Url.Content("~/Scripts/jquery.jqRangeSlider.min.js") %>" type="text/javascript"></script>
    <!--[if IE]><script lang="javascript" type="text/javascript" src="<%: Url.Content("~/Scripts/excanvas.js") %>"></script><![endif]-->
    <script src="<%: Url.Content("~/Scripts/i18n/chart.locale-de.js") %>" type="text/javascript"></script>
</head>
<body>
    <div>
        <%= Html.JQChart()
                .Chart(Model)
                .ID("jqChart")
                .Width(500)
                .Height(300)
                .Title("Localization")
                .Legend(false)
                .Border(border => border.StrokeStyle("#6ba851").Padding(16))
                .Background(background => background.LinearGradient(0, 0, 0, 1).ColorStops(stop =>
                {
                    stop.Add(0, "#d2e6c9");
                    stop.Add(1, "white");
                }))
                .Tooltips(tooltips => tooltips.TooltipsType(TooltipsType.Shared))
                .Crosshairs(el => el.Enabled(true).VerticalLine(line => line.StrokeStyle("#cc0a0c")).HorizontalLine(false))
                .Animation(TimeSpan.FromSeconds(2))
                .Shadows(true)
                .Axes(axis =>
                    {
                        axis.DateTimeAxis(Location.Bottom)
                            .ZoomEnabled(true)
                            .Labels(el => el.StringFormat("d. mmmm yyyy"));
                    }
                )
                .Series(series =>
                    {
                        series.Line()
                              .XValues(el => el.ValueX)
                              .YValues(el => el.ValueY1)
                              .Markers(false);

                        series.Line()
                              .XValues(el => el.ValueX)
                              .YValues(el => el.ValueY2)
                              .Markers(false);
                    }
                )
                .Render()%>
    </div>
    <script lang="javascript" type="text/javascript">
        $(document).ready(function () {
            $('#jqChart').bind('tooltipFormat', function (e, data) {

                if ($.isArray(data) == false) {

                    var date = data.chart.stringFormat(data.x, "dddd, d. mmmm yyyy");

                    var tooltip = '<b>' + date + '</b><br />' +
                          '<span style="color:' + data.series.fillStyle + '">' + data.series.title + ': </span>' +
                          '<b>' + data.y + '</b><br />';

                    return tooltip;
                }

                var date = data[0].chart.stringFormat(data[0].x, "dddd, d. mmmm yyyy");

                var tooltip = '<b>' + date + '</b><br />' +
                      '<span style="color:' + data[0].series.fillStyle + '">' + data[0].series.title + ': </span>' +
                      '<b>' + data[0].y + '</b><br />' +
                      '<span style="color:' + data[1].series.fillStyle + '">' + data[1].series.title + ': </span>' +
                      '<b>' + data[1].y + '</b><br />';

                return tooltip;
            });
        });
    </script>
</body>
</html>

                                        
 
@model IEnumerable<SamplesBrowser.Models.DateTimeXAxisChartData>
@using JQChart.Web.Mvc

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>    
    <link rel="stylesheet" type="text/css" href="~/Content/jquery.jqChart.css" />
    <link rel="stylesheet" type="text/css" href="~/Content/jquery.jqRangeSlider.css" />
    <link rel="stylesheet" type="text/css" href="~/Content/themes/le-frog/jquery-ui-1.8.20.css" />
    <script src="@Url.Content("~/Scripts/jquery-1.11.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.mousewheel.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.jqChart.min.js")" type="text/javascript"></script>    
    <script src="@Url.Content("~/Scripts/jquery.jqRangeSlider.min.js")" type="text/javascript"></script>
    <!--[if IE]><script lang="javascript" type="text/javascript" src="@Url.Content("~/Scripts/excanvas.js")"></script><![endif]-->
    <script src="@Url.Content("~/Scripts/i18n/chart.locale-de.js")" type="text/javascript"></script>
</head>
<body>
    <div>
          @(Html.JQChart()
                .Chart(Model)
                .ID("jqChart")
                .Width(500)
                .Height(300)
                .Title("Localization")
                .Legend(false)
                .Border(border => border.StrokeStyle("#6ba851").Padding(16))
                .Background(background => background.LinearGradient(0, 0, 0, 1).ColorStops(stop =>
                {
                    stop.Add(0, "#d2e6c9");
                    stop.Add(1, "white");
                }))
                .Tooltips(tooltips => tooltips.TooltipsType(TooltipsType.Shared))
                .Crosshairs(el => el.Enabled(true).VerticalLine(line => line.StrokeStyle("#cc0a0c")).HorizontalLine(false))
                .Animation(TimeSpan.FromSeconds(2))
                .Shadows(true)
                .Axes(axis =>
                    {
                        axis.DateTimeAxis(Location.Bottom)
                            .ZoomEnabled(true)
                            .Labels(el => el.StringFormat("d. mmmm yyyy"));
                    }
                )
                .Series(series =>
                    {
                        series.Line()
                              .XValues(el => el.ValueX)
                              .YValues(el => el.ValueY1)
                              .Markers(false);

                        series.Line()
                              .XValues(el => el.ValueX)
                              .YValues(el => el.ValueY2)
                              .Markers(false);
                    }
                )
                .Render() 
          )
    </div>
    <script lang="javascript" type="text/javascript">
        $(document).ready(function () {
            $('#jqChart').bind('tooltipFormat', function (e, data) {

                if ($.isArray(data) == false) {

                    var date = data.chart.stringFormat(data.x, "dddd, d. mmmm yyyy");

                    var tooltip = '<b>' + date + '</b><br />' +
                          '<span style="color:' + data.series.fillStyle + '">' + data.series.title + ': </span>' +
                          '<b>' + data.y + '</b><br />';

                    return tooltip;
                }

                var date = data[0].chart.stringFormat(data[0].x, "dddd, d. mmmm yyyy");

                var tooltip = '<b>' + date + '</b><br />' +
                      '<span style="color:' + data[0].series.fillStyle + '">' + data[0].series.title + ': </span>' +
                      '<b>' + data[0].y + '</b><br />' +
                      '<span style="color:' + data[1].series.fillStyle + '">' + data[1].series.title + ': </span>' +
                      '<b>' + data[1].y + '</b><br />';

                return tooltip;
            });
        });
    </script>
</body>
</html>

                                        
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SamplesBrowser.Models
{
    public class DateTimeXAxisChartData
    {
        public static List<DateTimeXAxisChartData> GetRandom()
        {
            var data = new List<DateTimeXAxisChartData>();

            Random rnd = new Random();

            double yValue1 = 50;
            double yValue2 = 200;

            var date = new DateTime(2010, 1, 1);

            for (var i = 0; i < 200; i++)
            {
                yValue1 += rnd.NextDouble() * 10 - 5;
                yValue2 += rnd.NextDouble() * 10 - 5;

                data.Add(new DateTimeXAxisChartData(date, Math.Round(yValue1, 2), Math.Round(yValue2, 2)));

                date = date.AddDays(1);

            }

            return data;
        }

        public static List<DateTimeXAxisChartData> GetLineChartData()
        {
            var data = new List<DateTimeXAxisChartData>();

            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 1), 62, 46));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 2), 60, 40));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 3), 68, 62));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 4), 58, 65));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 5), 52, 60));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 6), 60, 36));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 7), 48, 70));

            return data;
        }

        public static List<DateTimeXAxisChartData> GetLineChartDataWithNullValues()
        {
            var data = new List<DateTimeXAxisChartData>();

            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 1), 62, 46, 36));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 2), 60, 40, 30));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 3), 68, 62, 22));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 4), 58, 65, 25));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 5), null, null, null));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 6), 60, 36, 16));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 7), 48, 70, 30));

            return data;
        }

        public static List<DateTimeXAxisChartData> GetAreaChartData()
        {
            var data = new List<DateTimeXAxisChartData>();

            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 1, 1), 56, 46));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 2, 1), -20, 40));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 3, 1), -32, 62));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 4, 1), 50, 65));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 5, 1), 40, 60));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 6, 1), 36, 36));
            data.Add(new DateTimeXAxisChartData(new DateTime(2010, 7, 1), 70, 70));

            return data;
        }

        public static List<DateTimeXAxisChartData> GetDateTimeAxisSampleChartData()
        {
            var data = new List<DateTimeXAxisChartData>();

            data.Add(new DateTimeXAxisChartData(new DateTime(2011, 1, 6), 70));
            data.Add(new DateTimeXAxisChartData(new DateTime(2011, 1, 8), 82));
            data.Add(new DateTimeXAxisChartData(new DateTime(2011, 1, 10), 85));
            data.Add(new DateTimeXAxisChartData(new DateTime(2011, 1, 12), 70));
            data.Add(new DateTimeXAxisChartData(new DateTime(2011, 1, 14), 65));
            data.Add(new DateTimeXAxisChartData(new DateTime(2011, 1, 16), 68));

            return data;
        }

        public DateTimeXAxisChartData(DateTime valueX, double valueY1)
        {
            this.ValueX = valueX;
            this.ValueY1 = valueY1;
        }

        public DateTimeXAxisChartData(DateTime valueX, double? valueY1, double? valueY2)
        {
            this.ValueX = valueX;
            this.ValueY1 = valueY1;
            this.ValueY2 = valueY2;
        }

        public DateTimeXAxisChartData(DateTime valueX, double? valueY1, double? valueY2, double? valueY3)
        {
            this.ValueX = valueX;
            this.ValueY1 = valueY1;
            this.ValueY2 = valueY2;
            this.ValueY3 = valueY3;
        }

        public DateTime ValueX { get; set; }
        public double? ValueY1 { get; set; }
        public double? ValueY2 { get; set; }
        public double? ValueY3 { get; set; }
    }
}
                                        
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SamplesBrowser.Models;

namespace SamplesBrowser.Controllers
{
    public class ChartController : Controller
    {

        public ActionResult Localization() 
        { 
            return View(DateTimeXAxisChartData.GetRandom());
        }

    }
}