java - 如何自定义 XYPlot 属性 - 添加 X 和 Y 轴标签并更改图例文本大小?
问题描述
我尝试了什么:我正在为我的动态图使用 XYPlot,它运行良好。我试图在我的initplot()
函数中自定义它。我尝试使用getLegendWidget()
,getDomainLabelWidget()
和getRangeLabelWidget()
函数(如下所示)。
我在找什么:但我不确定,
- 如何添加 X 和 Y 轴标签,如下图所示。
- 如何增加图例项的文本大小
我要使用哪个参数?我的尝试如下图所示。我真的很感激对此的任何建议。
-谢谢-
情节.xml:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.androidplot.xy.XYPlot
android:id="@+id/dynamicPlot"
title="Data Plot"
android:layout_width="wrap_content"
android:layout_height="530dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF" />
</FrameLayout>
初始化图():
private void initPlot() {
plot = (XYPlot) getView().findViewById(R.id.dynamicPlot);
//..LPF formatting here
plot.getLegendWidget().setTableModel(new DynamicTableModel(1,3));
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
plot.getLegendWidget().setSize(new SizeMetrics(width/3, SizeLayoutType.ABSOLUTE, height/4, SizeLayoutType.ABSOLUTE));
//..domain/range color formatting here
plot.getGraphWidget().getDomainLabelPaint().setTextSize(40);
plot.getDomainLabelWidget().pack();
outlinePaint = plot.getGraphWidget().getDomainOriginLinePaint();
outlinePaint.setStrokeWidth(3);
plot.getGraphWidget().setClippingEnabled(false);
plot.getGraphWidget().getRangeLabelPaint().setTextSize(30);
plot.getRangeLabelWidget().pack();
outlinePaint = plot.getGraphWidget().getRangeOriginLinePaint();
outlinePaint.setStrokeWidth(3);
//plot.getLayoutManager().remove(plot.getRangeLabelWidget());
//plot.getLayoutManager().remove(plot.getDomainLabelWidget());
plot.getDomainLabelWidget().setVisible(true);
}
解决方案
推荐阅读
- c++ - qt c++ QPaint 与 QVector
- jquery - Jquery:在焦点输出上更改输入文本值
- blazor - 添加到 ValidationSummary 的消息仅显示在 ValidationSummary 中
- elasticsearch - 如何使用字段和子字段计数制作弹性搜索 API(查询)
- angular - 使用 Angular CLI 生成组件时,有没有办法更改规范文件的位置?
- java - Docker不释放内存
- ios - 如何在 ios 中跟踪 Apple 搜索广告以外的活动?
- django - Django中的动态允许主机
- python - 为什么我不能取消旋转(融化)这个熊猫数据框(python)
- i2c - Intel MAX10 I2C 不发送任何信号。我该如何解决?