Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9166385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:08:30+00:00 2026-06-17T15:08:30+00:00

I need to have exactly one tickmark per datapoint. I would love to give

  • 0

I need to have exactly one tickmark per datapoint.

I would love to give an array with the datapoints as parameter to the refreshTicksHorizontal in the NumberAxis (actually i work with symbolAxis which is a subclass) class which i have overwritten. Actually I did this, but I have absolutely know idea (after some hours of getting just nearly correct results) how to convert this double values into the pixel (or at least somehow mysteriously related to tickUnit) values i have to put into the currentTickValue variable in refreshTicksHorizontal.

I also tried – since the datapoints all have the same distance to its neighbours – to give

ratio = (datapoint[1] - datapoint[0]) / (Axis.UpperBound - datapoint[0])

as parameter and different other things. But i dont know the (pixel respectively Java2D)-value of the first datapoint so i could have my i-th currentTickValue as

ratio*i * (dataArea.getMaxX() - firstDataPointInJava2D)…

In my (wrong) solutions i always get slightly too big or too less tick mark distances. Do you know how to fix this or are there possibly entirely different approaches to the problem?

EDIT

To illustrate the problem here is a compiling minimalistic example:

import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.*;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.Ellipse2D;

public class Example {
    public static void main(String[] args) {
        double[] dataPoints = {1.249860779781E12, 1.249861186272E12, 1.249861592763E12, 1.249861999254E12,
                1.249862405745E12};
        String[] dataNames = {"Hades", "Hagen", "Herakles", "Hermes", "Horowitz"};
        Shape shape = new Ellipse2D.Float(-2, -2, 4, 4);
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true);

        XYSeries[] lines = new XYSeries[5];
        XYSeriesCollection dataset = new XYSeriesCollection();

        for (int i = 0; i < 5; i++) {
            lines[i] = new XYSeries(new Integer(i).toString());
            lines[i].add(dataPoints[i], 0.05d);
            lines[i].add(dataPoints[i], 0.95d);
            dataset.addSeries(lines[i]);
            renderer.setSeriesShape(i, shape);
            renderer.setSeriesPaint(i, Color.black);
        }

        ValueAxis timeAxis = new DateAxis("");
        NumberAxis yAxis = new NumberAxis("");
        yAxis.setVisible(false);
        yAxis.setTickMarksVisible(false);
        yAxis.setRange(0.0d, 1.0d);

        SymbolAxis labelAxis = new SymbolAxis("", dataNames);
        labelAxis.setVerticalTickLabels(true);

        XYPlot plot = new XYPlot(dataset, timeAxis, yAxis, renderer);

        plot.setDomainAxis(1, labelAxis);
        plot.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT);
        JFreeChart chart = new JFreeChart("", plot);
        chart.removeLegend();
        ChartPanel panel = new ChartPanel(chart);
        panel.setPreferredSize(new Dimension(800, 300));

        JFrame frame = new JFrame("");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        JScrollPane scroller = new JScrollPane(panel);
        frame.add(scroller);
        frame.pack();
        frame.setVisible(true);
    }
}

The result looks like this:
Example Plot

So far so good. The PROBLEM is, i want the names (Horowitz and so on) exactly over the lines. Can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:08:31+00:00Added an answer on June 17, 2026 at 3:08 pm

    As a purely empirical measure, they line up perfectly using either

    timeAxis.setLowerMargin(0.125);
    timeAxis.setUpperMargin(0.125);
    

    or

    timeAxis.setRange(dataPoints[0] - 200000, dataPoints[4] + 200000);
    

    You may be able to generalize this as a function of your dataset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to find files which have been in the folder Wastebasket exactly one
I have exactly the same problem as the one raised and answered here .
I have problem with XML schema. I need inside one element elements of three
I have exactly one Node server, which is currently running some code. This code
I have an istream and i need to read exactly a specific amount of
I have two lists, the first of which is guaranteed to contain exactly one
I have two LINQ objects which have exactly the same columns and I would
I have need to produce LINE, BAR, and PIE charts in Rails. I have
I have need to return multiple results from a subquery and have been unable
I have need to pack four signed bytes into 32-bit integral type. this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.