Esempio n. 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     //初始化
     countryChart.Dispose();
     dockContainer.Dispose();
     dockClear();
     countryChart  = new ChartControl();
     dockContainer = new ControlContainer();
     //显示dock
     dockShow();
     dockpanel.Resize += new System.EventHandler(this.dockpanel_Resize);
     dockContainer.Controls.Add(countryChart);
     dockpanel.Controls.Add(dockContainer);
     //设置属性
     dockContainer.Location            = new System.Drawing.Point(0, 0);
     dockContainer.Name                = "country_Container";
     dockContainer.Size                = new Size(dockpanel.Size.Width, dockpanel.Size.Height - 30);
     dockContainer.TabIndex            = 0;
     countryChart.Size                 = new Size(dockpanel.Size.Width, dockpanel.Size.Height - 20);
     countryChart.RuntimeHitTesting    = true;
     countryChart.MouseUp             += CountryChart_MouseUp;
     countryChart.CustomDrawCrosshair += CountryChart_CustomDrawCrosshair;
     //填充数据
     showChart(countryChart, "country", "ARM");
 }
        void CreatePalettesMenu()
        {
            miPalettes = new BarSubItem(this.manager, "&调色板");
            ChartControl chart = new ChartControl();

            string[] paletteNames      = chart.GetPaletteNames();
            int      naturalColorIndex = 0;

            for (int i = 0; i < paletteNames.Length; i++)
            {
                BarItem miPaletteName = new BarCheckItem(this.manager);
                miPaletteName.Caption = paletteNames[i];
                if (paletteNames[i] == "Nature Colors")
                {
                    naturalColorIndex = i;
                }
                miPaletteName.ItemClick += new ItemClickEventHandler(this.miPaletteName_Click);
                miPalettes.ItemLinks.Add(miPaletteName);
            }
            chart.Dispose();
            if (paletteNames.Length > 0)
            {
                BarCheckItem item = miPalettes.ItemLinks[naturalColorIndex].Item as BarCheckItem;
                if (miPalettes != null)
                {
                    miPaletteName_Click(this.manager, new ItemClickEventArgs(item, null));
                    item.Checked = true;
                }
            }
        }
Esempio n. 3
0
        private void barMgrAlarmHistoryChart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string fileName = GetFilePath(e.Item.Caption, GetFilter(e.Item.Caption));

            if ("" == fileName)
            {
                return;
            }

            switch (e.Item.Caption)
            {
            case "Export to Excel":
            {
                ctcAlarmHistory.ExportToXlsx(fileName);
            }
            break;

            case "Export to IMG":
            {
                ChartControl chart = (ChartControl)ctcAlarmHistory.Clone();
                chart.Size = new Size(1200, 1200);
                chart.ExportToImage(fileName, ImageFormat.Jpeg);
                chart.Dispose();
            }
            break;

            case "Export to PDF":
            {
                ctcAlarmHistory.ExportToXlsx(fileName);
            }
            break;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Called when pane is closed.
        /// </summary>
        protected override void OnClose()
        {
            base.OnClose();

            _control.Dispose();
            _control = null;
        }
 public void AddChart(ChartControl chart)
 {
     if (_Chart != null)
     {
         _Chart.Dispose();
     }
     _Chart          = chart;
     RecommendedSize = chart.Size;
     _Chart.Parent   = this;
     _Chart.Dock     = DockStyle.Fill;
 }
Esempio n. 6
0
        private void ShowChartForIndividual(string name)
        {
            this.Cursor = Cursors.WaitCursor;

            _chartControl.Dispose();
            _chartControl      = new ChartControl();
            _chartControl.Dock = DockStyle.Fill;
            pnlChart.Controls.Add(_chartControl);

            string result = _metrics.GetQuoteRequestsPerMonth();

            if (result != "")
            {
                MessageBox.Show(result);
                return;
            }
            _chartControl.DataSource = _metrics.quoteRequestsPerMonth;

            // Create series for each Quote Engineer
            Series series1 = new Series();

            series1.ArgumentDataMember  = "QuoteMonth";
            series1.ValueDataMembers[0] = "NumberOfQuotes";
            series1.ChangeView(DevExpress.XtraCharts.ViewType.Bar);
            series1.DataFilters.Add(new DataFilter("QuoteEngineer", "String", DataFilterCondition.Equal, name));

            // Add series to chart
            _chartControl.Series.Add(series1);

            ChartTitle chartTitle = new ChartTitle();

            chartTitle.Text = string.Format("Quote Requests Received by Month for {0}", name);
            _chartControl.Titles.Add(chartTitle);

            _chartControl.Legend.Visible = false;

            this.Cursor = Cursors.Default;
        }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get char width and height from the query string
        string sWidth    = Request.QueryString["w"];
        string sHeight   = Request.QueryString["h"];
        Size   imageSize = new Size(Int32.Parse(sWidth), Int32.Parse(sHeight));


        ChartControl control = new ChartControl();

        control.HttpServer = this.Server;
        control.Size       = imageSize;

        XmlDocument xmlChartDocument = new XmlDocument();

        ResourceLoader.WebServer = this.Server;
        Stream stream = ResourceLoader.GetFileStream("charts/UserChart.xml");

        xmlChartDocument.Load(stream);
        stream.Close();

        control.LoadTheme(xmlChartDocument["Charts"]);


        int liCategoryCount = 7; // Set desirable number of the categories
        int liSeriesCount   = 1; // Set desirable number of the series

        // Declare array of doubles
        double[,] ldaData = new double[liCategoryCount, liSeriesCount];

        // Fill array with data here
        // ....
        for (int j = 0; j < liCategoryCount; ++j)
        {
            ldaData[j, 0] = j;
        }


        IChartDataSource loDataSource = new ArrayDataSource(ldaData, DataOrientation.CategoryInRow);


        control.Charts[0].LoadData(loDataSource, false, true);

        for (int i = 0; i < liCategoryCount; ++i)
        {
            control.Charts[0].Layout.Categories[i].Title.Text = "Cat" + i.ToString();
        }



        control.Draw();


        MemoryStream imageStream = new MemoryStream();

        control.Image.Save(imageStream, ImageFormat.Png);


        // return byte array to caller with image type
        Response.ContentType = "image/png";
        Response.BinaryWrite(imageStream.GetBuffer());

        // Don't forget to dispose chart control after use.
        control.Dispose();
    }
