ラベル

ラベル

機能

Settings

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

Description

このサンプルは、さまざまなラベルが付いた MVC FlexChart を画像ファイルにエクスポートする方法を示します。
using C1.Web.Mvc.Chart;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApiExplorer.Models;

namespace WebApiExplorer.Controllers
{
    public partial class MVCFlexChartController : Controller
    {
        const string CHART_TYPE = "ChartType";
        const string DATA_LABEL_POSITION = "DataLabel.Position";
        const string DATA_LABEL_BORDER = "DataLabel.Border";

        private static IDictionary<string, object[]> CreateLabelSettings()
        {
            var settings = new Dictionary<string, object[]>
            {
                {CHART_TYPE, new object[]{"Column", "Bar", "Scatter", "Line", "LineSymbols", "Area", "Spline", "SplineSymbols", "SplineArea"}},
                {DATA_LABEL_POSITION, new object[]{LabelPosition.Top, LabelPosition.Right, LabelPosition.Bottom, LabelPosition.Left, LabelPosition.None}},
                {DATA_LABEL_BORDER, new object[]{false, true}},
            };

            return settings;
        }

        public ActionResult Labels()
        {
            var model = new ClientSettingsModel
            {
                Settings = CreateLabelSettings(),
                HeaderNames = new Dictionary<string, string>
                {
                    {CHART_TYPE, Resources.Wijmo5FlexChart.Labels_ChartType },
                    {DATA_LABEL_POSITION, Resources.Wijmo5FlexChart.Labels_LabelPosition },
                    {DATA_LABEL_BORDER, Resources.Wijmo5FlexChart.Labels_LabelsBorder }
                }
            };
            ViewBag.Options = _flexChartModel;
            return View(model);
        }
    }
}
@model ClientSettingsModel
@{
    ViewBag.DemoSettings = true;
    ImageExportOptions optionsModel = ViewBag.Options;
    ViewBag.DemoSettingsModel = Model;
    IEnumerable<Fruit> fruits = Fruit.GetFruitsSales();
}

@(Html.C1().FlexChart().Id(optionsModel.ControlId).Bind("Name", fruits).Series(sers =>
{
    sers.Add().Binding("MarPrice").Name("March");
    sers.Add().Binding("AprPrice").Name("April");
    sers.Add().Binding("MayPrice").Name("May");
}).DataLabel(dl => dl.Position(C1.Web.Mvc.Chart.LabelPosition.Top).Content("{y}")))

@section Settings{
    @Html.Partial("_ImageExportOptions", optionsModel)
}

@section Description{
    @Html.Raw(Resources.MVCFlexChart.Labels_Text0)
}