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

Message ListMessage List     Post MessagePost Message

  ViewPortControl not showing full chart
Posted by Kamil on Apr-20-2022 23:17
Attachments:
Hi All. I'm writing application which uses ChartDirector for wxWidgets and I have a problem with ViewPortControl. I am able to display full chart in ChartViewer but the chart in ViewPortControl is cut off. You can see on attached image that the upper chart is displayed fine but the bottom one doesn't show lower values. Both, the ChartViewer and ViewPortControl, have the same data passed. Thank you in advance for any tips.
2022-04-20_17h09_04.png

  Re: ViewPortControl not showing full chart
Posted by Peter Kwan on Apr-21-2022 01:29
Hi Kamil,

I suspect it is due to the y-axis scale configuration of the chart in the ViewPortControl. For example, if the y-axis scale is set to 37500 to 50000, then the part below y = 37500 will fall outside the chart.

I noticed in the ViewPortControl, the y-axis has no labels, so we cannot see what is the y-axis scale. If the y-axis is not configured at all, ChartDirector should automatically generate a scale that allows all data to be displayed and include labels on the y-axis. Would mind to inform me how the y-axis is configured in your code that draws the chart in the ViewPortControl?

Regards
Peter Kwan

  Re: ViewPortControl not showing full chart
Posted by Kamil on Apr-21-2022 03:20
Hi Peter,

I don't see any specific configuration of y-axis scale of ViewPortControl in my code, however I'm basing on a code that initially was an example so I could be not aware that it is somewhere.
Initially I was thinking the same as you, that y-axis of ViewPortControl is not set correctly but honestly speaking I can't find any functions I could use on ViewPortControl to set it as it should be. So my question is: Could you possibly tell me the applicable function(s) to set y-axis scale of ViewPortControl, please?
And my second question is: Does setting y-axis scale of ChartViewer has impact on ViewPortControl y-axis scale? (In my code I set ChartViewer's y-axis scale and ChartViewer is bound to ViewPortControl by using setViewer() method)

  Re: ViewPortControl not showing full chart
Posted by Peter Kwan on Apr-21-2022 16:23
Hi Kamil,

Sorry for the misinformation. I checked our C++ sample code and found that our own code would hide the y-axis by setting its color to Chart::Transparent. So it is normal for having no visible y-axis labels.

In your chart, I cannot see the x-axis labels too. I am thinking, is it possible the chart is resized smaller after "layout" or being drawn, so that the bottom part is cropped out?

Please try to comment out the line c->yAxis()->setColors(Chart::Transparent, Chart::Transparent); so the y-axis becomes visible. Then add the line:

c->yAxis()->setLinearScale(0, 10, 1);

This would put the labels (0, 1, 2, ... 10) on the y-axis. If the bottom part is cropped out, the first few labels may fall outside the visible region.

Please let me known what is the result.

Regards
Peter Kwan

  Re: ViewPortControl not showing full chart
Posted by Peter Kwan on Apr-21-2022 16:30
Hi Kamil,

Another possibility is the plot area (configured with XYChart::setPlotArea) is too tall so that the bottom part falls outside the chart. You can also add the line near the end of your code:

char buffer[1000];
sprintf(buffer, "chart height=%d, plot area bottom=%d", c->getHeight(), c->getPlotArea()->getTopY() + c->getPlotArea()->getHeight());
c->addTitle(buffer);

Now you should see a chart title that displays the chart height and the lower bound of the plot area. You can verify if part of the plot area is outside the chart.

Regards
Peter Kwan

  Re: ViewPortControl not showing full chart
Posted by Kamil on Apr-22-2022 03:18
Hi Peter,

Thank you for your assistance. The issue was improper usage of setPlotArea(). I used wrong values and also the values was the same in DrawChart() and DrawFullChart() which shold be slightly different.