private void ConfigureChart(RadChart chart)
        {
            AreaSeriesDefinition lineSeries = new AreaSeriesDefinition();

            lineSeries.ShowItemLabels = false;
            lineSeries.ShowPointMarks = false;

            SeriesMapping dataMapping = new SeriesMapping();

            dataMapping.SeriesDefinition = lineSeries;
            dataMapping.ItemMappings.Add(new ItemMapping("TimePositionAsDateTime", DataPointMember.XValue));
            dataMapping.ItemMappings.Add(new ItemMapping("PercentageThreshold", DataPointMember.YValue));
            dataMapping.ItemMappings[1].SamplingFunction = ChartSamplingFunction.KeepExtremes;

            chart.SeriesMappings.Add(dataMapping);

            chart.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.None;
            chart.DefaultView.ChartArea.ZoomScrollSettingsY.ScrollMode = ScrollMode.None;

            chart.DefaultView.ChartLegend.Visibility             = System.Windows.Visibility.Collapsed;
            chart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "#VAL{HH:mm:ss}";
            chart.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{p0}";
            chart.AxisElementBrush = new SolidColorBrush(Colors.White);
            chart.AxisForeground   = new SolidColorBrush(Colors.White);
            chart.DefaultView.ChartArea.AxisY.MajorGridLinesVisibility = Visibility.Collapsed;
            chart.DefaultView.ChartArea.AxisY.MinorGridLinesVisibility = Visibility.Collapsed;
            chart.DefaultView.ChartArea.AxisY.StripLinesVisibility     = Visibility.Collapsed;
            chart.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Collapsed;
            chart.DefaultView.ChartArea.LabelFormatBehavior            = LabelFormatBehavior.None;
            chart.SamplingSettings.SamplingThreshold     = 1000;
            chart.DefaultView.ChartArea.EnableAnimations = false;
        }
Exemple #2
0
    protected void PopulateRotator()
    {
        // Get values and populate..
        ArrayList rotatorImages  = new ArrayList();
        String    user_territory = Util.GetUserTerritory();

        // Iterate offices
        RadChart rc  = GenerateGroupVersusChart();
        Bitmap   img = new Bitmap(rc.GetBitmap());

        img.Save(Util.path + "ZedGraphImages\\groupVersus.png", System.Drawing.Imaging.ImageFormat.Png);
        rotatorImages.Add("groupVersus.png");
        for (int i = 0; i < offices.Rows.Count; i++)
        {
            String territory = (String)offices.Rows[i]["office"];
            rc = GenerateVersusChart(territory);
            if (rc != null)
            {
                img = new Bitmap(rc.GetBitmap());
                img.Save(Util.path + "ZedGraphImages\\" + Util.SanitiseStringForFilename(territory) + "Versus.png", System.Drawing.Imaging.ImageFormat.Png);
                rotatorImages.Add(territory + "Versus.png");
            }
        }

        rr_versus.DataSource = rotatorImages;
        rr_versus.DataBind();
    }
Exemple #3
0
        private void PopulatePages()
        {
            int skinIndex = 0;

            foreach (ChartSeriesType seriesType in Enum.GetValues(typeof(ChartSeriesType)))
            {
                RadPageViewPage page = new RadPageViewPage();
                page.Text = seriesType.ToString();

#pragma warning disable 618
                RadChart chart = new RadChart();
                chart.DefaultType         = seriesType;
                chart.Dock                = DockStyle.Fill;
                chart.Skin                = ChartSkins[skinIndex++];
                chart.SkinsOverrideStyles = true;

                Telerik.Charting.ChartSeries series = new Telerik.Charting.ChartSeries("StripMode");
                series.AddItem(10, series.Name);
                chart.Series.Add(series);

                series = new Telerik.Charting.ChartSeries("StackMode");
                series.AddItem(20, series.Name);
                chart.Series.Add(series);

                series = new Telerik.Charting.ChartSeries("OutlookMode");
                series.AddItem(30, series.Name);
                chart.Series.Add(series);

                page.Controls.Add(chart);
                this.radPageView1.Pages.Add(page);
            }
        }
        private void BuildChart(RadChart chart, DataTable seriesData)
        {
            // Handle Legend Labels
            chart.Series.Clear();
            var nSeries = new ChartSeries();
            var nSeries2 = new ChartSeries();
            
            nSeries.Name = "School %";
            nSeries2.Name = "District %";
            chart.Legend.Appearance.ItemTextAppearance.AutoTextWrap = AutoTextWrap.False;

            //double minval = 100;
            //double maxval = 0;

            ChartAxisItemsCollection caic = new ChartAxisItemsCollection();

            var year_list = new List<String>();
            // Begin Experience tab
            foreach (DataRow dr in seriesData.Rows)
            {
                var myItem = new ChartSeriesItem(DataIntegrity.ConvertToDouble(dr["SuspensionRate"]), dr["LevelLabel"].ToString()) { Name = dr["SchoolYear"].ToString() };
                if (String.IsNullOrEmpty(dr["SuspensionRate"].ToString())) myItem.Appearance.Visible = false;   // hide bar and text if the value is null (no data)
                //myItem.Label.Appearance.LabelLocation = StyleSeriesItemLabel.ItemLabelLocation.Auto;
                if (dr["Level"].Equals("District"))
                {
                    nSeries2.AddItem(myItem);
                }
                else
                {
                    nSeries.AddItem(myItem);
                }
                
                year_list.Add(dr["SchoolYear"].ToString());
                
                //if (minval > DataIntegrity.ConvertToDouble(dr["SuspensionRate"])) minval = DataIntegrity.ConvertToDouble(dr["SuspensionRate"]);
                //if (maxval < DataIntegrity.ConvertToDouble(dr["SuspensionRate"])) maxval = DataIntegrity.ConvertToDouble(dr["SuspensionRate"]);
            }
            foreach (var yl in year_list.Distinct())
            {
                ChartAxisItem ai = new ChartAxisItem();
                ai.TextBlock.Text = yl;
                caic.Add(ai);    
            }
            
            chart.PlotArea.XAxis.AddItem(caic);

            chart.PlotArea.YAxis.MinValue = 0;
            //chart.PlotArea.YAxis.Step = (maxval - (minval - 5)) / 2;
            chart.PlotArea.YAxis.Step = 5;
            chart.PlotArea.YAxis.AutoScale = true;
            //chart.PlotArea.YAxis.MaxValue = maxval == 100 ? maxval : maxval + 5;
            //chart.PlotArea.YAxis.a = maxval == 100 ? maxval : maxval + 5;

            chart.Series.Add(nSeries);
            chart.Series.Add(nSeries2);

            chart.ChartTitle.Visible = false;

            chart.SetSkin("SuspensionRate");
        }
        private void chartAreaMonthlyZamowienia_ItemToolTipOpening(ItemToolTip2D tooltip, ItemToolTipEventArgs e)
        {
            RadChart chart = new RadChart();
            chart.Height = 200;
            chart.Width = 350;
            chart.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;

            chart.DefaultView.ChartTitle.Content = "Sprzedaż Miesięczna";
            chart.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Inside;

            var data = from d in zamowieniaContext.Data.Cast<KoszykPOCO>()
                       where d.RokZrealizowania == int.Parse(_selectedYear) && d.MiesiacZrealizowania == int.Parse(ConvertMonthToInt(e.DataPoint.XCategory))
                       select d;
            SeriesMapping mapping  = new SeriesMapping();
            mapping.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.XCategory, FieldName = "Dayzrealizowania" });
            mapping.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Ilosc", AggregateFunction = ChartAggregateFunction.Sum });
            mapping.SortDescriptors.Add(new ChartSortDescriptor() { Member = "Dayzrealizowania", SortDirection = System.ComponentModel.ListSortDirection.Ascending });
            mapping.GroupingSettings.GroupDescriptors.Add(new ChartGroupDescriptor() { Member = "Dayzrealizowania" });
            chart.SeriesMappings.Add(mapping);
            chart.ItemsSource = data;
            if (chart.DefaultView.ChartArea.DataSeries.Count > 0)
            {
                chart.DefaultView.ChartArea.DataSeries.First().Definition = new SplineAreaSeriesDefinition();
            }
                tooltip.Content = chart;
        }
