问题描述
我使用的是.NET WinForm的版本的TeeChart 4.1.2012.1032。
我修改您提供的样本。 扩展\减少点数\下采样附加但是当我放大图,快绳的标志数是不是100,downSampling.DisplayedPointCount。我怎样才能解决这个问题?
私人无效InitializeChart()
{
this.cursorTool1 =新Steema.TeeChart.Tools.CursorTool(); //
this.tChart1.Tools.Add(this.cursorTool1); //
this.cursorTool1.FollowMouse = TRUE; //
this.cursorTool1.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical; //
this.cursorTool1.Change + =新Steema.TeeChart.Tools.CursorChangeEventHandler(this.cursorTool1_Change); //
CreateArrays();
tChart1.Aspect.View3D = FALSE;
tChart1.Zoom.Direction = ZoomDirections.Both; //水平; //
tChart1.Series.Add(点=新Steema.TeeChart.Styles.Points());
tChart1.Series.Add(快绳=新Steema.TeeChart.Styles.FastLine());
下采样=新Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points.Add(xValues,yValues);
points.Active = FALSE;
downSampling.DisplayedPointCount = 100;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLast; //空;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.DataSource =分;
fastLine.Function =下采样;
this.tChart1.Axes.Custom.Add(新Steema.TeeChart.Axis(this.tChart1.Chart)); //
this.tChart1 [1] .CustomVertAxis = this.tChart1.Axes.Custom [0]; //
this.tChart1 [0] .CustomVertAxis = this.tChart1.Axes.Custom [0]; //
this.fastLine.Marks.Visible = TRUE; //
}
私人无效CreateArrays()
{
INT长度= 2600000;
xValues =新的可空<双> [长度];
yValues =新的可空<双> [长度];
随机RND =新的随机();
的for(int i = 0; I<长度;我++)
{
xValues [我] =我;
yValues [我] =我;
}
}
私人无效tChart1_Zoomed(对象发件人,EventArgs的)
{
tChart1 [1] .CheckDataSource(); //系列1是功能系列
}
在DisplayedPointCount指定多少点下采样功能应该油漆并显示这个数字为点的最大数量。作为<一个href="http://www.teechart.net/support/viewtopic.php?f=4&t=9575&p=39483&hilit=DisplayedPointCount#p39483"相对=nofollow>我在这里解释,你可能需要将它与宽容属性相结合来获得期望的结果。所以,你可以做这样的事情:
公共部分类Form1中:形态
{
公共Form1中()
{
的InitializeComponent();
InitializeChart();
}
私人无效InitializeChart()
{
//tChart1.Dock = DockStyle.Fill;
tChart1.Aspect.View3D = FALSE;
tChart1.Zoomed + = tChart1_Zoomed;
Steema.TeeChart.Styles.Points points1 =新Steema.TeeChart.Styles.Points(tChart1.Chart);
随机Y =新的随机();
的for(int i = 0; I&LT; 10000;我++)
{
points1.Add(DateTime.Now.AddHours(ⅰ),y.Next());
}
points1.XValues.DateTime =真;
points1.Pointer.HorizSize = 1;
points1.Pointer.VertSize = 1;
Steema.TeeChart.Functions.DownSampling downSampling1 =新Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
downSampling1.Method = Steema.TeeChart.Functions.DownSamplingMethod.Average;
downSampling1.Tolerance = 100;
downSampling1.DisplayedPointCount = Convert.ToInt32(downSampling1.Tolerance * 4);
Steema.TeeChart.Styles.Line行1 =新Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.Function = downSampling1;
line1.DataSource = points1;
line1.Marks.Visible = TRUE;
line1.Marks.Style = MarksStyles.PointIndex;
UpdateTitle();
}
无效tChart1_Zoomed(对象发件人,EventArgs的)
{
tChart1 [1] .CheckDataSource();
UpdateTitle();
}
私人无效UpdateTitle()
{
tChart1.Header.Text =(tChart1 [1]。功能作为Steema.TeeChart.Functions.DownSampling).DisplayedPointCount.ToString();
}
}
I use a .NET Winform version teechart 4.1.2012.1032.
I modified the sample that you supplied. "Extended\Reducing number of points\DownSampling Additions"But When I zoom in chart, fastline's marks count is not 100 , downSampling.DisplayedPointCount.How can I resolve it?
private void InitializeChart()
{
this.cursorTool1 = new Steema.TeeChart.Tools.CursorTool();//
this.tChart1.Tools.Add(this.cursorTool1);//
this.cursorTool1.FollowMouse = true;//
this.cursorTool1.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;//
this.cursorTool1.Change += new Steema.TeeChart.Tools.CursorChangeEventHandler(this.cursorTool1_Change);//
CreateArrays();
tChart1.Aspect.View3D = false;
tChart1.Zoom.Direction = ZoomDirections.Both;//.Horizontal;//
tChart1.Series.Add(points = new Steema.TeeChart.Styles.Points());
tChart1.Series.Add(fastLine = new Steema.TeeChart.Styles.FastLine());
downSampling = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
points.Add(xValues, yValues);
points.Active = false;
downSampling.DisplayedPointCount = 100;
downSampling.Method = Steema.TeeChart.Functions.DownSamplingMethod.MinMaxFirstLast;// Null;
fastLine.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint;
fastLine.DataSource = points;
fastLine.Function = downSampling;
this.tChart1.Axes.Custom.Add(new Steema.TeeChart.Axis(this.tChart1.Chart));//
this.tChart1[1].CustomVertAxis = this.tChart1.Axes.Custom[0];//
this.tChart1[0].CustomVertAxis = this.tChart1.Axes.Custom[0];//
this.fastLine.Marks.Visible = true;//
}
private void CreateArrays()
{
int length = 2600000;
xValues = new Nullable<double>[length];
yValues = new Nullable<double>[length];
Random rnd = new Random();
for (int i = 0; i < length; i++)
{
xValues[i] = i;
yValues[i] = i;
}
}
private void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource(); //series 1 is the function series
}
The DisplayedPointCount specifies how many points the DownSampling function should paint and displays this number as a maximum number of points. As I explained here, you may need to combine it with Tolerance property to get the results you expect. So, you could do something like this:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
//tChart1.Dock = DockStyle.Fill;
tChart1.Aspect.View3D = false;
tChart1.Zoomed += tChart1_Zoomed;
Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
Random y = new Random();
for (int i = 0; i < 10000; i++)
{
points1.Add(DateTime.Now.AddHours(i), y.Next());
}
points1.XValues.DateTime = true;
points1.Pointer.HorizSize = 1;
points1.Pointer.VertSize = 1;
Steema.TeeChart.Functions.DownSampling downSampling1 = new Steema.TeeChart.Functions.DownSampling(tChart1.Chart);
downSampling1.Method = Steema.TeeChart.Functions.DownSamplingMethod.Average;
downSampling1.Tolerance = 100;
downSampling1.DisplayedPointCount = Convert.ToInt32(downSampling1.Tolerance * 4);
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.Function = downSampling1;
line1.DataSource = points1;
line1.Marks.Visible = true;
line1.Marks.Style = MarksStyles.PointIndex;
UpdateTitle();
}
void tChart1_Zoomed(object sender, EventArgs e)
{
tChart1[1].CheckDataSource();
UpdateTitle();
}
private void UpdateTitle()
{
tChart1.Header.Text = (tChart1[1].Function as Steema.TeeChart.Functions.DownSampling).DisplayedPointCount.ToString();
}
}
这篇关于放大下采样图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!