Guest drobig Posted April 4, 2016 Report Share Posted April 4, 2016 Stacke bar chart: help my I was having an issue with this in a larger project, so I created a empty one just to isolate the problem. I have an empty windows form on which I dropped a single chart. In the form load event, I have the following code : Trial 8.0: c# public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { try { chart1.Data.Clear(); } catch { } chart1.Data.Series = 9; chart1.Data.Points = 3; chart1.ToolBar.Visible = true; chart1.DataGrid.Visible = true; Int32 serie = 0; chart1.Series[serie].Text = "Ancho"; chart1.Series[serie].Gallery = Gallery.Bar; chart1.Data[serie, 1] = 965; chart1.Data[serie, 2] = 0; chart1.Data[serie, 3] = 0; serie++; chart1.Series[serie].Text = "Espesor"; chart1.Series[serie].Gallery = Gallery.Lines; chart1.Data[serie, 1] = 6.35; chart1.Data[serie, 2] = 2.66; chart1.Data[serie, 3] = 6.35; chart1.Series[serie].AxisY = chart1.AxisY2; serie++; chart1.Series[serie].Text = "Serie3"; chart1.Series[serie].Gallery = Gallery.Lines; chart1.Data[serie, 1] = 0; chart1.Data[serie, 2] = 0; chart1.Data[serie, 3] = 0; serie++; chart1.Series[serie].Text = "Serie4"; chart1.Series[serie].Gallery = Gallery.Lines; chart1.Data[serie, 1] = 0; chart1.Data[serie, 2] = 0; chart1.Data[serie, 3] = 0; serie++; chart1.Series[serie].Text = "Salto Ancho"; chart1.Series[serie].Gallery = Gallery.Bar; chart1.Series[serie].Stacked = true; chart1.Data[serie, 1] = 0; chart1.Data[serie, 2] = 417.54; chart1.Data[serie, 3] = 482.50; serie++; chart1.Series[serie].Text = "Salto Espesor"; chart1.Series[serie].Gallery = Gallery.Bar; chart1.Series[serie].Stacked = true; chart1.Data[serie, 1] = 0; chart1.Data[serie, 2] = 417.54; chart1.Data[serie, 3] = 482.50; serie++; chart1.Series[serie].Text = "Ensanche"; chart1.Series[serie].Gallery = Gallery.Bar; chart1.Series[serie].Stacked = true; chart1.Data[serie, 1] = 0; chart1.Data[serie, 2] = 417.54; chart1.Data[serie, 3] = 0; serie++; chart1.Series[serie].Text = "Salto Dureza"; chart1.Series[serie].Gallery = Gallery.Bar; chart1.Series[serie].Stacked = true; chart1.Data[serie, 1] = 0; chart1.Data[serie, 2] = 0; chart1.Data[serie, 3] = 0; serie++; chart1.Series[serie].Text = "Salto Temperatura"; chart1.Series[serie].Gallery = Gallery.Bar; chart1.Series[serie].Stacked = true; chart1.Data[serie, 1] = 0; chart1.Data[serie, 2] = 0; chart1.Data[serie, 3] = 0; foreach (SeriesAttributes selSeries in chart1.Series) listBox1.Items.Add(selSeries.Text); listBox1.SelectedIndex = 0; } private void buttonToFront_Click(object sender, EventArgs e) { string sName = chart1.Series[listBox1.SelectedIndex].Text; chart1.Series[listBox1.SelectedIndex].BringToFront(); //Bring item to first in list and select it listBox1.Items.RemoveAt(listBox1.Items.IndexOf(sName)); listBox1.Items.Insert(0, sName); listBox1.SelectedIndex = 0; } private void buttonToBack_Click(object sender, EventArgs e) { string sName = chart1.Series[listBox1.SelectedIndex].Text; int nIndex; chart1.Series[listBox1.SelectedIndex].SendToBack(); //Put item Last in list and select it listBox1.Items.RemoveAt(listBox1.Items.IndexOf(sName)); nIndex = listBox1.Items.Add(sName); listBox1.SelectedIndex = nIndex; } private void button1_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex < listBox1.Items.Count - 1) { //cache the series array //SeriesAttributesCollection series = chart1.Series; System.Collections.ObjectModel.Collection<SeriesAttributes> series = chart1.Series; int nIndex = listBox1.SelectedIndex; SeriesAttributes currentSeries = chart1.Series[nIndex]; series.RemoveAt(nIndex); series.Insert(nIndex + 1, currentSeries); string sName = currentSeries.Text; listBox1.Items.RemoveAt(nIndex); listBox1.Items.Insert(nIndex + 1, sName); listBox1.SelectedIndex = nIndex + 1; } } private void button2_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex > 0) { //cache the series array // SeriesAttributesCollection series = chart1.Series; System.Collections.ObjectModel.Collection<SeriesAttributes> series = chart1.Series; int nIndex = listBox1.SelectedIndex; SeriesAttributes currentSeries = chart1.Series[nIndex]; series.RemoveAt(nIndex); series.Insert(nIndex - 1, currentSeries); string sName = currentSeries.Text; listBox1.Items.RemoveAt(nIndex); listBox1.Items.Insert(nIndex - 1, sName); listBox1.SelectedIndex = nIndex - 1; } } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { buttonToFront.Visible = listBox1.SelectedIndex > 0; buttonToBack.Visible = listBox1.SelectedIndex < listBox1.Items.Count - 1; } } } And: private void InitializeComponent() { this.chart1 = new ChartFX.WinForms.Chart(); this.buttonToBack = new System.Windows.Forms.Button(); this.buttonToFront = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.listBox1 = new System.Windows.Forms.ListBox(); ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); this.SuspendLayout(); // // chart1 // this.chart1.AllowDrop = true; this.chart1.AllSeries.MarkerTemplate = null; this.chart1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.chart1.Location = new System.Drawing.Point(9, 125); this.chart1.Name = "chart1"; this.chart1.PlotAreaColor = System.Drawing.Color.Transparent; this.chart1.RandomData.Points = 1; this.chart1.RandomData.Series = 1; this.chart1.Size = new System.Drawing.Size(561, 510); this.chart1.TabIndex = 0; // // buttonToBack // this.buttonToBack.Location = new System.Drawing.Point(305, 88); this.buttonToBack.Name = "buttonToBack"; this.buttonToBack.Size = new System.Drawing.Size(87, 20); this.buttonToBack.TabIndex = 11; this.buttonToBack.Text = "Send To Back"; this.buttonToBack.Click += new System.EventHandler(this.buttonToBack_Click); // // buttonToFront // this.buttonToFront.Location = new System.Drawing.Point(305, 66); this.buttonToFront.Name = "buttonToFront"; this.buttonToFront.Size = new System.Drawing.Size(87, 20); this.buttonToFront.TabIndex = 10; this.buttonToFront.Text = "Bring To Front"; this.buttonToFront.Visible = false; this.buttonToFront.Click += new System.EventHandler(this.buttonToFront_Click); // // button2 // this.button2.Location = new System.Drawing.Point(305, 13); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(87, 20); this.button2.TabIndex = 9; this.button2.Text = "Up"; this.button2.Click += new System.EventHandler(this.button2_Click); // // button1 // this.button1.Location = new System.Drawing.Point(305, 35); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(87, 20); this.button1.TabIndex = 8; this.button1.Text = "Down"; this.button1.Click += new System.EventHandler(this.button1_Click); // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(6, 13); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(81, 13); this.label2.TabIndex = 7; this.label2.Text = "Select a Series:"; // // listBox1 // this.listBox1.FormattingEnabled = true; this.listBox1.Location = new System.Drawing.Point(88, 12); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(211, 95); this.listBox1.TabIndex = 6; this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScroll = true; this.ClientSize = new System.Drawing.Size(582, 647); this.Controls.Add(this.buttonToBack); this.Controls.Add(this.buttonToFront); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.label2); this.Controls.Add(this.listBox1); this.Controls.Add(this.chart1); this.Name = "Form1"; this.Text = "Serie Perdida"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } private ChartFX.WinForms.Chart chart1; private System.Windows.Forms.Button buttonToBack; private System.Windows.Forms.Button buttonToFront; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label2; private System.Windows.Forms.ListBox listBox1; References: Ddls Trial 8.0 Dlls version ChartFX.Designer.8 8.0.5693.19342 ChartFX.WinForms.8 8.0.5693.19342 ChartFX.WinForms.Adornments.8 8.0.5693.19342 SoftwareFX.WinForms.Base.8 8.0.5693.19203 SoftwareFX.WinForms.Data.8 8.0.5693.19203 Chart: empty. ( < image not allowed > ) And press any key: ( < image not allowed > ) Trial 7.0 c#: Same code, replacing lines: //cache the series array SeriesAttributesCollection series = chart1.Series; // Trial 8.0: System.Collections.ObjectModel.Collection<SeriesAttributes> series = chart1.Series; Referencias: ddls Dlls version ChartFX.Designer 7.0.4962.20724 ChartFX.WinForms 7.0.4962.20751 ChartFX.WinForms.Adornments 7.0.4962.20707 ChartFX.WinForms.Base 7.0.4962.20686 ChartFX.WinForms.Data 7.0.4962.20801 Chart: in point x = 4, "Santo Ancho" and "Salto Espesor" by 483 is cero (0) ? ( < image not allowed >) And changing the order of the series: Note series "Espesor" is the first but is plotted behind “Salto Espesor”. ( < image not allowed > ) Please, I need to help me. I can not change the order of the series, as in the demo. This problem I have with the same dlls, but version : ChartFX.WinForms 7.0.4259.29043 ChartFX.WinForms.Adornments 7.0.4259.29005 ChartFX.WinForms.Base 7.0.4259.28993 ChartFX.WinForms.Data 7.0.4259.29087 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.