Discussion of article "Visualize this! MQL5 graphics library similar to 'plot' of R language" - page 4

 
Roman Konopelko:

Good afternoon, how exactly did you try to redraw the chart?

If you just need to change the data for a specific curve, here is an example:

#include <Graphics\Graphic.mqh>
//+------------------------------------------------------------------+
//| Script programme start function|
//+------------------------------------------------------------------+
voidOnStart()
  {
//--- data 1
   double x1[]={-10,-4,-1,2,3,4,5,6,7,8};
   double y1[]={-5,4,-10,23,17,18,-9,13,17,4};
//--- data 2
   double x2[]={-10,-10,10,10};
   double y2[]={-10,10,-10,10};
//--- graphic
   CGraphic graph;
   graph.HistoryNameWidth(80);
   graph.Create(0,"Graph",0,30,30,830,430);
//--- Points
   CCurve *curve=graph.CurveAdd(x1,y1,CURVE_LINES);
   graph.CurvePlot(0);
   graph.Update();
   Sleep(1000);
   curve.Update(x2,y2);
   graph.Redraw(true);
   graph.Update();
   Sleep(1000);
  }
P.S. There is a topic about Graphics library on the forum, this question has already been raised there.

It is clear in the script, but how to update it in the Expert Advisor? For example, here is a code that creates a random chart on each tick:

#include <Graphics\Graphic.mqh>

 double Xg[10]={0,1,2,3,4,5,6,7,8,9};
 double Yg[10]={0,0,0,0,0,0,0,0,0,0};

//------------------------------------------ 
int OnInit()
  {
   graf(); //draw the graph
//---
   return(INIT_SUCCEEDED);
  }
//------------------------------------------ 
void OnTick()
  {  
   for(int i=0; i<=9; i++){
    Yg[i]=(int)MathRand()/1000;  
   }
   ObjectDelete(0,"Graph");//delete the chart, I realise it's not the right approach, but I can't do it any other way.
   graf(); //draw a new chart
  }
//-------------------------------------------------------------
void graf(){
   CGraphic graph;
   graph.HistoryNameWidth(80);
   graph.Create(0,"Graph",0,30,30,830,430);

   CCurve *curve=graph.CurveAdd(Xg,Yg,CURVE_LINES);
   graph.CurvePlotAll();
   graph.Update(true);
}
//-------------------------------------------------------------

I can't figure out how to update the data without deleting the chart. Please tell me who knows how to do it.

 

Please, if anyone knows how to change font sizes and styles for signatures in this library? - I tried FontSet - it didn't work.....

 
transcendreamer:

Please, if anyone knows how to change font sizes and styles for signatures in this library? - I tried FontSet - it didn't work.....

Open the source of the library and in the search type font.

 
fxsaber:

Open the source of the bibla and type font in the search.

Directly shardcode it there? 😁

I just thought there was some ready-made method.

Actually by searching for font I found FontSet but it refuses to co-operate.

 
transcendreamer:

Please, if anyone knows how to change font sizes and styles for signatures in this library? - I tried FontSet - it didn't work.....

For captions in the legend?

graphicL.HistorySymbolSize(Point_K);//Get/Set the symbol size of the symbols of the symbols
 
Aleksey Vyazmikin:

For signatures in the legend?

Thank you.

Actually for the axes too.

 
-vallen- #:

It is clear in the script, but how to update in the Expert Advisor? For example, here is a code that creates a random chart on each tick:

I can't figure out how to update the data without deleting the chart. Please tell me who knows how to do it.

Any answer ?

 

Изначально класс CCanvas содержал только два режима отрисовки графических примитивов   со сглаживанием (antialiasing, AA) и без него. Затем были добавлены новые функции для создания примитивов на основе алгоритма Ву:

Methods with smoothing for Arc() and Pie() are missing.

Документация по MQL5: Стандартная библиотека / Пользовательская графика / CCanvas / Arc
Документация по MQL5: Стандартная библиотека / Пользовательская графика / CCanvas / Arc
  • www.mql5.com
Arc(int,int,int,int,int,int,int,int,const uint) - CCanvas - Пользовательская графика - Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

Also need these fill methods with smoothed edges:

   void              FillTriangle(int x1,int y1,int x2,int y2,int x3,int y3,const uint clr);
   void              FillPolygon(int &x[],int &y[],const uint clr);
   void              FillCircle(int x,int y,int r,const uint clr);
   void              FillEllipse(int x1,int y1,int x2,int y2,const uint clr);
   void              Fill(int x,int y,const uint clr);
   void              Fill(int x,int y,const uint clr,const uint threshould);

//---

Currently, even if you first draw a circle with fill using the FillCircle() method and then trace around it using the CircleWu() method, the smoothing is partially lost.

Документация по MQL5: Стандартная библиотека / Пользовательская графика / CCanvas / FillCircle
Документация по MQL5: Стандартная библиотека / Пользовательская графика / CCanvas / FillCircle
  • www.mql5.com
FillCircle(int,int,int,const uint) - CCanvas - Пользовательская графика - Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Anatoli Kazharski #:

You also need these smooth edge fill methods:

//---

Currently, even if you first draw a circle with fill using the FillCircle() method and then trace around it using the CircleWu() method, the smoothing is partially lost.

All smoothing methods depend heavily on the opacity of the line. At about 50% opacity, everything becomes unaliased and has artefacts.