Draw a graph with open polyline

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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.  
Last edited on
> 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.
Okay, thanks!

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')

maxLine.add(Point{t.max, t*2});

minLine.add(Point{t.min, t*2});
Topic archived. No new replies allowed.