[C#]
for (int i = 0; i < series.Points.Count; i++)
{
if (series.Points[i].YValues[0] > 0)
{
series.Styles[i].Border.Width = 2;
//Color for line type series like line, spline, etc
series.Styles[i].Border.Color = Color.Green;
//Color for column and other types of series like column, bar, pie, candle, etc
series.Styles[i].Interior = new Syncfusion.Drawing.BrushInfo(Color.Green);
}
else
{
series.Styles[i].Border.Width = 2;
series.Styles[i].Border.Color = Color.Red;
series.Styles[i].Interior = new Syncfusion.Drawing.BrushInfo(Color.Red);
}
}
|
Thank u for your fast reply.
series.Styles[i].Interior = new Syncfusion.Drawing.BrushInfo(Color.Red);
was worked for me for spline series rather than
private void MyTimer_Tick(object sender, EventArgs e)
{
if (chart.PrimaryXAxis.StripLines[0].End == 50)
{
chart.PrimaryXAxis.StripLines[0].Start = 0;
chart.PrimaryXAxis.StripLines[0].End = chart.PrimaryXAxis.StripLines[0].Start + 5;
myTimer.Stop();
}
else
{
chart.PrimaryXAxis.StripLines[0].Start = chart.PrimaryXAxis.StripLines[0].End;
chart.PrimaryXAxis.StripLines[0].End = chart.PrimaryXAxis.StripLines[0].End + 5;
}
} |
[C#]
chart.PrimaryXAxis.VisibleRangeChanged += PrimaryXAxis_VisibleRangeChanged;
//Update strip line whenever axis range gets changed
void PrimaryXAxis_VisibleRangeChanged(object sender, EventArgs e)
{
ChartAxis axis = sender as ChartAxis;
ChartStripLine stripLine = axis.StripLines[0];
//Customize stripline for the first time
if(!axis.StripLines[0].Enabled){
stripLine.Text = "ECG";
stripLine.Enabled = true;
stripLine.Vertical = true;
stripLine.TextColor = Color.Cyan;
stripLine.Period = 2000;
stripLine.TextAlignment = ContentAlignment.MiddleCenter;
stripLine.Font = new Font("Arial", 10, FontStyle.Bold);
stripLine.Interior = new BrushInfo(230, new BrushInfo(GradientStyle.ForwardDiagonal, Color.Gray, Color.Gainsboro));
}
stripLine.Start = axis.VisibleRange.Min;
stripLine.Width = 5;
stripLine.End = axis.VisibleRange.Min + 5;
}
|
[C#]
void PopulateData(ChartSeries series, int pointsCount)
{
//Binding list to bind with chart
data = new BindingList<ChartData>();
double y = 0;
//Populate the data for binding list
for (int i = 0; i < pointsCount; i++)
{
y = r.Next(-5, 5);
y = y > 2 ? 0.5 : y < -2 ? -0.5 : 0;
data.Add(new ChartData() { X = i, Y = y });
}
//Bind the BindingList with ChartSeries using ChartDataBindModel
//Chart will update automatically whenever the binding list is updated
//No additional code required for updating
series.SeriesModel = new ChartDataBindModel(data) {
//Field to bind with X-values of chart series
XName = "X",
//Field to bind with Y-values of chart series
YNames = new string[]
{ "Y" }
};
}
|
chart.BeginUpdate();
//Intially adding 200 points for each series
for (int i = 0; i < 200; i++)
{
series.Points.Add(i, random.Next(0, 50));
series1.Points.Add(i, random.Next(100, 150));
series2.Points.Add(i, random.Next(150, 200));
series3.Points.Add(i, random.Next(50, 100));
series4.Points.Add(i, random.Next(200, 250));
}
chart.EndUpdate(); |
void timer_Tick(object sender, EventArgs e)
{
if (count < 1000)
{
count = count + 1;
chart.BeginUpdate();
series.Points.Add(count, random.Next(0, 50));
series1.Points.Add(count, random.Next(100, 150));
series2.Points.Add(count, random.Next(150, 200));
series3.Points.Add(count, random.Next(50, 100));
series4.Points.Add(count, random.Next(200, 250));
chart.EndUpdate();
}
else
{
count = 0;
}
} |
chart.ImprovePerformance = true;
chart.CalcRegions = true;
series.EnableStyles = false;
series1.EnableStyles = false;
series2.EnableStyles = false;
series3.EnableStyles = false;
series4.EnableStyles = false;
chart.BeginUpdate();
//Add or update points here
chart.EndUpdate(); |
private void button1_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += pd_PrintPage;
pd.Print();
}
void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
this.chartControl1.Draw(ev.Graphics, new Rectangle(0, 0, 250, 250));
this.chartControl2.Draw(ev.Graphics, new Rectangle(0, 260, 250, 250));
this.chartControl3.Draw(ev.Graphics, new Rectangle(0, 260, 250, 250));
} |
Hi Sir,
I have problem in plotting data in three charts at the same time.I have two minutes of recorded data. I have to plot that data like just it is plotting while recording.
I have Three lists of data and have to be plotted like said above. I used timers for this but it is slow. I need graph to be plotted in 2 minutes.
list1 and list 2 each list has count of 34045 approximately
list3 with count of 6710 approximately.
I have to plot this 3 lists in 3 separate chart controls.(but not the series of same chart)
I used chartseriesmodel also but it is not showing graphically,but adding in the chart points in debugging.
Please help me to solve this issue....
public void AddPoint(int val1, int val2){
if (point1 < 34046)
{
for (int i = val1-6809; i < val1; i++)
{
populations.Add(new PopulationData(i, random.Next(50, 100)));
populations1.Add(new PopulationData(i, random.Next(30, 50)));
}
for (int j = val2-1342; j < val2; j++)
{
populations2.Add(new PopulationData(j, random.Next(10, 20)));
}
ChartDataBindModel dataSeriesModel = new ChartDataBindModel(populations);
ChartDataBindModel dataSeriesModel1 = new ChartDataBindModel(populations1);
ChartDataBindModel dataSeriesModel2 = new ChartDataBindModel(populations2);
dataSeriesModel.YNames = new string[] { "Y" };
dataSeriesModel1.YNames = new string[] { "Y" };
dataSeriesModel2.YNames = new string[] { "Y" };
series.SeriesModel = dataSeriesModel;
series1.SeriesModel = dataSeriesModel1;
series2.SeriesModel = dataSeriesModel2;
point1 = point1 + 6809;
point2 = point2 + 1342;
}
else
{
timer.Stop();
MessageBox.Show("stopped");
}
} |
chartControl1.ImprovePerformance = true;
chartControl2.ImprovePerformance = true;
chartControl3.ImprovePerformance = true;
chartControl1.CalcRegions = false;
chartControl2.CalcRegions = false;
chartControl3.CalcRegions = false; |