I wonder how I can draw a graph with Open_polyline. I haven't done it before and it is not much info online how to do it. I'll put the code I've written down below. Thanks.
struct Temps
{
double max, min;
};
Temps t;
vector<Temps> temperatur;
ifstream temp_file{"temperaturer.txt"};
while ( temp_file >> t )
{
temperatur.push_back(t);
}
//Some code here in the middle where I am creating a window and such.
Open_polyline maxLine;
Open_polyline minLine;
for (Temps t : temperatur)
{
maxLine.add(Point{t.max, t*2});
minLine.add(Point{t.min, t*2});
}
//What is the right way here to make my polyline? This doesn't seem to work and I know I haven't attached anything but I get error codes already here.
> I wonder how I can draw a graph with Open_polyline.
You put your current problem to one side, and you practice with the unfamiliar in a separate project.
Just focus on drawing just ONE line between two known points.
Things that could trip you up
- the viewport is in the wrong place, or so distant that your line is a single pixel.
- the coordinate system is inverted to your expectation (0,0 can be bottom-left or top-left)
- the line needs a thickness, or a colour, or a style.
But I think my main problem is to use my max and min values (that are stored in a vector with type Temps) as a coordinate to the Point that I am trying to add to the open polylines. So, how do I do that ?
I get this errorcode for this part of the code : Invalid operands to binary expression ('Temps' and 'int')