/// <summary>
        /// 创建一个横向柱体
        /// </summary>
        /// <param name="SID"></param>
        /// <param name="IID"></param>
        /// <returns></returns>
        public Chart GetBar(bool is3D, string title, string CalloutAnnotationText)
        {
            Chart chart = new Chart();

            Title titleChart = new Title();  //设置标题

            titleChart.Text = title;
            chart.Titles.Add(titleChart);

            Series series0 = new Series();

            chart.Series.Add(series0);

            ChartArea ChartArea0 = new ChartArea();

            ChartArea0.Name = "a";
            chart.ChartAreas.Add(ChartArea0);

            Legend Legends0 = new Legend();

            Legends0.Name = "Default";
            chart.Legends.Add(Legends0);

            CalloutAnnotation CalloutAnnotation0 = new CalloutAnnotation();

            CalloutAnnotation0.Name = "Callout1";
            chart.Annotations.Add(CalloutAnnotation0);

            CalloutAnnotation0.Text = CalloutAnnotationText;

            SetBarProperty(chart, is3D);
            return(chart);
        }
示例#2
0
        private void Chart_MouseMove(object sender, MouseEventArgs e)
        {
            if (!Form1.EnCursors)
            {
                return;
            }
            if (sender.GetType().ToString() != "System.Windows.Forms.DataVisualization.Charting.Chart")
            {
                return;
            }
            Chart chart = sender as Chart;

            chart.ChartAreas[0].CursorX.SetCursorPixelPosition(new PointF(e.X, e.Y), true);
            chart.ChartAreas[0].CursorY.SetCursorPixelPosition(new PointF(e.X, e.Y), true);

            CalloutAnnotation Xannotation = chart.Annotations[0] as CalloutAnnotation;
            CalloutAnnotation Yannotation = chart.Annotations[1] as CalloutAnnotation;

            Xannotation.Text = chart.ChartAreas[0].CursorX.Position.ToString();
            Yannotation.Text = chart.ChartAreas[0].CursorY.Position.ToString();

            Xannotation.X = chart.ChartAreas[0].CursorX.Position;
            Xannotation.Y = /*Yoffset[tabControl1.SelectedIndex]*//*chart.ChartAreas[0].AxisY.Minimum + (chart.ChartAreas[0].AxisY.Maximum - chart.ChartAreas[0].AxisY.Minimum) / 2.0*/ chart.ChartAreas[0].AxisY.Minimum;

            Yannotation.X = /*Xoffset[tabControl1.SelectedIndex]*//*chart.ChartAreas[0].AxisX.Minimum + (chart.ChartAreas[0].AxisX.Maximum - chart.ChartAreas[0].AxisX.Minimum) / 2.0*/ chart.ChartAreas[0].AxisX.Minimum;
            Yannotation.Y = chart.ChartAreas[0].CursorY.Position;

            //Text = $"{e.X} {e.Y}";
        }
示例#3
0
    private void chart5()
    {
        using (WebClient client = new WebClient())
        {
            client.Headers[HttpRequestHeader.ContentType] = "text/json";
            //URL = "http://localhost:50463/Service1.svc";

            string strQuery = "SELECT COUNT(case when client_status_with_rms = 'Connected' then client_status_with_rms end) as Connected, COUNT(case when client_status_with_rms = 'Disconnected' then client_status_with_rms end) as Disconnected FROM pcmc.health_recent";

            string     JsonString    = JsonConvert.SerializeObject(strQuery);
            EncRequest objEncRequest = new EncRequest();
            objEncRequest.RequestData = AesGcm256.Encrypt(JsonString);
            string dataEncrypted = JsonConvert.SerializeObject(objEncRequest);

            string result = client.UploadString(URL + "/GetPieChart", "POST", dataEncrypted);

            EncResponse objResponse = JsonConvert.DeserializeObject <EncResponse>(result);
            objResponse.ResponseData = AesGcm256.Decrypt(objResponse.ResponseData);
            JsonSerializer json = new JsonSerializer();
            json.NullValueHandling = NullValueHandling.Ignore;
            StringReader sr = new StringReader(objResponse.ResponseData);
            Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr);

            Reply objReply = json.Deserialize <Reply>(reader);
            //Chart5 Start
            string[] seriesArray = { "Activated", "Pending" };
            int[]    pointsArray = new int[2];

            if (objReply.res && objReply.DS != null)
            {
                pointsArray[0] = Convert.ToInt32(objReply.DS.Tables[0].Rows[0][0]);
                pointsArray[1] = Convert.ToInt32(objReply.DS.Tables[0].Rows[0][1]);
            }

            Title title = Chart5.Titles.Add("Title1");
            title.Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
            Chart5.Titles["Title1"].Text = "Machine Activated";
            Chart5.Series["Series1"].Points.DataBindXY(seriesArray, pointsArray);
            Chart5.Series["Series1"].Points[0].Color = Color.Green;
            Chart5.Series["Series1"].Points[1].Color = Color.Red;


            CalloutAnnotation objAnnotation = new CalloutAnnotation();
            objAnnotation.AnchorDataPoint = Chart5.Series["Series1"].Points[0];
            objAnnotation.Text            = pointsArray[0].ToString();
            objAnnotation.Visible         = true;
            Chart5.Annotations.Add(objAnnotation);

            CalloutAnnotation objAnnotation1 = new CalloutAnnotation();
            objAnnotation1.AnchorDataPoint = Chart5.Series["Series1"].Points[1];
            objAnnotation1.Text            = pointsArray[1].ToString();
            objAnnotation1.Visible         = true;
            Chart5.Annotations.Add(objAnnotation1);

            seriesArray    = null;
            pointsArray    = null;
            objAnnotation  = null;
            objAnnotation1 = null;
        }
    }
