示例#1
0
        private static ChartPlotter SamplePlot()
        {
            ChartPlotter           plotter  = new ChartPlotter();
            HorizontalDateTimeAxis dateAxis = new HorizontalDateTimeAxis();

            plotter.HorizontalAxis = dateAxis;

            // chart.Children.Add(plotter);

            int    size   = 15;
            Random random = new Random();

            DateTime[] dates   = new DateTime[size];
            int[]      values1 = new int[size];
            int[]      values2 = new int[size];

            for (int i = 0; i < size; ++i)
            {
                dates[i]   = DateTime.Today.AddDays(i);
                values1[i] = random.Next(0, 10);
                values2[i] = random.Next(5, 15);
            }

            var datesDataSource = new EnumerableDataSource <DateTime>(dates);

            datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));

            var numberOpenDataSource = new EnumerableDataSource <int>(values1);

            numberOpenDataSource.SetYMapping(y => y);

            var numberOpenDataSource2 = new EnumerableDataSource <int>(values2);

            numberOpenDataSource2.SetYMapping(y => y);

            var datesDataSource2 = new EnumerableDataSource <DateTime>(dates);

            datesDataSource2.SetXMapping(x => dateAxis.ConvertToDouble(((DateTime)x).AddDays(2)));

            CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, numberOpenDataSource);
            CompositeDataSource compositeDataSource2 = new CompositeDataSource(
                datesDataSource2,
                numberOpenDataSource2);
            LinearPalette pal = new LinearPalette(Colors.Crimson, Colors.DarkBlue);

            plotter.AddLineGraph(compositeDataSource1,
                                 new Pen(Brushes.Blue, 2),
                                 new CirclePointMarker {
                Size = 10.0, Fill = Brushes.Red
            },
                                 new PenDescription("1n"));
            plotter.AddLineGraph(compositeDataSource2,
                                 new Pen(Brushes.Cyan, 1),
                                 new TrianglePointMarker {
                Size = 5.0
            },
                                 new PenDescription("2n"));

            return(plotter);
        }
示例#2
0
        void LogYWindow_Loaded(object sender, RoutedEventArgs e)
        {
            ChartPlotter plotter = new ChartPlotter();

            plotter.Children.Add(new CursorCoordinateGraph());

            plotter.DataTransform = new Log10YTransform();
            VerticalAxis axis = new VerticalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider()
            };

            plotter.MainVerticalAxis = axis;

            plotter.AxisGrid.DrawVerticalMinorTicks = true;

            const int count = 500;

            double[] xs = Enumerable.Range(1, count).Select(x => x * 0.01).ToArray();
            EnumerableDataSource <double> xDS = xs.AsXDataSource();

            var pows        = xs.Select(x => Math.Pow(10, x));
            var linear      = xs.Select(x => x);
            var logXs       = Enumerable.Range(101, count).Select(x => x * 0.01);
            var logarithmic = logXs.Select(x => Math.Log10(x));

            plotter.AddLineGraph(pows.AsYDataSource().Join(xDS), "f(x) = 10^x");
            plotter.AddLineGraph(linear.AsYDataSource().Join(xDS), "f(x) = x");
            plotter.AddLineGraph(logarithmic.AsYDataSource().Join(logXs.AsXDataSource()), "f(x) = log(x)");

            Content = plotter;
        }
        private void CreatePowGraphOnLeftYAxis(ChartPlotter plotter)
        {
            EnumerableDataSource <TPoint> edsPow = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = Math.Pow(10, s / 700.0)
            }
                                                 ).ToList());

            edsPow.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsPow.SetYMapping(s => s.Y);

            double minData, maxData, M, B;

            GetMinAndMaxForEDS(edsPow, out minData, out maxData);
            Get_M_and_B(Math.Floor(Math.Log10(minData)), Math.Ceiling(Math.Log10(maxData)), out M, out B);

            Func <double, double> ConvertToDouble = s => M *Math.Log10(s) + B;

            Func <double, double> ConvertFromDouble = t => Math.Pow(10.0, (t - B) / M);
            Func <Point, Point>   DataToViewport    = s => new Point(s.X, ConvertToDouble(s.Y));
            Func <Point, Point>   ViewportToData    = t => new Point(t.X, ConvertFromDouble(t.Y));

            Brush          brushPow   = new SolidColorBrush(Colors.Green);
            Pen            linePenPow = new Pen(brushPow, 2.0);
            PenDescription descPow    = new PenDescription("f(x) = 10 ^ x");
            LineGraph      lg         = plotter.AddLineGraph(edsPow, linePenPow, descPow);

            lg.DataTransform            = new LambdaDataTransform(DataToViewport, ViewportToData);
            yAxisLeft.ConvertFromDouble = ConvertFromDouble;
            yAxisLeft.ConvertToDouble   = ConvertToDouble;
        }
        private void CreateLinearGraphOnRightYAxis(ChartPlotter plotter)
        {
            EnumerableDataSource <TPoint> edsLinear = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = s
            }
                                                 ).ToList());

            edsLinear.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsLinear.SetYMapping(s => s.Y);

            double minData, maxData, M, B;

            GetMinAndMaxForEDS(edsLinear, out minData, out maxData);
            Get_M_and_B(minData, maxData, out M, out B);

            Func <double, double> ConvertToDouble   = s => M * s + B;
            Func <double, double> ConvertFromDouble = t => (t - B) / M;
            Func <Point, Point>   DataToViewport    = s => new Point(s.X, ConvertToDouble(s.Y));
            Func <Point, Point>   ViewportToData    = t => new Point(t.X, ConvertFromDouble(t.Y));

            Brush          brushLinear   = new SolidColorBrush(Colors.Blue);
            Pen            linePenLinear = new Pen(brushLinear, 2.0);
            PenDescription descLinear    = new PenDescription("f(x) = x");
            LineGraph      lg            = plotter.AddLineGraph(edsLinear, linePenLinear, descLinear);

            lg.DataTransform             = new LambdaDataTransform(DataToViewport, ViewportToData);
            yAxisRight.ConvertFromDouble = ConvertFromDouble;
            yAxisRight.ConvertToDouble   = ConvertToDouble;
        }
