Page 1 of 1

How to draw a diagram like this...(inside)

Posted: Wed Feb 25, 2009 7:53 pm
by extreme001

I want to draw a diagram/graph. I tried wxMathPlot, wxPlotCtrl but can't get the result i wanted.

would be nice if someone could help.

Look a the attachment or look here: ... _thumb.png

Thank you!

Posted: Wed Feb 25, 2009 9:37 pm
by computerquip
wxMathPlot should work. Could you show us the resulting code when you attempted to use it?

Posted: Wed Feb 25, 2009 11:32 pm
by extreme001
Heres a piece of code i used for testing:

Code: Select all

m_graph = new mpWindow( this, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE );
	itemBoxSizer2->Add(m_graph, 1, wxGROW|wxALL, 0);

	// @ home

	// Car shape:
    std::vector<float> car_xs(20), car_ys(20);
    car_xs[0]=100;  car_ys[0]=300;
    car_xs[1]=500;  car_ys[1]=800;
    car_xs[2]=1000;  car_ys[2]=400;
    car_xs[3]= 800;     car_ys[3]=300;
    /*car_xs[i]= 0;     car_ys[i++]=-0.5;
    car_xs[i]= 0.6;  car_ys[i++]=-0.5;
    car_xs[i]= 0.6;  car_ys[i++]=-0.6;
    car_xs[i]= 0.8;  car_ys[i++]=-0.6;
    car_xs[i]= 0.8;  car_ys[i++]=-0.5;
    car_xs[i]= 1.0;  car_ys[i++]=-0.5;
    car_xs[i]= 1.0;  car_ys[i++]= 0.5;
    car_xs[i]= 0.8;  car_ys[i++]= 0.5;
    car_xs[i]= 0.8;  car_ys[i++]= 0.6;
    car_xs[i]= 0.6;  car_ys[i++]= 0.6;
    car_xs[i]= 0.6;  car_ys[i++]= 0.5;
    car_xs[i]= 0;     car_ys[i++]= 0.5;
    car_xs[i]= 0;     car_ys[i++]= 0.6;
    car_xs[i]=-0.2;  car_ys[i++]= 0.6;
    car_xs[i]=-0.2;  car_ys[i++]= 0.5;
    car_xs[i]=-0.5;  car_ys[i++]= 0.5;*/

	mpFXYVector* vecs = new mpFXYVector(_("one"), mpALIGN_NE );
	vecs->SetPen(wxPen(*wxGREEN, 5, wxSOLID));
	vecs->SetData(car_xs, car_ys);

	mpScaleX* xaxis = new mpScaleX(GetLabelX(), mpALIGN_BOTTOM, true);
    mpScaleY* yaxis = new mpScaleY(GetLabelY(), mpALIGN_LEFT, true);
	wxBrush hatch2(wxColour(163,208,212), wxSOLID);
    mpInfoLegend* leg;
    m_graph->AddLayer( leg = new mpInfoLegend(wxRect(200,20,40,40), &hatch2));

Posted: Thu Feb 26, 2009 2:13 pm
by extreme001
problem solved! I used the vector data in a worng way, so the graph drawed back to my first x-coord.