示例#4
0
        /// <summary>
        /// Initialises the chart
        /// </summary>
        private void InitChart()
        {
            _mainChartArea.AxisX.ScaleView.Zoomable = true;
            _mainChartArea.AxisY.ScaleView.Zoomable = true;
            _mainChartArea.CursorX.AutoScroll       = true;
            _mainChartArea.CursorY.AutoScroll       = true;
            //_mainChartArea.AxisY2.Enabled = AxisEnabled.True;

            _priceAnnotation           = new RectangleAnnotation();
            _priceAnnotation.ForeColor = Color.Black;
            _priceAnnotation.Font      = new Font("Arial", 9);;
            _priceAnnotation.LineWidth = 1;
            _priceAnnotation.BackColor = Color.LemonChiffon;

            chartCtrl.Annotations.Add(_priceAnnotation);


            _maxPriceAnnotation                 = new CalloutAnnotation();
            _maxPriceAnnotation.ForeColor       = Color.Black;
            _maxPriceAnnotation.Font            = new Font("Arial", 9);;
            _maxPriceAnnotation.LineWidth       = 1;
            _maxPriceAnnotation.CalloutStyle    = CalloutStyle.SimpleLine;
            _maxPriceAnnotation.AnchorAlignment = ContentAlignment.BottomRight;
            chartCtrl.Annotations.Add(_maxPriceAnnotation);


            _minPriceAnnotation                 = new CalloutAnnotation();
            _minPriceAnnotation.ForeColor       = Color.Black;
            _minPriceAnnotation.Font            = new Font("Arial", 9);;
            _minPriceAnnotation.LineWidth       = 1;
            _minPriceAnnotation.CalloutStyle    = CalloutStyle.SimpleLine;
            _minPriceAnnotation.AnchorAlignment = ContentAlignment.MiddleRight;
            _minPriceAnnotation.AxisX           = _mainChartArea.AxisX;
            _minPriceAnnotation.AxisY           = _mainChartArea.AxisY;

            chartCtrl.Annotations.Add(_minPriceAnnotation);

            _currentPriceAnnotation                 = new ArrowAnnotation();
            _currentPriceAnnotation.ForeColor       = Color.Black;
            _currentPriceAnnotation.Font            = new Font("Arial", 9);
            _currentPriceAnnotation.LineWidth       = 1;
            _currentPriceAnnotation.Width           = 1;
            _currentPriceAnnotation.Height          = 1;
            _currentPriceAnnotation.ArrowSize       = 1;
            _currentPriceAnnotation.AxisX           = _mainChartArea.AxisX;
            _currentPriceAnnotation.AxisY           = _mainChartArea.AxisY;
            _currentPriceAnnotation.ArrowSize       = 3;
            _currentPriceAnnotation.Height          = 0;
            _currentPriceAnnotation.AnchorAlignment = ContentAlignment.MiddleLeft;
            //_currentPriceAnnotation.AnchorAlignment = ContentAlignment.MiddleRight;

            chartCtrl.Annotations.Add(_currentPriceAnnotation);

            // _mainChartArea.BackSecondaryColor = _mainChartArea.BackColor = Color.Black;
            chartCtrl.Series[Constants.PriceSerieName]["PriceUpColorUp"] = "Green";
        }
        private void InitializeChart()
        {
            MainChart.Palette = ChartColorPalette.Pastel;
            var area = new ChartArea();

            {
                area.AxisX.Minimum                     = -1;
                area.AxisX.IsMarginVisible             = false;
                area.AxisX.MajorGrid.Enabled           = true;
                area.AxisX.MajorGrid.LineColor         = Color.FromArgb(230, 230, 230);
                area.AxisX.MajorTickMark.TickMarkStyle = TickMarkStyle.None;
                area.AxisX.LabelStyle.Enabled          = false;
                area.AxisX.LineColor                   = Color.DarkGray;
                area.AxisX.IntervalOffsetType          = DateTimeIntervalType.Milliseconds;
                area.AxisX.ScaleView.Zoomable          = true;
                area.AxisX.ScrollBar.Enabled           = false;

                area.AxisY.Minimum                     = 0;
                area.AxisY.Maximum                     = ChartMaxYValue;
                area.AxisY.IsMarginVisible             = false;
                area.AxisY.MajorGrid.Enabled           = true;
                area.AxisY.MajorGrid.LineColor         = Color.FromArgb(230, 230, 230);
                area.AxisY.MajorTickMark.TickMarkStyle = TickMarkStyle.None;
                area.AxisY.LabelStyle.Enabled          = false;
                area.AxisY.LineColor                   = Color.DarkGray;
                area.AxisY.ScaleView.Zoomable          = true;
                area.AxisY.ScrollBar.Enabled           = false;
            }
            m_valueAnnotation = new CalloutAnnotation
            {
                AxisX = area.AxisX,
                AxisY = area.AxisY
            };
            MainChart.ChartAreas.Add(area);
            MainChart.Annotations.Add(m_valueAnnotation);
            MainChart.MouseMove += MainChart_MouseMove;

            MainChartHorizontalScrollBar.Scroll += (s, e) =>
            {
                m_isScrollingHorizontally = e.Type != ScrollEventType.EndScroll;
                IsTracking = MainChartHorizontalScrollBar.Value == MainChartHorizontalScrollBar.Maximum;
            };
            MainChartHorizontalScrollBar.ValueChanged += (s, e) =>
            {
                ScrollChartHorizontally(MainChartHorizontalScrollBar.Value == MainChartHorizontalScrollBar.Maximum);
            };
            MainChartVerticalScrollBar.ValueChanged += (s, e) => ScrollChartVertically();
        }
        public int AddCallout(string name, string text, CalloutStyle style, double x, double y, double width, double height)
        {
            CalloutAnnotation calloutAnnotation = new CalloutAnnotation();

            if (name.Length > 0)
            {
                calloutAnnotation.Name = name;
            }
            calloutAnnotation.X            = x;
            calloutAnnotation.Y            = y;
            calloutAnnotation.Width        = width;
            calloutAnnotation.Height       = height;
            calloutAnnotation.Text         = text;
            calloutAnnotation.CalloutStyle = style;
            return(base.List.Add(calloutAnnotation));
        }
        private void AddCalloutAnnotation()
        {
            // create a callout annotation
            CalloutAnnotation annotation = new CalloutAnnotation();

            // setup visual attributes
            annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
            annotation.Text            = "Attached to Point";
            annotation.BackColor       = Color.FromArgb(255, 255, 192);
            annotation.ClipToChartArea = "Default";

            // prevent moving or selecting
            annotation.AllowMoving       = false;
            annotation.AllowAnchorMoving = false;
            annotation.AllowSelecting    = false;

            // add the annotation to the collection
            Chart1.Annotations.Add(annotation);
        }
示例#8
0
        public void AddEntryToChart(ChartArea area, Series series, AnnotationCollection annotations, double y = 0)
        {
            if (Date == null)
            {
                throw new Exception();
            }

            var p1 = new DataPoint(Date.Value.AddDays(-1).ToOADate(), y);
            var p2 = new DataPoint(GetEndDate.ToOADate(), y);

            series.Points.Add(p1);
            series.Points.Add(p2);

            var line = new LineAnnotation
            {
                LineWidth       = 10,
                Height          = 0,
                LineColor       = DrawColor ?? Color.Red,
                ClipToChartArea = area.Name,
            };

            line.SetAnchor(p1, p2);

            var callout = new CalloutAnnotation
            {
                Text            = Note ?? "ERROR: NOT SET",
                AnchorDataPoint = p1,
                CalloutStyle    = CalloutStyle.RoundedRectangle,
                ForeColor       = DrawColor ?? Color.Red,
                LineColor       = DrawColor ?? Color.Red,
                //BackColor = Color.Transparent,
                Font            = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold),
                SmartLabelStyle = { IsMarkerOverlappingAllowed = true, AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes, MaxMovingDistance = 100, IsOverlappedHidden = false, MovingDirection = LabelAlignmentStyles.Bottom | LabelAlignmentStyles.BottomLeft | LabelAlignmentStyles.BottomRight },
                AnchorAlignment = ContentAlignment.TopCenter,
                ToolTip         = (Note ?? "ERROR: NOT SET") + "\n(" + Date.Value.ToShortDateString() + " - " + GetEndDate.ToShortDateString() + ")",
                Alignment       = ContentAlignment.MiddleCenter
            };

            annotations.Add(line);
            annotations.Add(callout);
        }
示例#9
0
    private void chart2()
    {
        //Chart2 Start
        string[] seriesArray = { "Card", "Cash" };
        int[]    pointsArray = new int[2];

        string strQuery = "SELECT COUNT(case when [Status] = '000' then [Status] end) as Successful,COUNT(case when [Status] != '000' then [Status] end)as Unsuccessful FROM [kmsdbv9.1].[dbo].[cashtxndetails] where [TxnDate] >= '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and [TxnDate] <= '" + DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59'";

        pointsArray[0] = Convert.ToInt32("65");
        pointsArray[1] = Convert.ToInt32("20");

        Title title = Chart2.Titles.Add("Title1");

        title.Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
        Chart2.Titles["Title1"].Text = "Payment Mode With Machine";
        Chart2.Series["Series1"].Points.DataBindXY(seriesArray, pointsArray);
        Chart2.Series["Series1"].Points[0].Color = Color.Green;
        Chart2.Series["Series1"].Points[1].Color = Color.Red;

        CalloutAnnotation objAnnotation = new CalloutAnnotation();

        objAnnotation.AnchorDataPoint = Chart2.Series["Series1"].Points[0];
        objAnnotation.Text            = pointsArray[0].ToString();
        objAnnotation.Visible         = true;
        Chart2.Annotations.Add(objAnnotation);

        CalloutAnnotation objAnnotation1 = new CalloutAnnotation();

        objAnnotation1.AnchorDataPoint = Chart2.Series["Series1"].Points[1];
        objAnnotation1.Text            = pointsArray[1].ToString();
        objAnnotation1.Visible         = true;
        Chart2.Annotations.Add(objAnnotation1);

        objAnnotation  = null;
        objAnnotation1 = null;
    }
