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 Markers()
{
var model = BoxData.GetDataFromJson().GetRange(0, 20);
ViewBag.DemoSettingsModel = new ClientSettingsModel() { Settings = CreateMarkersSettings() };
return View(model);
}
private static IDictionary<string, object[]> CreateMarkersSettings()
{
var settings = new Dictionary<string, object[]>
{
{"Alignment", new object[]{"Auto","Bottom","Left","Right","Top"}},
{"Interaction", new object[]{"Move","Drag","None"}},
{"Lines", new object[]{"Both","Horizontal","Vertical","None"}},
};
return settings;
}
}
}
@using FinancialChartExplorer.Models
@model List<FinanceData>
@{
ViewBag.DemoSettings = true;
ClientSettingsModel demoSettingsModel = ViewBag.DemoSettingsModel;
}
<script type="text/javascript">
function customChangeAlignment(control, value) {
var marker = getLineMarker(control);
if (marker) {
marker.alignment = wijmo.chart.LineMarkerAlignment[value];
}
}
function customChangeInteraction(control,value) {
var marker = getLineMarker(control);
if (marker) {
marker.interaction = wijmo.chart.LineMarkerInteraction[value];
}
}
function customChangeLines(control,value) {
var marker = getLineMarker(control);
if (marker) {
marker.lines = wijmo.chart.LineMarkerLines[value];
}
}
function lineMarkerContent(ht, pt) {
var item = ht.series.collectionView.items[ht.pointIndex];
if (item) {
return 'Date: ' + wijmo.Globalize.format(ht.x, 'MMM-dd') + '<br/>' +
'High: ' + item.High.toFixed() + '<br/>' +
'Low: ' + item.Low.toFixed() + '<br/>' +
'Open: ' + item.Open.toFixed() + '<br/>' +
'Close: ' + item.Close.toFixed() + '<br/>' +
'Volume: ' + item.Volume.toFixed();
}
}
function getLineMarker(control) {
return c1.getExtender(control, 'LineMarker');
}
</script>
@(Html.C1().FinancialChart()
.Id(demoSettingsModel.ControlId)
.Bind(Model)
.BindingX("X")
.ChartType(C1.Web.Mvc.Finance.ChartType.Candlestick)
.Series(sers =>
{
sers.Add().Binding("High,Low,Open,Close,Volume").Name("BOX");
})
.Tooltip(tp => tp.Content(""))
.AddLineMarker(lm => lm.Id("LineMarker")
.Alignment(C1.Web.Mvc.Chart.LineMarkerAlignment.Auto)
.Lines(C1.Web.Mvc.Chart.LineMarkerLines.Both)
.DragContent(true)
.Interaction(C1.Web.Mvc.Chart.LineMarkerInteraction.Move).Content("lineMarkerContent")))
@section Description{
<p>@Html.Raw(Resources.Home.Markers_Text0)</p>
<p>@Html.Raw(Resources.Home.Markers_Text1)</p>
}
@section Summary{
<p>@Html.Raw(Resources.Home.Markers_Text2)</p>
}