Note that there are some explanatory texts on larger screens.

plurals
  1. POGridlines above chart in JFreeChart
    primarykey
    data
    text
    <p>Is it possible to retrieve all rangeAxis-values for a BarChart? I have manage to draw new GridLines(Markers) like this:</p> <p><img src="https://i.stack.imgur.com/HXaUz.png" alt="enter image description here"></p> <p>But I need to know which values that are pressent for the chart in the value-axis to be able to draw all lines. Any ideas how to get all value on the "Value"-axis?(RangeAxis)</p> <pre><code>public class BarChartDemo extends ApplicationFrame { /** * Creates a new demo instance. * * @param title the frame title. */ public BarChartDemo(final String title) { super(title); final CategoryDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); } /** * Returns a sample dataset. * * @return The dataset. */ private CategoryDataset createDataset() { // row keys... final String series1 = "First"; // column keys... final String category1 = "Category 1"; final String category2 = "Category 2"; final String category3 = "Category 3"; // create the dataset... final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(3.5, series1, category1); dataset.addValue(4.0, series1, category2); dataset.addValue(3.0, series1, category3); return dataset; } /** * Creates a sample chart. * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart( "Bar Chart Demo", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend false, // tooltips? false // URLs? ); CategoryPlot plot = chart.getCategoryPlot(); plot.getDomainAxis().setCategoryMargin(.01); plot.setRangeGridlinesVisible(false); for(int i=1; i&lt;=4; i++){ Marker marker = new ValueMarker(i); marker.setStroke(new BasicStroke( 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {3.0f, 8.0f}, 0.0f )); marker.setPaint(new Color(224,224,224)); plot.addRangeMarker(marker); } return chart; } public static void main(final String[] args) { final BarChartDemo demo = new BarChartDemo("Bar Chart Demo"); demo.pack(); demo.setVisible(true); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload