square axes
Posted: Mon Jan 09, 2006 2:01 am
Hello,
I am trying to force the tchart to always have an equal length X and Y axis, irrespective of the size of the TChart.BoundsRect.
I have tried the following change to Procedure TCustomAxisPanel.InternalDraw. (look for "// dn changes")
Begin
Old:=AutoRepaint;
AutoRepaint:=False;
CalcInvertedRotation;
tmp:=UserRectangle;
if not InternalCanvas.SupportsFullRotation then
PanelPaint(tmp);
BroadcastToolEvent(cteBeforeDraw); // 5.02
DoOnBeforeDrawChart;
for t:=0 to SeriesCount-1 do
With Series[t] do if Active then DoBeforeDrawChart;
if not InternalCanvas.SupportsFullRotation then
DrawTitlesAndLegend(True);
SetSeriesZOrder;
CalcWallsRect;
tmp:=ChartRect;
CalcAxisRect;
// dn changes - adjust the chart rect to have equal axes
minAx:=minIntValue([chartWidth,chartHeight]);
chartRect.right:=chartRect.left+minAx;
chartRect.Bottom:=chartRect.top+minAx;
recalcWidthHeight;
... everything the same after here.
This seems to work quite well, except that the X axis text is drawn on the bottom of the plot. (not sure why the image is not coming up)
The bottom axis X position of the text is correct, but the Y position is not. Is there a way to "pin" the text to be relative to the chartRect.bottom instead of just the bottom of the plot?
I am trying to force the tchart to always have an equal length X and Y axis, irrespective of the size of the TChart.BoundsRect.
I have tried the following change to Procedure TCustomAxisPanel.InternalDraw. (look for "// dn changes")
Begin
Old:=AutoRepaint;
AutoRepaint:=False;
CalcInvertedRotation;
tmp:=UserRectangle;
if not InternalCanvas.SupportsFullRotation then
PanelPaint(tmp);
BroadcastToolEvent(cteBeforeDraw); // 5.02
DoOnBeforeDrawChart;
for t:=0 to SeriesCount-1 do
With Series[t] do if Active then DoBeforeDrawChart;
if not InternalCanvas.SupportsFullRotation then
DrawTitlesAndLegend(True);
SetSeriesZOrder;
CalcWallsRect;
tmp:=ChartRect;
CalcAxisRect;
// dn changes - adjust the chart rect to have equal axes
minAx:=minIntValue([chartWidth,chartHeight]);
chartRect.right:=chartRect.left+minAx;
chartRect.Bottom:=chartRect.top+minAx;
recalcWidthHeight;
... everything the same after here.
This seems to work quite well, except that the X axis text is drawn on the bottom of the plot. (not sure why the image is not coming up)
The bottom axis X position of the text is correct, but the Y position is not. Is there a way to "pin" the text to be relative to the chartRect.bottom instead of just the bottom of the plot?