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

function formatItem(engine, hitTestInfo, defaultFormatter) {
    var fsz = engine.fontSize;
    engine.fontSize = '10';
    defaultFormatter();
    var point = hitTestInfo.point.clone();
    var text = hitTestInfo.name + '=' + hitTestInfo.value.toFixed(1);
    var sz = engine.measureString(text);
    var fill = engine.fill;
    engine.fill = 'white';
    engine.drawRect(point.x - 2 - sz.width / 2, point.y - sz.height + 10, sz.width + 4, sz.height);
    engine.fill = fill;
    point.x -= sz.width / 2;
    point.y += 9;
    engine.drawString(text, point);
    engine.fontSize = fsz;
}

myapp.PieFormatItem.FlexPie_render = function (element, contentItem) {
    var pie = new c1.cba.FlexPie($(element), contentItem);
    var collectionView = new c1.cba.LightSwitchCollectionView(contentItem);
    pie.wjControl.itemFormatter = formatItem;
    pie.wjControl.itemsSource = collectionView;
};

