ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Just display axes with a background image
Posted by Anuta Christian on Aug-09-2019 22:04
Greetings,

I have the simplest piece of code to have one XYChart with a background image BUT I can't display the axes because I don't have any data added to the XYChart. Is there a way to do it ? Here is the code :

XYChart* c = new XYChart(1255, 528);

c->setPlotArea(0, 0, 1255, 528);

c->setBgImage("placeholder.png");

c->yAxis()->setWidth(3);
c->xAxis()->setWidth(3);

viewer->setChart(c);

  Re: Just display axes with a background image
Posted by Peter Kwan on Aug-10-2019 00:13
Hi Anuta,

Yes, you can display the axes. However, the axes will have no labels. They are just a straight line. Also, in your code, the plot area includes the entire chart surface. The axis labels are put outside the plot area, so even if there are labels, they will be outside the chart.

If you want to have something visible, try:

XYChart* c = new XYChart(1255, 528);
c->setPlotArea(5, 5, 1245, 518);
c->setBgImage("placeholder.png");
c->yAxis()->setWidth(3);
c->xAxis()->setWidth(3);
viewer->setChart(c);

or

XYChart* c = new XYChart(1255, 528);

        c->setPlotArea(5, 5, 1245, 518);
c->setBgImage("placeholder.png");
c->yAxis()->setWidth(3);
c->xAxis()->setWidth(3);

        // You can use setLinearScale to define the axis labels
        c->yAxis()->setLinearScale(0, 100, 20);
        // Put the labels inside the plot area (instead of outside it)
        c->yAxis()->setLabelGap(-1);

viewer->setChart(c);

Hope this can help.

Regards
Peter Kwan

  Re: Just display axes with a background image
Posted by Anuta Christian on Aug-14-2019 23:05
Great, you're right. The axes were just on the border. I can see them now but I don't understand why I cannot change the colors. I'm using this piece of code :

c->yAxis()->setColors(-5555555);
c->xAxis()->setColors(5555555);

The axes are still black. I've used tons of different values but nothing changes.

Sincerely yours

  Re: Just display axes with a background image
Posted by Anuta Christian on Aug-14-2019 23:12
And also, do you have any idea how to have the axes on bottom and left side ? Currently it's on top and left side.

Thank you

  Re: Just display axes with a background image
Posted by Peter Kwan on Aug-15-2019 05:03
Hi Anuta,

The plot area always have 4 axes on its 4 sides, but only the axes that are actually used will be drawn. That's why in many XYChart, you can only see the bottom and left axes, which are the primary x and y axes.

For your case, is it possible your code never used the axes, so they are not drawn. If you do not use the axes, you may still see a rectangle, which is the plot area border. The default color of the plot area border is black.

If you do not need to use an axis, you can force it to appear by just adding a dummy empty title the the axis. It is like:

XYChart* c = new XYChart(1255, 528);
c->setPlotArea(5, 5, 1245, 518);
c->setBgImage("placeholder.png");
c->yAxis()->setWidth(3);
c->xAxis()->setWidth(3);

        // Set the axes colors
c->yAxis()->setColors(0xff0000);
c->xAxis()->setColors(0x00ff00);

        // Add dummy title to make the otherwise unused axes appear
c->yAxis()->setTitle(" ");
c->xAxis()->setTitle(" ");

For the right and top axes, they can be accessed with c->xAxis2() and c->yAxis2(). You can also move the primary y and x axes to the left and top sides by using:

        c->setXAxisOnTop();
        c->setYAxisOnRight();

If you are not using the axes, but just need to line somewhere, you can also use BaseChart::addLine to add lines to the chart.

Hope this can help.

Regards
Peter Kwan

  Re: Just display axes with a background image
Posted by Anuta Christian on Aug-15-2019 05:44
Thanks a lot about your help, now it's perfect.


cix porn hard porn kostenlose porn amateur xxx love porn amateur sex hd porn free 3 xxx moblie porn