示例#5
0
        public Window1()
        {
            InitializeComponent();

            Content = plot;

            plot.MainHorizontalAxis = axis;

            const int N = 10;

            double[]   x    = new double[N];
            double[]   y    = new double[N];
            DateTime[] date = new DateTime[N];

            for (int i = 0; i < N; i++)
            {
                x[i]    = i * 0.1;
                y[i]    = Math.Sin(x[i]);
                date[i] = DateTime.Now.AddMinutes(-N + i);
            }

            EnumerableDataSource <double> xs = new EnumerableDataSource <double>(x);

            xs.SetYMapping(_x => _x);
            EnumerableDataSource <DateTime> ys = new EnumerableDataSource <DateTime>(date);

            ys.SetXMapping(axis.ConvertToDouble);

            CompositeDataSource ds = new CompositeDataSource(xs, ys);

            plot.AddLineGraph(ds);
        }
示例#6
0
        public virtual UIElement process(Function f)
        {
            if (f == null)
            {
                return(null);
            }

            ChartPlotter plotter = new ChartPlotter();

            LinkedList <double> x = new LinkedList <double>(), y = new LinkedList <double>();

            Function processedFunction = processFunction(f);

            for (double _x = processedFunction.minX; _x < processedFunction.maxX + processedFunction.step / 2; _x += processedFunction.step)
            {
                x.AddLast(_x);
                y.AddLast(processedFunction.getValue(_x));
            }

            var xDataSource = x.AsXDataSource();
            var yDataSource = y.AsYDataSource();

            CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);

            plotter.AddLineGraph(compositeDataSource, System.Windows.Media.Colors.Blue, 3, title);

            return((UIElement)plotter);
        }
示例#7
0
        public void AddToPlotter(ChartPlotter plotter)
        {
            var ds = new EnumerableDataSource <Point>(_points);

            ds.SetXMapping(p => ((HorizontalDateTimeAxis)plotter.HorizontalAxis).ConvertToDouble(p.Time));
            ds.SetYMapping(p => p.Value);
            _linegraph = plotter.AddLineGraph(ds, _color, 2, _name);
        }
示例#8
0
        private void timer_Tick(object sender, EventArgs e)
        {
            matrix.neighbours();
            matrix.actualizar();
            matrixrectangle_phase       = matrix.colorearphase(matrixrectangle_phase);
            matrixrectangle_temperature = matrix.colortemperature(matrixrectangle_temperature);

            listPoint_solids  = matrix.contarsolids(listPoint_solids);
            listPoint_avgtemp = matrix.avgtemp(listPoint_avgtemp);

            RawDataSource d1 = new RawDataSource(listPoint_solids);
            RawDataSource d2 = new RawDataSource(listPoint_avgtemp);

            plot_phase.AddLineGraph(d1, Colors.Blue, 1, "Number solids");
            plot_phase.LegendVisible = false;
            plot_temp.AddLineGraph(d2, Colors.Red, 1, "Average temperature");
            plot_temp.LegendVisible = false;
        }
        public void Register(HotItem item, ObservableDataSource <ItemProxy> items)
        {
            items.SetYMapping(y => y.SellPrice);
            items.SetXMapping(x => HorizontalAxis.ConvertToDouble(x.DateTime));

            ChartPlotter.AddLineGraph(items, 2.0, item.Name + " S");

            chartItems.Add(item.DataId, items);
            item.PropertyChanged += item_PropertyChanged;
        }
示例#10
0
 public virtual void initChart()
 {
     clearLines();
     datalist.Clear();
     listgraph.Clear();
     testlock = false;
     t        = 0;
     foreach (KeyValuePair <string, string> pkg in pkglist)
     {
         datalist.Add(pkg.Key, new ObservableDataSource <Point>());
         listgraph.Add(chart.AddLineGraph(datalist[pkg.Key], colorpool[linenum++], 2, pkg.Key));//Color.FromRgb(72, 118, 255)
     }
 }
示例#11
0
        /// <summary>
        /// 绘制曲线
        /// </summary>
        private void Curve()
        {
            try
            {
                int        len = _aValues.Length / 2, index = 0;
                DateTime[] dates      = new DateTime[len];
                Double[]   numberOpen = new Double[len];
                Double[]   intDate    = new Double[len];
                for (int i = 0; i < _aValues.Length; ++i)
                {
                    if (_vValues[i] > 64436 && _aValues[i] > 0)
                    {
                        if (i > 0 && _vValues[i] == _vValues[i - 1])
                        {
                            continue;
                        }

                        //DateTime dt = Convert.ToDateTime("01/01/000" + (_vValues[i] - 64436));
                        DateTime dt = Convert.ToDateTime("01/01/000" + (i + 1));
                        dates[index] = dt;

                        //intDate[index] = (int)_vValues[i];
                        numberOpen[index] = (Double)_aValues[i];
                        index++;
                    }
                }

                var datesDataSource = new EnumerableDataSource <DateTime>(dates);
                datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));

                //var datesDataSource = new EnumerableDataSource<Double>(intDate);
                //datesDataSource.SetXMapping(x => dateAxis.ConvertFromDouble(x));
                var numberOpenDataSource = new EnumerableDataSource <Double>(numberOpen);
                numberOpenDataSource.SetYMapping(y => y);

                CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, numberOpenDataSource);

                plotter.AddLineGraph(compositeDataSource1,
                                     new Pen(Brushes.Red, 2),
                                     new CirclePointMarker {
                    Size = 2.0, Fill = Brushes.Blue
                },
                                     new PenDescription("Number bugs open"));
                plotter.Viewport.FitToView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#12
0
        void TimeChartControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (Env.Current.Mode == EnvironmentMode.Runtime)
            {
                foreach (TimeTrend trend in Trends)
                {
                    trend.ConvertToDouble = (_chart.HorizontalAxis as DateTimeAxis).ConvertToDouble;
                    _chart.AddLineGraph(trend.DataSource,
                                        (trend.Brush as System.Windows.Media.SolidColorBrush).Color,
                                        1, trend.Name);
                }
                dispatcherTimer          = new System.Windows.Threading.DispatcherTimer();
                dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
                dispatcherTimer.Interval = new TimeSpan(0, 0, 1);

                dispatcherTimer.Start();
            }
        }