Esempio n. 8
0
 void CreateAppearancesMenu()
 {
     miAppearances = new BarSubItem(this.manager, "&Appearances");
     ChartControl chart = new ChartControl();
     string[] appearanceNames = chart.GetAppearanceNames();
     int naturalColorIndex = 0;
     for (int i = 0; i < appearanceNames.Length; i++)
     {
         BarItem miAppearanceName = new BarCheckItem(this.manager);
         miAppearanceName.Caption = appearanceNames[i];
         if (appearanceNames[i] == "Nature Colors")
             naturalColorIndex = i;
         //miAppearanceName.ItemClick += new ItemClickEventHandler(this.miAppearanceName_Click);
         miAppearances.ItemLinks.Add(miAppearanceName);
     }
     chart.Dispose();
     if (appearanceNames.Length > 0)
     {
         BarCheckItem item = miAppearances.ItemLinks[naturalColorIndex].Item as BarCheckItem;
         if (miAppearances != null)
         {
             //miAppearanceName_Click(this.manager, new ItemClickEventArgs(item, null));
             item.Checked = true;
         }
     }
 }
Esempio n. 9
0
    protected void drawChart()
    {
        int qType = 1;

        try
        {
            qType = Int32.Parse(Request["t"].ToString());
        }
        catch (Exception)
        {
        }



        string sWidth  = Request.QueryString["w"];
        string sHeight = Request.QueryString["h"];

        if (sWidth == null)
        {
            sWidth = "10";
        }
        if (sHeight == null)
        {
            sHeight = "10";
        }
        Size imageSize = new Size(Int32.Parse(sWidth), Int32.Parse(sHeight));


        ChartControl control = new ChartControl();

        control.HttpServer = this.Server;
        control.Size       = imageSize;

        XmlDocument xmlChartDocument = new XmlDocument();

        ResourceLoader.WebServer = this.Server;
        Stream stream = ResourceLoader.GetFileStream("charts/UserChart.xml");

        xmlChartDocument.Load(stream);
        stream.Close();

        control.LoadTheme(xmlChartDocument["Charts"]);

        control.Charts.ComponentLayout.Titles.TitleList[0].Text = "GMAT Club Rating (" + Request.QueryString["name"] + ")";



        SqlCommand cmd = connection_.CreateCommand();

        cmd.CommandText = "select idx,user_idx,measured,q_type,result from StatisticResult where user_idx=@UserId order by measured desc;";
        cmd.Parameters.Add(new SqlParameter("@UserId", base.access_manager_.UserId));

        int liCategoryCount = 7; // Set desirable number of the categories
        int liSeriesCount   = 1; // Set desirable number of the series

        double[,] ldaData = new double[liCategoryCount, liSeriesCount];
        DateTime[] dates = new DateTime[liCategoryCount];

        using (SqlDataReader reader = cmd.ExecuteReader())
        {
            int cnt = 6;
            while (reader.Read())
            {
                if ((int)reader[3] == qType)
                {
                    ldaData[cnt, 0] = (int)reader[4];
                    DateTime d = (DateTime)reader[2];
                    dates[cnt] = d;
                    cnt--;
                    if (cnt < 0)
                    {
                        break;
                    }
                }
            }
            reader.Close();
        }


        // Declare array of doubles



        IChartDataSource loDataSource = new ArrayDataSource(ldaData, DataOrientation.CategoryInRow);


        control.Charts[0].LoadData(loDataSource, false, true);

        for (int i = 0; i < liCategoryCount; ++i)
        {
            DateTime d = dates[i];
            control.Charts[0].Layout.Categories[i].Title.Text = d.Day.ToString() + "/" + d.Month.ToString();
        }



        control.Charts[0].Name = "asdsad";

        control.Draw();


        MemoryStream imageStream = new MemoryStream();

        control.Image.Save(imageStream, ImageFormat.Png);


        // return byte array to caller with image type
        Response.ContentType = "image/png";
        Response.BinaryWrite(imageStream.GetBuffer());

        // Don't forget to dispose chart control after use.
        control.Dispose();
    }