Wijmo5FlexChart
Wijmo5FlexChart
Box & Whisker
This sample demonstrates how to export a Wijmo 5 FlexChart Box and Whisker series to image file.
Features
Group Width:
Gap Width:
Quartile Calculation:
Inclusive Median
Settings
Export
Export Format :
Height :
Width :
Export Name :
PNG
Description
This sample demonstrates how to export a Wijmo 5 FlexChart Box and Whisker series to image file.
1 2 3 4 5 6 7 8 9 10 11 12 13 | using System.Web.Mvc; namespace WebApiExplorer.Controllers { public partial class Wijmo5FlexChartController : Controller { public ActionResult BoxWhisker() { ViewBag.Options = _flexChartModel; 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 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | @using WebApiExplorer.Models @ { ImageExportOptions optionsModel = ViewBag.Options; ViewBag.DemoSettings = true ; } < div id = "@(optionsModel.ControlId)" ></ div > < div > < div class = "col-md-6" > @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_GroupWidth) < div id = "boxGroupWidth" ></ div > </ div > < div class = "col-md-6" > @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_GapWidth) < div id = "boxGapWidth" ></ div > </ div > < div class = "col-md-6" > < label for = "boxShowMeanLine" > @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_ShowMeanLine)</ label > < input id = "boxShowMeanLine" type = "checkbox" /> </ div > < div class = "col-md-6" > < label for = "boxShowMeanMarker" > @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_ShowMeanMarker)</ label > < input id = "boxShowMeanMarker" type = "checkbox" /> </ div > < div class = "col-md-6" > < label for = "boxShowInnerPoints" > @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_ShowInnerPoints)</ label > < input id = "boxShowInnerPoints" type = "checkbox" /> </ div > < div class = "col-md-6" > < label for = "boxShowOutliers" > @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_ShowOutliers)</ label > < input id = "boxShowOutliers" type = "checkbox" /> </ div > < div class = "col-md-6" > < label for = "boxRotated" > @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_Rotated)</ label > < input id = "boxRotated" type = "checkbox" /> </ div > < div class = "col-md-6" > < label for = "boxShowLabel" > @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_ShowLabel)</ label > < input id = "boxShowLabel" type = "checkbox" /> </ div > < div > @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_QuartileCalculation) < select id = "boxQuartileCalculation" > < option value = "0" selected = "selected" >Inclusive Median</ option > < option value = "1" >Exclusive Median</ option > </ select > </ div > </ div > @section Settings{ @Html .Partial( "_ImageExportOptions" , optionsModel) } <script> var boxwhiskerChart = new wijmo.chart.FlexChart( '#@(optionsModel.ControlId)' ), groupWidth = new wijmo.input.InputNumber( '#boxGroupWidth' ), gapWidth = new wijmo.input.InputNumber( '#boxGapWidth' ), quartileCalculation = new wijmo.input.Menu( '#boxQuartileCalculation' ); // populate itemsSource // generate some random data var countries = 'US,Germany,UK,Japan,Italy,Greece' .split( ',' ), funnelData = [], boxData = []; for ( var i = 0; i < countries.length ; i++) { boxData.push({ country: countries[i], downloads: [getData(), getData(), getData(), getData(), getData(), getData(), getData(), getData(), getData(), getData()], sales: [getData(), getData(), getData(), getData(), getData(), getData(), getData(), getData(), getData(), getData()], expenses: [getData(), getData(), getData(), getData(), getData(), getData(), getData(), getData(), getData(), getData()] }); } function getData() { return Math.round(Math.random() * 100); } //create Box & Whisker series boxwhiskerChart.beginUpdate(); boxwhiskerChart.tooltip.content = function (hti) { return '<b>' + hti.name + '</b> - <b>' + hti.x + '</b></br>' + '<b>min</b>: ' + hti.item.min + '</br>' + '<b>firstQuartile</b>: ' + hti.item.firstQuartile + '</br>' + '<b>median</b>: ' + hti.item.median + '</br>' + '<b>thirdQuartile</b>: ' + hti.item.thirdQuartile + '</br>' + '<b>max</b>: ' + hti.item.max + '</br>' + '<b>mean</b>: ' + hti.item.mean + '</br>' ; } boxwhiskerChart.itemsSource = boxData; boxwhiskerChart.bindingX = 'country' ; var boxwhisker1 = new wijmo.chart.analytics.BoxWhisker(); boxwhisker1.name = 'downloads' ; boxwhisker1.binding = 'downloads' ; boxwhiskerChart.series.push(boxwhisker1); var boxwhisker2 = new wijmo.chart.analytics.BoxWhisker(); boxwhisker2.name = 'sales' ; boxwhisker2.binding = 'sales' ; boxwhiskerChart.series.push(boxwhisker2); var boxwhisker3 = new wijmo.chart.analytics.BoxWhisker(); boxwhisker3.name = 'expenses' ; boxwhisker3.binding = 'expenses' ; boxwhiskerChart.series.push(boxwhisker3); boxwhiskerChart.endUpdate(); // groupWidth - initialize InputNumber's properties groupWidth.min = 0; groupWidth.max = 1; groupWidth.step = 0.1; groupWidth.valueChanged.addHandler( function (sender) { if (sender.value < sender.min || sender.value > sender.max) { return ; } boxwhisker1.groupWidth = sender.value; boxwhisker2.groupWidth = sender.value; boxwhisker3.groupWidth = sender.value; boxwhiskerChart.refresh( true ); }); groupWidth.value = 0.8; // gapWidth - initialize InputNumber's properties gapWidth.min = 0; gapWidth.max = 1; gapWidth.step = 0.1; gapWidth.valueChanged.addHandler( function (sender) { if (sender.value < sender.min || sender.value > sender.max) { return ; } boxwhisker1.gapWidth = sender.value; boxwhisker2.gapWidth = sender.value; boxwhisker3.gapWidth = sender.value; boxwhiskerChart.refresh( true ); }); gapWidth.value = 0.1; updateMenuHeader(quartileCalculation); quartileCalculation.selectedIndexChanged.addHandler( function () { if (quartileCalculation.selectedValue) { var val = +quartileCalculation.selectedValue; boxwhisker1.quartileCalculation = val; boxwhisker2.quartileCalculation = val; boxwhisker3.quartileCalculation = val; updateMenuHeader(quartileCalculation); boxwhiskerChart.refresh( true ); } }); var showMeanLine = document.getElementById( 'boxShowMeanLine' ); showMeanLine.addEventListener( 'click' , function () { boxwhisker1.showMeanLine = this . checked ; boxwhisker2.showMeanLine = this . checked ; boxwhisker3.showMeanLine = this . checked ; boxwhiskerChart.refresh( true ); }); var showMeanMarker = document.getElementById( 'boxShowMeanMarker' ); showMeanMarker.addEventListener( 'click' , function () { boxwhisker1.showMeanMarker = this . checked ; boxwhisker2.showMeanMarker = this . checked ; boxwhisker3.showMeanMarker = this . checked ; boxwhiskerChart.refresh( true ); }); var boxShowInnerPoints = document.getElementById( 'boxShowInnerPoints' ); boxShowInnerPoints.addEventListener( 'click' , function () { boxwhisker1.showInnerPoints = this . checked ; boxwhisker2.showInnerPoints = this . checked ; boxwhisker3.showInnerPoints = this . checked ; boxwhiskerChart.refresh( true ); }); var boxShowOutliers = document.getElementById( 'boxShowOutliers' ); boxShowOutliers.addEventListener( 'click' , function () { boxwhisker1.showOutliers = this . checked ; boxwhisker2.showOutliers = this . checked ; boxwhisker3.showOutliers = this . checked ; boxwhiskerChart.refresh( true ); }); var boxRotated = document.getElementById( 'boxRotated' ); boxRotated.addEventListener( 'click' , function () { boxwhiskerChart.rotated = this . checked ; boxwhiskerChart.refresh( true ); }); var boxShowLabel = document.getElementById( 'boxShowLabel' ); boxShowLabel.addEventListener( 'click' , function () { boxwhiskerChart.dataLabel.content = this . checked ? '{y}' : '' ; boxwhiskerChart.refresh( true ); }); // helper function for Menu headers function updateMenuHeader(menu) { menu.header = menu.text; } </script> @section Description{ @Html .Raw(Resources.Wijmo5FlexChart.BoxWhisker_Text0) } |