示例#10
0
    private void chart7()
    {
        WebClient client = new WebClient();

        client.Headers[HttpRequestHeader.ContentType] = "text/json";

        //Chart7 Start
        string[] seriesArray = { "Offline Activate Machine", "Online Activate Machine" };
        int[]    pointsArray = new int[2];

        // string strQuery = "SELECT COUNT(case when [Status] = '000' then [Status] end) as Successful,COUNT(case when [Status] != '000' then [Status] end)as Unsuccessful FROM pcmc.o.[cashtxndetails] where [TxnDate] >= '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and [TxnDate] <= '" + DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59'";
        DateTime healthTime = DateTime.Now.AddHours(-2);
        string   strQuery   = "SELECT * FROM pcmc.health_recent ";


        string     JsonString    = JsonConvert.SerializeObject(strQuery);
        EncRequest objEncRequest = new EncRequest();

        objEncRequest.RequestData = AesGcm256.Encrypt(JsonString);
        string dataEncrypted = JsonConvert.SerializeObject(objEncRequest);

        string result = client.UploadString(URL + "/GetPieChart", "POST", dataEncrypted);

        EncResponse objResponse = JsonConvert.DeserializeObject <EncResponse>(result);

        objResponse.ResponseData = AesGcm256.Decrypt(objResponse.ResponseData);
        JsonSerializer json = new JsonSerializer();

        json.NullValueHandling = NullValueHandling.Ignore;
        StringReader sr = new StringReader(objResponse.ResponseData);

        Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr);

        Reply objReply = json.Deserialize <Reply>(reader);

        int connected    = 1;
        int disConnected = 0;


        //foreach (DataRow item in objReply.DS.Tables[0].Rows)
        //{
        //    var timestr = item["date_time"].ToString();
        //    DateTime dt = DateTime.ParseExact(timestr, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);

        //    if (dt > healthTime)
        //    {
        //        connected++;
        //    }
        //    else {
        //        disConnected++;
        //    }
        //}



        pointsArray[0] = disConnected;
        pointsArray[1] = connected;


        Title title = Chart7.Titles.Add("Title1");

        title.Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
        Chart7.Titles["Title1"].Text = "Machine Connected with server";
        Chart7.Series["Series1"].Points.DataBindXY(seriesArray, pointsArray);
        Chart7.Series["Series1"].Points[0].Color = Color.Red;
        Chart7.Series["Series1"].Points[1].Color = Color.Green;


        CalloutAnnotation objAnnotation = new CalloutAnnotation();

        objAnnotation.AnchorDataPoint = Chart7.Series["Series1"].Points[0];
        objAnnotation.Text            = pointsArray[0].ToString();
        objAnnotation.Visible         = true;
        Chart7.Annotations.Add(objAnnotation);

        CalloutAnnotation objAnnotation1 = new CalloutAnnotation();

        objAnnotation1.AnchorDataPoint = Chart7.Series["Series1"].Points[1];
        objAnnotation1.Text            = pointsArray[1].ToString();
        objAnnotation1.Visible         = true;
        Chart7.Annotations.Add(objAnnotation1);

        objAnnotation  = null;
        objAnnotation1 = null;
    }
示例#11
0
    private void chart6()
    {
        //Chart6 Start

        WebClient client = new WebClient();

        client.Headers[HttpRequestHeader.ContentType] = "text/json";

        string[] seriesArray = { "Online Machine", "Offline Machine" };
        int[]    pointsArray = new int[2];

        //  string selectedLocation = ddlLocations.SelectedItem.Text;

        // string strQuery = "SELECT COUNT(case when client_status_with_rms = 'Connected' then 'connected' end)  as Online,COUNT(case when client_status_with_rms = 'Disconnected' then 'Disconnected' end) as Offline from health_recent where f_kiosk_id in (select kiosk_id from kiosk_master where location = '"+selectedLocation+"')";

        //string JsonString = JsonConvert.SerializeObject(strQuery);
        //EncRequest objEncRequest = new EncRequest();
        //objEncRequest.RequestData = AesGcm256.Encrypt(JsonString);
        //string dataEncrypted = JsonConvert.SerializeObject(objEncRequest);

        //string result = client.UploadString(URL + "/GetPieChart", "POST", dataEncrypted);

        //EncResponse objResponse = JsonConvert.DeserializeObject<EncResponse>(result);
        //objResponse.ResponseData = AesGcm256.Decrypt(objResponse.ResponseData);
        //JsonSerializer json = new JsonSerializer();
        //json.NullValueHandling = NullValueHandling.Ignore;
        //StringReader sr = new StringReader(objResponse.ResponseData);
        //Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr);

        //Reply objReply = json.Deserialize<Reply>(reader);
        //if (objReply.res&&objReply.DS!=null)
        //{
        //    pointsArray[0] = Convert.ToInt32(objReply.DS.Tables[0].Rows[0][0].ToString());
        //    pointsArray[1] = Convert.ToInt32(objReply.DS.Tables[0].Rows[0][1].ToString());
        //}

        pointsArray[0] = 1;
        pointsArray[1] = 0;

        Title title = Chart6.Titles.Add("Title1");

        title.Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
        Chart6.Titles["Title1"].Text = "";
        Chart6.Series["Series1"].Points.DataBindXY(seriesArray, pointsArray);
        Chart6.Series["Series1"].Points[0].Color = Color.LightGreen;
        Chart6.Series["Series1"].Points[1].Color = Color.MediumPurple;
        Chart6.Series["Series1"].ChartType       = SeriesChartType.Pie;


        CalloutAnnotation objAnnotation = new CalloutAnnotation();

        objAnnotation.AnchorDataPoint = Chart6.Series["Series1"].Points[0];
        objAnnotation.Text            = pointsArray[0].ToString();
        objAnnotation.Visible         = true;
        Chart6.Annotations.Add(objAnnotation);

        CalloutAnnotation objAnnotation1 = new CalloutAnnotation();

        objAnnotation1.AnchorDataPoint = Chart6.Series["Series1"].Points[1];
        objAnnotation1.Text            = pointsArray[1].ToString();
        objAnnotation1.Visible         = true;
        Chart6.Annotations.Add(objAnnotation1);

        objAnnotation  = null;
        objAnnotation1 = null;
    }