Exemple #6
0
 void SetXAxis(string Pregunta, int NumeroDePreguntas, RadChart Grafica)
 {
     Grafica.ChartTitle.TextBlock.Text = Pregunta;
     Grafica.PlotArea.XAxis.AutoScale  = false;
     Grafica.PlotArea.XAxis.Clear();
     Grafica.PlotArea.XAxis.AddItem(NumeroDePreguntas.ToString("#,###") + " Encuestas");
 }
Exemple #7
0
 protected void HideLabels(RadChart radChart)
 {
     foreach (ChartSeries series in radChart.Series)
     {
         series.Appearance.LabelAppearance.Visible = false;
     }
 }
Exemple #8
0
        /// <summary>
        /// Creates the graphs for each question.
        /// </summary>
        private void CreateGraphs()
        {
            var questions = new SurveyRepository().LoadAnswerResponseCounts(this.SurveyId);

            foreach (var questionPair in questions)
            {
                var question = questionPair.First;
                var answers  = questionPair.Second.ToArray();

                const int TitleHeight        = 25;
                const int AnswerHeight       = 16;
                const int HeaderFooterHeight = 70;
                var       linesOfTitleText   = (int)Math.Ceiling(question.Text.Length / (double)35);
                var       chart = new RadChart
                {
                    ChartTitle        = { TextBlock = { Text = this.GetQuestionLabel(question.RelativeOrder, question.Text, false) } },
                    SeriesOrientation = ChartSeriesOrientation.Horizontal,
                    Skin                   = TelerikChartsSkin,
                    Height                 = Unit.Pixel((linesOfTitleText * TitleHeight) + (AnswerHeight * answers.Length) + HeaderFooterHeight),
                    Legend                 = { Visible = false },
                    AutoTextWrap           = true,
                    AutoLayout             = true,
                    HttpHandlerUrl         = this.ResolveUrl("~/ChartImage.axd"),
                    EnableHandlerDetection = false,
                    PlotArea               =
                    {
                        XAxis = { Appearance = { TextAppearance = { Visible = false                            }      } },
                        YAxis = { AxisLabel  = { TextBlock      = { Text    = this.Localize("Axis Label.Text") }, Visible = true} }
                    },
                };

                var chartSeries = new ChartSeries();
                foreach (var answerPair in answers)
                {
                    var answer      = answerPair.First;
                    var answerCount = answerPair.Second;

                    chartSeries.Items.Insert(0, new ChartSeriesItem(answerCount, this.GetAnswerLabel(answer.RelativeOrder, answer.Text, false)));
                }

                chart.Series.Add(chartSeries);
                this.ChartsPanel.Controls.Add(chart);
            }

            var charts = this.ChartsPanel.Controls.OfType <RadChart>();

            if (!charts.Any())
            {
                return;
            }

            var maxHeight = charts.Select(c => (int)c.Height.Value).Max();

            foreach (var chart in charts)
            {
                chart.Height = Unit.Pixel(maxHeight);
            }
        }
 protected override Image DoCreateChartImage()
 {
     var radChart = new RadChart {Width = Parameters.ChartWidth, Height = Parameters.ChartHeight};
     var tmpSeries = new ChartSeries() { Type = ChartSeriesType.Line };
     foreach (var point in Parameters.SeriaData)
         tmpSeries.Items.Add(new ChartSeriesItem(point.Key, point.Value));
     radChart.AddChartSeries(tmpSeries);
     return radChart.GetBitmap();
 }
        public static void ChartAreaZoom(RadChart rc_graphic)
        {
            CameraExtension cameraExtension = new CameraExtension();

            cameraExtension.SpinAxis    = SpinAxis.XY;
            cameraExtension.ZoomEnabled = true;

            rc_graphic.DefaultView.ChartArea.Extensions.Add(cameraExtension);
        }
Exemple #11
0
    public void Piechart()
    {
        int    A     = 0;
        int    B     = 0;
        int    C     = 0;
        int    D     = 0;
        int    E     = 0;
        int    count = 0;
        AbcDAL MyDAL = new AbcDAL("");

        DataTable ResultTable      = MyDAL.SelectStudentByAuthID(1);
        string    StudentID        = ResultTable.Rows[0]["StudentID"].ToString().Trim();
        DataTable ResultTableClass = MyDAL.PopulateClassByStudentID(StudentID);

        RadChart radChart = new RadChart();

        radChart.ChartTitle.TextBlock.Text = "My RadChart";
        ChartSeries chartSeries = new ChartSeries();

        chartSeries.Name = "Overall Grade";
        chartSeries.Type = ChartSeriesType.Bar;
        // add new items to the series,
        // passing a value and a label string

        foreach (DataRow row in ResultTableClass.Rows)
        {
            if (ResultTableClass.Rows[count]["Grade"].ToString().Trim() == "A")
            {
                A++;
            }
            else if (ResultTableClass.Rows[count]["Grade"].ToString().Trim() == "B")
            {
                B++;
            }
            else if (ResultTableClass.Rows[count]["Grade"].ToString().Trim() == "C")
            {
                C++;
            }
            else if (ResultTableClass.Rows[count]["Grade"].ToString().Trim() == "D")
            {
                D++;
            }
            else if (ResultTableClass.Rows[count]["Grade"].ToString().Trim() == "E")
            {
                E++;
            }
            count++;
        }
        chartSeries.AddItem(A, "A");
        chartSeries.AddItem(B, "B");
        chartSeries.AddItem(C, "C");
        chartSeries.AddItem(D, "D");
        chartSeries.AddItem(E, "E");

        RCStudent.AddChartSeries(chartSeries);
    }
