using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FinancialChartExplorer.Models;
namespace FinancialChartExplorer.Controllers
{
public partial class HomeController : Controller
{
public ActionResult Kagi()
{
var model = BoxData.GetDataFromJson();
ViewBag.DemoSettingsModel = new ClientSettingsModel() { Settings = CreateKagiSettings() };
return View(model);
}
private static IDictionary<string, object[]> CreateKagiSettings()
{
var settings = new Dictionary<string, object[]>
{
{"Options.Kagi.ReversalAmount", new object[]{"2","3","4","5","6","7","8","9","10"}},
{"Options.Kagi.RangeMode", new object[]{"Fixed","ATR","Percentage"}},
{"Options.Kagi.Fields", new object[]{"High","Low","Open","Close","HighLow","HL2","HLC3","HLOC4"}},
};
return settings;
}
}
}
@using FinancialChartExplorer.Models
@model List<FinanceData>
@{
ViewBag.DemoSettings = true;
ClientSettingsModel demoSettingsModel = ViewBag.DemoSettingsModel;
}
<script type="text/javascript">
function customChangeOptions_Kagi_ReversalAmount(control, value) {
var reversalAmount = +value;
control.options.kagi.reversalAmount = control.options.kagi.rangeMode === wijmo.chart.finance.RangeMode.Percentage ? (reversalAmount / 100) : reversalAmount;
control.invalidate();
}
function customChangeOptions_Kagi_RangeMode(control, value) {
var reversalAmount = control.options.kagi.reversalAmount;
if (value !== "Percentage") {
if (reversalAmount < 1) {
control.options.kagi.reversalAmount = Math.round(reversalAmount * 100);
}
} else {
if (reversalAmount > 1) {
control.options.kagi.reversalAmount = reversalAmount / 100;
}
}
control.options.kagi.rangeMode = wijmo.chart.finance.RangeMode[value];
control.invalidate();
}
function convertOptions_Kagi_Fields(value) {
return wijmo.chart.finance.DataFields[value];
}
</script>
@(Html.C1().FinancialChart()
.Id(demoSettingsModel.ControlId)
.Bind(Model)
.BindingX("X")
.ChartType(C1.Web.Mvc.Finance.ChartType.Kagi)
.Options(o => { o.KagiReversalAmount(2); o.KagiFields(C1.Web.Mvc.Finance.DataFields.High); o.KagiRangeMode(C1.Web.Mvc.Finance.RangeMode.Fixed); })
.Series(sers =>
{
sers.Add().Binding("High,Low,Open,Close").Name("BOX");
})
.Tooltip(t => t.Content("financialTooltip")))
@section Description{
<p>@Html.Raw(Resources.Home.Kagi_Text0)</p>
<p>@Html.Raw(Resources.Home.Kagi_Text1)</p>
}
@section Summary{
<p>@Html.Raw(Resources.Home.Kagi_Text2)</p>
}