示例#13
0
        public void drawgraph(List <int> y, List <int> x, ChartPlotter plotter1)
        {
            var datesDataSource = new EnumerableDataSource <int>(y);

            datesDataSource.SetXMapping(t => t);

            var numberOpenDataSource = new EnumerableDataSource <int>(x);

            numberOpenDataSource.SetYMapping(k => k);

            CompositeDataSource compositeDataSource1 = new
                                                       CompositeDataSource(datesDataSource, numberOpenDataSource);

            plotter1.Children.RemoveAll((typeof(LineGraph)));
            plotter1.AddLineGraph(compositeDataSource1,
                                  new Pen(Brushes.Blue, 2),
                                  new CirclePointMarker {
                Size = 0.0, Fill = Brushes.Red
            },
                                  new PenDescription("Angle variation"));


            plotter1.Viewport.FitToView();
        }
示例#14
0
        private void button_calculate_Click(object sender, RoutedEventArgs e)
        {
            // Calculate the simulation!
            try
            {
                if (isCalculatePressed == true)
                {
                    MessageBox.Show("To calculate something, first restart the situation");
                }
                else if (textBox_columns.Text != "" && textBox_rows.Text != "" && textBox_rho.Text != "" && textBox_P.Text != "" && textBox_T.Text != "" && textBox_M.Text != "" && textBox_R.Text != "" && textBox_E.Text != "" && textBox_gamma.Text != "" && textBox_theta.Text != "" && isCalculatePressed == false)
                {
                    int    rows    = Convert.ToInt32(textBox_rows.Text);
                    int    columns = Convert.ToInt32(textBox_columns.Text);
                    double rho     = Convert.ToDouble(textBox_rho.Text);
                    double P       = Convert.ToDouble(textBox_P.Text);
                    double T       = Convert.ToDouble(textBox_T.Text);
                    double M       = Convert.ToDouble(textBox_M.Text);
                    double R       = Convert.ToDouble(textBox_R.Text);
                    double Gamma   = Convert.ToDouble(textBox_gamma.Text);
                    double E       = Convert.ToDouble(textBox_E.Text);
                    double theta   = Convert.ToDouble(textBox_theta.Text);

                    matrix.setParameters(rows, columns, rho, P, T, M, R, Gamma, E, theta);

                    matrix.Initialize();
                    matrix.calculate();
                    matrix.calculatePoligons();
                    matrix.colorPolygons();
                    List <List <Polygon> > listPolygons = matrix.getListPolygons();
                    listPolygons_u   = listPolygons[0];
                    listPolygons_v   = listPolygons[1];
                    listPolygons_rho = listPolygons[2];
                    listPolygons_P   = listPolygons[3];
                    listPolygons_T   = listPolygons[4];
                    listPolygons_M   = listPolygons[5];

                    listCells = matrix.getListCells();

                    for (int i = 0; i < listPolygons_u.Count; i++)
                    {
                        listPolygons_u[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_u[i].MouseLeave += Polygon_MouseLeave;

                        grid_u.Children.Add(listPolygons_u[i]);

                        listPolygons_v[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_v[i].MouseLeave += Polygon_MouseLeave;

                        grid_v.Children.Add(listPolygons_v[i]);

                        listPolygons_rho[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_rho[i].MouseLeave += Polygon_MouseLeave;

                        grid_rho.Children.Add(listPolygons_rho[i]);

                        listPolygons_P[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_P[i].MouseLeave += Polygon_MouseLeave;

                        grid_P.Children.Add(listPolygons_P[i]);

                        listPolygons_T[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_T[i].MouseLeave += Polygon_MouseLeave;

                        grid_T.Children.Add(listPolygons_T[i]);

                        listPolygons_M[i].MouseEnter += Polygon_MouseEnter;
                        listPolygons_M[i].MouseLeave += Polygon_MouseLeave;

                        grid_M.Children.Add(listPolygons_M[i]);
                    }

                    listTables = matrix.createTables();

                    rectangle_gradient.Visibility = Visibility.Visible;

                    label_min.Visibility = Visibility.Visible;
                    label_max.Visibility = Visibility.Visible;


                    List <List <Point> > listPoints = matrix.calculateGraph();
                    RawDataSource        u_body     = new RawDataSource(listPoints[0]);
                    RawDataSource        v_body     = new RawDataSource(listPoints[1]);
                    RawDataSource        rho_body   = new RawDataSource(listPoints[2]);
                    RawDataSource        P_body     = new RawDataSource(listPoints[3]);
                    RawDataSource        T_body     = new RawDataSource(listPoints[4]);
                    RawDataSource        M_body     = new RawDataSource(listPoints[5]);

                    RawDataSource u_bnd   = new RawDataSource(listPoints[6]);
                    RawDataSource v_bnd   = new RawDataSource(listPoints[7]);
                    RawDataSource rho_bnd = new RawDataSource(listPoints[8]);
                    RawDataSource P_bnd   = new RawDataSource(listPoints[9]);
                    RawDataSource T_bnd   = new RawDataSource(listPoints[10]);
                    RawDataSource M_bnd   = new RawDataSource(listPoints[11]);

                    plot_u.AddLineGraph(u_body, Colors.Blue, 2, "Body");
                    plot_u.AddLineGraph(u_bnd, Colors.Red, 2, "Boundary");

                    plot_v.AddLineGraph(v_body, Colors.Blue, 2, "Body");
                    plot_v.AddLineGraph(v_bnd, Colors.Red, 2, "Boundary");

                    plot_rho.AddLineGraph(rho_body, Colors.Blue, 2, "Body");
                    plot_rho.AddLineGraph(rho_bnd, Colors.Red, 2, "Boundary");

                    plot_P.AddLineGraph(P_body, Colors.Blue, 2, "Body");
                    plot_P.AddLineGraph(P_bnd, Colors.Red, 2, "Boundary");

                    plot_T.AddLineGraph(T_body, Colors.Blue, 2, "Body");
                    plot_T.AddLineGraph(T_bnd, Colors.Red, 2, "Boundary");

                    plot_M.AddLineGraph(M_body, Colors.Blue, 2, "Body");
                    plot_M.AddLineGraph(M_bnd, Colors.Red, 2, "Boundary");

                    grid_plot_u.Children.Add(plot_u);
                    grid_plot_v.Children.Add(plot_v);
                    grid_plot_rho.Children.Add(plot_rho);
                    grid_plot_P.Children.Add(plot_P);
                    grid_plot_T.Children.Add(plot_T);
                    grid_plot_M.Children.Add(plot_M);

                    plot_u.Background   = Brushes.Transparent;
                    plot_v.Background   = Brushes.Transparent;
                    plot_rho.Background = Brushes.Transparent;
                    plot_P.Background   = Brushes.Transparent;
                    plot_T.Background   = Brushes.Transparent;
                    plot_M.Background   = Brushes.Transparent;

                    plot_u.Foreground   = Brushes.White;
                    plot_v.Foreground   = Brushes.White;
                    plot_rho.Foreground = Brushes.White;
                    plot_P.Foreground   = Brushes.White;
                    plot_T.Foreground   = Brushes.White;
                    plot_M.Foreground   = Brushes.White;

                    plot_u.Legend.Foreground   = Brushes.Black;
                    plot_v.Legend.Foreground   = Brushes.Black;
                    plot_rho.Legend.Foreground = Brushes.Black;
                    plot_P.Legend.Foreground   = Brushes.Black;
                    plot_T.Legend.Foreground   = Brushes.Black;

                    label_plot_yaxis.Content = "U (m/s)";
                    grid_plot_u.Visibility   = Visibility.Visible;

                    label_plot_title.Visibility = Visibility.Visible;
                    label_plot_xaxis.Visibility = Visibility.Visible;
                    label_plot_yaxis.Visibility = Visibility.Visible;

                    isCalculatePressed = true;
                }
                else
                {
                    MessageBox.Show("First select all initial parameters");
                }
            }
            catch (Exception j)
            {
                MessageBox.Show(j.Message);
            }
        }
示例#15
0
        void LogYWindow_Loaded(object sender, RoutedEventArgs e)
        {
            //ChartPlotter plotter = new ChartPlotter();

            //plotter.Children.Add(new CursorCoordinateGraph());

            //plotter.DataTransform = new Log10YTransform();
            //VerticalAxis axis = new VerticalAxis
            //{
            //    TicksProvider = new LogarithmNumericTicksProvider(10),
            //    LabelProvider = new UnroundingLabelProvider()
            //};
            //plotter.MainVerticalAxis = axis;

            //plotter.AxisGrid.DrawVerticalMinorTicks = true;

            //const int count = 500;
            //double[] xs = Enumerable.Range(1, count).Select(x => x * 0.01).ToArray();
            //EnumerableDataSource<double> xDS = xs.AsXDataSource();

            //var pows = xs.Select(x => Math.Pow(10, x));
            //var linear = xs.Select(x => x);
            //var logXs = Enumerable.Range(101, count).Select(x => x * 0.01);
            //var logarithmic = logXs.Select(x => Math.Log10(x));

            //plotter.AddLineGraph(pows.AsYDataSource().Join(xDS), "f(x) = 10^x");
            //plotter.AddLineGraph(linear.AsYDataSource().Join(xDS), "f(x) = x");
            //plotter.AddLineGraph(logarithmic.AsYDataSource().Join(logXs.AsXDataSource()), "f(x) = log(x)");

            //Content = plotter;

            ChartPlotter plotter = new ChartPlotter();

            plotter.DataTransform = new Log10YTransform();
            VerticalAxis yAxis = new VerticalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider()
            };

            plotter.MainVerticalAxis = yAxis;
            plotter.AxisGrid.DrawVerticalMinorTicks = true;

            HorizontalDateTimeAxis xAxis = new HorizontalDateTimeAxis();

            plotter.MainHorizontalAxis = xAxis;

            EnumerableDataSource <TPoint> edsPow = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = Math.Pow(10, s / 5000.0)
            }
                                                 ).ToList());

            //edsPow.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
            edsPow.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsPow.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
            edsPow.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => string.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

            EnumerableDataSource <TPoint> edsLinear = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = s / 2000.0
            }
                                                 ).ToList());

            //edsLinear.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
            edsLinear.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsLinear.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
            edsLinear.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => string.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

            edsLog10 = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = Math.Log10(s)
            }
                                                 ).Where(s => s.Y > 0).ToList());
            //edsLog10.SetXYMapping(s => new Point(xax.ConvertToDouble(s.X), s.Y));
            edsLog10.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsLog10.SetYMapping(s => yAxis.ConvertToDouble(s.Y));
            edsLog10.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, s => string.Format("Vol:{0}\r\nOn:{1}", s.Y, s.X.ToShortDateString()));

            SolidColorBrush          brushPow   = new SolidColorBrush(Colors.Green);
            Pen                      linePenPow = new Pen(brushPow, 2.0);
            CircleElementPointMarker markerPow  = new CircleElementPointMarker
            {
                Size  = 4,
                Brush = brushPow,
                Fill  = brushPow
            };
            PenDescription descPow = new PenDescription("f(x) = 10 ^ x");
            //var chartPow = plotter.AddLineGraph(edsPow, linePenPow, (ShapeElementPointMarker)null/*markerPow*/, descPow);

            SolidColorBrush          brushLinear   = new SolidColorBrush(Colors.Blue);
            Pen                      linePenLinear = new Pen(brushLinear, 2.0);
            CircleElementPointMarker markerLinear  = new CircleElementPointMarker
            {
                Size  = 4,
                Brush = brushLinear,
                Fill  = brushLinear
            };
            PenDescription descLinear = new PenDescription("f(x) = x");
            //var chartLinear = plotter.AddLineGraph(edsLinear, linePenLinear, (ShapeElementPointMarker)null/*markerLinear*/, descLinear);

            SolidColorBrush          brushLog10   = new SolidColorBrush(Colors.Red);
            Pen                      linePenLog10 = new Pen(brushLog10, 2.0);
            CircleElementPointMarker markerLog10  = new CircleElementPointMarker
            {
                Size  = 4,
                Brush = brushLog10,
                Fill  = brushLog10
            };
            PenDescription descLog10  = new PenDescription("f(x) = log(x)");
            var            chartLog10 = plotter.AddLineGraph(edsLog10, linePenLog10, (ShapeElementPointMarker)null /*markerLog10*/, descLog10);

            //plotter.Children.Add(new DataFollowChart(chartPow.LineGraph).WithProperty(c =>
            //{
            //    c.Marker.SetValue(Shape.FillProperty, brushPow);
            //    c.Marker.SetValue(Shape.StrokeProperty, brushPow.MakeDarker(0.2));
            //}));
            //plotter.Children.Add(new DataFollowChart(chartLinear.LineGraph).WithProperty(c =>
            //{
            //    c.Marker.SetValue(Shape.FillProperty, brushLinear);
            //    c.Marker.SetValue(Shape.StrokeProperty, brushLinear.MakeDarker(0.2));
            //}));

            plotter.Children.Add(new CursorCoordinateGraph());

            ValueStore      store           = new ValueStore();
            DataFollowChart dataFollowChart = new DataFollowChart(chartLog10.LineGraph);

            dataFollowChart.Marker.SetValue(Shape.FillProperty, brushLog10);
            dataFollowChart.Marker.SetValue(Shape.StrokeProperty, brushLog10.ChangeLightness(0.8));
            dataFollowChart.MarkerPositionChanged += new EventHandler(dataFollowChart_MarkerPositionChanged);
            //dataFollowChart.CustomDataContextCallback = () =>
            //    {
            //        if (dataFollowChart.ClosestPointIndex != -1)
            //        {
            //            var closestPoint = ((List<TPoint>)edsLog10.Data)[dataFollowChart.ClosestPointIndex];
            //            return store.SetValue("X", closestPoint.Y.ToString()).SetValue("Y", closestPoint.X.ToShortDateString());
            //        }
            //        else return null;
            //    };

