English 中文(简体)
JavaFX XY图表对数图
原标题:JavaFX XYChart Logarithmic plot
  • 时间:2012-05-25 09:30:55
  •  标签:
  • javafx-2

我有一个XY图集在Y轴上以线性步骤绘制数据, 我想用对数或半对数Y比例来绘制数据, 如何修改我的以下代码?

public class BaseXYChart extends Application {

@Override
public void start(Stage stage) {
   stage.setTitle("Linear plot");

   final CategoryAxis xAxis = new CategoryAxis();
   final NumberAxis yAxis = new NumberAxis(1, 22, 0.5);

   yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis){
        @Override
    public String toString(Number object){
        return String.format("%7.2f", object);
    }
});
final LineChart<String, Number>lineChart = new LineChart<String, Number>(xAxis, yAxis);

   lineChart.setCreateSymbols(false);
   lineChart.setAlternativeRowFillVisible(false);

   XYChart.Series series1 = new XYChart.Series();

    series1.getData().add(new XYChart.Data("Jan", 1));
    series1.getData().add(new XYChart.Data("Feb", 1.5));
    series1.getData().add(new XYChart.Data("Mar", 2));
    series1.getData().add(new XYChart.Data("Apr", 2.5));
    series1.getData().add(new XYChart.Data("May", 3));
    series1.getData().add(new XYChart.Data("Jun", 4));
    series1.getData().add(new XYChart.Data("Jul", 6));
    series1.getData().add(new XYChart.Data("Aug", 9));
    series1.getData().add(new XYChart.Data("Sep", 12));
    series1.getData().add(new XYChart.Data("Oct", 15));
    series1.getData().add(new XYChart.Data("Nov", 20));
    series1.getData().add(new XYChart.Data("Dec", 22));

    BorderPane pane = new BorderPane();
    pane.setCenter(lineChart);          
    Scene scene = new Scene(pane, 800, 600);
    lineChart.getData().addAll(series1);

    stage.setScene(scene);

    stage.show();
}

public static void main(String[] args) {
    launch(args);
}

}

谢谢大家多谢

最佳回答

我认为在 JavaFX Vanilla 中不可能。 但您可以在这里查看 : < a href="http://blog.dooapp.com/2013/06/logarithmic- size-strikes- repack- in.html" rel=“ nofollow” >http://blog.dooap.com/2013/06/logarithmic- size-strikes- repack-in.html

问题回答

暂无回答




相关问题
Tutorial/Blog for GroovyFx

I need links for blog, tutorials that covers GroovyFx. I have tried searching it on google, i m not getting any useful tutorials. I need a full coverage of GroovyFx from top to bottom! Thanks in ...

Adding JFXPanel to a JFrame. Why is it not working?

I am trying to add a JFXPanel to my JFrame. I am using Netbeans and Netbeans Swing GUI Builder. When I run it I do not get any errors and the JFrame is created successfully but the JFXPanel with the ...

what is yaml file in java and use of it?

i saw some site like this http://jyaml.sourceforge.net/ for yaml in java. but i can t to use of that. how can i use form yaml files? if is it possible to use it in javafx 2.0? thanks.

javaFX 2.0 how to select files aka FileChooser

I m trying out the new JavaFx 2.0 beta release but cannot find anyway of selecting files using a dialog box like JfileChooser. Any ideas on how to do this? Thanks

How to wrap a swing component in a javaFX 2.0 application

The ability to wrap a swing component in a javaFX application seems to have vanished from javaFX 2: javafx.ext.swing.SwingComponent is not there any more in javaFX 2 beta API. Is there still a ...

Does JavaFX 2.0 run on Google App Engine?

As I just read about the release of JavaFX 2.0 beta and the NetBeans 7.0 plugin in the article JavaFX: The Resurrection (Java FX 2.0 Released), is there information available if it runs on Google App ...

热门标签