示例#12
0
        protected override void CustomizeChartSeries(IList <Series> seriesList)
        {
            var min     = _dailyWeights.Min(d => d.Weight);
            var max     = _dailyWeights.Max(d => d.Weight);
            var maxDate = _dailyWeights.Max(d => d.WeightDate);
            var minDate = _dailyWeights.Min(d => d.WeightDate);
            int padding;

            var dateDiff = maxDate.Subtract(minDate);

            if (dateDiff.Days <= 31)
            {
                padding = 2;
            }
            else if (dateDiff.Days < 100)
            {
                padding = 5;
            }
            else
            {
                padding = 15;
            }
            MinimumYScale = Convert.ToInt32(Math.Floor(min / 5)) * 5;
            MaximumYScale = Convert.ToInt32(Math.Ceiling(max / 5)) * 5;
            Series weights = seriesList.Single();

            weights.SmartLabelStyle.Enabled = true;
            weights.Name = "Weights";
            foreach (var record in _dailyWeights)
            {
                weights.Points.AddXY(record.WeightDate, record.Weight);
            }
            var font            = new Font("Trebuchet MS", 8.25F, FontStyle.Bold);
            var startAnnotation = new CalloutAnnotation
            {
                AnchorDataPoint = weights.Points[0],
                AnchorOffsetX   = 5,
                AnchorOffsetY   = -5,
                Text            = weights.Points[0].YValues.Single().ToString("0.0"),
                ForeColor       = Color.Black,
                Font            = font,
                CalloutStyle    = CalloutStyle.RoundedRectangle,
                Height          = 7,
                Width           = 7,
                BackColor       = Color.FromArgb(128, Color.Green)
            };

            Chart.Annotations.Add(startAnnotation);
            var endAnnotation = new CalloutAnnotation
            {
                AnchorDataPoint = weights.Points.Last(),
                Text            = weights.Points.Last().YValues.Single().ToString("0.0"),
                AnchorOffsetY   = 5,
                AnchorOffsetX   = 5,
                ForeColor       = Color.Black,
                Font            = font,
                CalloutStyle    = CalloutStyle.RoundedRectangle,
                Height          = 7,
                Width           = 7,
                BackColor       = Color.FromArgb(128, Color.Red)
            };

            Chart.Annotations.Add(endAnnotation);
            Chart.ChartAreas[0].AxisY.Minimum             = (AutoScale) ? Double.NaN : MinimumYScale;
            Chart.ChartAreas[0].AxisY.Maximum             = (AutoScale) ? Double.NaN : MaximumYScale;
            Chart.ChartAreas[0].AxisX.LabelStyle.Format   = "MMM-d";
            Chart.ChartAreas[0].AxisX.LabelStyle.Interval = 20;
            Chart.ChartAreas[0].AxisX.Maximum             = (AutoScale) ? Double.NaN : maxDate.AddDays(padding).ToOADate();
        }
示例#13
0
    private void chart4()
    {
        //Chart4 Start
        DateTime objFromDate;
        DateTime objToDate;

        objToDate   = DateTime.Now.AddDays(-1);
        objFromDate = DateTime.Now.AddDays(-8);
        string[] seriesArray = new string[7];
        int      i;
        DateTime objWeek = DateTime.Today;

        for (i = 0; i < seriesArray.Length; i++)
        {
            objWeek            = objWeek.AddDays(-1);
            seriesArray[6 - i] = objWeek.ToString("dd-MMM-yy");
        }

        int[] pointsArray = new int[7];
        Title title       = Chart4.Titles.Add("Title1");

        title.Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
        Chart4.Titles["Title1"].Text = "Last 7 Days Transaction Hitting";

        CalloutAnnotation objAnnotation = null;

        for (int iDays = 1; iDays <= 7; iDays++)  //Last 7 Days Txn
        {
            using (WebClient client = new WebClient())
            {
                client.Headers[HttpRequestHeader.ContentType] = "text/json";
                //URL = "http://localhost:50463/Service1.svc";

                DateTime objTxnDtTime = DateTime.Today;
                objTxnDtTime = objTxnDtTime.AddDays(-iDays);

                string strQuery = "SELECT bill_payemnt_txn as total_bill_payemnt_txn, birth_certificate_txn as total_birth_certificate_txn, death_certificate_txn as total_death_certificate_txn FROM seva_sindhu_" + objTxnDtTime.ToString("yy") + ".txn_detail_" + objTxnDtTime.ToString("MMM") + " where txn_date_time >= '" + objTxnDtTime.ToString("yyyy-MM-dd") + "' and txn_date_time <= '" + objTxnDtTime.ToString("yyyy-MM-dd") + " 23:59:59'";

                string     JsonString    = JsonConvert.SerializeObject(strQuery);
                EncRequest objEncRequest = new EncRequest();
                objEncRequest.RequestData = AesGcm256.Encrypt(JsonString);
                string dataEncrypted = JsonConvert.SerializeObject(objEncRequest);

                string result = client.UploadString(URL + "/GetPieChart", "POST", dataEncrypted);

                EncResponse objResponse = JsonConvert.DeserializeObject <EncResponse>(result);
                objResponse.ResponseData = AesGcm256.Decrypt(objResponse.ResponseData);
                JsonSerializer json = new JsonSerializer();
                json.NullValueHandling = NullValueHandling.Ignore;
                StringReader sr = new StringReader(objResponse.ResponseData);
                Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr);

                Reply objReply = json.Deserialize <Reply>(reader);

                if (objReply.res && objReply.DS != null)
                {
                    pointsArray[7 - iDays] = Convert.ToInt32(objReply.DS.Tables[0].Rows[0][0].ToString() != "" ? objReply.DS.Tables[0].Rows[0][0].ToString() : "0") +
                                             Convert.ToInt32(objReply.DS.Tables[0].Rows[0][1].ToString() != "" ? objReply.DS.Tables[0].Rows[0][0].ToString() : "0") +
                                             Convert.ToInt32(objReply.DS.Tables[0].Rows[0][2].ToString() != "" ? objReply.DS.Tables[0].Rows[0][2].ToString() : "0");
                }
                else
                {
                    pointsArray[7 - iDays] = 0;
                }
            }
        }

        Chart4.Series["Series1"].Points.DataBindXY(seriesArray, pointsArray);

        objAnnotation = new CalloutAnnotation();
        objAnnotation.AnchorDataPoint = Chart4.Series["Series1"].Points[0];
        objAnnotation.Text            = pointsArray[0].ToString();
        objAnnotation.Visible         = true;
        Chart4.Annotations.Add(objAnnotation);
        objAnnotation = null;

        objAnnotation = new CalloutAnnotation();
        objAnnotation.AnchorDataPoint = Chart4.Series["Series1"].Points[1];
        objAnnotation.Text            = pointsArray[1].ToString();
        objAnnotation.Visible         = true;
        Chart4.Annotations.Add(objAnnotation);
        objAnnotation = null;

        objAnnotation = new CalloutAnnotation();
        objAnnotation.AnchorDataPoint = Chart4.Series["Series1"].Points[2];
        objAnnotation.Text            = pointsArray[2].ToString();
        objAnnotation.Visible         = true;
        Chart4.Annotations.Add(objAnnotation);
        objAnnotation = null;

        objAnnotation = new CalloutAnnotation();
        objAnnotation.AnchorDataPoint = Chart4.Series["Series1"].Points[3];
        objAnnotation.Text            = pointsArray[3].ToString();
        objAnnotation.Visible         = true;
        Chart4.Annotations.Add(objAnnotation);
        objAnnotation = null;

        objAnnotation = new CalloutAnnotation();
        objAnnotation.AnchorDataPoint = Chart4.Series["Series1"].Points[4];
        objAnnotation.Text            = pointsArray[4].ToString();
        objAnnotation.Visible         = true;
        Chart4.Annotations.Add(objAnnotation);
        objAnnotation = null;

        objAnnotation = new CalloutAnnotation();
        objAnnotation.AnchorDataPoint = Chart4.Series["Series1"].Points[5];
        objAnnotation.Text            = pointsArray[5].ToString();
        objAnnotation.Visible         = true;
        Chart4.Annotations.Add(objAnnotation);
        objAnnotation = null;

        objAnnotation = new CalloutAnnotation();
        objAnnotation.AnchorDataPoint = Chart4.Series["Series1"].Points[6];
        objAnnotation.Text            = pointsArray[6].ToString();
        objAnnotation.Visible         = true;
        Chart4.Annotations.Add(objAnnotation);
        objAnnotation = null;
    }