Exemple #12
0
        protected override void CreateChildControls()
        {
            string[] colors = { "#FFDA43", "#2F89C2", "#F267CD", "#79E364", "#EB5D2D", "#42AE18", "#FF9C40", "#B99A72", "#9BC0FF", "#98CC88", "#C3B600" };
            chart                  = new RadChart();
            chart.UseSession       = false;
            chart.TempImagesFolder = "~/_layouts/temp";
            chart.RadControlsDir   = "~/_layouts/radcontrols/RadControls/";

            ChartSeries chartSeries = new ChartSeries();

            chart.AddChartSeries(chartSeries);
            ChartTitle title = new ChartTitle();


            ChartSeries series = chart.GetChartSeries(0);

            series.Name = surveyQuestion;

            chart.Legend.HAlignment  = ChartHAlignment.Center;
            chart.Legend.VAlignment  = ChartVAlignment.Bottom;
            chart.Legend.LegendStyle = LegendItemsPositionType.Row;


            response               = GetSurveyResponse("http://server/sites/techresources/", "http://server/sites/techresources/Lists/Survey2");
            title.Text             = surveyQuestion;
            title.TextFont         = new Font("Verdana", 7);
            chart.Chart.ChartTitle = title;

            series.Clear();
            series.DiameterScale            = 0.40;
            series.ShowLabelConnectors      = false;
            series.ShowLabels               = true;
            series.LabelAppearance.Distance = 7;
            series.LabelAppearance.TextFont = new Font("Verdana", 7);
            series.NotOverlapLabels         = true;
            series.Type = ChartSeriesType.Pie;
            ColorConverter cc = new ColorConverter();
            int            i  = 0;

            foreach (Response res in response)
            {
                ChartSeriesItem seriesItem = new ChartSeriesItem();
                seriesItem.YValue                 = res.totalResponse;
                seriesItem.ItemMap.ToolTip        = res.choiceName;
                seriesItem.Label                  = res.totalResponse.ToString();
                seriesItem.Appearance.MainColor   = (Color)cc.ConvertFromString(colors[i++]);
                seriesItem.Appearance.BorderColor = Color.DimGray;
                seriesItem.Appearance.FillStyle   = FillStyle.Solid;
                seriesItem.Name = res.choiceName;
                series.Items.Add(seriesItem);
            }
            chart.Skin = "LightGreen";
            this.Controls.Add(chart);
        }
Exemple #13
0
        public void CreateFile(string _path, string _url, string _fileName, out string _tag, RadChart _chart)
        {
            string _file = _path + "/" + _fileName;
            _chart.Save(_file, System.Drawing.Imaging.ImageFormat.Png);

            _tag = "";

            _chart.Visible = false;
            _chart.DataBind();

        }
        public static void SetAxisYVisibility(CheckBox AxisYCheckbox, RadChart RadChart)
        {
            bool isChecked = (bool)AxisYCheckbox.IsChecked;

            if (isChecked)
            {
                RadChart.DefaultView.ChartArea.AxisY.Visibility = Visibility.Visible;
            }
            else
            {
                RadChart.DefaultView.ChartArea.AxisY.Visibility = Visibility.Collapsed;
            }
        }
