Box and Whisker Series
Box and Whisker series (AKA boxplots) show groups of numerical data through their quartiles. They have lines extending vertically from the boxes (whiskers) indicating variability outside the upper and lower quartiles.
To create a Box and Whisker chart, follow these steps:
- Create one or more BoxWhisker series objects,
- Configure the BoxWhisker series by setting their name and binding properties (they should be bound to properties that contain number arrays), and
- Set additional properties such as showOutliers and showInnerPoints if you want to fine-tune the display.
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | // This file locates: "Scripts/Lesson/C1FlexChart/AnalyticsBoxplot.js". c1.documentReady(function () { var theChart = wijmo.Control.getControl( '#theChart' ); theChart.itemsSource = getData(); // create BoxWhisker series for 'sales' and add it to the chart var sales = new wijmo.chart.analytics.BoxWhisker(); sales.name = 'Sales' ; sales.binding = 'sales' ; sales.groupWidth = .7; sales.gapWidth = .2; theChart.series.push(sales); // create BoxWhisker series for 'expenses' and add it to the chart var expenses = new wijmo.chart.analytics.BoxWhisker(); expenses.name = 'Expenses' ; expenses.binding = 'expenses' ; expenses.groupWidth = .7; expenses.gapWidth = .2; theChart.series.push(expenses); // customize the BoxWhisker series document.getElementById( 'innerPoints' ).addEventListener( 'click' , function (e) { theChart.series.forEach(function (series) { series.showInnerPoints = e.target. checked ; }); }); document.getElementById( 'outliers' ).addEventListener( 'click' , function (e) { theChart.series.forEach(function (series) { series.showOutliers = e.target. checked ; }); }); // randomize the data document.getElementById( 'btnRandomize' ).addEventListener( 'click' , function () { theChart.itemsSource = getData(); }); // create some random data // the data items contain arrays of values rather than single values function getData() { var countries = 'US,Canada,Mexico,Germany,UK,France,Japan,Korea,China' .split( ',' ), data = []; for (var i = 0; i < countries.length; i++) { data.push({ country: countries[i], sales: getRandomArray(20, 10000), expenses: getRandomArray(20, 5000), }); } return data; } function getRandomArray(count, max) { var arr = []; for (var i = 0; i < count; i++) { arr.push( Math.random() * max / 3 + Math.random() * max / 3 + Math.random() * max / 3); } return arr; } }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 | using System.Web.Mvc; namespace LearnMvcClient.Controllers { public partial class C1FlexChartController : Controller { // GET: AnalyticsBoxplot public ActionResult AnalyticsBoxplot() { return View(); } } } |
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 38 | < h1 > @Html .Raw(Resources.C1FlexChart.AnalyticsBoxplot_Title) </ h1 > < p > @Html .Raw(Resources.C1FlexChart.AnalyticsBoxplot_Text1) </ p > < p > @Html .Raw(Resources.C1FlexChart.AnalyticsBoxplot_Text2) </ p > < ol > < li > @Html .Raw(Resources.C1FlexChart.AnalyticsBoxplot_Text3) </ li > < li > @Html .Raw(Resources.C1FlexChart.AnalyticsBoxplot_Text4) </ li > < li > @Html .Raw(Resources.C1FlexChart.AnalyticsBoxplot_Text5) </ li > </ ol > < div class = "demo-settings" > < label for = "innerPoints" > @Html .Raw(Resources.C1FlexChart.AnalyticsBoxplot_Text6) </ label > < input id = "innerPoints" type = "checkbox" >< br /> < label for = "outliers" > @Html .Raw(Resources.C1FlexChart.AnalyticsBoxplot_Text7) </ label > < input id = "outliers" type = "checkbox" >< br /> < label for = "btnRandomize" > @Html .Raw(Resources.C1FlexChart.AnalyticsBoxplot_Text8)</ label > < button id = "btnRandomize" class = "btn btn-default" > @Resources .Resource.Btn_Go </ button > </ div > @ (Html.C1().FlexChart().Id( "theChart" ) .BindingX( "country" ) .Tooltip(t=>t.Content( "{seriesName}: <b>{x}</b>" )) ) |