Exemplo n.º 1
0
        void setPreview()
        {
            if (lstGraphic.SelectedItem == null)
            {
                return;
            }
            try
            {
                var graph  = (TabloidConfigGraph)lstGraphic.SelectedItem;
                var sqlSet = TabloidGraphHelper.GetSQL(_view, graph, "", null);//find sql


                sqlSet.Select.Where = string.Format("deleted_{0}=0", _view);

                var data  = TabloidGraphHelper.GetData(graph, _view, sqlSet.Select.Command, Program.AppSet.ConnectionString);
                var chart = new System.Web.UI.DataVisualization.Charting.Chart();
                chart.Width  = imgGraphic.Width;
                chart.Height = imgGraphic.Height;
                string champX = sqlSet.Select.GroupBy;
                TabloidGraphHelper.GetChart(_view, graph, ref champX, chart, data);

                using (MemoryStream stream = new MemoryStream())
                {
                    chart.SaveImage(stream, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Png);
                    imgGraphic.Image = Image.FromStream(stream);
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, ex.Message, Properties.Resources.Erreur, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        void UpdateGraph()
        {
            toolStripStatusLabel1.Text = "";

            if (string.IsNullOrEmpty(_currentGraph.ChampX) || string.IsNullOrEmpty(_currentGraph.ChampY))
            {
                return;
            }

            var where = string.IsNullOrEmpty(txtId.Text)?"":_view.DbKey + "=" + txtId.Text;

            var sqlSet = TabloidGraphHelper.GetSQL(_view, _currentGraph, where, null);//find sql

            txtSql.Text = sqlSet.Select.Command;

            DataView data;

            try
            {
                data = TabloidGraphHelper.GetData(_currentGraph, _view, sqlSet.Select.Command, Program.AppSet.ConnectionString);
            }
            catch (Exception e)
            {
                toolStripStatusLabel1.Text = e.Message;
                return;
            }


            //chart.Width = 500;
            //chart.Height = 300;
            string champX = "";

            chart.BackColor = System.Drawing.Color.Transparent;
            //chart.TextAntiAliasingQuality = TextAntiAliasingQuality.SystemDefault;
            //chart.AntiAliasing = AntiAliasingStyles.Graphics;
            getChartSeries(_view, _currentGraph, chart, ref champX);

            var chartArea = new ChartArea
            {
                Name        = "ChartArea1",
                BorderColor = System.Drawing.Color.Transparent,
                BackColor   = System.Drawing.Color.Transparent,
            };


            chartArea.Area3DStyle.Enable3D    = _currentGraph.volume;
            chartArea.Area3DStyle.Inclination = 30;
            //chartArea.Area3DStyle.PointDepth = 999;

            chart.ChartAreas.Clear();
            chart.ChartAreas.Add(chartArea);

            chart.DataSource         = data;
            dataGridView1.DataSource = data;
            chart.DataBind();



            //chart.ChartAreas[0].AxisX.LabelStyle.Interval = data.Count / 20;
            UpdatewizardView();
        }