i am using ColumnSeries in UltraDataChart.
Create a Series in one function and call the SaveTo function.Sometimes an empty image is created.So I want to check the state of the chart control and call a SaveTo function.ex)void Test(){ createSeries(chart); chart.SaveTo(~~);}
Hello,
Thank you for the post.
You should be calling Flush method before save to, Usually flush is called if the visual of the SeriesViewer needs to be synchronously saved or evaluated.
Let me know if you have any question.
Regards,
Divya Jain
That method failed. Can you please check the attached file?
I have been investigating into the behavior you are seeing, and the biggest reason I can think of that your export to image isn’t working is likely due to the IsTransitionInEnabled property being set to true on your ColumnSeries. This will cause the ColumnSeries to animate at the start, and since your export happens right after assigning the series in your button click, this animation has not finished yet, and so the export is blank.
To prevent this, I would recommend marking your button click as an async method so that you can do an “await Task.Delay(2000),” which I have found works to export the chart successfully.
I am attaching a sample project to demonstrate. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
UltraDataChartSaveToImageDemo.zip
i can't upload file.
so i upload .cs and .designer.cs codes.
using Infragistics.Win.DataVisualization; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace DataChart { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void ultraButton1_Click(object sender, EventArgs e) { int imageWidth = 488; int imageHeigh = 268; Size size = new System.Drawing.Size(imageWidth, imageHeigh); setchart1(ultraDataChart1); ultraDataChart1.Flush(); ultraDataChart1.SaveTo("test.png",System.Drawing.Imaging.ImageFormat.Png,size); } private void setchart1(UltraDataChart chart) { chart.Series.Clear(); //이전 데이터 사용할거면 아래 축 초기화 X chart.Axes.Clear(); model1 model1 = new model1() { Name = "model1", data1 = 2, data2 = 2 }; List<model1> data = new List<model1>() { model1 }; var xAxis = new CategoryXAxis { Label = "Name", DataSource = data, LabelLocation = AxisLabelsLocation.OutsideBottom }; var yAxis = new NumericYAxis { Title = "titleY", //MinimumValue = Math.Round(data[0].Plus / 2) }; for (int i = 0; i < 2; i++) { var series = new ColumnSeries { DataSource = data, ValueMemberPath = i==0? "data1": "data2", XAxis = xAxis, YAxis = yAxis, IsHighlightingEnabled = true, IsTransitionInEnabled = true, ShowDefaultTooltip = true, }; chart.Series.Add(series); } chart.Axes.Add(xAxis); chart.Axes.Add(yAxis); } class model1 { public string Name { get; set; } public double data1 { get; set; } public double data2 { get; set; } } private void ultraButton2_Click(object sender, EventArgs e) { ultraDataChart1.Series.Clear(); //이전 데이터 사용할거면 아래 축 초기화 X ultraDataChart1.Axes.Clear(); } } }
namespace DataChart { partial class Form1 { /// <summary> /// 필수 디자이너 변수입니다. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 사용 중인 모든 리소스를 정리합니다. /// </summary> /// <param name="disposing">관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form 디자이너에서 생성한 코드 /// <summary> /// 디자이너 지원에 필요한 메서드입니다. /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. /// </summary> private void InitializeComponent() { this.ultraDataChart1 = new Infragistics.Win.DataVisualization.UltraDataChart(); this.ultraButton1 = new Infragistics.Win.Misc.UltraButton(); this.ultraButton2 = new Infragistics.Win.Misc.UltraButton(); ((System.ComponentModel.ISupportInitialize)(this.ultraDataChart1)).BeginInit(); this.SuspendLayout(); // // ultraDataChart1 // this.ultraDataChart1.BackColor = System.Drawing.Color.White; this.ultraDataChart1.CrosshairPoint = new Infragistics.Win.DataVisualization.Point(double.NaN, double.NaN); this.ultraDataChart1.Location = new System.Drawing.Point(12, 12); this.ultraDataChart1.MarkerBrushes.Add(new Infragistics.Win.DataVisualization.SolidColorBrush(System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))))); this.ultraDataChart1.Name = "ultraDataChart1"; this.ultraDataChart1.Size = new System.Drawing.Size(291, 235); this.ultraDataChart1.TabIndex = 0; this.ultraDataChart1.Text = "ultraDataChart1"; // // ultraButton1 // this.ultraButton1.Location = new System.Drawing.Point(12, 253); this.ultraButton1.Name = "ultraButton1"; this.ultraButton1.Size = new System.Drawing.Size(75, 23); this.ultraButton1.TabIndex = 6; this.ultraButton1.Text = "run"; this.ultraButton1.Click += new System.EventHandler(this.ultraButton1_Click); // // ultraButton2 // this.ultraButton2.Location = new System.Drawing.Point(93, 253); this.ultraButton2.Name = "ultraButton2"; this.ultraButton2.Size = new System.Drawing.Size(75, 23); this.ultraButton2.TabIndex = 7; this.ultraButton2.Text = "clear"; this.ultraButton2.Click += new System.EventHandler(this.ultraButton2_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(313, 282); this.Controls.Add(this.ultraButton2); this.Controls.Add(this.ultraButton1); this.Controls.Add(this.ultraDataChart1); this.Name = "Form1"; this.Text = "Form1"; ((System.ComponentModel.ISupportInitialize)(this.ultraDataChart1)).EndInit(); this.ResumeLayout(false); } #endregion private Infragistics.Win.DataVisualization.UltraDataChart ultraDataChart1; private Infragistics.Win.Misc.UltraButton ultraButton1; private Infragistics.Win.Misc.UltraButton ultraButton2; } }