Exemple #15
0
 /// <summary>
 /// Method to Print Chart
 /// </summary>
 /// <param name="chart"></param>
 public static RadDocument PrintChart(RadChart chart)
 {
     try
     {
         RadDocument document = new RadDocument();
         document = CreateChartDocumentPart(chart);
         return(document);
     }
     catch (Exception ex)
     {
         Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
         return(null);
     }
 }
        public void AddLineToChart(int numTable, TimeAndFileSize newStr)
        {
            String numTableString = numTable.ToString();

            Dispatcher.BeginInvoke(new ThreadStart(delegate
            {
                //график
                string _mHour = newStr.Date.Hour.ToString();
                if (_mHour.Length == 1)
                {
                    _mHour = "0" + _mHour;
                }

                string _mMinute = newStr.Date.Minute.ToString();
                if (_mMinute.Length == 1)
                {
                    _mMinute = "0" + _mMinute;
                }

                string _xCategory = _mHour + ":" + _mMinute;

                int numChart       = 0;
                int _otherNumTable = 0;
                if ((numTable % 2) == 0)
                {
                    numChart       = 0;
                    _otherNumTable = 1;
                }
                else
                {
                    numChart       = 1;
                    _otherNumTable = 0;
                }

                int numRadChart = numTable / 2;

                string _elementName       = "RadChart" + numRadChart.ToString();
                RadChart _elementRadChart = FindElementRadChart(this.GridTable.Children, _elementName);

                DataSeries lineSeries = _elementRadChart.DefaultView.ChartArea.DataSeries[numChart];
                AddPointInChart(lineSeries, _xCategory, newStr.SizeMegabyte, true);

                //другая линия

                lineSeries = _elementRadChart.DefaultView.ChartArea.DataSeries[_otherNumTable];
                AddPointInChart(lineSeries, _xCategory, 0, false);
                //-
            }));
        }
        private void AddChartInGrid(int numRadChart, string _strNameExchange, string _strNameExchangeBack
                                    , string _strFilePath, string _strFilePathBack)
        {
            Dispatcher.BeginInvoke(new ThreadStart(delegate
            {
                string _elementName       = "RadChart" + numRadChart.ToString();
                RadChart _elementRadChart = FindElementRadChart(this.GridTable.Children, _elementName);
                Telerik.Windows.Controls.RadChart telerikChart = _elementRadChart;

                //добавление в Grid новой строки
                System.Windows.Controls.RowDefinition newRow = new System.Windows.Controls.RowDefinition();
                GridLengthConverter myGridLengthConverter    = new GridLengthConverter();
                newRow.Height = (GridLength)myGridLengthConverter.ConvertFromString("*");
                GridTable.RowDefinitions.Add(newRow);
                _elementRadChart.Visibility = System.Windows.Visibility.Visible;
                //-

                telerikChart.DefaultView.ChartTitle.HorizontalAlignment    = HorizontalAlignment.Center; //Chart Legend
                telerikChart.DefaultView.ChartLegend.UseAutoGeneratedItems = true;                       //Line Chart
                telerikChart.DefaultView.ChartTitle.Content = _strNameExchange;                          // "Обмен " + _strNameExchange; //+" и " + _strNameExchangeBack;

                DataSeries lineSeries  = new DataSeries();
                lineSeries.LegendLabel = _strNameExchange;                     // "Обмен " + _strNameExchange;
                lineSeries.Definition  = new LineSeriesDefinition();
                telerikChart.DefaultView.ChartArea.DataSeries.Add(lineSeries); //Bar Chart

                DataSeries barSeries  = new DataSeries();
                barSeries.LegendLabel = _strNameExchangeBack; // "Обмен " + _strNameExchangeBack;
                barSeries.Definition  = new LineSeriesDefinition();
                telerikChart.DefaultView.ChartArea.DataSeries.Add(barSeries);
            }));

            StrPathToExange _newStr = new StrPathToExange();

            _newStr._strNameExchange     = _strNameExchange;
            _newStr._strNameExchangeBack = _strNameExchangeBack;
            _newStr._strFilePath         = _strFilePath;
            _newStr._strFilePathBack     = _strFilePathBack;

            if (FileChecker.Instance._filePathList == null)
            {
                FileChecker.Instance._filePathList = new List <StrPathToExange>();
            }
            FileChecker.Instance._filePathList.Add(_newStr);
            FileChecker.Instance.CreateFileWatcher();

            //CreateChart_DefaultView();
        }
		public MainWindow()
		{
			InitializeComponent();
			RadChart telerikChart = new RadChart();    //Chart Title
			telerikChart.DefaultView.ChartTitle.Content = "Year 2009";
			telerikChart.DefaultView.ChartTitle.HorizontalAlignment = HorizontalAlignment.Center;    //Chart Legend
			telerikChart.DefaultView.ChartLegend.UseAutoGeneratedItems = true;
			
			//Line Chart
			DataSeries lineSeries = new DataSeries();
			lineSeries.LegendLabel = "Turnover";
			lineSeries.Definition = new LineSeriesDefinition();
			lineSeries.Add(new DataPoint() { YValue = 154, XCategory = "Jan" });
			lineSeries.Add(new DataPoint() { YValue = 138, XCategory = "Feb" });
			lineSeries.Add(new DataPoint() { YValue = 143, XCategory = "Mar" });
			lineSeries.Add(new DataPoint() { YValue = 120, XCategory = "Apr" });
			lineSeries.Add(new DataPoint() { YValue = 135, XCategory = "May" });
			lineSeries.Add(new DataPoint() { YValue = 125, XCategory = "Jun" });
			lineSeries.Add(new DataPoint() { YValue = 179, XCategory = "Jul" });
			lineSeries.Add(new DataPoint() { YValue = 170, XCategory = "Aug" });
			lineSeries.Add(new DataPoint() { YValue = 198, XCategory = "Sep" });
			lineSeries.Add(new DataPoint() { YValue = 187, XCategory = "Oct" });
			lineSeries.Add(new DataPoint() { YValue = 193, XCategory = "Nov" });
			lineSeries.Add(new DataPoint() { YValue = 176, XCategory = "Dec" });
			telerikChart.DefaultView.ChartArea.DataSeries.Add(lineSeries);
			
			//Bar Chart
			DataSeries barSeries = new DataSeries();
			barSeries.LegendLabel = "Expenses";
			barSeries.Definition = new BarSeriesDefinition();
			barSeries.Add(new DataPoint() { YValue = 45, XCategory = "Jan" });
			barSeries.Add(new DataPoint() { YValue = 48, XCategory = "Feb" });
			barSeries.Add(new DataPoint() { YValue = 53, XCategory = "Mar" });
			barSeries.Add(new DataPoint() { YValue = 41, XCategory = "Apr" });
			barSeries.Add(new DataPoint() { YValue = 32, XCategory = "May" });
			barSeries.Add(new DataPoint() { YValue = 28, XCategory = "Jun" });
			barSeries.Add(new DataPoint() { YValue = 63, XCategory = "Jul" });
			barSeries.Add(new DataPoint() { YValue = 74, XCategory = "Aug" });
			barSeries.Add(new DataPoint() { YValue = 77, XCategory = "Sep" });
			barSeries.Add(new DataPoint() { YValue = 85, XCategory = "Oct" });
			barSeries.Add(new DataPoint() { YValue = 89, XCategory = "Nov" });
			barSeries.Add(new DataPoint() { YValue = 80, XCategory = "Dec" });
			telerikChart.DefaultView.ChartArea.DataSeries.Add(barSeries);

			this.AddChild(telerikChart);
		}
 private void LoadChart(RadChart chart, List<ReportData> dt, string seriesname)
 {
     if (dt != null)
     {
         chart.DataManager.DataSource = dt;
         //set the column in the datasource to be used for the labels    
         chart.DataManager.LabelsColumn = "Value";
         chart.DataManager.ValuesYColumns = new string[] { "Count" };
         //sets the labels so that there are no overlaps            
         chart.IntelligentLabelsEnabled = true;
         chart.DataBind();
         chart.Series[0].Name = seriesname;
         //the legend will display the labels of the items, instead of the name of the series             
         chart.Series[0].Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.Nothing;
         chart.Update();
     }
     else { chart.Clear(); chart.Update(); chart.Refresh(); }
 }
Exemple #20
0
 /// <summary>
 /// Event handler when user wants to Export the Grid to PDF
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public static void btnExportChartPDF_Click(RadChart chart, Stream stream, DocumentLayoutMode layoutMode = DocumentLayoutMode.Paged,
                                            PageOrientation orientation = PageOrientation.Landscape)
 {
     try
     {
         RadDocument document = PrintChart(chart);
         document.LayoutMode = layoutMode;
         document.SectionDefaultPageOrientation = orientation;
         document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
         document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));
         PdfFormatProvider provider = new PdfFormatProvider();
         provider.Export(document, stream);
     }
     catch (Exception ex)
     {
         Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
     }
 }
