轴标题和Axis在Android中的TeeChart之间距离的变化 [英] Change distance between Axis Title and Axis in Android TeeChart
问题描述
我试图改变在Android中的TeeChart轴标题和轴之间的距离。我打一点点周围
I've tried to change the distance between axis title and axis in Android TeeChart. I played a little bit around with
tChart.getAxes().getLeft().getTitle().setCustomSize();
tChart.getAxes().getBottom().getTitle().setCustomSize();
tChart.getAxes().getLeft().getLabels().setCustomSize();
tChart.getAxes().getBottom().getLabels().setCustomSize();
在左轴它的伟大工程,但BUTTOM轴标题停留在相同的位置。任何人都知道一个解决方案吗?
On the left Axis it works great, but the buttom Axis Title stays in the same Position. Anyone knows a solution?
感谢。
推荐答案
恐怕没有一个单一的财产可以设置轴标题和轴之间添加额外的空间。结果
我能想到的,以实现它的更简单的方法是通过增加一定的余量,以图表和手动绘制轴标题在画布上。即:
I'm afraid there isn't an single property you can set to add extra space between the axis title and the axis.
The easier way I can think to achieve it is by adding some margin to the chart and draw the axis titles manually on the canvas. Ie:
Bar bar1 = new Bar(tChart1.getChart());
bar1.fillSampleValues();
tChart1.addChartPaintListener(new ChartPaintAdapter() {
@Override
public void chartPainted(ChartDrawEvent e) {
String leftText = "Left Axis Title";
String bottomText = "Bottom Axis Title";
int YMid = tChart1.getChart().getChartRect().y + (tChart1.getChart().getChartRect().height / 2);
int XMid = tChart1.getChart().getChartRect().x + (tChart1.getChart().getChartRect().width / 2);
tChart1.getGraphics3D().setFont(tChart1.getAxes().getLeft().getTitle().getFont());
int leftHeight = tChart1.getGraphics3D().textWidth(leftText);
tChart1.getGraphics3D().rotateLabel(10, YMid + (leftHeight / 2), leftText, 90);
tChart1.getGraphics3D().setFont(tChart1.getAxes().getBottom().getTitle().getFont());
int bottomWidth = tChart1.getGraphics3D().textWidth(bottomText);
tChart1.getGraphics3D().textOut(XMid - (bottomWidth / 2), tChart1.getHeight() - 20, bottomText);
}
});
tChart1.getPanel().setMarginLeft(10);
tChart1.getPanel().setMarginBottom(10);
然后,您可以轻松地添加更多的保证金或移动的标题。
Then, you can easily add more margin or move the titles.
这篇关于轴标题和Axis在Android中的TeeChart之间距离的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!