ComponentOne
Web API Explorer ASP.NET Web API Explorer
MVCFlexRadar

MVCFlexRadar

概要

機能

Settings

エクスポート
エクスポート形式:
高さ:
幅:
Export Name :

Description

このサンプルでは、MVC FlexRadar を画像ファイルにエクスポートする方法を示します。
using System.Collections.Generic;
using System.Web.Mvc;
using WebApiExplorer.Models;

namespace WebApiExplorer.Controllers
{
    public partial class MVCFlexRadarController : Controller
    {
        private readonly ImageExportOptions _imageExportOptions = new ImageExportOptions
        {
            Exporter = "wijmo.chart.ImageExporter"
        };

        public ActionResult Index()
        {
            ViewBag.Options = _imageExportOptions;
            ViewBag.DemoSettingsModel = new ClientSettingsModel
            {
                Settings = CreateRadarSettings(),
                DefaultValues = GetIndexDefaultValues()
            };

            return View(ProductSales.GetData());
        }

        private static IDictionary<string, object[]> CreateRadarSettings()
        {
            var settings = new Dictionary<string, object[]>
            {
                {"ChartType", new object[]{"Column", "Scatter", "Line", "LineSymbols", "Area"}},
                {"Stacking", new object[]{"None", "Stacked", "Stacked100pc"}},
                {"StartAngle", new object[]{0, 60, 120, 180, 240, 300, 360}},
                {"TotalAngle", new object[]{60, 120, 180, 240, 300, 360}},
                {"Reversed", new object[]{false, true}}
            };

            return settings;
        }

        private static IDictionary<string, object> GetIndexDefaultValues()
        {
            var defaultValues = new Dictionary<string, object>
            {
                {"TotalAngle", 360}
            };

            return defaultValues;
        }
    }
}
@model IEnumerable<ProductSales>
@using C1.Web.Mvc.Chart
@{
    ClientSettingsModel settings = ViewBag.DemoSettingsModel;
    ImageExportOptions optionsModel = ViewBag.Options;
    ViewBag.DemoSettings = true;
}

@(Html.C1().FlexRadar().Id(optionsModel.ControlId)
    .Bind("Country", "Downloads", Model)
    .ChartType(RadarChartType.Column)
    .DataLabel(label =>
    {
        label.Content("{y}");
    })
    .Series(ser =>
    {
        ser.Add().Name("Downloads");
        ser.Add().Binding("Sales").Name("Sales");
    })
    .Legend(Position.Top)
    .Width("500px")
    .Height("400px")
)
@section Settings{
    @Html.Partial("_ImageExportOptions", optionsModel)
}

@section Description{
    @Html.Raw(Resources.MVCFlexRadar.Index_Text0)
}