Exemple #21
0
        /// <summary>
        /// Helper Method for printing Chart
        /// </summary>
        /// <param name="chart">The Chart to be Printed</param>
        private static RadDocument CreateChartDocumentPart(RadChart chart)
        {
            try
            {
                RadDocument document = new RadDocument();
                Telerik.Windows.Documents.Model.Section   section   = new Telerik.Windows.Documents.Model.Section();
                Telerik.Windows.Documents.Model.Paragraph paragraph = new Telerik.Windows.Documents.Model.Paragraph();
                BitmapImage bi = new BitmapImage();

                using (MemoryStream ms = new MemoryStream())
                {
                    chart.ExportToImage(ms, new PngBitmapEncoder());
                    bi.SetSource(ms);
                }

                double imageWidth  = chart.ActualWidth;
                double imageHeight = chart.ActualHeight;

                if (imageWidth > 625)
                {
                    imageWidth  = 625;
                    imageHeight = chart.ActualHeight * imageWidth / chart.ActualWidth;
                }

                ImageInline image = new ImageInline(new WriteableBitmap(bi))
                {
                    Width = imageWidth, Height = imageHeight
                };
                paragraph.Inlines.Add(image);
                section.Blocks.Add(paragraph);
                document.Sections.Add(section);
                return(document);
            }
            catch (Exception ex)
            {
                Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                return(null);
            }
        }
        private void ButtonOfSettings_Click(object sender, RoutedEventArgs e)
        {
            Nullable <bool> result = new WindowSettings().ShowDialog();

            if (result != true)
            {
                return;
            }

            //Максимальное количество точек
            //ButtonMaxCountPoint.Content = Peremennye.Instance._maxCountPoint.ToString();

            foreach (UIElement _elementChildren in this.GridTable.Children)
            {
                if (_elementChildren.GetType().Name != "RadChart")
                {
                    continue;
                }
                RadChart _elementRadChart = (RadChart)_elementChildren;

                foreach (DataSeries lineSeries in _elementRadChart.DefaultView.ChartArea.DataSeries)
                {
                    DeletePointInChart(lineSeries);
                }
            }
            //-

            //Добавление-удаление графиков
            int _beginI = FileChecker.Instance._filePathList.Count;
            int _endI   = Peremennye.Instance._tableFilePath.Count;

            for (int i = _beginI; i < _endI; i++)
            {
                int             numRadChart = i;
                StrPathToExange _newStr     = Peremennye.Instance._tableFilePath[i];

                AddChartInGrid(numRadChart, _newStr._strNameExchange, _newStr._strNameExchangeBack, _newStr._strFilePath, _newStr._strFilePathBack);
            }
        }
        public void InstallationOfColorOfTheChart(int numTable, Boolean exchangeIsStopped)
        {
            String numTableString = numTable.ToString();

            Dispatcher.BeginInvoke(new ThreadStart(delegate
            {
                int numRadChart           = numTable / 2;
                string _elementName       = "RadChart" + numRadChart.ToString();
                RadChart _elementRadChart = FindElementRadChart(this.GridTable.Children, _elementName);


                System.Windows.Media.Brush br;
                if (exchangeIsStopped)
                {
                    br = new SolidColorBrush(System.Windows.Media.Color.FromArgb(40, 255, 0, 0));
                }
                else
                {
                    br = new SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 255, 255, 255));
                }

                if (!(_elementRadChart.Background is System.Windows.Media.SolidColorBrush))
                {
                    _elementRadChart.Background = br;
                }

                if (((System.Windows.Media.SolidColorBrush)(_elementRadChart.Background)).Color !=
                    ((System.Windows.Media.SolidColorBrush)(br)).Color)
                {
                    _elementRadChart.Background = br;
                    if (this.WindowState == System.Windows.WindowState.Minimized)
                    {
                        this.WindowState     = System.Windows.WindowState.Normal;
                        MyNotifyIcon.Visible = false;
                        this.ShowInTaskbar   = true;
                    }
                }
            }));
        }
Exemple #24
0
        internal static void ApplyOfficeBlackThemeForChart(RadChart radChart, ChartArea chartArea, ChartLegend chartLegend)
        {
            //Old Fills
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 0, 198, 255)));
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 27, 255, 0)));
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 255, 141, 0)));
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 255, 35, 0)));
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 169, 0, 255)));
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 255, 0, 212)));
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 55, 172, 179)));
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 180, 191, 53)));
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 54, 92, 161)));
            //radChart.PaletteBrushes.Add(new SolidColorBrush(Color.FromArgb(255, 152, 115, 93)));

            //radChart.DefaultView.ChartArea.AxisX.Title = "AxisX";
            //radChart.DefaultView.ChartArea.AxisY.Title = "AxisY";
            //radChart.DefaultView.ChartTitle.Content = "Office Black";

            radChart.Style            = Application.Current.Resources["CustomChart"] as Style;
            radChart.AxisElementBrush = new SolidColorBrush(Colors.White);
            radChart.AxisForeground   = new SolidColorBrush(Colors.White);

            if (chartLegend != null)
            {
                chartLegend.Style           = Application.Current.Resources["CustomLegend"] as Style;
                chartLegend.LegendItemStyle = Application.Current.Resources["CustomLegendItemTemplate"] as Style;
            }

            radChart.DefaultView.ChartTitle.Style = Application.Current.Resources["CustomTitle"] as Style;

            if (chartArea != null)
            {
                chartArea.AxisX.AxisStyles.AlternateStripLineStyle = Application.Current.Resources["HorizontalStripLineStyle"] as Style;
                chartArea.AxisY.AxisStyles.AlternateStripLineStyle = Application.Current.Resources["VerticalStripLineStyle"] as Style;
            }
        }
        /// <summary>
        /// Creates the graphs for each question.
        /// </summary>
        private void CreateGraphs()
        {
            var questions = new SurveyRepository().LoadAnswerResponseCounts(this.SurveyId);
            foreach (var questionPair in questions)
            {
                var question = questionPair.First;
                var answers = questionPair.Second.ToArray();

                const int TitleHeight = 25;
                const int AnswerHeight = 16;
                const int HeaderFooterHeight = 70;
                var linesOfTitleText = (int)Math.Ceiling(question.Text.Length / (double)35);
                var chart = new RadChart
                    {
                        ChartTitle = { TextBlock = { Text = this.GetQuestionLabel(question.RelativeOrder, question.Text, false) } },
                        SeriesOrientation = ChartSeriesOrientation.Horizontal,
                        Skin = TelerikChartsSkin,
                        Height = Unit.Pixel((linesOfTitleText * TitleHeight) + (AnswerHeight * answers.Length) + HeaderFooterHeight),
                        Legend = { Visible = false },
                        AutoTextWrap = true,
                        AutoLayout = true,
                        HttpHandlerUrl = this.ResolveUrl("~/ChartImage.axd"),
                        EnableHandlerDetection = false,
                        PlotArea =
                            {
                                XAxis = { Appearance = { TextAppearance = { Visible = false } } },
                                YAxis = { AxisLabel = { TextBlock = { Text = this.Localize("Axis Label.Text") }, Visible = true } }
                            },
                    };

                var chartSeries = new ChartSeries();
                foreach (var answerPair in answers)
                {
                    var answer = answerPair.First;
                    var answerCount = answerPair.Second;

                    chartSeries.Items.Insert(0, new ChartSeriesItem(answerCount, this.GetAnswerLabel(answer.RelativeOrder, answer.Text, false)));
                }

                chart.Series.Add(chartSeries);
                this.ChartsPanel.Controls.Add(chart);
            }

            var charts = this.ChartsPanel.Controls.OfType<RadChart>();
            if (!charts.Any())
            {
                return;
            }

            var maxHeight = charts.Select(c => (int)c.Height.Value).Max();
            foreach (var chart in charts)
            {
                chart.Height = Unit.Pixel(maxHeight);
            }
        }
