Chart DataPerformance !!!Bar and Column ChartsLine and Area ChartsPie ChartsScatter and Bubble ChartsRadar and Polar ChartsFinancial ChartsCombinational ChartsDynamic ChartsWorking with Chart AxesChart FeaturesCustomizing ChartClient-Side Events |
The DateTime Axis maps time values evenly between a minimum and maximum value along
a chart axis. By default, it determines Minimum, Maximum, Interval and IntervalType
values from the charting data to fit all of the chart elements on the screen. You
can also explicitly set specific values for these properties.
The DateTime Axis chooses the most reasonable intervals to mark the axis by examining the range between the minimum and maximum values of the axis. In this sample the Minimum, Maximum, Interval and IntervalType are set explicitly. 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.5.2.min.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]-->
</head>
<body>
<div>
<%= Html.JQChart()
.Chart(Model)
.ID("jqChart")
.Width(500)
.Height(300)
.Title("DateTime Axis")
.Animation(TimeSpan.FromSeconds(1))
.Axes(axis =>
{
axis.DateTimeAxis(Location.Bottom)
.Minimum(new DateTime(2011, 1, 4))
.Maximum(new DateTime(2011, 1, 18))
.Interval(1)
.IntervalType(DateTimeIntervalType.Days);
}
)
.Series(series =>
{
series.Line().Title("Series 1")
.XValues(el => el.ValueX)
.YValues(el => el.ValueY1);
}
)
.Render()%>
</div>
</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.5.2.min.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]-->
</head>
<body>
<div>
@(Html.JQChart()
.Chart(Model)
.ID("jqChart")
.Width(500)
.Height(300)
.Title("DateTime Axis")
.Animation(TimeSpan.FromSeconds(1))
.Axes(axis =>
{
axis.DateTimeAxis(Location.Bottom)
.Minimum(new DateTime(2011, 1, 4))
.Maximum(new DateTime(2011, 1, 18))
.Interval(1)
.IntervalType(DateTimeIntervalType.Days);
}
)
.Series(series =>
{
series.Line().Title("Series 1")
.XValues(el => el.ValueX)
.YValues(el => el.ValueY1);
}
)
.Render()
)
</div>
</body>
</html>
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 DateTimeAxis()
{
return View(DateTimeXAxisChartData.GetDateTimeAxisSampleChartData());
}
}
}
|
Follow us on Twitter