FlexChart
FlexChart
Labels
Labels
This view demonstrates how you can use the FlexChart's DataLabel
property to add labels to each data point.
Features
Settings
Chart Type: Column
Data Label Position: Top
Data Label Border: False
Description
Labels
This view demonstrates how you can use the FlexChart's DataLabel property to add labels to each data point.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using MvcExplorer.Models; using C1.Web.Mvc; using C1.Web.Mvc.Serialization; using C1.Web.Mvc.Chart; namespace MvcExplorer.Controllers { public partial class FlexChartController : Controller { public ActionResult Labels() { var model = new ClientSettingsModel { Settings = CreateLabelSettings() }; return View(model); } private static IDictionary< string , object []> CreateLabelSettings() { var settings = new Dictionary< string , object []> { { "ChartType" , new object []{ "Column" , "Bar" , "Scatter" , "Line" , "LineSymbols" , "Area" , "Spline" , "SplineSymbols" , "SplineArea" }}, { "DataLabel.Position" , new object []{LabelPosition.Top, LabelPosition.Right, LabelPosition.Bottom, LabelPosition.Left, LabelPosition.None}}, { "DataLabel.Border" , new object []{ false , true }}, }; return settings; } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | @model ClientSettingsModel @ { ViewBag.DemoSettings = true ; ViewBag.DemoSettingsModel = Model; IEnumerable< Fruit > fruits = Fruit.GetFruitsSales(); } @ (Html.C1().FlexChart().Id(Model.ControlId).Bind( "Name" , fruits).Series(sers => { sers.Add().Binding( "MarPrice" ).Name( "March" ); sers.Add().Binding( "AprPrice" ).Name( "April" ); sers.Add().Binding( "MayPrice" ).Name( "May" ); }).DataLabel(dl => dl.Position(C1.Web.Mvc.Chart.LabelPosition.Top).Content( "{y}" ))) @section Description{ < h3 > @Html .Raw(Resources.FlexChart.Labels_Labels) </ h3 > < p > @Html .Raw(Resources.FlexChart.Labels_Text0)</ p > } |