FlexPie
Format Item
This view shows the FlexPie's labels created using ItemFormatter.
Features
Description
This view shows the FlexPie's labels created using ItemFormatter.
1 2 3 4 5 6 7 8 9 10 11 12 13 | using System.Web.Mvc; using MvcExplorer.Models; namespace MvcExplorer.Controllers { public partial class FlexPieController : Controller { public ActionResult ItemFormatter() { return View(CustomerOrder.GetCountryGroupOrderData()); } } } |
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 | @model IEnumerable< MvcExplorer.Models.CustomerOrder > @section Scripts{ <script> function formatItem(engine, hitTestInfo, defaultFormatter) { var fsz = engine.fontSize; engine.fontSize = '10' ; defaultFormatter(); var point = hitTestInfo.point.clone(); var text = hitTestInfo.name + '=' + hitTestInfo.value.toFixed(1); var sz = engine.measureString(text); var fill = engine.fill; var x = point.x - 2 - sz.width / 2; var y = point.y - sz.height + 4; engine.fill = 'white' ; engine.drawRect(x, y < 0 ? 0 : y, sz.width + 4, sz.height); engine.fill = fill; point.x - = sz .width / 2; point.y += 4; engine.drawString(text, point); engine.fontSize = fsz ; } </script> } @ (Html.C1().FlexPie().Bind( "Country" , "Count" , Model).ItemFormatter( "formatItem" )) @section Description{ @Html .Raw(Resources.FlexPie.ItemFormatter_Text0) } |