示例#14
0
    private void chart3()
    {
        using (WebClient client = new WebClient())
        {
            client.Headers[HttpRequestHeader.ContentType] = "text/json";
            // URL = "http://localhost:50463/Service1.svc";

            DateTime objTxnDtTime = DateTime.Today;

            string strQuery = "SELECT SUM(bill_payemnt_txn) as total_bill_payemnt_txn, SUM(birth_certificate_txn) as total_birth_certificate_txn, SUM(death_certificate_txn) as total_death_certificate_txn FROM seva_sindhu_" + objTxnDtTime.ToString("yy") + ".txn_detail_" + objTxnDtTime.ToString("MMM") + " where txn_date_time >= '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and txn_date_time <= '" + DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59'";

            string     JsonString    = JsonConvert.SerializeObject(strQuery);
            EncRequest objEncRequest = new EncRequest();
            objEncRequest.RequestData = AesGcm256.Encrypt(JsonString);
            string dataEncrypted = JsonConvert.SerializeObject(objEncRequest);

            string result = client.UploadString(URL + "/GetPieChart", "POST", dataEncrypted);

            EncResponse objResponse = JsonConvert.DeserializeObject <EncResponse>(result);
            objResponse.ResponseData = AesGcm256.Decrypt(objResponse.ResponseData);
            JsonSerializer json = new JsonSerializer();
            json.NullValueHandling = NullValueHandling.Ignore;
            StringReader sr = new StringReader(objResponse.ResponseData);
            Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr);

            Reply objReply = json.Deserialize <Reply>(reader);

            //Chart3 Start
            string[] seriesArray = { "Bill Payment", "Birth Certificate", "Death Certificate" };
            int[]    pointsArray = new int[3];

            if (objReply.res && objReply.DS != null)
            {
                pointsArray[0] = Convert.ToInt32(objReply.DS.Tables[0].Rows[0][0].ToString() != "" ? objReply.DS.Tables[0].Rows[0][0].ToString() : "0");
                pointsArray[1] = Convert.ToInt32(objReply.DS.Tables[0].Rows[0][1].ToString() != "" ? objReply.DS.Tables[0].Rows[0][1].ToString() : "0");
                pointsArray[2] = Convert.ToInt32(objReply.DS.Tables[0].Rows[0][2].ToString() != "" ? objReply.DS.Tables[0].Rows[0][2].ToString() : "0");
            }

            Title title = Chart3.Titles.Add("Title1");
            title.Font = new System.Drawing.Font("Arial", 16, FontStyle.Bold);
            Chart3.Titles["Title1"].Text = "Transaction Hitting On Service Type";
            Chart3.Series["Series1"].Points.DataBindXY(seriesArray, pointsArray);

            Chart3.Series["Series1"].Points[0].Color = Color.LightBlue;
            Chart3.Series["Series1"].Points[1].Color = Color.LightGreen;
            Chart3.Series["Series1"].Points[2].Color = Color.LightYellow;
            Chart3.Series["Series1"].ChartType       = SeriesChartType.Pie;

            CalloutAnnotation objAnnotation = new CalloutAnnotation();
            objAnnotation.AnchorDataPoint = Chart3.Series["Series1"].Points[0];
            objAnnotation.Text            = pointsArray[0].ToString();
            objAnnotation.Visible         = true;
            Chart3.Annotations.Add(objAnnotation);

            CalloutAnnotation objAnnotation1 = new CalloutAnnotation();
            objAnnotation1.AnchorDataPoint = Chart3.Series["Series1"].Points[1];
            objAnnotation1.Text            = pointsArray[1].ToString();
            objAnnotation1.Visible         = true;
            Chart3.Annotations.Add(objAnnotation1);


            CalloutAnnotation objAnnotation2 = new CalloutAnnotation();
            objAnnotation2.AnchorDataPoint = Chart3.Series["Series1"].Points[2];
            objAnnotation2.Text            = pointsArray[2].ToString();
            objAnnotation1.Visible         = true;
            Chart3.Annotations.Add(objAnnotation2);

            objAnnotation  = null;
            objAnnotation1 = null;
            objAnnotation2 = null;
        }
    }
示例#15
0
        private void InitializeChart()
        {
            MainChart.Palette = ChartColorPalette.Pastel;
            var area = new ChartArea();
            {
                area.AxisX.IsMarginVisible             = false;
                area.AxisX.MajorGrid.Enabled           = true;
                area.AxisX.MajorGrid.LineColor         = Color.FromArgb(230, 230, 230);
                area.AxisX.MajorTickMark.TickMarkStyle = TickMarkStyle.None;
                area.AxisX.LabelStyle.Enabled          = false;
                area.AxisX.LineColor          = Color.DarkGray;
                area.AxisX.IntervalOffsetType = DateTimeIntervalType.Milliseconds;
                area.AxisX.ScaleView.Zoomable = true;
                area.AxisX.ScrollBar.Enabled  = false;

                area.AxisY.IsMarginVisible             = false;
                area.AxisY.MajorGrid.Enabled           = true;
                area.AxisY.MajorGrid.LineColor         = Color.FromArgb(230, 230, 230);
                area.AxisY.MajorTickMark.TickMarkStyle = TickMarkStyle.None;
                area.AxisY.LabelStyle.Enabled          = false;
                area.AxisY.LineColor = Color.DarkGray;
            }
            var valueAnnotation = new CalloutAnnotation
            {
                AxisX = area.AxisX,
                AxisY = area.AxisY
            };

            MainChart.ChartAreas.Add(area);
            MainChart.Annotations.Add(valueAnnotation);

            DataPoint pointUnderCursor = null;

            MainChart.MouseMove += (s, e) =>
            {
                var result = MainChart.HitTest(e.X, e.Y);

                if (result.ChartElementType != ChartElementType.DataPoint ||
                    result.PointIndex < 0 ||
                    result.Series.Points.Count <= result.PointIndex)
                {
                    return;
                }

                if (result.Series.Points.Count <= result.PointIndex)
                {
                    return;
                }
                if (pointUnderCursor != null)
                {
                    pointUnderCursor.MarkerSize = 0;
                }

                pointUnderCursor            = result.Series.Points[result.PointIndex];
                pointUnderCursor.MarkerSize = 7;

                valueAnnotation.BeginPlacement();

                // You must set AxisX before binding to xValue!
                valueAnnotation.AnchorX = pointUnderCursor.XValue;
                valueAnnotation.AnchorY = pointUnderCursor.YValues[0];
                valueAnnotation.Text    = pointUnderCursor.Tag.ToString();

                valueAnnotation.EndPlacement();
            };

            MainChartScrollBar.Scroll       += (s, e) => IsTracking = MainChartScrollBar.Value == MainChartScrollBar.Maximum;
            MainChartScrollBar.ValueChanged += (s, e) => ScrollChart(false);
        }
