public override Drilldown BusinessToData(Drilldown drilldown, BUSDrilldown businessEntity, TContext context, bool NewRecord) { Drilldown dataEntity = base.BusinessToData(drilldown, businessEntity, context, NewRecord); dataEntity.Applet = businessEntity.Applet; dataEntity.AppletId = businessEntity.AppletId; dataEntity.DestinationBusinessComponent = businessEntity.DestinationBusinessComponent; dataEntity.DestinationBusinessComponentId = businessEntity.DestinationBusinessComponentId; dataEntity.DestinationField = businessEntity.DestinationField; dataEntity.DestinationFieldId = businessEntity.DestinationFieldId; dataEntity.DestinationScreen = businessEntity.DestinationScreen; dataEntity.DestinationScreenId = businessEntity.DestinationScreenId; dataEntity.DestinationScreenItem = businessEntity.DestinationScreenItem; dataEntity.DestinationScreenItemId = businessEntity.DestinationScreenItemId; dataEntity.HyperLinkField = businessEntity.HyperLinkField; dataEntity.HyperLinkFieldId = businessEntity.HyperLinkFieldId; dataEntity.SourceField = businessEntity.SourceField; dataEntity.SourceFieldId = businessEntity.SourceFieldId; return(dataEntity); }
/// <summary> /// Options for drill down, the concept of inspecting increasingly high resolution data through clicking on chart items like columns or pie slices. /// The drilldown feature requires the drilldown.js file to be loaded, found in the modules directory of the download package, or online at code.highcharts.com/modules/drilldown.js. /// </summary> /// <param name="drilldown">The drilldown options.</param> /// <returns></returns> public Highcharts SetDrilldown(Drilldown drilldown) { _Drilldown = drilldown; return(this); }
public ActionResult Drilldown() { Applet currentApplet = viewInfo.CurrentPopupApplet ?? viewInfo.CurrentApplet; currentApplet = context.Applets .AsNoTracking() .Select(a => new { id = a.Id, name = a.Name, type = a.Type, busComp = new { id = a.BusComp.Id, name = a.BusComp.Name, routing = a.BusComp.Routing }, drilldowns = a.Drilldowns.Select(d => new { id = d.Id, name = d.Name, hyperLinkFieldId = d.HyperLinkFieldId, sourceField = new { id = d.SourceField.Id, name = d.SourceField.Name }, destinationBusinessComponent = new { id = d.DestinationBusinessComponent.Id, name = d.DestinationBusinessComponent.Name, routing = d.DestinationBusinessComponent.Routing }, destinationField = new { id = d.DestinationField.Id, name = d.DestinationField.Name }, destinationScreenId = d.DestinationScreenId, destinationScreenItemId = d.DestinationScreenItemId, destinationScreenItem = new { id = d.DestinationScreenItem.Id, view = new { id = d.DestinationScreenItem.View.Id, busObjectId = d.DestinationScreenItem.View.BusObjectId } } }) }) .Select(a => new Applet { Id = a.id, Name = a.name, Type = a.type, BusComp = new BusinessComponent { Id = a.busComp.id, Name = a.busComp.name, Routing = a.busComp.routing }, Drilldowns = a.drilldowns.Select(d => new Drilldown { Id = d.id, Name = d.name, HyperLinkFieldId = d.hyperLinkFieldId, SourceField = new Field { Id = d.sourceField.id, Name = d.sourceField.name }, DestinationBusinessComponent = new BusinessComponent { Id = d.destinationBusinessComponent.id, Name = d.destinationBusinessComponent.name, Routing = d.destinationBusinessComponent.routing }, DestinationField = new Field { Id = d.destinationField.id, Name = d.destinationField.name }, DestinationScreenId = d.destinationScreenId, DestinationScreenItem = new ScreenItem { Id = d.destinationScreenItem.id, View = new View { Id = d.destinationScreenItem.view.id, BusObjectId = d.destinationScreenItem.view.busObjectId } } }).ToList() }) .FirstOrDefault(i => i.Id == currentApplet.Id); if (currentApplet != null) { string controlName; Field field; switch (currentApplet.Type) { case "Tile": controlName = viewInfo.CurrentColumn.Name; field = viewInfo.CurrentColumn.Field; break; default: controlName = viewInfo.CurrentPopupControl?.Name ?? viewInfo.CurrentControl?.Name; field = viewInfo.CurrentPopupControl?.Field ?? viewInfo.CurrentControl?.Field; break; } if (field != null) { TBUSFactory BUSFactory = new TBUSFactory(); Drilldown drilldown = currentApplet.Drilldowns.FirstOrDefault(i => i.HyperLinkFieldId == field.Id); if (drilldown != null && drilldown.DestinationBusinessComponent?.Name != null && drilldown.DestinationField?.Name != null && drilldown.SourceField?.Name != null) { // Целевой экран Screen destinationScreen = context.Screens.AsNoTracking().FirstOrDefault(i => i.Id == drilldown.DestinationScreenId); if (destinationScreen != null) { applicationInfo.CurrentScreen = destinationScreen; // Целевыое представление View destinationView = context.Views.AsNoTracking().FirstOrDefault(i => i.Id == drilldown.DestinationScreenItem.View.Id); if (destinationView != null) { applicationInfo.CurrentView = destinationView; // Исходное поле dynamic sourceRecord = BUSFactory.GetRecord(null, context, viewInfo, currentApplet.BusComp, "Id", viewInfo.CurrentRecord); PropertyInfo sourceProperty = sourceRecord.GetType().GetProperty(drilldown.SourceField.Name); if (sourceProperty != null) { // Очистка старой информации о выбранных записях if (screenInfo.Screen.Name != destinationScreen.Name) { ComponentsRecordsInfo.Dispose(); } // Установка текущей выбранной записи на целевой бизнес компоненте var sourcePropertyValue = sourceProperty.GetValue(sourceRecord); if (sourcePropertyValue != null) { dynamic destinationRecord = BUSFactory.GetRecord(null, context, viewInfo, drilldown.DestinationBusinessComponent, drilldown.DestinationField.Name, sourcePropertyValue.ToString()); if (destinationRecord != null) { ComponentsRecordsInfo.SetSelectedRecord(drilldown.DestinationBusinessComponent.Name, destinationRecord.Id.ToString()); } // Установка текущих выбранных записей на всех родительских бизнес компонентах целевой компоненты BusinessObject destinationBO = context.BusinessObjects .AsNoTracking() .Include(boc => boc.BusObjectComponents) .ThenInclude(l => l.Link) .ThenInclude(cf => cf.ChildField) .Include(boc => boc.BusObjectComponents) .ThenInclude(l => l.Link) .ThenInclude(pf => pf.ParentField) .FirstOrDefault(i => i.Id == destinationView.BusObjectId); BusinessObjectComponent destinationComponent = destinationBO.BusObjectComponents.FirstOrDefault(i => i.BusCompId == drilldown.DestinationBusinessComponent.Id); dynamic childRecord = destinationRecord; if (destinationComponent.Link != null) { BusinessComponent parentBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, table = new { id = bc.Table.Id, name = bc.Table.Name } }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Table = new Table { Id = bc.table.id, Name = bc.table.name } }) .FirstOrDefault(i => i.Id == destinationComponent.Link.ParentBCId); BusinessComponent childBusComp = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name }) .FirstOrDefault(i => i.Id == destinationComponent.Link.ChildBCId); string childFieldValue = childRecord.GetType().GetProperty(destinationComponent.Link.ChildField.Name).GetValue(childRecord).ToString(); string parentFieldName = destinationComponent.Link.ParentField.Name; IEnumerable <dynamic> parentRecords = (IEnumerable <dynamic>)(context.GetType().GetProperty(parentBusComp.Table.Name).GetValue(context)); string searchSpecificationByParent = $"{parentFieldName} = \"{childFieldValue}\""; dynamic parentRecord = parentRecords.AsQueryable().Where(searchSpecificationByParent).FirstOrDefault(); ComponentsRecordsInfo.SetSearchSpecification(childBusComp.Name, SearchSpecTypes.SearchSpecificationByParent, searchSpecificationByParent); ComponentsRecordsInfo.SetSelectedRecord(parentBusComp.Name, parentRecord.Id.ToString()); destinationComponent = destinationBO.BusObjectComponents.FirstOrDefault(i => i.BusCompId == destinationComponent.Link.ParentBCId); childRecord = parentRecord; } // Установка хлебных крошек ScreenItem crumb = screenInfo.Screen.ScreenItems.FirstOrDefault(n => n.View != null && n.View.Name == screenInfo.CurrentView.Name); ComponentsRecordsInfo.AppendCrumb(crumb); if (screenInfo.Screen.Name == destinationScreen.Name) { screenInfo.Initialize(screenInfo.Screen.Name, destinationView.Name, context); screenInfoUI.Initialize(screenInfo, context); viewInfo.View = destinationView; } viewInfo.ActionType = ActionType.Drilldown; } } } } } } } return(Ok()); }
public override BUSDrilldown DataToBusiness(Drilldown dataEntity, TContext context) { // Applet BUSDrilldown businessEntity = base.DataToBusiness(dataEntity, context); Applet applet = context.Applets .AsNoTracking() .Select(a => new { id = a.Id, name = a.Name, busCompId = a.BusCompId, busComp = new { id = a.BusComp.Id, name = a.BusComp.Name, fields = a.BusComp.Fields.Select(f => new { id = f.Id, name = f.Name }) } }) .Select(a => new Applet { Id = a.id, Name = a.name, BusCompId = a.busCompId, BusComp = new BusinessComponent { Id = a.busComp.id, Name = a.busComp.name, Fields = a.busComp.fields.Select(f => new Field { Id = f.id, Name = f.name }).ToList() } }) .FirstOrDefault(i => i.Id == dataEntity.AppletId); businessEntity.Applet = applet; businessEntity.AppletId = applet.Id; if (applet.BusComp != null) { businessEntity.SourceBusinessComponent = applet.BusComp; businessEntity.SourceBusinessComponentId = (Guid)applet.BusCompId; // Source and hyperlink fields if (applet.BusComp.Fields?.Count > 0) { Field sourceField = applet.BusComp.Fields.FirstOrDefault(i => i.Id == dataEntity.SourceFieldId); if (sourceField != null) { businessEntity.SourceField = sourceField; businessEntity.SourceFieldId = sourceField.Id; businessEntity.SourceFieldName = sourceField.Name; } Field hyperLinkField = applet.BusComp.Fields.FirstOrDefault(i => i.Id == dataEntity.HyperLinkFieldId); if (hyperLinkField != null) { businessEntity.HyperLinkField = hyperLinkField; businessEntity.HyperLinkFieldId = hyperLinkField.Id; businessEntity.HyperLinkFieldName = hyperLinkField.Name; } } // Destination business component and destination field BusinessComponent destinationBusinessComponent = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, fields = bc.Fields.Select(f => new { id = f.Id, name = f.Name }) }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Fields = bc.fields.Select(f => new Field { Id = f.id, Name = f.name }).ToList() }) .FirstOrDefault(i => i.Id == dataEntity.DestinationBusinessComponentId); if (destinationBusinessComponent != null) { businessEntity.DestinationBusinessComponent = destinationBusinessComponent; businessEntity.DestinationBusinessComponentId = destinationBusinessComponent.Id; businessEntity.DestinationBusinessComponentName = destinationBusinessComponent.Name; Field destinationField = destinationBusinessComponent.Fields.FirstOrDefault(i => i.Id == dataEntity.DestinationFieldId); if (destinationField != null) { businessEntity.DestinationField = destinationField; businessEntity.DestinationFieldId = destinationField.Id; businessEntity.DestinationFieldName = destinationField.Name; } } // Destination screen and destination view Screen destinationScreen = context.Screens .AsNoTracking() .Select(s => new { id = s.Id, name = s.Name, screenItems = s.ScreenItems.Select(si => new { id = si.Id, name = si.Name }) }) .Select(s => new Screen { Id = s.id, Name = s.name, ScreenItems = s.screenItems.Select(si => new ScreenItem { Id = si.id, Name = si.name }).ToList() }) .FirstOrDefault(i => i.Id == dataEntity.DestinationScreenId); if (destinationScreen != null) { businessEntity.DestinationScreen = destinationScreen; businessEntity.DestinationScreenId = destinationScreen.Id; businessEntity.DestinationScreenName = destinationScreen.Name; ScreenItem destinationScreenItem = destinationScreen.ScreenItems.FirstOrDefault(i => i.Id == dataEntity.DestinationScreenItemId); if (destinationScreenItem != null) { businessEntity.DestinationScreenItem = destinationScreenItem; businessEntity.DestinationScreenItemId = destinationScreenItem.Id; businessEntity.DestinationScreenItemName = destinationScreenItem.Name; } } } return(businessEntity); }
/// <summary> /// Options for drill down, the concept of inspecting increasingly high resolution data through clicking on chart items /// like columns or pie slices. /// The drilldown feature requires the drilldown.js file to be loaded, found in the modules directory of the download /// package, or online at code.highcharts.com/modules/drilldown.js. /// </summary> /// <param name="drilldown">The drilldown options.</param> /// <returns></returns> public Highcharts SetDrilldown(Drilldown drilldown) { _Drilldown = drilldown; return this; }
public ActionResult PieWithDrilldown() { Data data = new Data(new[] { new SeriesData { Y = 55.11, Name = "MSIE versions", Drilldown = "MSIE" }, new SeriesData { Y = 21.63, Name = "Firefox versions", Drilldown = "Firefox" }, new SeriesData { Y = 11.94, Name = "Chrome versions", Drilldown = "Chrome" }, new SeriesData { Y = 7.15, Name = "Safari versions", Drilldown = "Safari" }, new SeriesData { Y = 2.14, Name = "Opera versions", Drilldown = "Opera" } }); Drilldown drilldown = new Drilldown { Series = new[] { new Series { Id = "MSIE", Data = new Data(new object[,] {{"MSIE 6.0", 10.85}, {"MSIE 7.0", 7.35}, {"MSIE 6.0", 10.85}, {"MSIE 8.0", 33.06}, {"MSIE 9.0", 2.81}}) }, new Series { Id = "Firefox", Data = new Data(new object[,] {{"Firefox 2.0", 0.20}, {"Firefox 3.0", 0.83}, {"Firefox 3.5", 1.58}, {"Firefox 3.6", 13.12}, {"Firefox 4.0", 5.43}}) }, new Series { Id = "Chrome", Data = new Data(new object[,] {{"Chrome 5.0", 0.12}, {"Chrome 6.0", 0.19}, {"Chrome 7.0", 0.12}, {"Chrome 8.0", 0.36}, {"Chrome 9.0", 0.32}, {"Chrome 10.0", 9.91}, {"Chrome 11.0", 0.50}, {"Chrome 12.0", 0.22}}) }, new Series { Id = "Safari", Data = new Data(new object[,] {{"Safari 5.0", 4.55}, {"Safari 4.0", 1.42}, {"Safari Win 5.0", 0.23}, {"Safari 4.1", 0.21}, {"Safari/Maxthon", 0.20}, {"Safari 3.1", 0.19}, {"Safari 4.1", 0.14}}) }, new Series { Id = "Opera", Data = new Data(new object[,] {{"Opera 9.x", 0.12}, {"Opera 10.x", 0.37}, {"Opera 11.x", 1.65}}) } } }; Highcharts chart = new Highcharts("chart") .InitChart(new Chart { Type = ChartTypes.Pie }) .SetTitle(new Title { Text = "Browser market share, April, 2011" }) .SetSubtitle(new Subtitle { Text = "Click the columns to view versions. " }) .SetXAxis(new XAxis { Type = AxisTypes.Category }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Total percent market share" } }) .SetLegend(new Legend { Enabled = false }) .SetTooltip(new Tooltip { HeaderFormat = "<span style=\"font-size:11px\">{series.name}</span><br>", PointFormat = "<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>" }) .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { BorderWidth = 0, DataLabels = new PlotOptionsColumnDataLabels { Enabled = true, Format = "{point.y:.1f}%", } } }) .SetSeries(new Series { Name = "Browser brands", Data = data, PlotOptionsBar = new PlotOptionsBar { ColorByPoint = true } }) .SetDrilldown(drilldown); return View(chart); }
public override BUSDrilldown UIToBusiness(UIDrilldown UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord) { BUSDrilldown businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord); Applet applet = context.Applets .AsNoTracking() .Select(a => new { id = a.Id, name = a.Name, busCompId = a.BusCompId, busComp = new { id = a.BusComp.Id, name = a.BusComp.Name, fields = a.BusComp.Fields.Select(f => new { id = f.Id, name = f.Name }) }, drilldowns = a.Drilldowns.Select(drilldown => new { id = drilldown.Id, name = drilldown.Name, }) }) .Select(a => new Applet { Id = a.id, Name = a.name, BusCompId = a.busCompId, BusComp = new BusinessComponent { Id = a.busComp.id, Name = a.busComp.name, Fields = a.busComp.fields.Select(f => new Field { Id = f.id, Name = f.name }).ToList() }, Drilldowns = a.drilldowns.Select(drilldown => new Drilldown { Id = drilldown.id, Name = drilldown.name }).ToList() }) .FirstOrDefault(n => n.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Applet")); if (applet == null) { businessEntity.ErrorMessage = "First you need create applet."; } if (applet.BusComp == null) { businessEntity.ErrorMessage = $"First you need to add a business component to applet \"{applet.Name}\"."; } else { Drilldown drilldown = applet.Drilldowns?.FirstOrDefault(n => n.Name == UIEntity.Name); if (drilldown != null && drilldown.Id != UIEntity.Id) { businessEntity.ErrorMessage = $"Drilldown with this name is already exists in applet \"{applet.Name}\"."; } else { businessEntity.Applet = applet; businessEntity.AppletId = applet.Id; businessEntity.SourceBusinessComponent = applet.BusComp; businessEntity.SourceBusinessComponentId = (Guid)applet.BusCompId; // Destination screen and screen item Screen destinationScreen = context.Screens .AsNoTracking() .Select(s => new { id = s.Id, name = s.Name, screenItems = s.ScreenItems.Select(si => new { id = si.Id, name = si.Name }) }) .Select(s => new Screen { Id = s.id, Name = s.name, ScreenItems = s.screenItems.Select(si => new ScreenItem { Id = si.id, Name = si.name }).ToList() }) .FirstOrDefault(n => n.Name == UIEntity.DestinationScreenName); if (destinationScreen != null) { businessEntity.DestinationScreen = destinationScreen; businessEntity.DestinationScreenId = destinationScreen.Id; businessEntity.DestinationScreenName = destinationScreen.Name; ScreenItem destinationScreenItem = destinationScreen.ScreenItems.FirstOrDefault(n => n.Name == UIEntity.DestinationScreenItemName); if (destinationScreenItem != null) { businessEntity.DestinationScreenItem = destinationScreenItem; businessEntity.DestinationScreenItemId = destinationScreenItem.Id; businessEntity.DestinationScreenItemName = destinationScreenItem.Name; BusinessComponent destinationBusinessComponent = context.BusinessComponents .AsNoTracking() .Select(bc => new { id = bc.Id, name = bc.Name, fields = bc.Fields.Select(f => new { id = f.Id, name = f.Name }) }) .Select(bc => new BusinessComponent { Id = bc.id, Name = bc.name, Fields = bc.fields.Select(f => new Field { Id = f.id, Name = f.name }).ToList() }) .FirstOrDefault(n => n.Name == UIEntity.DestinationBusinessComponentName); if (destinationBusinessComponent != null) { businessEntity.DestinationBusinessComponent = destinationBusinessComponent; businessEntity.DestinationBusinessComponentId = destinationBusinessComponent.Id; businessEntity.DestinationBusinessComponentName = destinationBusinessComponent.Name; Field destinationField = destinationBusinessComponent.Fields.FirstOrDefault(n => n.Name == UIEntity.DestinationFieldName); if (destinationField != null) { businessEntity.DestinationField = destinationField; businessEntity.DestinationFieldId = destinationField.Id; businessEntity.DestinationFieldName = destinationField.Name; } Field sourceField = applet.BusComp.Fields.FirstOrDefault(n => n.Name == UIEntity.SourceFieldName); if (sourceField != null) { businessEntity.SourceField = sourceField; businessEntity.SourceFieldId = sourceField.Id; businessEntity.SourceFieldName = sourceField.Name; } Field hyperLinkField = applet.BusComp.Fields.FirstOrDefault(n => n.Name == UIEntity.HyperLinkFieldName); if (hyperLinkField != null) { businessEntity.HyperLinkField = hyperLinkField; businessEntity.HyperLinkFieldId = hyperLinkField.Id; businessEntity.HyperLinkFieldName = hyperLinkField.Name; } } } } } } return(businessEntity); }
public ActionResult DonutChart() { string[] categories = { "MSIE", "Firefox", "Chrome", "Safari", "Opera" }; Data data = new Data(new[] { new Point { Y = 55.11, Color = Color.FromName("colors[0]"), Drilldown = new Drilldown { Name = "MSIE versions", Categories = new[] { "MSIE 6.0", "MSIE 7.0", "MSIE 8.0", "MSIE 9.0" }, Data = new Data(new object[] { 10.85, 7.35, 33.06, 2.81 }), Color = Color.FromName("colors[0]") } }, new Point { Y = 21.63, Color = Color.FromName("colors[1]"), Drilldown = new Drilldown { Name = "Firefox versions", Categories = new[] { "Firefox 2.0", "Firefox 3.0", "Firefox 3.5", "Firefox 3.6", "Firefox 4.0" }, Data = new Data(new object[] { 0.20, 0.83, 1.58, 13.12, 5.43 }), Color = Color.FromName("colors[1]") } }, new Point { Y = 11.94, Color = Color.FromName("colors[2]"), Drilldown = new Drilldown { Name = "Chrome versions", Categories = new[] { "Chrome 5.0", "Chrome 6.0", "Chrome 7.0", "Chrome 8.0", "Chrome 9.0", "Chrome 10.0", "Chrome 11.0", "Chrome 12.0" }, Data = new Data(new object[] { 0.12, 0.19, 0.12, 0.36, 0.32, 9.91, 0.50, 0.22 }), Color = Color.FromName("colors[2]") } }, new Point { Y = 7.15, Color = Color.FromName("colors[3]"), Drilldown = new Drilldown { Name = "Safari versions", Categories = new[] { "Safari 5.0", "Safari 4.0", "Safari Win 5.0", "Safari 4.1", "Safari/Maxthon", "Safari 3.1", "Safari 4.1" }, Data = new Data(new object[] { 4.55, 1.42, 0.23, 0.21, 0.20, 0.19, 0.14 }), Color = Color.FromName("colors[3]") } }, new Point { Y = 2.14, Color = Color.FromName("colors[4]"), Drilldown = new Drilldown { Name = "Opera versions", Categories = new[] { "Opera 9.x", "Opera 10.x", "Opera 11.x" }, Data = new Data(new object[] { 0.12, 0.37, 1.65 }), Color = Color.FromName("colors[4]") } } }); List <Point> browserData = new List <Point>(categories.Length); List <Point> versionsData = new List <Point>(); for (int i = 0; i < categories.Length; i++) { browserData.Add(new Point { Name = categories[i], Y = data.SeriesData[i].Y, Color = data.SeriesData[i].Color }); for (int j = 0; j < data.SeriesData[i].Drilldown.Categories.Length; j++) { Drilldown drilldown = data.SeriesData[i].Drilldown; versionsData.Add(new Point { Name = drilldown.Categories[j], Y = Number.GetNumber(drilldown.Data.ArrayData[j]), Color = drilldown.Color }); } } Highcharts chart = new Highcharts("chart") .InitChart(new Chart { DefaultSeriesType = ChartTypes.Pie }) .SetTitle(new Title { Text = "Browser market share, April, 2011" }) .SetSubtitle(new Subtitle { Text = "Total percent market share" }) .SetPlotOptions(new PlotOptions { Pie = new PlotOptionsPie { Shadow = false } }) .SetTooltip(new Tooltip { Formatter = @"function() { return '<b>'+ this.point.name +'</b>: '+ this.y +' %';}" }) .AddJavascripVariable("colors", "Highcharts.getOptions().colors") .SetSeries(new[] { new Series { Name = "Browsers", Data = new Data(browserData.ToArray()), PlotOptionsPie = new PlotOptionsPie { Size = new PercentageOrPixel(60, true), DataLabels = new PlotOptionsPieDataLabels { Formatter = "function() { return this.y > 5 ? this.point.name : null; }", Color = Color.White, Distance = -30 } } }, new Series { Name = "Versions", Data = new Data(versionsData.ToArray()), PlotOptionsPie = new PlotOptionsPie { InnerSize = new PercentageOrPixel(60, true), DataLabels = new PlotOptionsPieDataLabels { Formatter = "function() { return this.y > 1 ? '<b>'+ this.point.name +':</b> '+ this.y +'%' : null; }" } } } }); return(View(chart)); }