Creating ChartDataItem Helper Class

The ChartDataItem class is used to create a list of objects that contain the data required to render ADF DVT chart components. For this example, each object will contain a single, aggregated data value for display in a stacked bar chart. For other DVT chart components, this class can provide up to three data points to represent the object in the data visualization. For example, the ChartDataItem object would provide two data points (x and y) for a Scatter Chart component and three data points (x, y, and z) for a Bubble Chart component. However, other DVT components, like Gauges, Maps, and Gantt Charts, have different data model requirements to structure the data values specific to the component. Review the Oracle® Fusion Middleware Developing Web User Interfaces with Oracle ADF Faces guide to find data model requirements for each DVT component.

To create the ChartDataItem class:

  1. In the Projects panel located on the left of the screen, right-click the Model project, select New, and then select From Gallery.

  2. On the New Gallery form, select Java from the Categories panel, and then select Class in the Items panel.

  3. On the Create Java Class form, enter 'ChartDataItem' in the Name field.

  4. Click OK to create the Java class.

  5. Add the following fields to ChartDataItem.java:

    private String series;
    	private String group;
    	private Double x;
    	private Double y;
    	private Double z;
    	
  6. Add the following constructors to ChartDataItem.java:

    public ChartDataItem(String group, String series, Double x)
    	{
    			    this.series = series;
        this.group = group;
    		    this.x = x;
    	}
     
    public ChartDataItem(String group, String series, Double x, Double y)
    	{
        		this(group, series, x);
        		this.y = y;
    	}
     
    	public ChartDataItem(String group, String series, Double x, Double y, Double z)
    	{
    		    this(group, series, x, y);
    		    this.z = z;
    }
  7. Right-click within the class and select Generate Accessors... from the context menu.

  8. Select all methods and click OK.

  9. Save changes to ChartDataItem.java.