Exemple #26
0
        /// <summary>
        /// Creates the chart control.
        /// </summary>
        private void CreateChartControl()
        {
            objRadChart = new RadChart();
            objRadChart.ID = "obj" + this.ReportName.ToString() + "chart";
            this.Controls.Add(objRadChart);

            objRadToolTipManager = new RadToolTipManager();
            objRadToolTipManager.ID = "objRadToolTipDirectionalSurvey";
            objRadToolTipManager.Animation = ToolTipAnimation.Slide;
            objRadToolTipManager.Position = ToolTipPosition.TopCenter;
            objRadToolTipManager.AutoTooltipify = true;
            objRadToolTipManager.Skin = "Telerik";
            objRadToolTipManager.Width = Unit.Pixel(200);
            this.Controls.Add(objRadToolTipManager);

            /// Read the values sent from Parent Window
            ReadParentWindowValue();
            /// Create Chart Appearance Properties
            CreateChartAppearanceProperties();

            /// Bind data to chart
            BindChartData();
        }
 public static void SetAnimationsSettings(RadChart rc_graphic)
 {
     rc_graphic.AnimationSettings.ItemAnimationDuration        = new TimeSpan(0, 0, 1);
     rc_graphic.AnimationSettings.ItemDelay                    = new TimeSpan(0);
     rc_graphic.AnimationSettings.TotalSeriesAnimationDuration = new TimeSpan(0, 0, 2);
 }
 private void SetupAxisXRange(RadChart chart, TimeSpan lengthOfClip)
 {
     chart.DefaultView.ChartArea.AxisX.MinValue = zeroTime.ToOADate();
     chart.DefaultView.ChartArea.AxisX.MaxValue = zeroTime.Add(lengthOfClip).ToOADate();
     chart.DefaultView.ChartArea.AxisX.Step     = 1.0 / 24.0 / 3600.0 / 2.0;
 }
Exemple #29
0
    protected RadChart GenerateGroupVersusChart()
    {
        RadChart rc = new RadChart();

        // Customise
        rc.Width  = 465;
        rc.Height = 300;
        rc.Skin   = "Black";
        rc.ChartTitle.TextBlock.Text = "Group: Weekly SPA Overview";
        rc.PlotArea.EmptySeriesMessage.TextBlock.Text = "There are no reports for this week.";
        rc.Legend.Appearance.Visible = false;
        rc.PlotArea.XAxis.AutoScale  = false;
        rc.PlotArea.YAxis.AutoScale  = false;
        rc.AutoLayout = true;
        rc.ChartTitle.TextBlock.Appearance.TextProperties.Font           = new Font("Verdana", 10, FontStyle.Regular);
        rc.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
        rc.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;

        double highest_count = 0;
        // Get current SPAs for area
        // S series
        ChartSeries SSeries = new ChartSeries("SSeries", ChartSeriesType.Bar);

        SSeries.Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
        SSeries.Appearance.TextAppearance.TextProperties.Color = Color.White;
        SSeries.Appearance.TextAppearance.TextProperties.Font  = new System.Drawing.Font("Verdana", 8, FontStyle.Bold);
        SSeries.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.Dot;
        SSeries.Appearance.Border.Visible  = true;

        // P series
        ChartSeries PSeries = new ChartSeries("PSeries", ChartSeriesType.Bar);

        PSeries.Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
        PSeries.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.White;
        PSeries.Appearance.TextAppearance.TextProperties.Font  = new Font("Verdana", 8, FontStyle.Bold);
        PSeries.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.Dot;
        PSeries.Appearance.Border.Visible  = true;

        // A series
        ChartSeries ASeries = new ChartSeries("ASeries", ChartSeriesType.Bar);

        ASeries.Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
        ASeries.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.White;
        ASeries.Appearance.TextAppearance.TextProperties.Font  = new Font("Verdana", 8, FontStyle.Bold);
        ASeries.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.Dot;
        ASeries.Appearance.Border.Visible  = true;

        // Add series to chart
        rc.Series.Add(SSeries);
        rc.Series.Add(PSeries);
        rc.Series.Add(ASeries);

        for (int i = 0; i < offices.Rows.Count; i++)
        {
            String office    = (String)offices.Rows[i]["Office"];
            String shortname = (String)offices.Rows[i]["ShortName"];

            String qry = "SELECT " +
                         "SUM((mS+tS+wS+thS+fS+xS)) as Suspects,  " +
                         "SUM((mP+tP+wP+thP+fP+xP)) as Prospects,  " +
                         "SUM((mA+tA+wA+thA+fA+xA)) as Approvals,  " +
                         "SUM((mTotalRev+tTotalRev+wTotalRev+thTotalRev+fTotalRev+xTotalRev)) as TR,  " +
                         "SUM(PersonalRevenue) as PR, " +
                         "COUNT(*) as CCAs " +
                         "FROM db_progressreport pr, db_progressreporthead prh " +
                         "WHERE prh.ProgressReportID = pr.ProgressReportID " +
                         "AND Office=@office " +
                         "GROUP BY prh.ProgressReportID " +
                         "ORDER BY StartDate DESC LIMIT 1";
            DataTable dt_pr_info = SQL.SelectDataTable(qry, "@office", office);

            if (dt_pr_info.Rows.Count > 0)
            {
                int s = Convert.ToInt32(dt_pr_info.Rows[0]["Suspects"]);
                int p = Convert.ToInt32(dt_pr_info.Rows[0]["Prospects"]);
                int a = Convert.ToInt32(dt_pr_info.Rows[0]["Approvals"]);
                SSeries.AddItem(s);
                PSeries.AddItem(p);
                ASeries.AddItem(a);

                highest_count = Math.Max(highest_count, s);

                rc.PlotArea.XAxis.Items.Add(new ChartAxisItem(shortname));
            }
        }
        double max_value = Math.Floor(highest_count + (highest_count / 100) * 20);
        double step      = Math.Floor(highest_count / 5);

        if (step == 0)
        {
            step = 1;
        }
        rc.PlotArea.YAxis.AddRange(0, max_value, step);
        return(rc);
    }
