using System.Windows;
using System.Collections.Generic;
using Telerik.Windows.Controls.Charting;
using System.Windows.Media;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();

            List<ChartData> data = new List<ChartData>();
            data.Add(new ChartData() { YValue = 21, PointData = "F1 M 6.5,3.5 L 3.5,0.5 0.5,3.5 3.5,6.5 0.5,9.5 3.5,12.5 6.5,9.5 9.5,12.5 12.5,9.5 9.5,6.5 12.5,3.5 9.5,0.5 6.5,3.5 Z" });
            data.Add(new ChartData() { YValue = 31, PointData = "M0.5,0.5 L11.5,0.5 L11.5,13.5 L0.5,13.5 z" });
            data.Add(new ChartData() { YValue = 11, PointData = "F1 M 6.5,3.5 L 3.5,0.5 0.5,3.5 3.5,6.5 0.5,9.5 3.5,12.5 6.5,9.5 9.5,12.5 12.5,9.5 9.5,6.5 12.5,3.5 9.5,0.5 6.5,3.5 Z" });
            data.Add(new ChartData() { YValue = 11, PointData = "M0.5,0.5 L11.5,0.5 L11.5,13.5 L0.5,13.5 z" });

            RadChart1.DefaultSeriesDefinition = new LineSeriesDefinition() { PointMarkItemStyle = this.Grid1.Resources["CustomPointMarkStyle"] as Style, ShowItemToolTips = true };
            RadChart1.DefaultView.ChartArea.ItemToolTipOpening += new ItemToolTipEventHandler(ChartArea_ItemToolTipOpening);
            RadChart1.ItemsSource = data;
        }

        private void ChartArea_ItemToolTipOpening(ItemToolTip2D tooltip, ItemToolTipEventArgs e)
        {
            if (e.DataPoint.YValue > 25)
            {
                tooltip.Foreground = new SolidColorBrush(Colors.White);
                tooltip.Background = new SolidColorBrush(Colors.Red);
            }
            else
            {
                tooltip.Foreground = new SolidColorBrush(Colors.White);
                tooltip.Background = new SolidColorBrush(Colors.Green);
            }
        }
    }

    public class ChartData
    {
        public int YValue
        {
            get;
            set;
        }

        public string PointData
        {
            get;
            set;
        }
    }
}
