Exemplo n.º 1
0
        /// <summary>
        /// Binds the specified graph.
        /// </summary>
        /// <param name="graph">The graph.</param>
        /// <param name="chart">The chart.</param>
        /// <param name="multiView">The multi view.</param>
        protected virtual void DataBind(Data.Model.Graph graph)
        {
            if (graph.GraphType == Data.Model.Enum.GraphType.Static)
            {
                this.Chart.Visible = true;
                this.dataBindGraphStatic(graph);
            }
            else
            {
                this.dataBindGraphDynamic(graph);
            }

            if (this.GraphUpdated != null)
            {
                this.GraphUpdated(this, EventArgs.Empty);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Datas the bind graph dynamic.
        /// </summary>
        /// <param name="graph">The graph.</param>
        private void dataBindGraphDynamic(Data.Model.Graph graph)
        {
            if (graph.ContainsData())
            {
                this.XType     = graph.XType;
                this.XLabel    = graph.XLabel;
                this.YLabel    = graph.YLabel;
                this.YYLabel   = graph.YYLabel;
                this.ChartType = graph.ChartType;

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                serializer.RegisterConverters(new JavaScriptConverter[] { new GraphConverter() });

                this.Json = serializer.Serialize(graph);
                this.Views.ActiveViewIndex = 1;
            }
            else
            {
                this.Views.ActiveViewIndex = 2;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Datas the bind graph static.
        /// </summary>
        /// <param name="graph">The graph.</param>
        private void dataBindGraphStatic(Data.Model.Graph graph)
        {
            SeriesChartType seriesChartType =
                AppActs.Client.WebSite.Base.Dictionaries.chartTypeToSeriesChartType[graph.ChartType];

            Font fontTitle = new Font("Verdana", 10, FontStyle.Regular);
            Font FontAxes  = new Font("Verdana", 8, FontStyle.Regular);

            this.Chart.ChartAreas["ChartAreaMain"].AxisX.LabelStyle.Font = FontAxes;
            this.Chart.ChartAreas["ChartAreaMain"].AxisX.TitleFont       = fontTitle;
            this.Chart.ChartAreas["ChartAreaMain"].AxisX.Title           = graph.XLabel;

            this.Chart.ChartAreas["ChartAreaMain"].AxisY.LabelStyle.Font = FontAxes;
            this.Chart.ChartAreas["ChartAreaMain"].AxisY.TitleFont       = fontTitle;
            this.Chart.ChartAreas["ChartAreaMain"].AxisY.Title           = graph.YLabel;

            if (graph.ContainsData())
            {
                foreach (GraphSeries graphSeries in graph.Series)
                {
                    Series series = new Series(graphSeries.Name);
                    series.ChartType = seriesChartType;

                    if (seriesChartType == SeriesChartType.Line)
                    {
                        series.MarkerStyle = MarkerStyle.Square;
                        series.BorderWidth = 4;
                        series.MarkerSize  = 6;
                    }
                    else if (seriesChartType == SeriesChartType.Bar)
                    {
                        //series["DrawingStyle"] = "Cylinder";
                        series.BackImageWrapMode = ChartImageWrapMode.Scaled;
                    }
                    else if (seriesChartType == SeriesChartType.Pie)
                    {
                        this.Chart.Legends.Add(new Legend()
                        {
                            Enabled = true
                        });
                        series["PieLabelStyle"]   = "Disabled";
                        series["PieDrawingStyle"] = "Default";
                    }

                    if (String.IsNullOrEmpty(graph.YYLabel))
                    {
                        if (graph.Series.Count == 1)
                        {
                            series.ToolTip = String.Format("{0} #VALX\n{1} #VALY\n", graph.XLabel, graph.YLabel);
                        }
                        else
                        {
                            series.ToolTip = String.Format("{0}\n {1} #VALX\n{2} #VALY\n", graphSeries.Name, graph.XLabel, graph.YLabel);
                        }

                        for (int i = graphSeries.Axis.Count - 1; i >= 0; i--)
                        {
                            series.Points.AddXY(graphSeries.Axis[i].X, graphSeries.Axis[i].Y);
                        }
                    }
                    else
                    {
                        if (graph.Series.Count == 1)
                        {
                            series.ToolTip = String.Format("{0} #VALX\n{1} #VALY\n {2} [YY]", graph.XLabel, graph.YLabel, graph.YYLabel);
                        }
                        else
                        {
                            series.ToolTip = String.Format("{0} \n {1} #VALX\n{2} #VALY\n {3} [YY]", graphSeries.Name, graph.XLabel, graph.YLabel, graph.YYLabel);
                        }

                        for (int i = graphSeries.Axis.Count - 1; i >= 0; i--)
                        {
                            int index = series.Points.AddXY(graphSeries.Axis[i].X, graphSeries.Axis[i].Y.ToString("n2"));
                            series.Points[index].ToolTip = series.Points[index].ToolTip.Replace("[YY]", graphSeries.Axis[i].YY.ToString());
                        }
                    }

                    this.Chart.Series.Add(series);
                }

                this.Views.ActiveViewIndex = 0;
            }
            else
            {
                this.Views.ActiveViewIndex = 2;
            }

            //if there are more then 1 series we need to show legends
            if (this.Chart.Series.Count > 1)
            {
                this.Chart.Legends.Add(new Legend()
                {
                    Enabled = true
                });
            }
        }