示例#16
0
        private void AnnotationStyle1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Arrow")
            {
                ArrowAnnotation annotation = (ArrowAnnotation)Chart1.Annotations[0];

                if (AnnotationStyle1.SelectedItem.ToString() != "")
                {
                    annotation.ArrowSize = int.Parse(AnnotationStyle1.SelectedItem.ToString());
                }
            }
            else if (Annotation.SelectedItem.ToString() == "Border3D")
            {
                Border3DAnnotation annotation = (Border3DAnnotation)Chart1.Annotations[0];

                annotation.BorderSkin.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Callout")
            {
                CalloutAnnotation annotation = (CalloutAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineColor = Color.FromName(AnnotationStyle1.SelectedItem.ToString());
            }
        }
        private void SetAnnotationStyle1()
        {
            if (AnnotationStyle1 == null || AnnotationStyle1.SelectedIndex == -1)
            {
                return;
            }

            if (Annotation.SelectedItem.Value == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Arrow")
            {
                ArrowAnnotation annotation = (ArrowAnnotation)Chart1.Annotations[0];

                if (AnnotationStyle1.SelectedItem.Value != "")
                {
                    annotation.ArrowSize = int.Parse(AnnotationStyle1.SelectedItem.Value);
                }
            }
            else if (Annotation.SelectedItem.Value == "Border3D")
            {
                Border3DAnnotation annotation = (Border3DAnnotation)Chart1.Annotations[0];

                annotation.BorderSkin.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Callout")
            {
                CalloutAnnotation annotation = (CalloutAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineColor = Color.FromName(AnnotationStyle1.SelectedItem.Value);
            }
        }
示例#18
0
        private void chart2_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                Point mousePoint = new Point(e.X, e.Y);
                chart2.ChartAreas[0].CursorX.SetCursorPixelPosition(mousePoint, true);
                chart2.ChartAreas[0].CursorY.SetCursorPixelPosition(mousePoint, true);

                CalloutAnnotation annotation = new CalloutAnnotation();
                //CalloutAnnotation test2 = new CalloutAnnotation();
                //test2.AllowMoving = true;

                annotation.Text    = "this is a test";
                annotation.Visible = true;
                //Point formPoint = this.PointToScreen( Control.MousePosition);//鼠标相对于窗体左上角的坐标
                //int x = formPoint.X;
                //int y = formPoint.Y;
                //double xValue = chart2.ChartAreas[0].AxisX.ValueToPixelPosition(e.X);
                //double yValue = chart2.ChartAreas[0].AxisY.ValueToPixelPosition(e.Y);
                //annotation.X = xValue;
                //annotation.Y = yValue;
                //label5.Text = xValue.ToString();
                //label6.Text = yValue.ToString();


                ChartArea  ca = chart2.ChartAreas[0];
                Series     S  = chart2.Series["price"];
                RectangleF rf = InnerPlotPositionClientRectangle(chart2, ca);
                float      px = (float)((e.X - rf.X) * S.Points.Count / rf.Width);

                int p0 = (int)px;  // previous point
                //int p1 = p0 + 1;   // next point

                //if (p0 >= 0 && p0 < S.Points.Count)
                //    Console.WriteLine("DataPoint # " + p0 + " has a y-value of " +
                //                       S.Points[p0].YValues[0].ToString("0.00"));

                annotation.AnchorDataPoint = S.Points[p0];


                //你通过比例关系计算点的高度值信息,传给toolTip1即可
                //PointF point = FindNearestDataPoint(e.X, e.Y);
                //annotation.AnchorDataPoint = chart2.Series["price"].Points[(int)point.X - 1];
                //if (!float.IsNaN(e.NewAnchorLocationX))
                //{
                //    // Get the nearest point to the new location
                //    PointF point = FindNearestDataPoint(e.NewAnchorLocationX, e.NewAnchorLocationY);

                //    annotation.AnchorDataPoint = Chart1.Series[0].Points[(int)point.X - 1];
                //    e.NewAnchorLocationX = point.X;
                //    e.NewAnchorLocationY = point.Y;
                //}
                //annotation.AnchorDataPoint = new DataPoint(e.X, e.Y);
                //annotation.X = (mousePoint).X;
                //annotation.Y = (mousePoint).Y;
                //test2.Text = "this is a test2";
                //test2.AnchorX = 30;
                //test2.AnchorY = 25;


                //if (!float.IsNaN(e.NewAnchorLocationX))
                //{
                //    // Get the nearest point to the new location
                //    PointF point = FindNearestDataPoint(e.NewAnchorLocationX, e.NewAnchorLocationY);

                //    annotation.AnchorDataPoint = Chart1.Series[0].Points[(int)point.X - 1];
                //    e.NewAnchorLocationX = point.X;
                //    e.NewAnchorLocationY = point.Y;
                //}


                //test2.AnchorDataPoint = chart2.Series["price"].Points[3]; ;
                chart2.Annotations.Clear();
                chart2.Annotations.Add(annotation);
                //chart2.Annotations.Add(test2);
                chart2.Refresh();
            }
            catch
            {
                return;
            }
        }
        protected override void CustomizeChartSeries(IList<Series> seriesList)
        {
            var min = _dailyWeights.Min(d => d.Weight);
            var max = _dailyWeights.Max(d => d.Weight);
            var maxDate = _dailyWeights.Max(d => d.WeightDate);
            var minDate = _dailyWeights.Min(d => d.WeightDate);
            int padding;

            var dateDiff = maxDate.Subtract(minDate);
            if (dateDiff.Days <= 31)
            {
                padding = 2;
            }
            else if (dateDiff.Days < 100)
            {
                padding = 5;
            }
            else
            {
                padding = 15;
            }
            MinimumYScale = Convert.ToInt32(Math.Floor(min / 5)) * 5;
            MaximumYScale = Convert.ToInt32(Math.Ceiling(max / 5)) * 5;
            Series weights = seriesList.Single();
            weights.SmartLabelStyle.Enabled = true;
            weights.Name = "Weights";
            foreach (var record in _dailyWeights)
            {
                weights.Points.AddXY(record.WeightDate, record.Weight);
            }
            var font = new Font("Trebuchet MS", 8.25F, FontStyle.Bold);
            var startAnnotation = new CalloutAnnotation
            {
                AnchorDataPoint = weights.Points[0],
                AnchorOffsetX = 5,
                AnchorOffsetY = -5,
                Text = weights.Points[0].YValues.Single().ToString("0.0"),
                ForeColor = Color.Black,
                Font = font,
                CalloutStyle = CalloutStyle.RoundedRectangle,
                Height = 7,
                Width = 7,
                BackColor = Color.FromArgb(128, Color.Green)
            };

            Chart.Annotations.Add(startAnnotation);
            var endAnnotation = new CalloutAnnotation
            {
                AnchorDataPoint = weights.Points.Last(),
                Text = weights.Points.Last().YValues.Single().ToString("0.0"),
                AnchorOffsetY = 5,
                AnchorOffsetX = 5,
                ForeColor = Color.Black,
                Font = font,
                CalloutStyle = CalloutStyle.RoundedRectangle,
                Height = 7,
                Width = 7,
                BackColor = Color.FromArgb(128, Color.Red)
            };

            Chart.Annotations.Add(endAnnotation);
            Chart.ChartAreas[0].AxisY.Minimum = (AutoScale) ? Double.NaN : MinimumYScale;
            Chart.ChartAreas[0].AxisY.Maximum = (AutoScale) ? Double.NaN : MaximumYScale;
            Chart.ChartAreas[0].AxisX.LabelStyle.Format = "MMM-d";
            Chart.ChartAreas[0].AxisX.LabelStyle.Interval = 20;
            Chart.ChartAreas[0].AxisX.Maximum = (AutoScale) ? Double.NaN : maxDate.AddDays(padding).ToOADate();
        }
示例#20
0
 private bool LineIntersectRectangle(RectangleF rect, PointF point1, PointF point2)
 {
     if (point1.X == point2.X)
     {
         if (point1.X >= rect.X && point1.X <= rect.Right)
         {
             if (point1.Y < rect.Y && point2.Y < rect.Y)
             {
                 return(false);
             }
             if (point1.Y > rect.Bottom && point2.Y > rect.Bottom)
             {
                 return(false);
             }
             return(true);
         }
         return(false);
     }
     if (point1.Y == point2.Y)
     {
         if (point1.Y >= rect.Y && point1.Y <= rect.Bottom)
         {
             if (point1.X < rect.X && point2.X < rect.X)
             {
                 return(false);
             }
             if (point1.X > rect.Right && point2.X > rect.Right)
             {
                 return(false);
             }
             return(true);
         }
         return(false);
     }
     if (point1.X < rect.X && point2.X < rect.X)
     {
         return(false);
     }
     if (point1.X > rect.Right && point2.X > rect.Right)
     {
         return(false);
     }
     if (point1.Y < rect.Y && point2.Y < rect.Y)
     {
         return(false);
     }
     if (point1.Y > rect.Bottom && point2.Y > rect.Bottom)
     {
         return(false);
     }
     if (!rect.Contains(point1) && !rect.Contains(point2))
     {
         PointF intersectionY = CalloutAnnotation.GetIntersectionY(point1, point2, rect.Y);
         if (rect.Contains(intersectionY))
         {
             return(true);
         }
         intersectionY = CalloutAnnotation.GetIntersectionY(point1, point2, rect.Bottom);
         if (rect.Contains(intersectionY))
         {
             return(true);
         }
         intersectionY = CalloutAnnotation.GetIntersectionX(point1, point2, rect.X);
         if (rect.Contains(intersectionY))
         {
             return(true);
         }
         intersectionY = CalloutAnnotation.GetIntersectionX(point1, point2, rect.Right);
         if (rect.Contains(intersectionY))
         {
             return(true);
         }
         return(false);
     }
     return(true);
 }
示例#21
0
        private void Annotation_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Chart1.Annotations.Clear();

            AnnotationStyle.Items.Clear();
            AnnotationStyle.Enabled = false;

            AnnotationStyle1.Items.Clear();
            AnnotationStyle1.Enabled = false;
            AnnotationStyle2.Items.Clear();
            AnnotationStyle2.Visible = false;

            if (Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = new LineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height          = -25;
                annotation.Width           = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if (Annotation.SelectedItem.ToString() == "Vertical Line")
            {
                VerticalLineAnnotation annotation = new VerticalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height          = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if (Annotation.SelectedItem.ToString() == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = new HorizontalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Width           = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if (Annotation.SelectedItem.ToString() == "Polyline")
            {
                PolylineAnnotation annotation = new PolylineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width  = 30;

                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 0;
                points[2].Y = 100;

                points[3].X = 100;
                points[3].Y = 100;

                points[4].X = 0;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

                SetLineControls(false);
            }
            else if (Annotation.SelectedItem.ToString() == "Text")
            {
                TextAnnotation annotation = new TextAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a TextAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);;

                Chart1.Annotations.Add(annotation);
                SetTextControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Rectangle")
            {
                RectangleAnnotation annotation = new RectangleAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a\nRectangleAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetTextControls();
                SetColorLineControls();
                AnnotationStyle1.SelectedIndex = 2;
            }
            else if (Annotation.SelectedItem.ToString() == "Ellipse")
            {
                EllipseAnnotation annotation = new EllipseAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am an EllipseAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);;
                annotation.LineWidth       = 2;
                annotation.Height          = 35;
                annotation.Width           = 60;

                Chart1.Annotations.Add(annotation);

                SetTextControls();
                SetColorLineControls();
                AnnotationStyle1.SelectedIndex = 2;
            }
            else if (Annotation.SelectedItem.ToString() == "Arrow")
            {
                ArrowAnnotation annotation = new ArrowAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height          = -25;
                annotation.Width           = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetArrowControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Border3D")
            {
                Border3DAnnotation annotation = new Border3DAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a Border3DAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);
                annotation.Height          = 40;
                annotation.Width           = 50;

                Chart1.Annotations.Add(annotation);

                SetBorder3DControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Callout")
            {
                CalloutAnnotation annotation = new CalloutAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a\nCalloutAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 10);;
                annotation.Height          = 35;
                annotation.Width           = 50;

                Chart1.Annotations.Add(annotation);

                SetCalloutControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = new PolygonAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width  = 30;

                annotation.BackColor = Color.FromArgb(128, Color.Orange);

                // define relative value points for a polygon
                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 100;
                points[2].Y = 100;

                points[3].X = 0;
                points[3].Y = 100;

                points[4].X = 50;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

                SetColorControl();
                SetColorLineControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Image")
            {
                if (Chart1.Images.IndexOf("MyBmp") < 0)
                {
                    Bitmap   Bmp = new Bitmap(200, 75);
                    Graphics g   = Graphics.FromImage(Bmp);
                    g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Bmp.Width, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleGoldenrod), Bmp.Width / 2, 0, Bmp.Width / 2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleVioletRed), 0, 0, Bmp.Width / 2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.DarkOrange)), 0, Bmp.Height / 2, Bmp.Width, Bmp.Height / 2);
                    g.DrawString("I am an ImageAnnotation", new Font("Arial", 12),
                                 new SolidBrush(Color.Black),
                                 new Rectangle(0, 0, Bmp.Width, Bmp.Height));

                    g.Dispose();

                    Chart1.Images.Add(new NamedImage("MyBmp", Bmp));
                }

                ImageAnnotation annotation = new ImageAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Image           = "MyBmp";

                Chart1.Annotations.Add(annotation);
                StyleLabel1.Text = "";
                StyleLabel2.Text = "";
            }
        }
        /// <summary>
        /// 创建一个饼图
        /// </summary>
        /// <param name="SID"></param>
        /// <param name="IID"></param>
        /// <returns></returns>
        public Chart GetPie(long SID, long IID)
        {
            long   nowRentCount = 0;
            string SurveryName  = "";

            DataTable dtChoosedOption = new WebChart_Layer().GetChoosedOption(ConvertHelper.ConvertString(SID));

            DataTable SurveyTable = new WebChart_Layer().GetSurveyTableName(ConvertHelper.ConvertString(SID));

            if (SurveyTable.Rows.Count == 1)
            {
                SurveryName = ConvertHelper.ConvertString(SurveyTable.Rows[0]["SurveyName"]);
            }

            DataTable SurveyItems = new WebChart_Layer().GetAllSurveyTtem(ConvertHelper.ConvertString(SID)); //获取问卷的所有题目

            Chart chart = new Chart();
            //chart.Titles.Add(ConvertHelper.ConvertString(drSurveyItem["ItemName"]));

            Series series0 = new Series();

            //series0.Type =SeriesChartType.Pie;
            chart.Series.Add(series0);

            ChartArea ChartArea0 = new ChartArea();

            ChartArea0.Name = "a";
            chart.ChartAreas.Add(ChartArea0);

            Legend Legends0 = new Legend();

            Legends0.Name = "Default";
            chart.Legends.Add(Legends0);

            CalloutAnnotation CalloutAnnotation0 = new CalloutAnnotation();

            CalloutAnnotation0.Name = "Callout1";
            chart.Annotations.Add(CalloutAnnotation0);

            SetPieProperty(chart);

            DataRow[] dataItemRows = dtChoosedOption.Select(string.Format("IID={0}", ConvertHelper.ConvertString(IID)));
            if (dataItemRows != null)
            {
                for (int i = 0; i < dataItemRows.Length; i++)
                {
                    nowRentCount = nowRentCount + ConvertHelper.ConvertLong(dataItemRows[i]["CountItemValue"]);
                }
            }

            DataTable dtTtemOption = new WebChart_Layer().GetTtemOption(ConvertHelper.ConvertString(SID), ConvertHelper.ConvertString(IID));  //获取题目的所有选项

            if (dtTtemOption != null)
            {
                int j = 0;
                foreach (DataRow dtItemOption in dtTtemOption.Rows)
                {
                    if (dtChoosedOption != null)
                    {
                        long frequence = GetFrequence(dtChoosedOption, ConvertHelper.ConvertString(IID), ConvertHelper.ConvertString(dtItemOption["OID"]));
                        if (frequence > 0)
                        {
                            chart.Series[0].Points.AddY(frequence * 100 / nowRentCount);
                            chart.Series[0].Points[j].Label      = Convert.ToString(Math.Round((double)frequence * 100 / nowRentCount, 2)) + "%";
                            chart.Series[0].Points[j].LegendText = ConvertHelper.ConvertString(dtItemOption["OptionName"]) + "(" + frequence + "个)";
                            j++;
                        }
                        else
                        {
                            //chart.Series[0].Points.AddY(0);
                            //chart.Series[0].Points[j].Label = "100%";
                            //chart.Series[0].Points[j].LegendText = ConvertHelper.ConvertString(dtItemOption["OptionName"]) + "(" + 0 + "个)";
                            //chart.Series[0].Enabled = false;
                            //j++;
                        }
                    }
                }
                j = 0;
            }

            nowRentCount = 0;

            return(chart);
        }
        /// <summary>
        /// 初始加载页
        /// </summary>
        public void InitPage()
        {
            //获取所有题目,根据SID
            //long SID = ConvertHelper.ConvertLong(Request.QueryString["SID"]);
            long   SID         = 96;
            string SurveryName = "";


            DataTable dtChoosedOption = new WebChart_Layer().GetChoosedOption(ConvertHelper.ConvertString(SID), "");
            long      nowRentCount    = 0;


            DataTable SurveyTable = new WebChart_Layer().GetSurveyTableName(ConvertHelper.ConvertString(SID));

            if (SurveyTable.Rows.Count == 1)
            {
                SurveryName = ConvertHelper.ConvertString(SurveyTable.Rows[0]["SurveyName"]);
            }

            DataTable SurveyItems = new WebChart_Layer().GetAllSurveyTtem(ConvertHelper.ConvertString(SID)); //获取问卷的所有题目

            if (SurveyItems.Rows.Count > 0)
            {
                foreach (DataRow drSurveyItem in SurveyItems.Rows)
                {
                    Chart chart = new Chart();
                    chart.Titles.Add(ConvertHelper.ConvertString(drSurveyItem["ItemName"]));

                    Series series0 = new Series();
                    //series0.Type =SeriesChartType.Pie;
                    chart.Series.Add(series0);

                    ChartArea ChartArea0 = new ChartArea();
                    ChartArea0.Name = "a";
                    chart.ChartAreas.Add(ChartArea0);

                    Legend Legends0 = new Legend();
                    Legends0.Name = "Default";
                    chart.Legends.Add(Legends0);

                    CalloutAnnotation CalloutAnnotation0 = new CalloutAnnotation();
                    CalloutAnnotation0.Name = "Callout1";
                    chart.Annotations.Add(CalloutAnnotation0);

                    SetChartProperty(chart);

                    DataRow[] dataItemRows = dtChoosedOption.Select(string.Format("IID={0}", ConvertHelper.ConvertString(drSurveyItem["IID"])));
                    if (dataItemRows != null)
                    {
                        for (int i = 0; i < dataItemRows.Length; i++)
                        {
                            nowRentCount = nowRentCount + ConvertHelper.ConvertLong(dataItemRows[i]["CountItemValue"]);
                        }
                    }

                    DataTable dtTtemOption = new WebChart_Layer().GetTtemOption(ConvertHelper.ConvertString(SID), ConvertHelper.ConvertString(drSurveyItem["IID"]));  //获取题目的所有选项
                    if (dtTtemOption != null)
                    {
                        int j = 0;
                        foreach (DataRow dtItemOption in dtTtemOption.Rows)
                        {
                            if (dtChoosedOption != null)
                            {
                                DataRow[] dataRows = dtChoosedOption.Select(string.Format("IID={0} and ItemValue={1}", ConvertHelper.ConvertString(drSurveyItem["IID"]), ConvertHelper.ConvertString(dtItemOption["OID"])));
                                if (dataRows.Length > 0)
                                {
                                    chart.Series[0].Points.AddY(Convert.ToInt64(dataRows[0]["CountItemValue"]) * 100 / nowRentCount);
                                    chart.Series[0].Points[j].Label      = Convert.ToString(Math.Round(Convert.ToDouble(dataRows[0]["CountItemValue"]) * 100 / nowRentCount, 2)) + "%";
                                    chart.Series[0].Points[j].LegendText = ConvertHelper.ConvertString(dtItemOption["OptionName"]) + "(" + dataRows[0]["CountItemValue"].ToString() + "个)";
                                    j++;
                                }
                                else
                                {
                                    //chart.Series[0].Points.AddY(0);
                                    //chart.Series[0].Points[j].Label = "100%";
                                    //chart.Series[0].Points[j].LegendText = ConvertHelper.ConvertString(dtItemOption["OptionName"]) + "(" + 0 + "个)";
                                    //chart.Series[0].Enabled = false;
                                    //j++;
                                }
                            }
                        }
                        j = 0;
                    }

                    Page.Controls.Add(chart);

                    nowRentCount = 0;
                }
            }
        }
