Change the unit of x axis in JFreeChart Gantt chart

Change the unit of x axis in JFreeChart Gantt chart

By : Hào Tử Tế
Date : November 17 2020, 01:00 AM
hop of those help? I'm a beginner in JFreeChart. I want to change the x axis values of this chart to milliseconds, with 5 ms intervals. I've tried , Some possibilities to consider:
code :
"TIME (ms)", // range axis label
DateAxis axis = (DateAxis) plot.getRangeAxis();
axis.setDateFormatOverride(new SimpleDateFormat("SSS"));
axis.setMaximumDate(new Date(300));

Share : facebook icon twitter icon
JFreeChart adding annotation to Gantt chart

JFreeChart adding annotation to Gantt chart

By : user2968615
Date : March 29 2020, 07:55 AM
wish help you to fix your issue A GanttChart has a CategoryPlot, so just use a CategoryAnnotation.
How to change color of particular sub-task in JFreeChart Gantt Chart?

How to change color of particular sub-task in JFreeChart Gantt Chart?

By : Ragesh N
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You can override the renderer's getItemPaint() method, as discussed here.
Addendum: As a Gnatt chart uses a GanttRenderer, you'd do something like this to see the existing colors. Just return your chosen color for a given row and column.
code :
plot.setRenderer(new MyRenderer());
private static class MyRenderer extends GanttRenderer {

