Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: Messenger design with C# Pin
Gerry Schmitz9-Dec-23 6:35
mveGerry Schmitz9-Dec-23 6:35 
Questionis there any way to get bordercolor same as candle color using ternary in the code below Pin
j k Nov20236-Dec-23 5:48
j k Nov20236-Dec-23 5:48 
AnswerRe: is there any way to get bordercolor same as candle color using ternary in the code below Pin
Gerry Schmitz9-Dec-23 6:32
mveGerry Schmitz9-Dec-23 6:32 
QuestionC# code to chart sometimes charting blank charts Pin
Iskander1234530-Nov-23 16:01
Iskander1234530-Nov-23 16:01 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Ralf Meier30-Nov-23 21:12
mveRalf Meier30-Nov-23 21:12 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123451-Dec-23 0:52
Iskander123451-Dec-23 0:52 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Ralf Meier1-Dec-23 2:03
mveRalf Meier1-Dec-23 2:03 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123451-Dec-23 4:43
Iskander123451-Dec-23 4:43 
I tried setting breakpoints, but then got an error which said something to the effect "break point won't break because some symbol isn't there". I couldn't do away with that error so I put some checks in the code itself, to make sure that the label86 was a proper integer, that there was actually data to be plotted etc, and I ran the new code. It never went to the coded error messages and still the charts were plotted blank. Is it possible the fault is somewhere in the chart settings? maybe the series become transparent or something? But why would this happen only when we use "Where" and try to plot a part of the table data?

void PlotChart()
        {
            try
            {
                // Check if label86.Text can be converted to an integer
                if (!int.TryParse(label86.Text.Trim(), out int rawDataOrder))
                {
                    MessageBox.Show("Invalid RawDataOrder value. Please enter a valid integer.", "Error PlotChart", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return; // Exit the method
                }

                using (SqlConnection connection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True"))
                {
                    using (SqlCommand command = new SqlCommand("SELECT * FROM SerialDataNIBP WHERE RawDataOrder = @RawDataOrder", connection))
                    {
                        // Open the connection if it's not already open
                        if (connection.State != ConnectionState.Open)
                        {
                            connection.Open();
                        }

                        command.Parameters.AddWithValue("@RawDataOrder", rawDataOrder);

                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            // Check if any data is returned
                            if (!reader.HasRows)
                            {
                                MessageBox.Show("No data found for the given RawDataOrder.", "Error PlotChart", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return; // Exit the method
                            }

                            chart1.Series.Clear();

                            Series PulseCh1 = new Series("Series11");
                            Series PressureCh1 = new Series("Series12");

                            PulseCh1.ChartType = SeriesChartType.Spline;
                            PressureCh1.ChartType = SeriesChartType.Spline;

                            PulseCh1.Color = Color.Blue;
                            PressureCh1.Color = Color.Orange;

                            while (reader.Read())
                            {
                                var id = reader.GetInt32(0);
                                var value11 = reader.GetInt32(1);
                                var value12 = reader.GetInt32(8);

                                PulseCh1.Points.AddXY(id, value11);
                                PressureCh1.Points.AddXY(id, value12);
                            }

                            chart1.Series.Add(PulseCh1);
                            chart1.Series.Add(PressureCh1);

                            chart1.Titles.Clear();
                            chart1.Titles.Add(new Title("Channel 1"));

                            // Uncomment the line below if you want to refresh the chart display
                            chart1.Update();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error PlotChart", MessageBoxButtons.OK, MessageBoxIcon.Error);

                // Log the exception or handle it based on your application's requirements
            }
        }

GeneralRe: C# code to chart sometimes charting blank charts Pin
Ralf Meier1-Dec-23 6:18
mveRalf Meier1-Dec-23 6:18 
SuggestionRe: C# code to chart sometimes charting blank charts Pin
Richard Deeming30-Nov-23 21:56
mveRichard Deeming30-Nov-23 21:56 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Richard MacCutchan30-Nov-23 22:15
mveRichard MacCutchan30-Nov-23 22:15 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123451-Dec-23 0:23
Iskander123451-Dec-23 0:23 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Richard MacCutchan1-Dec-23 2:06
mveRichard MacCutchan1-Dec-23 2:06 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Dave Kreskowiak1-Dec-23 5:02
mveDave Kreskowiak1-Dec-23 5:02 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Andre Oosthuizen1-Dec-23 22:30
mveAndre Oosthuizen1-Dec-23 22:30 
AnswerRe: C# code to chart sometimes charting blank charts Pin
jschell1-Dec-23 6:35
jschell1-Dec-23 6:35 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Gerry Schmitz2-Dec-23 8:02
mveGerry Schmitz2-Dec-23 8:02 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123452-Dec-23 16:02
Iskander123452-Dec-23 16:02 
Questionc# code Pin
j k Nov202329-Nov-23 17:13
j k Nov202329-Nov-23 17:13 
AnswerRe: c# code Pin
lmoelleb29-Nov-23 19:31
lmoelleb29-Nov-23 19:31 
GeneralRe: c# code Pin
j k Nov202329-Nov-23 20:04
j k Nov202329-Nov-23 20:04 
AnswerRe: c# code Pin
jschell30-Nov-23 6:05
jschell30-Nov-23 6:05 
AnswerRe: c# code Pin
Andre Oosthuizen1-Dec-23 22:35
mveAndre Oosthuizen1-Dec-23 22:35 
GeneralRe: c# code Pin
j k Nov20232-Dec-23 20:34
j k Nov20232-Dec-23 20:34 
GeneralRe: c# code Pin
Andre Oosthuizen3-Dec-23 2:35
mveAndre Oosthuizen3-Dec-23 2:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.