Runtime Control of Y-axis Labels in Chart

jeffreymac
edited February 11, 2022 in Analytics #1
I would like to be able to control the format of the y-axis labels depending on the maximum y value of the data to be displayed. Is this possible and if so, what evnet handler do I need to use and how to I obtain the max value within the event handler?

Comments

  • Virgil Dodson
    Virgil Dodson E admin
    edited December 31, 1969 #2
    Hi jeffreymac,

    There are a couple of event handlers needed to get at the values, and format the axis label. Below is a javascript example that may work for you. This one will color the label corresponding to the largest data value.

    var maxval=0;
    var dataSetProcessor;

    function beforeDataSetFilled(series, idsp, icsc) {
    dataSetProcessor = idsp;
    }

    function afterDataSetFilled(series, dataSet, icsc) {
    maxval = dataSetProcessor.getMaximum( dataSet );
    }

    function beforeDrawAxisLabel(axis, label, icsc)
    {
    importPackage(Packages.org.eclipse.birt.chart.model.attribute);
    importPackage(Packages.org.eclipse.birt.chart.model);
    importPackage(Packages.org.eclipse.birt.chart.model.data);
    importPackage(Packages.org.eclipse.birt.chart.model.data.impl);

    if (maxval <= parseFloat(label.getCaption().getValue())) {
    if (axis.getType() != AxisType.TEXT_LITERAL) {
    label.getCaption().getColor( ).set( 208, 32, 0);
    }
    }
    }
    Warning No formatter is installed for the format ipb
  • jeffreymac
    edited December 31, 1969 #3
    Thanks very much for the fast response and help! The code you provided worked fine. For some reason I had to remove the import statements to prevent errors.