    public Paint getItemPaint(int row, int col) {
        System.out.println(row + " " + col + " " + super.getItemPaint(row, col));
        return super.getItemPaint(row, col);
JFreechart Gantt chart millisecond X axis?

JFreechart Gantt chart millisecond X axis?

By : user5137234
Date : March 29 2020, 07:55 AM
I hope this helps . Assuming ChartFactory.createGanttChart(), you can specify any desired format when calling setNumberFormatOverride() on the plot's DateAxis. There's a related example here.
Gantt Chart in jfreeChart?

Gantt Chart in jfreeChart?

By : Károly Kiripolszky
Date : March 29 2020, 07:55 AM
Does that help As an alternative to TimePeriod, you can use the Task constructor that accepts two Date instances:
code :
public Task(java.lang.String description,
    java.util.Date start,
    java.util.Date end)
Task t1 = new Task("Design", date(1, MAY), date(31, MAY));
Task t2 = new Task("Proposal", date(1, JUNE), date(31, JUNE));
private static Date date(final int day, final int month) {
    final Calendar calendar = Calendar.getInstance();
    calendar.set(2012, month, day);
    final Date result = calendar.getTime();
    return result;
Change the starting value of value axis in Bar chart with Jfreechart

Change the starting value of value axis in Bar chart with Jfreechart

By : Mike
Date : March 29 2020, 07:55 AM
will be helpful for those in need I have the following values to be shown in a BAR chart in my Java web application. 9.46373791E8 9.45942547E8 9.45559945E8 9.45187023E8 9.44856693E8 9.44417826E8 9.44007878E8 , I guess you want to do the following:
code :
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;

public class ChartTester extends JFrame {

    private static final long serialVersionUID = 1L;

    public ChartTester(final String title) {
        final CategoryDataset dataset = createDataset();
        final JFreeChart chart = createChart(dataset);
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new Dimension(500, 270));


     * Returns a sample dataset.
     * @return The dataset.
    private CategoryDataset createDataset() {
        final String rowName = "Row";
        final String[] columnName = { "Column1","Column2","Column3","Column4","Column5"};
        final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        dataset.addValue(9.2, rowName, columnName[0]);
        dataset.addValue(9.3, rowName, columnName[1]);
        dataset.addValue(9.4, rowName, columnName[2]);
        dataset.addValue(9.5, rowName, columnName[3]);
        dataset.addValue(10.0, rowName, columnName[4]);

        return dataset;

     * Creates a sample chart.
     * @param dataset  the dataset.
     * @return The chart.
    private JFreeChart createChart(final CategoryDataset dataset) {
        double d =9.0;
        final JFreeChart chart =
                    "Chart Title",
                    "X Axis",
                    "Y Axis",
        // Set the background color of the chart
        // Adjust the color of the title
        CategoryPlot plot = chart.getCategoryPlot();
        // Get the Plot object for a bar graph
        CategoryItemRenderer renderer = plot.getRenderer();
        renderer.setSeriesPaint(0, Color.decode("#00008B"));
        return chart;

    public static void main(final String[] args) {
        final ChartTester test = new ChartTester("Test");
Related Posts Related Posts :
  • Repeating for loop in menu
  • Can Java garbage collector randomly delete objects in the On-Heap tier?
  • Apache CXF Exception: SSL connection unexpectedly closed
  • Add properties to ArrayList<Object> in Java
  • Multiple Adapters or One Adapter for different lists and objects - Code Performance
  • Is it good practice in Java for a class's method to redundantly return a modified global field of the class?
  • How to change the color of the background in libgdx labels?
  • direct file path not working
  • ClassFileTransformer + Javassist: no such field
  • How do I change and instance variable for an object which the user selects from a combobox?
  • reading and updating a large xml file in java
  • ActionListener and Thread.sleep
  • What is the maximum of number of arguments for varargs in java?
  • When I compile I get an error as "ask" cannot be resolved or is not a field"
  • What is the best way to check if 4 integer variables are equal to 0?
  • Storing constant webdriver elements in an enum
  • Java: Why main class does not extend Thread class
  • Java - how to find out if a directory is being used by another process?
  • How can I get a method to print?
  • Java unknown exceptions
  • BufferedReader,StreamWriter crash
  • found raw type: JComboBox
  • Java Generics -> Function return type
  • how to refresh contents of jtable on event of action listener?
  • Why does List interface extend Collection interface?
  • Pros and Cons of Clojure http client libraries
  • use final inside a for each loop
  • Convert java data object to service object
  • Unsupported major.minor version 51.0 while executing JSP
  • How do I display a word diagonally in Java?
  • making sure one task completes before another starts in java
  • My program gives an index out of bounds error
  • Removing duplicate characters in a String (user inputted keyword)
  • Jersey 2.0 Content-Length not set
  • AWS.SimpleQueueService.NonExistentQueue Exception thrown when Accessing Existing SQS queue
  • Where can I find the source code for the com.sun.jdi package?
  • How can I get path of resource under WEB-INF/class folder (java ee web dynamic project)
  • convert a hexadecimal into a decimal via string convert in java
  • error populating a table using jstl
  • If Singletons are bad then how do you store global state for a framework
  • input system where the user inputs the array position of the object followed by a # to indiacte quantity but it gives me
  • Java: when would I ever want to use static methods when I can use a singleton instead?
  • Extracting RSA public key modulus and exponent stored in unsigned char arrays
  • What does "cannot be resolved to a type" mean, and how can I fix it? Java Android 4.0
  • How can I have a callback on stdout/stderr readiness instead of busy polling?
  • How to report AWT/Swing event queue length programmatically?
  • What is the difference between different for loops in Java?
  • Java arrays effective use/alternative
  • EasyMock chained method call producing null pointer exception
  • Installing Java on Windows 8
  • Java: Is it bad practice to write methods that start with "get" when they aren't getters?
  • Can Iterable.filter() skip processing with "constant" (including short circuited) Predicates?
  • How to save edited JTable data to database?
  • Java Packet Sniffer
  • I have a getText error
  • Reading bytestream and writing to file
  • dat file is not get created by buffered writer
  • Converting a pdf to word document using java
  • Measuring memory use of a piece of code at runtime in Java as an on-going functionality of a service
  • What is Matrix.frustumM(mProjMatrix, 0, -ratio, ratio, -1, 1, 3, 7); in OpenGL ES 20?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org