【问题标题】:How to auto scale Y axis in OHLC chart using afreechart library如何使用 afreechart 库在 OHLC 图表中自动缩放 Y 轴
【发布时间】:2014-10-06 07:24:37
【问题描述】:

我想根据值自动缩放图表 Y 轴。

这个问题中的图片解释了我的确切问题,但那是 jfreechart 库,我尝试了解决方案但没有奏效。

Auto-Scale Y-Axis in JfreeChart

这是我的代码

        NumberAxis rangeAxis1 = new NumberAxis();
        rangeAxis1.setStandardTickUnits(createTickUnits());
        rangeAxis1.setAutoTickUnitSelection(true);
        rangeAxis1.setAutoRange(true);
        rangeAxis1.setAutoRangeIncludesZero(false);
        rangeAxis1.setAxisLinePaintType(white);
        rangeAxis1.setAxisLineStroke(1);
        rangeAxis1.setTickMarkPaintType(white);
        rangeAxis1.setTickMarkStroke(1);
        rangeAxis1.setTickMarkOutsideLength(2);
        rangeAxis1.setLabelPaintType(white);
        rangeAxis1.setTickLabelPaintType(white);
        rangeAxis1.setTickLabelInsets(new RectangleInsets(10, 0, 10, 0));
        rangeAxis1.setLimitAble(/*true*/false);
        rangeAxis1.setLimitRange(20, 70);


        HighLowRenderer renderer1 = new HighLowRenderer();



        renderer1.setBaseOutlinePaintType(white);
        renderer1.setBaseOutlineStroke(1.0f);

        renderer1.setOpenTickPaintType(red);
        renderer1.setCloseTickPaintType(blue);

        XYPlot subplot1 = new XYPlot(dataset1, null, rangeAxis1, renderer1);


        subplot1.setDataset(1, dataset3);
        subplot1.setRenderer(1, renderer3);*/

        subplot1.setBackgroundPaintType(black);
        subplot1.setDomainGridlinePaintType(darkGreen);
        subplot1.setRangeGridlinePaintType(darkGreen);
        subplot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
        subplot1.setOutlineVisible(true);
        subplot1.setOutlinePaintType(white);
        subplot1.setOutlineStroke(2.0f);


        ValueAxis timeAxis = new DateAxis("Date");
        timeAxis.setAxisLinePaintType(white);
        timeAxis.setAxisLineStroke(1);

        timeAxis.setTickMarkPaintType(white);
        timeAxis.setTickMarkStroke(1);
        timeAxis.setTickMarkOutsideLength(2);

        timeAxis.setLabelPaintType(white);
        timeAxis.setTickLabelPaintType(white);

        CombinedDomainXYPlot plot = new CombinedDomainXYPlot(timeAxis);
        plot.setBackgroundPaintType(black);
        plot.add(subplot1, 2);

        AFreeChart chart=  ChartFactory.
        createHighLowChart("OHLCPreview","Time","Value",dataset1,false);
        // setting chart
        chart.setBackgroundPaintType(white);

【问题讨论】:

    标签: android charts


    【解决方案1】:

    我终于找到了解决办法......

    我实际上是用最后一行代码覆盖了最后的 subplot1

    AFreeChart chart=  ChartFactory.
    createHighLowChart("OHLCPreview","Time","Value",dataset1,false);
    

    替换为

    AFreeChart chart = new AFreeChart(
    "OHLCPreview",
    AFreeChart.DEFAULT_TITLE_FONT,
    plot, false);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-23
      • 1970-01-01
      • 2011-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-27
      相关资源
      最近更新 更多