JavaFX2.2:如何实现扩展折线图的新图表

JavaFX2.2:如何实现扩展折线图的新图表,java,charts,javafx,javafx-2,linechart,Java,Charts,Javafx,Javafx 2,Linechart,我正在尝试实现一个支持绘制次要网格线的新图表。早些时候,我尝试通过绘制线来实现它。我想走绘制路径的原生路线,而不是绘制线 我是JavaFx新手,如有任何帮助/指导,将不胜感激。当前的代码只专注于绘制次要的水平网格线 public class CTChart extends LineChart { private final Path horizontalMinorGridLines = new Path(); public CTChart(final NumberAxis xAxis, fin

我正在尝试实现一个支持绘制次要网格线的新图表。早些时候,我尝试通过绘制线来实现它。我想走绘制路径的原生路线,而不是绘制线

我是JavaFx新手,如有任何帮助/指导,将不胜感激。当前的代码只专注于绘制次要的水平网格线

public class CTChart extends LineChart
{
private final Path horizontalMinorGridLines = new Path();

public CTChart(final NumberAxis xAxis, final NumberAxis yAxis)
{
    super(xAxis, yAxis);
    this.setAnimated(false);
    this.setCreateSymbols(false);
    this.setAlternativeRowFillVisible(false);
    this.setLegendVisible(false);
    this.setHorizontalGridLinesVisible(true);
    this.setVerticalGridLinesVisible(true);

    getPlotChildren().add(horizontalMinorGridLines);
    horizontalMinorGridLines.getStyleClass().setAll("chart-horizontal-minor-grid-lines");

    int lowerBound = (int) yAxis.getLowerBound();
    int upperBound = (int) yAxis.getUpperBound();
    int tickUnit = (int) yAxis.getTickUnit();
    int minorTickCount = yAxis.getMinorTickCount();
    int minorTickUnit = tickUnit / minorTickCount;

    horizontalMinorGridLines.getElements().clear();

    for (int i = lowerBound; i < upperBound; i = i + minorTickUnit) {

        ObservableList<TickMark<Number>> tickMarks = yAxis.getTickMarks();
        for (TickMark<Number> tickMark : tickMarks) {
            tickMark.getPosition();
            // horizontalMinorGridLines.getElements().add(new MoveTo(zero, tickMark.getPosition()));
            // horizontalMinorGridLines.getElements().add(new LineTo(zero + xAxis.getWidth(), tickMark.getPosition()));
        }
    }
}
}
公共类CTChart扩展了线形图
{
私有最终路径horizontalMinorGridLines=新路径();
公共CTChart(最终数字axis xAxis,最终数字axis yAxis)
{
超级(xAxis,yAxis);
此.setAnimated(false);
此.setCreateSymbles(false);
此.setAlternativeRowFillVisible(false);
此.setLegendVisible(false);
此.setHorizontalGridLinesVisible(true);
此.setVerticalGridLinesVisible(true);
getPlotChildren().add(水平线);
horizontalMinorGridLines.getStyleClass().setAll(“图表水平次要网格线”);
int lowerBound=(int)yAxis.getLowerBound();
int upperBound=(int)yAxis.getUpperBound();
int tickUnit=(int)yAxis.getTickUnit();
int minorTickCount=yAxis.getMinorTickCount();
int minorTickUnit=tickUnit/minorTickCount;
horizontalMinorGridLines.getElements().clear();
for(int i=lowerBound;i
我搞不懂的事情

  • 我的方向对吗
  • 如何获取MoveTo和LineTo API的X,Y坐标
  • 如何渲染/哪些代码渲染次要网格线
  • 一切都应该在构造函数中吗
  • yourObject.setOnMouseMoved(事件->{ double x=event.getX(); 双y=event.getY(); }

  • 。在CSS中使用此选项:

    .图表替代行填充{ -外汇填充:透明; -fx笔划:透明; -fx笔画宽度:0; }

  • 折线图的设置属性必须在构造函数中。添加序列不必在构造函数中