/// <reference path="~/GeneratedArtifacts/viewModel.js" />
/// <reference path="../Scripts/wijmo.cba.js" />

var tooltipContent = function (ht) {
    var item = ht.series.collectionView.items[ht.pointIndex];
    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();
};

myapp.ChartFinanceData.FlexChart_render = function (element, contentItem) {
    var chart = new c1.cba.FlexChart($(element), contentItem);
    var collectionView = new c1.cba.LightSwitchCollectionView(contentItem);
    chart.wjControl.itemsSource = collectionView;
    chart.wjControl.tooltip.content = tooltipContent;
    myapp.chart = chart.wjControl;
};

myapp.ChartFinanceData.ChartType_render = function (element, contentItem) {
    $("<select><option>Candlestick</option><option>HighLowOpenClose</option></select>")
    .appendTo($(element))
    .change(function () {
        myapp.chart.series[0].chartType = $(this).val();
    });
};