Logarithmic scales

A logarithmic scale is used to examine values that span many orders of magnitude, having application in various fields, like astronomy, sound level analysis, stock market analysis, etc.
A logarithmic scale increment is based on multiplication, rather than addition. The increment grows exponentially, by linearly raising the logarithmic base value, starting with exponent 0. For example, a logarithmic scale of base 10 is increased as follows:
1,10,100,1000,10000, and so on. A logarithmic scale is not automatic and does not support negative values.

The application below displays a line series plotted against a logarithmic scale of base 10. The inner grid lines are enabled and chart data is read from the logchart.xml file.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.jinsight.jetchart.*;
import java.io.*;

public class Main extends JFrame  {

   public Main() {

        Graph graph=new Graph();

        graph.setTitle(new String[]{"The JetChart Library","Logarithmic scales"});

        graph.setVerticalLabelsEnabled(true);

        GraphSet graphSet=graph.getGraphSet(0);
        
        Scale scale=graphSet.getScale();

        // Disables the automatic scale. 
        scale.setAutoScaleEnabled(false);

        scale.setLogEnabled(true);
        scale.setLogBase(10); 

        // Sets the indexes of the only visible scale labels, from top to bottom.
        scale.setVisibleLabelsIndexes(new int[]{0,11,22,33,44});

        scale.setValueFormat("$ ###,###,###");
        scale.setMaxValue(1000000);
        scale.setMinValue(100);
        
        Grid grid=graphSet.getGrid();
        grid.setEnabled(true);
        grid.setColor(Color.decode("#cccccc"));
        
        // Enables the inner logarithmic grid lines and set the number of inner lines
        // to 10.
        grid.setInnerLogLinesEnabled(true);
        grid.setInnerLogLinesCount(10);
        
        LineSerie ls=new LineSerie();
        ls.setTitle("Line series");
        ls.setColor(Color.red);
        ls.setThickness(2);
        ls.setMarksEnabled(false);

        graph.addSerie(ls);

        FileReader fr=null;
        try {
           fr=new FileReader("logchart.xml");
           graph.readXMLData(fr);
        }
        catch (IOException e) {
           e.printStackTrace();
        }
        finally {
           try {
              if (fr!=null)
                 fr.close();
           }
           catch (IOException e) {
           }
        }
   
        Container ct=getContentPane();
        ct.add(graph);

        setSize(500,400);
        setVisible(true);
   }

   public static void main(String[] args) {
       new Main();
   }

}