Exemple #30
0
    protected RadChart GenerateVersusChart(String office)
    {
        RadChart rc = new RadChart();

        rc.Clear();
        rc.PlotArea.XAxis.Items.Clear();

        rc.Width  = 450;
        rc.Height = 300;
        rc.Skin   = "Black";
        rc.ChartTitle.TextBlock.Text = office + ": Weekly SPA Overview (Target to Actual)";
        rc.ChartTitle.TextBlock.Appearance.TextProperties.Font = new Font("Verdana", 10, FontStyle.Regular);
        rc.PlotArea.EmptySeriesMessage.TextBlock.Text          = "Error, database connection could not be establised.";
        //rc.PlotArea.SeriesOrientation = ChartSeriesOrientation.Horizontal;
        rc.Legend.Appearance.Visible = false;
        rc.PlotArea.YAxis.Appearance.TextAppearance.Visible = false;
        rc.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
        rc.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
        rc.PlotArea.XAxis.AutoScale = false;
        rc.PlotArea.YAxis.AutoScale = false;
        rc.AutoLayout = true;

        // Define chart target series
        ChartSeries SPATargetSeries = new ChartSeries("revTarget", ChartSeriesType.Bar);

        SPATargetSeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
        SPATargetSeries.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;;
        SPATargetSeries.Appearance.TextAppearance.TextProperties.Font  = new Font("Verdana", 7, FontStyle.Regular);
        rc.Series.Add(SPATargetSeries);

        // Define chart values series
        ChartSeries SPASeries = new ChartSeries("rev", ChartSeriesType.Bar);

        SPASeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
        SPASeries.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;;
        SPASeries.Appearance.TextAppearance.TextProperties.Font  = new Font("Verdana", 7, FontStyle.Regular);
        rc.Series.Add(SPASeries);

        int s       = 0;
        int p       = 0;
        int a       = 0;
        int tr      = 0;
        int pr      = 0;
        int no_ccas = 0;

        // Grab SPA
        String qry = "SELECT prh.ProgressReportID," +
                     "SUM((mS+tS+wS+thS+fS+xS)) as Suspects, " +
                     "SUM((mP+tP+wP+thP+fP+xP)) as Prospects, " +
                     "SUM((mA+tA+wA+thA+fA+xA)) as Approvals, " +
                     "SUM((mTotalRev+tTotalRev+wTotalRev+thTotalRev+fTotalRev+xTotalRev)) as TR, " +
                     "SUM(PersonalRevenue) as PR, " +
                     "COUNT(*) as CCAs, " +
                     "0 as RD, " +
                     "0 as PD " +
                     "FROM db_progressreport pr, db_progressreporthead prh " +
                     "WHERE prh.ProgressReportID = pr.ProgressReportID " +
                     "AND Office=@office " +
                     "GROUP BY prh.ProgressReportID " +
                     "ORDER BY StartDate DESC LIMIT 1";
        DataTable dt_report_info = SQL.SelectDataTable(qry, "@office", office);

        if (dt_report_info.Rows.Count > 0)
        {
            // Grab Target SPA
            int no_631 = 0;
            int no_321 = 0;
            qry = "SELECT CCAType, COUNT(*) as no FROM db_progressreport WHERE ProgressReportID=@ProgressReportID GROUP BY CCAType";
            DataTable ccas_types = SQL.SelectDataTable(qry, "@ProgressReportID", dt_report_info.Rows[0]["ProgressReportID"]);
            if (ccas_types.Rows.Count > 0)
            {
                for (int j = 0; j < ccas_types.Rows.Count; j++)
                {
                    switch (ccas_types.Rows[j]["CCAType"].ToString())
                    {
                    case "-1":
                        no_631 += Convert.ToInt32(ccas_types.Rows[j]["no"]);
                        break;

                    case "1":
                        no_631 += Convert.ToInt32(ccas_types.Rows[j]["no"]);
                        break;

                    case "2":
                        no_321 = Convert.ToInt32(ccas_types.Rows[j]["no"]);
                        break;
                    }
                }
            }
            int target_s = (no_631 * 3) + (no_321 * 6);
            int target_p = (no_631 * 2) + (no_321 * 3);
            int target_a = no_631 + no_321;

            s       = Convert.ToInt32(dt_report_info.Rows[0]["Suspects"]);
            p       = Convert.ToInt32(dt_report_info.Rows[0]["Prospects"]);
            a       = Convert.ToInt32(dt_report_info.Rows[0]["Approvals"]);
            tr      = Convert.ToInt32(dt_report_info.Rows[0]["TR"]);
            pr      = Convert.ToInt32(dt_report_info.Rows[0]["PR"]);
            no_ccas = Convert.ToInt32(dt_report_info.Rows[0]["CCAs"]);

            int greatest = s;
            greatest = Math.Max(p, greatest);
            greatest = Math.Max(a, greatest);
            greatest = Math.Max(a, greatest);
            greatest = Math.Max(target_s, greatest);
            greatest = Math.Max(target_p, greatest);
            greatest = Math.Max(target_a, greatest);
            greatest = Convert.ToInt32((((float)greatest / 100) * 108));

            double max_value = Convert.ToDouble(greatest) + 0.5;
            double step      = 1;
            rc.PlotArea.YAxis.AddRange(0, max_value, step);

            // Actual SPA
            ChartSeriesItem csi_a = new ChartSeriesItem(a, a.ToString(), Color.DodgerBlue, false);
            ChartSeriesItem csi_p = new ChartSeriesItem(p, p.ToString(), Color.Magenta, false);
            ChartSeriesItem csi_s = new ChartSeriesItem(s, s.ToString(), Color.Lime, false);
            // Target SPA
            ChartSeriesItem csi_ta = new ChartSeriesItem(target_a, target_a.ToString(), Color.DarkOrange, false);
            ChartSeriesItem csi_tp = new ChartSeriesItem(target_p, target_p.ToString(), Color.DarkOrange, false);
            ChartSeriesItem csi_ts = new ChartSeriesItem(target_s, target_s.ToString(), Color.DarkOrange, false);

            SPASeries.AddItem(csi_a);
            SPASeries.AddItem(csi_p);
            SPASeries.AddItem(csi_s);
            SPATargetSeries.AddItem(csi_ta);
            SPATargetSeries.AddItem(csi_tp);
            SPATargetSeries.AddItem(csi_ts);

            rc.PlotArea.XAxis.Items.Add(new ChartAxisItem("Ap"));
            rc.PlotArea.XAxis.Items.Add(new ChartAxisItem("Pr"));
            rc.PlotArea.XAxis.Items.Add(new ChartAxisItem("Su"));
            //rc.PlotArea.XAxis.Items.Add(new ChartAxisItem("T" + Environment.NewLine + Environment.NewLine + "A"));
            SPASeries.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            SPASeries.Appearance.Border.Visible  = true;
        }
        else
        {
            rc = null;
        }

        return(rc);
    }
 private void ConvertToBar(RadChart chart)
 {
     chart.Series[0].Type = Telerik.Charting.ChartSeriesType.Bar;
     chart.Update();
     chart.Refresh();
 }
    // Graphs
    protected void BindChart(RadChart chart, ChartSeriesType chartType, String chartTimeScale)
    {
        // Clear chart and reset total_usd
        double total_usd = 0;

        chart.Clear();
        chart.PlotArea.XAxis.Items.Clear();

        // Define parent chart series and format
        ChartSeries parent_series = new ChartSeries("parent_series", chartType);

        parent_series.Appearance.LegendDisplayMode = Telerik.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
        parent_series.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
        chart.Series.Add(parent_series);

        // Iterate offices
        double highest_price = 0;
        double lowest_price  = 999999;

        for (int i = 0; i < offices.Rows.Count; i++)
        {
            String territory = (String)offices.Rows[i]["Office"];
            String shortname = (String)offices.Rows[i]["ShortName"];
            Color  colour    = Util.ColourTryParse((String)offices.Rows[i]["Colour"]);

            // Toggle latest/annual data
            String timeScaleExpr = String.Empty;
            if (chartTimeScale == "latest")
            {
                timeScaleExpr = "=(SELECT SalesBookID FROM db_salesbookhead WHERE Office=@office ORDER BY StartDate DESC LIMIT 1) ";
            }
            else if (chartTimeScale == "annual")
            {
                timeScaleExpr = "IN (SELECT SalesBookID FROM db_salesbookhead WHERE Office=@office AND YEAR(StartDate)=@year) ";
            }

            // For each office..
            String qry = "SELECT ROUND(IFNULL(CONVERT(SUM(Price*Conversion), SIGNED),0)- " +
                         "IFNULL((SELECT CONVERT(SUM(rl_price*Conversion), SIGNED) " +
                         "FROM db_salesbook sb, db_salesbookhead sbh " +
                         "WHERE sb.rl_sb_id = sbh.SalesBookID " +
                         "AND sbh.SalesBookID " + timeScaleExpr +
                         "AND red_lined=1 AND IsDeleted=0 AND Office=@office),0)) as total_price " +
                         "FROM db_salesbook sb, db_salesbookhead sbh " +
                         "WHERE sb.sb_id = sbh.SalesBookID " +
                         "AND sbh.SalesBookID " + timeScaleExpr +
                         "AND deleted=0 AND IsDeleted=0";
            String[]  pn         = { "@office", "@year" };
            Object[]  pv         = { territory, dd_annual_year.Text };
            DataTable totalprice = SQL.SelectDataTable(qry, pn, pv);

            if (totalprice.Rows.Count > 0 && totalprice.Rows[0]["total_price"] != DBNull.Value)
            {
                double price             = Convert.ToDouble(totalprice.Rows[0]["total_price"]);
                String currency_terrtory = territory;

                total_usd += price;

                // Get max and min for chart padding
                highest_price = Math.Max(highest_price, price);
                lowest_price  = Math.Min(lowest_price, price);

                ChartSeriesItem csi_item = new ChartSeriesItem(
                    price,
                    Util.TextToCurrency(price.ToString(), "usd"),
                    colour,
                    false);

                csi_item.Name   = territory;
                csi_item.Parent = parent_series;
                parent_series.AddItem(csi_item);

                if (chart.ID.Contains("bar"))
                {
                    chart.PlotArea.XAxis.Items.Add(new ChartAxisItem(shortname));
                }
                else
                {
                    csi_item.Appearance.FillStyle.MainColor   = colour;
                    csi_item.Appearance.FillStyle.SecondColor = colour;
                }
            }
        }

        // Individual chart formatting
        if (chart.ID.Contains("rc_pie"))
        {
            parent_series.Appearance.TextAppearance.TextProperties.Color = Color.DarkOrange;
            lbl_drill_down.Text      = "Click a pie section to drill down";
            chart.ChartTitle.Visible = false;
            chart.Height             = 300;
        }
        else if (chart.ID.Contains("rc_bar"))
        {
            if (chart.ID.Contains("latest"))
            {
                parent_series.ActiveRegionToolTip = "Click to view the latest book for this territory.";
            }
            parent_series.Appearance.TextAppearance.TextProperties.Font = new Font("Verdana", 8, FontStyle.Regular);

            if (lowest_price != 0)
            {
                lowest_price = (lowest_price + (lowest_price / 100) * 40);
            }
            double step = highest_price / 10;
            if (step == 0)
            {
                step = 1;
            }
            rc_bar_latest.PlotArea.YAxis.AddRange(0, (highest_price + (highest_price / 100) * 20), step);
        }

        // Set total USD label
        lbl_total_usd.Text = "Total USD: " + Util.TextToCurrency(total_usd.ToString(), "us");
    }
