Good afternoon,
I want to have a Fl_Chart updated every time the data is added or replaced. I
tried to do a test using Ercolano's example but I did not succeed. By the way,
I want to thank Greg for the tutorial videos and the code examples. Great job!
Here goes my try:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Chart.H>
#include <math.h>
#include <Windows.h>
void MyFun(Fl_Widget* w, void* u)
{
w->redraw();
}
int main() {
Fl_Window *win = new Fl_Window(1000, 480);
Fl_Chart *chart = new Fl_Chart(20, 20, win->w()-40, win->h()-40, "Chart");
chart->bounds(-125,125);
chart->callback(MyFun);
for ( double t=0; t<15; t+=0.5 ) {
double val = sin(t) * 125.0;
static char val_str[20];
sprintf(val_str, "%.0lf", val);
chart->add(val, val_str, (val<0)?FL_RED:FL_GREEN);
}
win->show();
chart->show();
for(int i=1;i<=30;i++)
{
static char c[10];
sprintf(c,"%i",i);
chart->replace(i,100,c,78);
Sleep(1000); //Simulate updates
}
return(Fl::run());
}
Thank you for your time,
Emer
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk