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 Category Axis is used for representing data grouped by a set of discrete values
along an axis. It defines a set of labels that appear along an axis of a chart.
For example, charts that renders data according to City, Country and so on.
This sample demonstrates how to set custom categories of category axis. 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.ChartData>>" %>
<%@ 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("Category Axis")
.Animation(TimeSpan.FromSeconds(1))
.Axes(axis =>
{
axis.CategoryAxis(Location.Bottom).Categories(el => el.Label);
}
)
.Series(series =>
{
series.Column().YValues(el => el.Value1);
}
)
.Render()%>
</div>
</body>
</html>
@model IEnumerable<SamplesBrowser.Models.ChartData>
@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("Category Axis")
.Animation(TimeSpan.FromSeconds(1))
.Axes(axis =>
{
axis.CategoryAxis(Location.Bottom).Categories(el => el.Label);
}
)
.Series(series =>
{
series.Column().YValues(el => el.Value1);
}
)
.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 CategoryAxis()
{
return View(ChartData.GetCategoryAxisSampleChartData());
}
}
}
|
Follow us on Twitter