示例#24
0
        private void SetAnnotationType()
        {
            Chart1.Annotations.Clear();

            if(Annotation.SelectedItem.Value == "Line")
            {
                LineAnnotation annotation = new LineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Vertical Line")
            {
                VerticalLineAnnotation annotation = new VerticalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = new HorizontalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Polyline")
            {
                PolylineAnnotation annotation = new PolylineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width = 30;

                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 0;
                points[2].Y = 100;

                points[3].X = 100;
                points[3].Y = 100;

                points[4].X = 0;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Text")
            {
                TextAnnotation annotation = new TextAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a TextAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Rectangle")
            {
                RectangleAnnotation annotation = new RectangleAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a\nRectangleAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Ellipse")
            {
                EllipseAnnotation annotation = new EllipseAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am an EllipseAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.LineWidth = 2;
                annotation.Height = 35;
                annotation.Width = 60;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Arrow")
            {
                ArrowAnnotation annotation = new ArrowAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Border3D")
            {
                Border3DAnnotation annotation = new Border3DAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a Border3DAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.Height = 40;
                annotation.Width = 50;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Callout")
            {
                CalloutAnnotation annotation = new CalloutAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text = "I am a\nCalloutAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 10);;
                annotation.Height = 35;
                annotation.Width = 50;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = new PolygonAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width = 30;

                annotation.BackColor = Color.FromArgb(128, Color.Orange);

                // define relative value points for a polygon
                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 100;
                points[2].Y = 100;

                points[3].X = 0;
                points[3].Y = 100;

                points[4].X = 50;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Image")
            {
                if (Chart1.Images.IndexOf("MyBmp") < 0)
                {
                    Bitmap Bmp = new Bitmap(200, 75);
                    Graphics g = Graphics.FromImage(Bmp);
                    g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Bmp.Width, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleGoldenrod), Bmp.Width/2, 0, Bmp.Width/2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleVioletRed), 0, 0, Bmp.Width/2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.DarkOrange)), 0, Bmp.Height/2, Bmp.Width, Bmp.Height/2);
                    g.DrawString("I am an ImageAnnotation", new Font("Arial", 12),
                        new SolidBrush(Color.Black),
                        new Rectangle( 0, 0, Bmp.Width, Bmp.Height));

                    g.Dispose();

                    Chart1.Images.Add(new NamedImage("MyBmp", Bmp));
                }

                ImageAnnotation annotation = new ImageAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Image = "MyBmp";

                Chart1.Annotations.Add(annotation);
            }
        }