#if true
            dataFollowChart.MarkerTemplate = (DataTemplate)FindResource("followMarkerTemplate");
#else
            dataFollowChart.MarkerAdjustCallback = marker =>
            {
                Ellipse ellipse        = (Ellipse)marker;
                var     markerPosition = c.MarkerPosition;
                var     date           = xAxis.ConvertFromDouble(markerPosition.X);
                var     y = yAxis.ConvertFromDouble(markerPosition.Y);
                ellipse.ToolTip = String.Format("Vol:{0}\r\nOn:{1}", y, date.ToShortDateString());
            };
#endif

            plotter.Children.Add(dataFollowChart);

            Content = plotter;
        }
        private void UpdateSpectrumChart(ChartPlotter parentPlotter)
        {
            if (Tutorials.Visibility == Visibility.Visible)
            {
                if (Tutorials.CurrentStep != null)
                {
                    if (Equals(Tutorials.CurrentStep.Tag, 2))
                    {
                        SpectrumLineChanged = true;
                    }
                }
            }


            var allPoints = GetAllPoints(parentPlotter).OrderBy(i => i.X).ToList();

            if (allPoints.Count == 0)
            {
                return;
            }

            var splus1 = Math.Max(allPoints[1].Y, allPoints[2].Y);

            var m = (allPoints[0].Y - allPoints[1].Y) / (allPoints[0].X - allPoints[1].X);

            var x0 = 0.0;
            var y0 = -m * allPoints[0].X + allPoints[0].Y;

            var x1 = (splus1 - allPoints[0].Y) / m + allPoints[0].X;
            var y1 = splus1;



            var lineGraph =
                parentPlotter.Children.Where(i => i is LineGraph)
                .Cast <LineGraph>()
                .FirstOrDefault(i => "spect".Equals(i.Tag));

            if (lineGraph == null)
            {
                var pen = new Pen(Brushes.Black, 5);
                pen.DashStyle = DashStyles.Dash;
                pen.DashCap   = PenLineCap.Round;

                var source = new ObservableDataSource <Point>();
                lineGraph     = parentPlotter.AddLineGraph(source, pen, null);
                lineGraph.Tag = "spect";
                Canvas.SetZIndex(lineGraph, 10000);
            }


            var src = lineGraph.DataSource as ObservableDataSource <Point>;

            src.Collection.Clear();


            var pts = new List <Point>();

            pts.Add(new Point(x0, y0));
            pts.Add(new Point(x1, y1));
            pts.Add(new Point(allPoints[2].X, splus1));

            var tmax = ApplicationSettings.Current.SpectrumsTMax;
            var dt   = ApplicationSettings.Current.SpectrumsDt;

            for (var t = allPoints[2].X; t < tmax; t += dt)
            {
                var x = (double)(allPoints[2].X / t);

                var y = splus1 * Math.Pow(x * x, 1 / 3.0);

                pts.Add(new Point(t, y));
            }

            src.AppendMany(pts);
        }