示例#1
0
        /// <summary>
        /// Initializes chart data from a sample data table.
        /// </summary>
        protected void InitializeChartData(int totalXValues)
        {
            // Create a sample table:
            DataTable tableSource = this.CreateLargeTable(totalXValues);

            //Initializes new chart series.
            ChartSeries series = new ChartSeries("population", ChartSeriesType.Spline);

            // Instantiate the Model that "dilutes" the large set of data points based on the current chart width. Instead of just skipping
            // points, this model uses an average of a set of points and uses those averages instead of the points.
            this.model = new ChartOversizedDataBindModel(this.chartControl1, tableSource, "X", "Y");

            // Update chart settings based on the Model:
            this.InitChartBasedOnModel(model);

            // Assign this data model to the new series.
            series.SeriesModel = model;

            //Adds the series to the ChartSeriesCollection.
            this.chartControl1.Series.Add(series);

            this.UpdateChartTitle();

            series.PrepareStyle += new ChartPrepareStyleInfoHandler(series_PrepareStyle);
            this.chartControl1.EnableXZooming        = true;
            model.DilutionFactorChanged             += new EventHandler(model_DilutionFactorChanged);
            this.chartControl1.ChartFormatAxisLabel += new ChartFormatAxisLabelEventHandler(ChartWebControl1_ChartFormatAxisLabel);
        }
示例#2
0
        void model_DilutionFactorChanged(object sender, EventArgs e)
        {
            // Could happen when chart resizes or zoomed in.
            this.UpdateChartTitle();
            ChartOversizedDataBindModel model = sender as ChartOversizedDataBindModel;

            this.chartControl1.PrimaryXAxis.Range = new MinMaxInfo(0, model.Count, (int)(model.Count / 10));
        }
示例#3
0
        private void InitChartBasedOnModel(ChartOversizedDataBindModel model)
        {
            this.chartControl1.PrimaryXAxis.ValueType = ChartValueType.Double;
            this.chartControl1.PrimaryXAxis.RangeType = ChartAxisRangeType.Set;
            this.chartControl1.PrimaryXAxis.Range     = new MinMaxInfo(0, model.Count, (int)(model.Count / 10));

            this.chartControl1.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;
            double maxY = model.GetMaxY();

            this.chartControl1.PrimaryYAxis.Range = new MinMaxInfo(0, maxY, (int)(maxY / 10));
        }
示例#4
0
        /// <summary>
        /// Initializes chart data from access database.
        /// </summary>
        protected void InitializeChartData()
        {
            int yMax         = 100;
            int totalXValues = 100000;

            DataTable tableSource = this.CreateLargeTable(totalXValues, yMax);

            #region MASTERCHART
            //Sets the value type and of the axes. Setting this ensures that the ranges stay consistent as you zoom into the chart.
            // Master Chart
            this.SetChartRange(this.chartControl1.PrimaryXAxis, new MinMaxInfo(0, totalXValues, totalXValues / 10));

            this.SetChartRange(this.chartControl1.PrimaryYAxis, new MinMaxInfo(0, yMax, yMax / 10));

            //Initializes new chart series.
            ChartSeries series = new ChartSeries();
            series.Name = "Population";
            series.Type = ChartSeriesType.Spline;

            // Model that "dilutes" the large set of data points based on the current chart width. Instead of just skipping
            // points, this model uses an average of a set of points.
            ChartOversizedDataBindModel model = new ChartOversizedDataBindModel(this.chartControl1, tableSource, "X", "Y", false);
            // Assign this data model to the new series.
            series.SeriesModel           = model;
            model.DilutionFactorChanged += new EventHandler(model_DilutionFactorChanged);
            //Adds the series to the ChartSeriesCollection.
            this.chartControl1.Series.Add(series);

            this.chartControl1.EnableXZooming = true;

            SetStripLine(0, 10000);
            #endregion

            #region DETAILCHART
            // Detail Chart
            this.SetChartRange(this.chartControl2.PrimaryXAxis, new MinMaxInfo(0, totalXValues / 10, totalXValues / 100));
            this.SetChartRange(this.chartControl2.PrimaryYAxis, new MinMaxInfo(0, yMax, yMax / 10));

            ChartSeries series2 = new ChartSeries();
            series2.Name = "Population";
            series2.Type = ChartSeriesType.Spline;

            ChartOversizedDataBindModel model2 = new ChartOversizedDataBindModel(this.chartControl2, tableSource, "X", "Y");
            // Assign this data model to the new series.
            series2.SeriesModel           = model2;
            model2.DilutionFactorChanged += new EventHandler(model_DilutionFactorChanged);
            this.chartControl2.Series.Add(series2);

            #endregion
            this.UpdateChartSubTitles();
        }
示例#5
0
        void ChartWebControl1_ChartFormatAxisLabel(object sender, ChartFormatAxisLabelEventArgs e)
        {
            if (e.AxisOrientation == ChartOrientation.Horizontal)
            {
                // Here we customize the label text for a point by getting the text from the model:
                ChartOversizedDataBindModel model = this.chartControl1.Series[0].SeriesModel as ChartOversizedDataBindModel;

                int index = (int)e.Value;
                if (model != null && index < model.Count)
                {
                    // The fact that the data type is DateTiem is based on our knowledge of the bound data source.
                    DateTime date = (DateTime)model.GetXData((int)e.Value);
                    e.Label = this.GetFormattedLabelText(date);
                }
                else
                {
                    e.Label = String.Empty;
                }

                e.Handled = true;
            }
        }