Home Forums WinForms controls Xceed Chart for WinForms Problem with X axis after changing values and refresh

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18984 |

    I have a chart with two line series, the first series showing the quantity of products purchased, the second series showing the future demand for a product. The user can select to display data over a one or two year period (x axis – date time, y axis – double) centred on the current date. The chart is initially configured to show data over a one year period. When changing the time period I clear the values from the line series and then add the new XY values. 

    The chart is initially displayed correctly for the one year period, however when changed to display for a two year period the data is plotted within a one year range.

    Initial one year display:

    One Year

    On changing to two year period the following is displayed:

    Here is the code to populate the data:

        public void UpdateData(DateQuantitySeriesInfoCollection salesOrderSummaryInfoCollection,

          DateQuantitySeriesInfoCollection mrpImportDataSummaryInfoCollection)

        {

          Chart chart = chartControl1.Charts[0];

     

          if (chart.Series.Count >= 2) {

            var historyLineSeries = (LineSeries)chart.Series[0];

            UpdateLineSeries(historyLineSeries, salesOrderSummaryInfoCollection);

     

            var projectionLineSeries = (LineSeries)chart.Series[1];

            UpdateLineSeries(projectionLineSeries, mrpImportDataSummaryInfoCollection);

          }

     

          chartControl1.Refresh();

        }

     

        private static void UpdateLineSeries(LineSeries lineSeries, DateQuantitySeriesInfoCollection dateQuantitySeriesInfoCollection)

        {

          lineSeries.Values.Clear();

          lineSeries.Interactivity.Tooltips.Clear();

     

          foreach (DateQuantitySeriesInfo dateQuantitySeriesInfo in dateQuantitySeriesInfoCollection) {

            double quantity = Convert.ToDouble(dateQuantitySeriesInfo.Quantity);

            lineSeries.AddXY(quantity, dateQuantitySeriesInfo.Date.ToOADate());

            lineSeries.Interactivity.Tooltips.Add(quantity);

          }

        }

     

    Imported from legacy forums. Posted by Chris (had 2317 views)

    User (Old forums)
    Member
    Post count: 23064

    I don’t know how you set up the X axis and the series, since you have not shown this part of the code, but the only thing I can think of at this point is that the dates filled to the series are not right (they are all within the same year).

    Imported from legacy forums. Posted by André (had 379 views)

    User (Old forums)
    Member
    Post count: 23064

    I have verified that the data is correct, and this is supported by the fact that the x axis changes to a two year range. The chart has been initialised using the designer in VS, the relevant code is shown below:

         #region Component Designer generated code

        /// <summary>
        /// Required method for Designer support – do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
          this.components = new System.ComponentModel.Container();
          System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PartAnalysisGraphView));
          this.kryptonHeaderGroup1 = new ComponentFactory.Krypton.Toolkit.KryptonHeaderGroup();
          this.buttonSpecHeaderGroup1 = new ComponentFactory.Krypton.Toolkit.ButtonSpecHeaderGroup();
          this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
          this.oneYearsDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
          this.twoYearsDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
          this.chartControl1 = new Xceed.Chart.ChartControl();
          ((System.ComponentModel.ISupportInitialize)(this.kryptonHeaderGroup1)).BeginInit();
          ((System.ComponentModel.ISupportInitialize)(this.kryptonHeaderGroup1.Panel)).BeginInit();
          this.kryptonHeaderGroup1.Panel.SuspendLayout();
          this.kryptonHeaderGroup1.SuspendLayout();
          this.contextMenuStrip1.SuspendLayout();
          this.SuspendLayout();
          //
          // kryptonHeaderGroup1
          //
          this.kryptonHeaderGroup1.ButtonSpecs.AddRange(new ComponentFactory.Krypton.Toolkit.ButtonSpecHeaderGroup[] {
                this.buttonSpecHeaderGroup1});
          this.kryptonHeaderGroup1.Dock = System.Windows.Forms.DockStyle.Fill;
          this.kryptonHeaderGroup1.HeaderStylePrimary = ComponentFactory.Krypton.Toolkit.HeaderStyle.Secondary;
          this.kryptonHeaderGroup1.HeaderVisibleSecondary = false;
          this.kryptonHeaderGroup1.Location = new System.Drawing.Point(0, 0);
          this.kryptonHeaderGroup1.Name = “kryptonHeaderGroup1”;
          //
          // kryptonHeaderGroup1.Panel
          //
          this.kryptonHeaderGroup1.Panel.Controls.Add(this.chartControl1);
          this.kryptonHeaderGroup1.Size = new System.Drawing.Size(853, 651);
          this.kryptonHeaderGroup1.TabIndex = 1;
          this.kryptonHeaderGroup1.Text = “History / Projection”;
          this.kryptonHeaderGroup1.ValuesPrimary.Description = “”;
          this.kryptonHeaderGroup1.ValuesPrimary.Heading = “History / Projection”;
          this.kryptonHeaderGroup1.ValuesPrimary.Image = null;
          this.kryptonHeaderGroup1.ValuesSecondary.Description = “”;
          this.kryptonHeaderGroup1.ValuesSecondary.Heading = “Description”;
          this.kryptonHeaderGroup1.ValuesSecondary.Image = null;
          //
          // buttonSpecHeaderGroup1
          //
          this.buttonSpecHeaderGroup1.ContextMenuStrip = this.contextMenuStrip1;
          this.buttonSpecHeaderGroup1.ExtraText = “1 years data”;
          this.buttonSpecHeaderGroup1.Image = null;
          this.buttonSpecHeaderGroup1.Text = “Graph:”;
          this.buttonSpecHeaderGroup1.ToolTipImage = null;
          this.buttonSpecHeaderGroup1.Type = ComponentFactory.Krypton.Toolkit.PaletteButtonSpecStyle.Context;
          this.buttonSpecHeaderGroup1.UniqueName = “838664DE44B84E16838664DE44B84E16”;
          //
          // contextMenuStrip1
          //
          this.contextMenuStrip1.Font = new System.Drawing.Font(“Segoe UI”, 8.25F);
          this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.oneYearsDataToolStripMenuItem,
                this.twoYearsDataToolStripMenuItem});
          this.contextMenuStrip1.Name = “contextMenuStrip1”;
          this.contextMenuStrip1.Size = new System.Drawing.Size(143, 48);
          //
          // oneYearsDataToolStripMenuItem
          //
          this.oneYearsDataToolStripMenuItem.Name = “oneYearsDataToolStripMenuItem”;
          this.oneYearsDataToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
          this.oneYearsDataToolStripMenuItem.Text = “1 years data”;
          this.oneYearsDataToolStripMenuItem.Click += new System.EventHandler(this.oneYearsDataToolStripMenuItem_Click);
          //
          // twoYearsDataToolStripMenuItem
          //
          this.twoYearsDataToolStripMenuItem.Name = “twoYearsDataToolStripMenuItem”;
          this.twoYearsDataToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
          this.twoYearsDataToolStripMenuItem.Text = “2 years data”;
          this.twoYearsDataToolStripMenuItem.Click += new System.EventHandler(this.twoYearsDataToolStripMenuItem_Click);
          //
          // chartControl1
          //
          this.chartControl1.BackColor = System.Drawing.SystemColors.Control;
          this.chartControl1.Background = ((Xceed.Chart.Standard.Background)(resources.GetObject(“chartControl1.Background”)));
          this.chartControl1.Charts = ((Xceed.Chart.Core.ChartCollection)(resources.GetObject(“chartControl1.Charts”)));
          this.chartControl1.Dock = System.Windows.Forms.DockStyle.Fill;
          this.chartControl1.InteractivityOperations = ((Xceed.Chart.Core.InteractivityOperationsCollection)(resources.GetObject(“chartControl1.InteractivityOperations”)));
          this.chartControl1.Labels = ((Xceed.Chart.Standard.ChartLabelCollection)(resources.GetObject(“chartControl1.Labels”)));
          this.chartControl1.Legends = ((Xceed.Chart.Core.LegendCollection)(resources.GetObject(“chartControl1.Legends”)));
          this.chartControl1.Location = new System.Drawing.Point(0, 0);
          this.chartControl1.Name = “chartControl1”;
          this.chartControl1.Settings = ((Xceed.Chart.Core.Settings)(resources.GetObject(“chartControl1.Settings”)));
          this.chartControl1.Size = new System.Drawing.Size(851, 623);
          this.chartControl1.TabIndex = 0;
          this.chartControl1.Text = “chartControl1”;
          this.chartControl1.Watermarks = ((Xceed.Chart.Standard.WatermarkCollection)(resources.GetObject(“chartControl1.Watermarks”)));
          //
          // PartAnalysisGraphView
          //
          this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
          this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
          this.Controls.Add(this.kryptonHeaderGroup1);
          this.Name = “PartAnalysisGraphView”;
          this.Size = new System.Drawing.Size(853, 651);
          ((System.ComponentModel.ISupportInitialize)(this.kryptonHeaderGroup1.Panel)).EndInit();
          this.kryptonHeaderGroup1.Panel.ResumeLayout(false);
          ((System.ComponentModel.ISupportInitialize)(this.kryptonHeaderGroup1)).EndInit();
          this.kryptonHeaderGroup1.ResumeLayout(false);
          this.contextMenuStrip1.ResumeLayout(false);
          this.ResumeLayout(false);

        }

        #endregion

    If you want me to send a test project illustrating this then let me know and let me know how to get it to you

    Imported from legacy forums. Posted by Chris (had 537 views)

    User (Old forums)
    Member
    Post count: 23064

    I was thinking more of the code where you actually setup the chart and the line series.

     

    Imported from legacy forums. Posted by André (had 1882 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.