2系列(不同尺寸)的坏总和

时间:2017-01-08 00:30:57

标签: teechart

我有两个系列 - 两个不同的大小。下面的屏幕显示糟糕的汇总。 我使用下面的代码来汇总2个系列。

version
PostgreSQL 9.5.5 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609, 64-bit 

SDIAppForm-> Chart4-> Series [4] - > DataSources-> Add(SDIAppForm-> Chart4-> Series [3]); SDIAppForm-> Chart4-> Series [4] - > DataSources-> Add(SDIAppForm-> Chart4-> Series 1);

SDIAppForm-> Chart4->系列[4] - > CheckDataSource();

Series1 and Series3 are red colour, Black is wrong summ (partially overlap series 3

你有什么简单的想法我怎么解决问题?我不是TeeChart的专家,所以我会以简单的例子来说明如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

使用插值函数解决问题

    float InterpolateLineSeries_Power(  double XValue, int APMChart4SeriesCounter_)
 // FirstIndex, LastIndex: Integer; XValue: Double): Double;
{
  int Index=0;
  double dx,dy;
               for ( Index = SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->FirstDisplayedIndex(); Index < SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->LastValueIndex ; Index++) {
                 if ((SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->XValues->Value[Index])>XValue)  break;

               }


  //safeguard
  if (Index<1)  Index=1;
  else if (Index>=SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->Count())  Index=SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->Count()-1;

  // y=(y2-y1)/(x2-x1)*(x-x1)+y1
  dx=SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->XValues->Value[Index] - SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->XValues->Value[Index-1];
  dy=SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->YValues->Value[Index] - SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->YValues->Value[Index-1];

  if (dx!=0)
    return dy/dx*(XValue - SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->XValues->Value[Index-1]) + SDIAppForm->Chart4->Series[APMChart4SeriesCounter+3]->YValues->Value[Index-1] ;
  else  return 0;
}