I use TeeChart.NET 2.0. I used WebChart and set Chart.XValues.DateTime = true, x value show in DateTime.
But when I use Export textformat, the xvalue in file always is float.
How can I to write datetime text in file?
My code:
string filename = Server.MapPath("~/App_Data/chart.txt");
Steema.TeeChart.Export.DataExport dataExport = new Steema.TeeChart.Export.DataExport(tChart1.Chart);
dataExport.Text.TextDelimiter = ",";
dataExport.Text.IncludeHeader = true;
dataExport.Text.IncludeIndex = false;
dataExport.Text.IncludeLabels = true;
dataExport.Text.Series = WebChart1.Chart.Series[0];
dataExport.Text.Save(filename);
Result text file:
X,Y
39106.6729166667,0
39106.6729166667,0
39106.6833333333,0
39106.6833333333,0
39106.69375,26.5299987792969
39106.69375,26.5299987792969
39106.7041666667,26.2299995422363
39106.7041666667,26.2299995422363
39106.7145833333,26.5299987792969
39106.725,25.6200008392334
TeeChart.NET 2.0 Export Text file datetime type
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi scott,
In that case you'll have to save the file in a stream and then manipulate the double values into the string values of your choice. Something like this:
In that case you'll have to save the file in a stream and then manipulate the double values into the string values of your choice. Something like this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Bar bar;
private void InitializeChart()
{
tChart1.Series.Add(bar = new Steema.TeeChart.Styles.Bar());
Random rnd = new Random();
DateTime now = DateTime.Today;
char label;
for (int i = 0; i < 10; i++)
{
label = Convert.ToChar(65 + i);
bar.Add(now, rnd.NextDouble(), label.ToString());
now = now.AddDays(1);
}
}
private void button1_Click(object sender, EventArgs e)
{
MemoryStream ms = new MemoryStream();
string fileName = @"C:\temp\newexport.txt";
tChart1.Export.Data.Text.IncludeHeader = true;
tChart1.Export.Data.Text.IncludeIndex = false;
tChart1.Export.Data.Text.IncludeLabels = true;
tChart1.Export.Data.Text.Save(ms);
ms.Position = 0;
StreamReader reader = new StreamReader(ms);
string line, newLine;
string[] lines;
DateTime date;
StringBuilder result = new StringBuilder(1);
if (tChart1.Export.Data.Text.IncludeHeader)
{
result.Append(reader.ReadLine() + tChart1.Export.Data.Text.TextLineSeparator);
}
while (!reader.EndOfStream)
{
line = reader.ReadLine();
lines = line.Split(Convert.ToChar(tChart1.Export.Data.Text.TextDelimiter));
if (lines.Length > 1)
{
date = DateTime.FromOADate(Convert.ToDouble(lines[1]));
newLine = lines[0] + tChart1.Export.Data.Text.TextDelimiter + date.ToLongDateString() +
tChart1.Export.Data.Text.TextDelimiter + lines[2] + tChart1.Export.Data.Text.TextLineSeparator;
result.Append(newLine);
}
}
StreamWriter writer = new StreamWriter(fileName, false, System.Text.Encoding.Unicode);
writer.Write(result.ToString());
writer.Flush();
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi scott,
You're welcome. I'm glad to hear this works fine at your end. We might consider adding the necessary properties to the export and import classes to do this automatically in future releases.
You're welcome. I'm glad to hear this works fine at your end. We might consider adding the necessary properties to the export and import classes to do this automatically in future releases.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |