Skip navigation links
Dashboard

Class PieChartWidget

Inheritance:
  • Field Detail

    • Columns!

      public BBjVector Columns!

      A vector of columns indicating which fields in the BBjRecordSet will be used to provide data for the widget

    • ConnectString$

      public BBjString ConnectString$

      A JDBC connect string used to connect to the database

    • IsCircular

      public BBjNumber IsCircular

      A number indicating whether the pie chart is circular or stretched into an elliptical shape

    • NumSlices

      public BBjNumber NumSlices

      A number indicating the number of slices in the pie chart

    • RecordSet!

      public BBjRecordSet RecordSet!

      A BBjRecordSet used to provide data for the widget

    • SQL$

      public BBjString SQL$

      A SQL query used to provide data for the widget

    • StartAngle

      public BBjNumber StartAngle

      A number indicating the starting angle of the pie chart. The initial default value is 90 degrees, which corresponds to 12 o'clock. A value of zero corresponds to 3 o'clock.

  • Constructor Detail

    • PieChartWidget

      public PieChartWidget(BBjString p_name$, BBjString p_title$, BBjString p_previewText$, BBjString p_previewImage$, BBjString p_chartTitle$, BBjNumber p_flat, BBjNumber p_legend)

      Create an empty Pie Chart specifying all parameters to be filled after creation with setDataSetValue()

      Note: As of BBj 23.00, the Dashboard Utility uses JFreeCharts 1.5.x which removes the pseudo-3D charts. Therefore, the p_flat parameter will be ignored in version 23 and higher.

      Parameters:
      p_name$ The unique name of the chart widget
      p_title$ Title which will display in the title bar
      p_previewText$ A description of the widget used for the preview text in the Customize screen and as the tooltip text on the widget's title
      p_previewImage$ A preview of the chart widget that is shown in the Add/Remove widgets Customize dialog
      p_chartTitle$ The title to be displayed above the pie chart (may be empty)
      p_flat A number that indicates whether the chart will be flat or 3D. 0=3D, 1=Flat (2D), ignored in version 23 and higher
      p_legend A number that indicates whether to show a legend for the chart. 0=Do not show legend, 1=Show legend
    • PieChartWidget

      public PieChartWidget(BBjString p_name$, BBjString p_title$, BBjString p_previewText$, BBjString p_previewImage$, BBjString p_chartTitle$, BBjNumber p_flat, BBjNumber p_legend, BBjNumber p_numSlices)

      Create an empty Pie Chart specifying all parameters to be filled after creation with setDataSetValue()

      Note: As of BBj 23.00, the Dashboard Utility uses JFreeCharts 1.5.x which removes the pseudo-3D charts. Therefore, the p_flat parameter will be ignored in version 23 and higher.

      Parameters:
      p_name$ The unique name of the chart widget
      p_title$ Title which will display in the title bar
      p_previewText$ A description of the widget used for the preview text in the Customize screen and as the tooltip text on the widget's title
      p_previewImage$ A preview of the chart widget that is shown in the Add/Remove widgets Customize dialog
      p_chartTitle$ The title to be displayed above the pie chart (may be empty)
      p_flat A number that indicates whether the chart will be flat or 3D. 0=3D, 1=Flat (2D), ignored in version 23 and higher
      p_legend A number that indicates whether to show a legend for the chart. 0=Do not show legend, 1=Show legend
      p_numSlices A number that indicates the total number of slices in the chart after it has been filled with data
    • PieChartWidget

      public PieChartWidget(BBjString p_name$, BBjString p_title$, BBjString p_previewText$, BBjString p_previewImage$, BBjString p_chartTitle$, BBjNumber p_flat, BBjNumber p_legend, BBjString p_connectString$, BBjString p_sql$)

      Create an SQL-based Pie Chart specifying all parameters

      Note: As of BBj 23.00, the Dashboard Utility uses JFreeCharts 1.5.x which removes the pseudo-3D charts. Therefore, the p_flat parameter will be ignored in version 23 and higher.

      Parameters:
      p_name$ The unique name of the chart widget
      p_title$ Title which will display in the title bar
      p_previewText$ A description of the widget used for the preview text in the Customize screen and as the tooltip text on the widget's title
      p_previewImage$ A preview of the chart widget that is shown in the Add/Remove widgets Customize dialog
      p_chartTitle$ The title to be displayed above the pie chart (may be empty)
      p_flat A number that indicates whether the chart will be flat or 3D. 0=3D, 1=Flat (2D), ignored in version 23 and higher
      p_legend A number that indicates whether to show a legend for the chart. 0=Do not show legend, 1=Show legend
      p_connectString$ The connection string to the desired database. Example: "jdbc:basis:localhost?database=ChileCompany&user=admin&password=admin123"
      p_sql$ The sql query used to populate the chart. The two columns should be key, value. Example: select salesperson, count(salesperson) from customer group by salesperson
    • PieChartWidget

      public PieChartWidget(BBjString p_name$, BBjString p_title$, BBjString p_previewText$, BBjString p_previewImage$, BBjString p_chartTitle$, BBjNumber p_flat, BBjNumber p_legend, BBjRecordSet p_rs!, BBjVector p_columns!)

      Create a BBjRecordSet-based Pie Chart specifying all parameters

      Note: As of BBj 23.00, the Dashboard Utility uses JFreeCharts 1.5.x which removes the pseudo-3D charts. Therefore, the p_flat parameter will be ignored in version 23 and higher.

      Parameters:
      p_name$ The unique name of the chart widget
      p_title$ Title which will display in the title bar
      p_previewText$ A description of the widget used for the preview text in the Customize screen and as the tooltip text on the widget's title
      p_previewImage$ A preview of the chart widget that is shown in the Add/Remove widgets Customize dialog
      p_chartTitle$ The title to be displayed above the pie chart (may be empty)
      p_flat A number that indicates whether the chart will be flat or 3D. 0=3D, 1=Flat (2D), ignored in version 23 and higher
      p_legend A number that indicates whether to show a legend for the chart. 0=Do not show legend, 1=Show legend
      p_rs! The BBjRecordSet containing the data used to populate the chart
      p_columns! A BBjVector that contains an ordered list of the columns to be used for the charts's data. The entries may be a string corresponding to a field name, or a 0-based index of the column number. If null() is passed in for the p_columns! vector then the first two columns of the BBjRecordSet will be used.
      See Also:
      BBjRecordSet
      BBjVector
    • PieChartWidget

      public PieChartWidget(BBjString p_name$, BBjString p_title$, BBjString p_previewText$, BBjString p_previewImage$, BBjString p_chartTitle$, BBjNumber p_flat, BBjNumber p_legend, BBjString p_connectString$, BBjString p_sql$, BBjString p_mode$)

      Create an SQL-based Pie Chart specifying all parameters

      Note: As of BBj 23.00, the Dashboard Utility uses JFreeCharts 1.5.x which removes the pseudo-3D charts. Therefore, the p_flat parameter will be ignored in version 23 and higher.

      Parameters:
      p_name$ The unique name of the chart widget
      p_title$ Title which will display in the title bar
      p_previewText$ A description of the widget used for the preview text in the Customize screen and as the tooltip text on the widget's title
      p_previewImage$ A preview of the chart widget that is shown in the Add/Remove widgets Customize dialog
      p_chartTitle$ The title to be displayed above the pie chart (may be empty)
      p_flat A number that indicates whether the chart will be flat or 3D. 0=3D, 1=Flat (2D), ignored in version 23 and higher
      p_legend A number that indicates whether to show a legend for the chart. 0=Do not show legend, 1=Show legend
      p_connectString$ The connection string to the desired database. Example: "jdbc:basis:localhost?database=ChileCompany&user=admin&password=admin123"
      p_sql$ The sql query used to populate the chart. The two columns should be key, value. Example: select salesperson, count(salesperson) from customer group by salesperson
      p_mode$ A string comprised of a list of properties and values separated by commas that will be passed to the database or JDBC connection at connect time. For example: "USER=myusername, PWD=mypass, AUTOCOMMIT=N"
      Since:
      BBj 16.00
    • Method Detail

      • clearDataSet

        public void clearDataSet()

        Clears the pie chart's underlying dataset. This is typically done in response to a refresh event, where the dataset is cleared and then repopulated with up-to-date data (via fill() or setDataSetValue().

      • clone

        public PieChartWidget clone()

        An internal method used by the Dashboard class to clone a category widget so that it may be displayed in a popped out window

        Returns:
        A cloned version of the original widget
      • create

        public void create(BBjChildWindow p_widgetControlWindow!)

        Creates the PieChartWidget

        Parameters:
        p_widgetControlWindow! The BBjChildWindow that will contain the widget
      • destroy

        public void destroy()

        Destroys the PieChartWidget

      • fill

        public void fill(BBjString p_connectString$, BBjString p_sql$)

        Fills the pie chart's underlying dataset with data from an SQL query

        Parameters:
        p_connectString$ The connection string to the desired database. Example: "jdbc:basis:localhost?database=ChileCompany&user=admin&password=admin123"
        p_sql$ The sql query used to populate the chart. The two columns should be key, value.
      • fill

        public void fill(BBjString p_connectString$, BBjString p_sql$, BBjString p_mode$)

        Fills the pie chart's underlying dataset with data from an SQL query and a mode string

        Parameters:
        p_connectString$ The connection string to the desired database. Example: "jdbc:basis:localhost?database=ChileCompany&user=admin&password=admin123"
        p_sql$ The sql query used to populate the chart. The two columns should be key, value.
        p_mode$ A string comprised of a list of properties and values separated by commas that will be passed to the database or JDBC connection at connect time. For example: "USER=myusername, PWD=mypass, AUTOCOMMIT=N"
        Since:
        BBj 16.00
      • fill

        public void fill(BBjRecordSet p_rs!, BBjVector p_columns!)

        Fills the pie chart's underlying dataset with data from a BBjRecordSet

        Parameters:
        p_rs! The BBjRecordSet containing the data used to populate the chart
        p_columns! A BBjVector that contains an ordered list of the columns to be used for the charts's data. The entries may be a string corresponding to a field name, or a 0-based index of the column number. If null() is passed in for the p_columns! vector then the first two columns of the BBjRecordSet will be used.
      • getDataset

        public Defaultorg.jfree.data.general.PieDataset getDataset()

        Returns the PieChart's underlying dataset, which is a JFreeChart DefaultPieDataset

        Note that PieCharts return a DefaultPieDataset, BarCharts and LineCharts return a DefaultCategoryDataset, and XYCharts return an XYSeriesCollection

        Returns:
        The chart's underlying dataset as a JFreeChart DefaultPieDataset
        See Also:
        JFreeChart's DefaultPieDataset documentation for more information.
      • getFormattedValue

        public BBjString getFormattedValue(BBjNumber p_value!)

        Returns a formatted string representation of the value.

        The formatting will be the same as specified in the setLabelFormat() method. If the setLabelFormat() method was never called, then the value will simply be converted to a string.

        Parameters:
        p_value The chart's numeric value to be formatted
        Returns:
        The numberic value formatted according to the label's NumberFormat, returned as a BBjString
      • getNumRows

        public BBjNumber getNumRows()

        Returns the number of rows in the pie chart's dataset (or slices in the pie)

        Returns:
        The number of slices in the pie chart
      • getResultSet

        public HashMap getResultSet()

        Returns the pie chart's underlying dataset as a BBjRecordSet

        Returns:
        The BBjRecordSet containing the data used to populate the chart
      • isDestroyed

        public BBjNumber isDestroyed()

        Returns if the PieChartWidget is destroyed

        Returns:
        Returns 1 if destroyed, otherwise 0 is returned
      • isEmpty

        public BBjNumber isEmpty()

        Indicates whether the widget's dataset is empty or not

        Returns:
        0=Not empty, 1=empty
        Since:
        BBj 16.00
      • isRecordSetBased

        public BBjNumber isRecordSetBased()

        Indicates whether the widget's dataset was built from a BBjRecordSet

        Returns:
        0=Not based on a BBjRecordSet, 1=Based on a BBjRecordSet
      • isSQLBased

        public BBjNumber isSQLBased()

        Indicates whether the widget's dataset was built from an SQL query

        Returns:
        0=Not SQL Based, 1=SQL Based
      • refresh

        public void refresh()

        Refreshes the chart, which results in the widget showing an up-to-date version of the chart. This is executed in response to a refresh event, and the chart is filled with curent data and all customizations are applied

      • set3dDepthFactor

        public void set3dDepthFactor(BBjNumber p_depthFactor)

        Sets the pie depth as a percentage of the height of the plot area. Values range from 0 to 1.

        Note: As of BBj 23.00, the Dashboard Utility uses JFreeCharts 1.5.x which removes the pseudo-3D charts. Therefore, this method is ignored in version 23 and higher.

        Setting the value to 0 results in a flat, non-3D chart. Setting the valute to 1 results in a 3D chart that is so extruded that you can only see the side, not the top. Values in the 0 to 0.2 range are more reasonable.

      • setDataSetValue

        public void setDataSetValue(BBjString p_key$, BBjNumber p_value)

        Adds a new dataset entry to the chart's underlying dataset. This method is typically used to fill a chart with data values one at a time programmatically, instead of filling it with the resultset of an SQL query which is done via the fill() method.

        Parameters:
        p_key$ A string that describes the dataset's row, which is used for the pie slice name
        p_value A number that denotes the data value for the specified row (or pie slice)
      • setEmbeddedLabels

        public void setEmbeddedLabels(BBjString p_colorHexString$, BBjNumber p_opacity)

        Turn on simple (embedded) labels. Calling this method will cause the pie plot to be rendered with the labels inside each pie slice instead of outside of the plot.

        Parameters:
        p_colorHexString$ A hex color string. An example would be "#ff00cc" or "#f0c"
        p_opacity The desired opacity value (0-1). 0=Fully Transparent, 1=Fully Opaque.
      • setExplodeAllSlicesPercent

        public void setExplodeAllSlicesPercent(BBjNumber p_percentExplode)

        Offset all pie slices by exploding them out from the center of the pie. Due to a limitation in JFreeCharts (as of version 1.0.19), this does not work with a 3D pie chart

        Parameters:
        p_percentExplode A number from 0-1 that determines the amount to be moved out. A value of 0.30 results in moving the slice outward 30% of the available plot space.
      • setExplodePercent

        public void setExplodePercent(BBjString p_sliceName$, BBjNumber p_percentExplode)

        Offset a pie slice by exploding it out from the center of the pie. Due to a limitation in JFreeCharts (as of version 1.0.19), this does not work with a 3D pie chart

        Parameters:
        p_sliceName$ The name (or key) of the slice that should be moved outward
        p_percentExplode A number from 0-1 that determines the amount to be moved out. A value of 0.30 results in moving the slice outward 30% of the available plot space.
      • setIgnoreZeroValues

        public void setIgnoreZeroValues(BBjNumber p_ignoreZeroValues)

        Sets whether the pie chart should ignore entries in the dataset that have a zero value.

        When set to 1, entries with a value of zero will not be displayed in the plot or legend. When set to 0, they will. The default is set to 1, which ignores entries with a zero value.

        Parameters:
        p_ignoreZeroValues A number (0 or 1) that indicates whether entries with a value of zero should be ignored by the pie chart.
      • setLabelBackgroundColor

        public void setLabelBackgroundColor(BBjString p_colorHexString$, BBjNumber p_opacity)

        Sets the label's background color for the pie chart

        Parameters:
        p_colorHexString$ A string with a hex description of the color for marker. Example: "#ffccaa" or "#fca"
        p_opacity A number from 0-1 that determines the starting opacity level (0=transparent, 1=opaque)
      • setLabelFormat

        public void setLabelFormat(BBjString p_customLabelFormat$)

        Define a custom label format for the pie chart

        Parameters:
        p_customLabelFormat$ A string defining the desired label format An example label format would be "{0}: {1} ({2})" and would display as "Apple: 40 (40%)" {0} = The text portion of the dataset entry {1} = The numeric portion of the dataset entry {2} = The numeric portion of the dataset entry followed by a percent sign
      • setLabelFormat

        public void setLabelFormat(BBjString p_customLabelFormat$, NumberFormat p_numberFormat!, NumberFormat p_percentageFormat!)

        Define a custom label format for the pie chart by providing a label string and NumberFormatters for the number and percentage fields.

        A sample use case would be:

        
         widget!.setLegendLabelFormat("{0}: {1}", java.text.NumberFormat.getCurrencyInstance(), java.text.NumberFormat.getPercentInstance())
         
        which would cause the label to display the key followed by the value formatted as currency. That way it would show up in a format similar to:
        
         Current: $218.10
         
        If the currency format is not specified, the value would display as "218.0" which does not include the pennies or currency unit.
        Parameters:
        p_customLabelFormat$ A string defining the desired label format An example label format would be "{0}: {1} ({2})" and would display as "Apple: 40 (40%)"
        • {0} = The text portion of the dataset entry
        • {1} = The numeric portion of the dataset entry
        • {2} = The numeric portion of the dataset entry followed by a percent sign
        p_numberFormat! A NumberFormat object that formats the numeric portion {1} of the dataset entry
        p_percentageFormat! A NumberFormat object that formats the percentage portion {2} of the dataset entry
        See Also:
        Oracle's NumberFormat documentation for more information.
      • setLabelsOff

        public void setLabelsOff()

        Turns off the pie chart's labels (the labels for the pie's slices, not the legend)

      • setPlotPadding

        public void setPlotPadding(BBjNumber p_padding)

        Sets the amount of padding, or space, between the pie plot and the edges of the chart itself.

        This controls the space between the edges of the pie plot and the plot area itself (the region where the section labels appear). Increasing the padding will ensure that labels will not be accidentally truncated.

        Parameters:
        p_padding The padding amount as a percentage of the plot as a whole, expressed as a number between 0 and 0.4. 0=NoPadding, 0.4=40% of the plot space will be allocated to padding.
        See Also:
        JFreeChart's setInteriorGap() method documentation for more information.
      • setShadowColor

        public void setShadowColor(BBjString p_shadowHexString$, BBjNumber p_opacity, BBjNumber p_xOffset, BBjNumber p_yOffset)

        Sets the pie chart's shadow with sharp edges

        Note that this only appears to work on a flat (non-3D PieChart) as of JFreeCharts 1.0.19 You may want to use setChartPlotShadow() instead as it provides a diffused shadow with more control over the parameters

        Parameters:
        p_shadowHexString$ A string with a hex description of the shadow color. Example: "#ffccaa" or "#fca"
        p_opacity A number from 0-1 that determines the opacity level (0=transparent, 1=opaque)
        p_xOffset The offset of the shadow in the X direction
        p_yOffset The offset of the shadow in the Y direction
      • setSliceOutlineColor

        public void setSliceOutlineColor(BBjString p_colorHexString$, BBjNumber p_opacity)

        Sets the color and opacity for the outline of each pie slice and its corresponding legend item

        Parameters:
        p_colorHexString$ A string with a hex description of the outline color. Example: "#ffccaa" or "#fca"
        p_opacity A number from 0-1 that determines the starting opacity level (0=transparent, 1=opaque)
      • setSliceOutlineWidth

        public void setSliceOutlineWidth(BBjNumber p_width)

        Sets the width of the outline for each pie slice and its corresponding legend with the default value set to 1.

        Notes:

        • The value does not have to be an integer, so 0.5 is an acceptible value
        Parameters:
        p_width The width of the outline in pixels
      • viewDataSet

        public void viewDataSet()

        Creates a table representation of the chart's DefaultPieDataset and displays it in a message box.

        This is primary aimed at debugging by providing a view into what a pie or ring chart's dataset looks like.

        A sample use case would be:

        
         myPieChartWidget!.viewDataSet()
         
        When the code is executed, the dashboard utility will display a message box with a tabular view of the chart's dataset