Exemple #33
0
        protected void RadChartGrafica_PreRender(object sender, EventArgs e)
        {
            RadChart serie = (RadChart)sender;

            serie.Appearance.BarWidthPercent = 80;
        }
Exemple #34
0
        public MainWindow()
        {
            InitializeComponent();
            RadChart telerikChart = new RadChart();                //Chart Title

            telerikChart.DefaultView.ChartTitle.Content                = "Year 2009";
            telerikChart.DefaultView.ChartTitle.HorizontalAlignment    = HorizontalAlignment.Center;             //Chart Legend
            telerikChart.DefaultView.ChartLegend.UseAutoGeneratedItems = true;

            //Line Chart
            DataSeries lineSeries = new DataSeries();

            lineSeries.LegendLabel = "Turnover";
            lineSeries.Definition  = new LineSeriesDefinition();
            lineSeries.Add(new DataPoint()
            {
                YValue = 154, XCategory = "Jan"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 138, XCategory = "Feb"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 143, XCategory = "Mar"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 120, XCategory = "Apr"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 135, XCategory = "May"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 125, XCategory = "Jun"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 179, XCategory = "Jul"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 170, XCategory = "Aug"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 198, XCategory = "Sep"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 187, XCategory = "Oct"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 193, XCategory = "Nov"
            });
            lineSeries.Add(new DataPoint()
            {
                YValue = 176, XCategory = "Dec"
            });
            telerikChart.DefaultView.ChartArea.DataSeries.Add(lineSeries);

            //Bar Chart
            DataSeries barSeries = new DataSeries();

            barSeries.LegendLabel = "Expenses";
            barSeries.Definition  = new BarSeriesDefinition();
            barSeries.Add(new DataPoint()
            {
                YValue = 45, XCategory = "Jan"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 48, XCategory = "Feb"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 53, XCategory = "Mar"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 41, XCategory = "Apr"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 32, XCategory = "May"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 28, XCategory = "Jun"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 63, XCategory = "Jul"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 74, XCategory = "Aug"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 77, XCategory = "Sep"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 85, XCategory = "Oct"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 89, XCategory = "Nov"
            });
            barSeries.Add(new DataPoint()
            {
                YValue = 80, XCategory = "Dec"
            });
            telerikChart.DefaultView.ChartArea.DataSeries.Add(barSeries);

            this.AddChild(telerikChart);
        }
        public static SeriesMapping InitChartData(ClusterEnsemble.Attribute att_objetive, SeriesMapping sm1, RadChart rc_graphic)
        {
            SeriesMapping result = null;

            switch (att_objetive.AttributeType)
            {
            case AttributeType.String:
            case AttributeType.Nominal:
            case AttributeType.Date:
                rc_graphic.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;
                result = InitChartDataString(sm1);
                break;

            case AttributeType.Numeric:
                rc_graphic.DefaultView.ChartArea.AxisX.LabelRotationAngle = 0;
                result = InitChartDataNumeric(sm1);
                break;

            default:
                break;
            }
            return(result);
        }
        public static SeriesMapping InitChart2D(ClusterEnsemble.Attribute att_objetive, RadChart rc_graphic)
        {
            SeriesMapping sm1 = new SeriesMapping();

            sm1.SeriesDefinition = new BarSeriesDefinition();
            sm1.LegendLabel      = "Set Values";

            return(InitChartData(att_objetive, sm1, rc_graphic));
        }
        public static SeriesMapping InitChart(ClusterEnsemble.Attribute att_objetive, RadChart rc_graphic, CheckBox dim)
        {
            bool isChecked = (bool)dim.IsChecked;

            if (isChecked)
            {
                return(InitChart3D(att_objetive, rc_graphic));
            }
            else
            {
                return(InitChart2D(att_objetive, rc_graphic));
            }
        }