Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JFreeChart+;JRuby-域轴上两点之间的填充区域_Java_Jruby_Jfreechart - Fatal编程技术网

Java JFreeChart+;JRuby-域轴上两点之间的填充区域

Java JFreeChart+;JRuby-域轴上两点之间的填充区域,java,jruby,jfreechart,Java,Jruby,Jfreechart,我正在使用JRuby访问JFreeChart。但我似乎无法在日期轴上设置域标记。。。有人能告诉我为什么这不起作用吗 def create_plot rangeaxis = NumberAxis.new rangeaxis.setAutoRangeIncludesZero(true) daxis = DateAxis.new daxis.setRange( Time.at(@dataset['date_start'].to_i) , Time.at(@datase

我正在使用JRuby访问JFreeChart。但我似乎无法在日期轴上设置域标记。。。有人能告诉我为什么这不起作用吗

def create_plot
    rangeaxis = NumberAxis.new
    rangeaxis.setAutoRangeIncludesZero(true)

    daxis = DateAxis.new
    daxis.setRange( Time.at(@dataset['date_start'].to_i) , Time.at(@dataset['date_end'].to_i) )  

    @plot = XYPlot.new(@datasets.first, daxis, rangeaxis, @base_renderer)
    @plot.setDatasetRenderingOrder(DatasetRenderingOrder::FORWARD)
    @plot.setBackgroundPaint(java.awt.Color.white)

    lol = IntervalMarker.new( 0, 99999999999, java.awt.Color.gray, BasicStroke.new(2.0), java.awt.Color.gray, nil, 1.0 )
    lol.setLabel("ARGH")
    @plot.addDomainMarker(lol)
  end
尽管这个标记应该覆盖1970年1月至5138年11月的灰色区域,但它没有显示出来。如果我用addRangeMarker替换调用,它可以工作,但我希望它在另一个轴上


谢谢你的回复

演示包中的BarChartDemo3显示了如何为特定域值绘制背景。可以使用矩形为该值的整个宽度上色。如果对相邻值执行此操作,则应获得所需的效果。以下是一些关键方法(我假设您可以查阅文档了解详细信息。)

在我看来,为文件支付额外费用是值得的

增加: 这就在上面的代码之前。它似乎正在定位标记。
        renderer.setItemLabelsVisible(true);
        ItemLabelPosition p = new ItemLabelPosition(
            ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0
        );
        renderer.setPositiveItemLabelPosition(p);
        plot.setRenderer(renderer);
然后在调用
addDomainMarker
之前出现了以下代码:

        marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
        marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);

我找到了一个更好的例子。我给的第一个是“分类标记”,你想要的是一个更通用的标记。本例中的域是时间,因此代码为标记设置一个时间间隔以覆盖范围,然后设置要显示的标签参数。这来自示例MarkerDemo2,它使用
createXYLineChart
。这应该是相关代码:

        Marker threshold = new ValueMarker(80.0);
        Hour hour1 = new Hour(18, 30, 6, 2005);
        Hour hour2 = new Hour(20, 30, 6, 2005);
        double millis1 = hour1.getFirstMillisecond();
        double millis2 = hour2.getFirstMillisecond();
        Marker cooling = new IntervalMarker(millis1, millis2);
        cooling.setLabelOffsetType(LengthAdjustmentType.EXPAND);
        cooling.setPaint(new Color(150, 150, 255));
        cooling.setLabel("Automatic Cooling");
        cooling.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));
        cooling.setLabelPaint(Color.blue);
        cooling.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        cooling.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        plot.addDomainMarker(cooling, Layer.BACKGROUND);

因此,关键是设置
IntervalMarker
,然后使用
addDomainMarker
附加该标记。您肯定想要一个
矩形锚

我不明白-如何将此标记与域值关联?仍然没有将此标记与一系列值关联的提示,这正是我打算做的:|

        Marker threshold = new ValueMarker(80.0);
        Hour hour1 = new Hour(18, 30, 6, 2005);
        Hour hour2 = new Hour(20, 30, 6, 2005);
        double millis1 = hour1.getFirstMillisecond();
        double millis2 = hour2.getFirstMillisecond();
        Marker cooling = new IntervalMarker(millis1, millis2);
        cooling.setLabelOffsetType(LengthAdjustmentType.EXPAND);
        cooling.setPaint(new Color(150, 150, 255));
        cooling.setLabel("Automatic Cooling");
        cooling.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));
        cooling.setLabelPaint(Color.blue);
        cooling.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        cooling.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        plot.addDomainMarker(cooling, Layer.BACKGROUND);