gpt4 book ai didi

java - AFreeChart 图表未填充父级

转载 作者:太空宇宙 更新时间:2023-11-03 10:23:37 25 4
gpt4 key购买 nike

我尝试用 AFreeChart 绘制一些图表,效果很好。但是图表没有填满显示的所有可用空间。我怎样才能做到这一点?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_gravity="center" >

<com.example.digitalfilter.DemoView
android:id="@+id/demoView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />

最佳答案

如果您使用 AbsChartView 作为您的基本图 TableView ,转到 paintComponent 并将其更改为以下代码部分:

    public void paintComponent(Canvas canvas) {

// first determine the size of the chart rendering area...
Dimension size = getSize();
RectangleInsets insets = getInsets();
RectShape available = new RectShape(insets.getLeft(), insets.getTop(),
size.getWidth() - insets.getLeft() - insets.getRight(),
size.getHeight() - insets.getTop() - insets.getBottom());

double drawWidth = available.getWidth();
double drawHeight = available.getHeight();
this.scaleX = 1.0;
this.scaleY = 1.0;

RectShape chartArea = new RectShape(0.0, 0.0, drawWidth,
drawHeight);

this.chart.draw(canvas, chartArea, this.anchor, this.info);

this.anchor = null;
}

然后它将使用 android View 显示的确切大小

关于java - AFreeChart 图表未填充父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15794116/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com