ComponentOne
Web API Explorer ASP.NET Web API Explorer

MVCFlexChart

ErrorBar

This sample demonstrates how to export a MVC FlexChart ErrorBar series to image file.

Features

PopulationChinaIndiaUSAIndonesiaBrazil04008001,200

Settings

Export
Export Format : Height :
Width :
Export Name :

Description

This sample demonstrates how to export a MVC FlexChart ErrorBar series to image file.
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
using C1.Web.Mvc.Chart;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using WebApiExplorer.Models;
 
namespace WebApiExplorer.Controllers
{
    public partial class MVCFlexChartController : Controller
    {
        private List<PopulationByCountry> _populationByCountry = PopulationByCountry.GetData();
        public ActionResult ErrorBar()
        {
            ViewBag.Options = _flexChartModel;
            var width = new object[] { 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 };
            var boolValues = new object[] { false, true };
            ViewBag.DemoSettingsModel = new ClientSettingsModel
            {
                Settings = new Dictionary<string, object[]>
                {
                    {"Direction", Enum.GetValues(typeof(ErrorBarDirection)).Cast<object>().ToArray()},
                    {"ErrorAmount", Enum.GetValues(typeof(ErrorAmount)).Cast<object>().ToArray()},
                    {"Value", new object[]{50, 100, 150, 200}},
                    {"EndStyle", Enum.GetValues(typeof(ErrorBarEndStyle)).Cast<object>().ToArray()}
                }
            };
 
            return View(_populationByCountry);
        }
    }
}
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
@model IEnumerable<PopulationByCountry>
@{
    ImageExportOptions optionsModel = ViewBag.Options;
    ViewBag.DemoSettings = true;
}
<script>
 
    function setProperty(control, property, value) {
        control.series.forEach(function (serie) {
            serie[property] = value;
        });
    }
 
    function customChangeDirection(control, value) {
        setProperty(control, 'direction', value);
    }
 
    function customChangeErrorAmount(control, value) {
        setProperty(control, 'errorAmount', value);
    }
 
    function customChangeValue(control, value) {
        setProperty(control, 'value', value);
    }
 
    function customChangeEndStyle(control, value) {
        setProperty(control, 'endStyle', value);
    }
 
</script>
 
@(Html.C1().FlexChart().Height(300)
    .Id(optionsModel.ControlId)
    .Bind("Country", "Population", Model)
    .Series(ser =>
    {
        ser.AddErrorBar().Name("Population").Value(50)
            .ErrorBarStyle(errorBarStyle => errorBarStyle.Fill("#e6e6e6").Stroke("#918254").StrokeWidth(2));
    })
)
 
@section Settings{
    @Html.Partial("_ImageExportOptions", optionsModel)
}
 
@section Description{
    @Html.Raw(Resources.MVCFlexChart.ErrorBar_Text0)
}