Hi I have create 4 different series with each series with different color :-
series item is populated as :-
seriesB.Points.Add(DateTime.ParseExact(Convert.ToString(reader["opportunity_timestamp"]).Split(' ')[0], "yyyy-MM-dd", null).Date, Convert.ToDouble(reader["open"]), Convert.ToDouble(reader["high"]), Convert.ToDouble(reader["low"]), Convert.ToDouble(reader["close"]));
x-axis date "YYYY-MM-DD HH:MM:SS is broken into only date via code, now
chart x-axis still shows date and time , I am unable to understand from where the time is coming.
Please see the candle wicks .. I think chart is not rendered properly, I refreshed the chart but doesnt work.
I have used the below code
this.chartControl1.PrimaryXAxis.ValueType = Syncfusion.Windows.Forms.Chart.ChartValueType.DateTime;
this.chartControl1.PrimaryXAxis.Format = "dd-MMM-yyyy";
I want only 90 candles shown on chart with proper spacing .. zooming can decrease the spacing between candles but should not increase
Thank you in advance - HB
zoomed :-
Hi Hitesh Bhardwaj,
We have validated your query and would like to inform you that the DateTimeAxis generates labels and intervals based on the chart range and series data points.
Query 1: To specify the label format for DateTimeAxis, you can use the DateTimeFormat property on PrimaryXAxis. Here’s an example:
chartControl1.PrimaryXAxis.DateTimeFormat = "MMM dd"; |
Query 2: In the screenshot, we suspect that may appear as an additional series rather than a candlestick wick. Since you mentioned using four series, it’s possible that an extra series might be affecting the appearance.
If possible, could you share the details of the 90 data points and confirm the types of series you are using? Its help us to provide the better solution.
Thank you for your patience and understanding.
Best regards,
Arul Jenith B.
In database timestamp is stored like below, just want to clarify the export I am attaching, I have to remove few columns from the table so excel changed the date:- Your guidance worked for :-
chartControl1.PrimaryXAxis.DateTimeFormat = "yyyy MMM dd";
Thank you !!!
I have attached you the code and csv file of the table. code have few addtional things which I am checking with chart object which are commented in c#
Hi Hitesh Bhardwaj,
Thank you for providing the data points and code snippets. We have prepared and tested the sample, ensuring that the candle wick renders as expected. Additionally, we have verified the functionality of zooming and panning, both of which are working as intended.
We have attached the sample for your reference. If possible, could you please attempt to reproduce the issue using the sample and share it back to us?
We appreciate your patience and understanding.
Best regards,
Arul Jenith B.
I am unable to understand how you loaded the text file to chart.. can you please help?
Hi Hitesh Bhardwaj,
We retrieve the data from the text file using StreamReader. In the provided sample, we included your provided text file in the sample folder and used its file path to retrieve the data.
Below is the code snippet:
private void GetSeriesPoints(ChartSeries seriesYellow, ChartSeries seriesBlue, ChartSeries seriesWhite, ChartSeries seriesGreen) { //Retrieve the data from the Text file and use the text file name. var data = ReadDataFromFile("bigmovechart.txt");
foreach (var (Date, Color, Open, High, Low, Close) in data) { ChartSeries series = Color switch { "Yellow" => seriesYellow, "Blue" => seriesBlue, "White" => seriesWhite, "Green" => seriesGreen, _ => null };
if (series != null) { series.Points.Add(new ChartPoint(Date.ToOADate(), new double[] { High, Low, Open, Close })); } } } |
private List<(DateTime Date, string Color, double Open, double High, double Low, double Close)> ReadDataFromFile(string filePath) { var data = new List<(DateTime, string, double, double, double, double)>();
try { using (var reader = new StreamReader(filePath)) { // Skip the header line reader.ReadLine();
while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(',');
// Parse each row var symbol = values[0]; var timestamp = DateTime.ParseExact(values[1], "dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture); var color = values[2]; var open = double.Parse(values[4]); var high = double.Parse(values[5]); var low = double.Parse(values[6]); var close = double.Parse(values[7]);
data.Add((timestamp, color, open, high, low, close)); } } } catch (Exception ex) { MessageBox.Show($"Error reading file: {ex.Message}"); }
return data; } |
For more details, you can review the attached sample. We hope this helps fulfill your requirements! If you need any further assistance, feel free to ask.
Thank you for your understanding.
Best regards,
Arul Jenith B.