Bar chart X series

Hi all,
Sorry I may have asked similar question for Y series, but this time I have a question regarding x Series,
My X series will always return no more than 3 values Red, Green and Yellow,
what I want to do is to change the bar color based on the each value , attached an example,
thanks for your help

Comments

  • edited April 17

    To change the "Low" bar to red, try (in beforeDrawDataPoint):

    if(dph.getBaseDisplayValue() == "Low") {fill.set( 255, 0, 0, 255 );}

    Jeff F.
    Customer Support Engineer I
    OpenText
  • Hey Jeff,
    I have applied the code into Script tab > beforeDrawDataPoint as you mentioned

    if(dph.getBaseDisplayValue() == "Low") {fill.set( 255, 0, 0, 255 );}

    but it make the chart disappear, as it doesnt work, is it possible that might be in different version of designer ?
    OpenText Analytics Designer
    Version: 24.4.0
    and the second part is If I want to apply all 3 colors would I repeat it with and? and if so how?

    thanks

  • If the chart disappears, there might be more information about what is causing the issue in the Eclipse Error Log.

    I created an example that does multiple changes to the bar colors. I put comments in the code indicating the effect of each line of code. I hope it is helpful.

    Jeff F.
    Customer Support Engineer I
    OpenText
  • Hey Jeff thanks, Your sample work great however I dont seem to modify the code to work with my scenario,
    my Category Series called row[dpr] and this row will always returns 3 values High, Medium and Low
    and my value Series is row[IS] this will only return IS and I am counting this row for my Y Series,
    so now what I am trying to do is make my x category to be High always red, medium always yellow and low always green.
    as per my screen shot
    thanks

  • Let's try some debugging. If you do not see the "Error Log" tab in your designer, go to the Window menu and select: Show View > Error Log. Make a copy of the report with the chart so that you have a backup. Delete any existing code in the chart. Add the following code:

    ///////////////
    function beforeDrawDataPoint( dph, fill, icsc )
    {
    java.util.logging.Logger.getLogger("birt.report.logger").warning("Chart Debug: " + dph.getBaseDisplayValue());
    }
    ///////////////

    Save and run the report. In the Error Log, you should see entries for "Low", "Medium", and "High". Is that what you see? If not, please post the logged messages. If you see those three values, then please post your code that is causing the chart to disappear. There is likely a syntax error.

    Jeff F.
    Customer Support Engineer I
    OpenText
  • Hey Jeff,
    I Have done as advised,
    I have add the above code on OnRender>New Event Function ( wasnt sure where else to add it )
    I didnt get the result expected but here is the error I have got,
    java.io.IOException: org/eclipse/birt/core/script/ParameterAttribute
    at org.eclipse.birt.core.util.IOUtil.readObject(IOUtil.java:651)
    at org.eclipse.birt.core.util.IOUtil.readMap(IOUtil.java:1074)
    at org.eclipse.birt.core.util.IOUtil.readMap(IOUtil.java:1046)
    at com.actuate.birt.report.engine.internal.datamart.storage.DatamartStorage.readCoreStreamV1(DatamartStorage.java:471)
    at com.actuate.birt.report.engine.internal.datamart.storage.DatamartStorage.readCoreStream(DatamartStorage.java:442)
    at com.actuate.birt.report.engine.internal.datamart.storage.DatamartStorage.read(DatamartStorage.java:306)
    at com.actuate.birt.report.engine.internal.datamart.storage.DatamartStorage.open(DatamartStorage.java:85)
    at com.actuate.birt.report.engine.internal.datamart.storage.DatamartStorage.open(DatamartStorage.java:97)
    at com.actuate.birt.report.engine.internal.ActuateReportEngine.openDatamartStorage(ActuateReportEngine.java:194)
    at com.actuate.birt.chart.reportitem.ui.GeneralDataMartRepository.getDatamartStorage(GeneralDataMartRepository.java:178)
    at com.actuate.birt.report.engine.internal.datamart.DteDatamartRepository._getDatamartStorage(DteDatamartRepository.java:461)
    at com.actuate.birt.report.engine.internal.datamart.DteDatamartRepository.getDatamartStorage(DteDatamartRepository.java:360)
    at com.actuate.birt.data.impl.datamart.DataMartStorageFetcher.getDataMartStorage(DataMartStorageFetcher.java:58)
    at com.actuate.birt.data.impl.datamart.PreparedDataMartDataSourceQuery$DataMartQueryExecutor.createOdiQuery(PreparedDataMartDataSourceQuery.java:389)
    at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(QueryExecutor.java:335)
    at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQuery.java:464)
    at com.actuate.birt.data.impl.datamart.PreparedDataMartDataSourceQuery.produceQueryResults(PreparedDataMartDataSourceQuery.java:157)
    at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(PreparedDataSourceQuery.java:178)
    at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.execute(DataRequestSessionImpl.java:651)
    at org.eclipse.birt.chart.reportitem.ui.DteAdapter.executeQuery(DteAdapter.java:219)
    at org.eclipse.birt.chart.reportitem.ui.ReportDataServiceProvider.executeDataSetQuery(ReportDataServiceProvider.java:1724)
    at com.actuate.birt.chart.reportitem.ui.ActuateChartDataServiceProvider.createBaseEvaluator(ActuateChartDataServiceProvider.java:1083)
    at org.eclipse.birt.chart.reportitem.ui.ReportDataServiceProvider.prepareRowExpressionEvaluator(ReportDataServiceProvider.java:1622)
    at org.eclipse.birt.chart.ui.util.ChartUIUtil.doLivePreview(ChartUIUtil.java:586)
    at org.eclipse.birt.chart.ui.util.ChartUIUtil.prepareLivePreview(ChartUIUtil.java:1776)
    at org.eclipse.birt.chart.ui.swt.wizard.TaskSelectType$5.run(TaskSelectType.java:2004)
    at org.eclipse.birt.chart.ui.swt.wizard.preview.ChartLivePreviewThread.run(ChartLivePreviewThread.java:200)
    Caused by: java.lang.ClassNotFoundException: org/eclipse/birt/core/script/ParameterAttribute
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.eclipse.birt.core.util.IOUtil$1.resolveClass(IOUtil.java:641)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
    at org.eclipse.birt.core.util.IOUtil.readObject(IOUtil.java:647)

    PS: I think your initial selution would work and that might have been when I didnt probably modify the script to work with my senario, ( my Category Series called row[dpr] and this row will always returns 3 values High, Medium and Low
    and my value Series is row[IS] this will only return IS and I am counting this row for my Y Series,
    so now what I am trying to do is make my x category to be High always red, medium always yellow and low always green.
    as per my screen shot )

    thanks

  • You placed the debug code in the correct location. I'm not sure about the "ClassNotFoundException". It might be an issue with the Classpath. You mentioned going back to the original solution. Since you are only getting the Java error when you try to run the debug code, I agree that it might be better to focus on the solution to the chart issue as opposed to debugging the debug code.

    Placing the following code in the OnRender event should change the bars to the colors in your screenshot based on the category names in the screenshot:

    function beforeDrawDataPoint( dph, fill, icsc )
    {
    if(dph.getBaseDisplayValue() == "Low") {fill.set( 46, 184, 46, 255 );}
    if(dph.getBaseDisplayValue() == "Medium") {fill.set( 255, 255, 100, 255 );}
    if(dph.getBaseDisplayValue() == "High") {fill.set( 255, 26, 26, 255 );}
    }

    Jeff F.
    Customer Support Engineer I
    OpenText
  • hey Jeff,
    Thanks again for your assistant,
    even though the script seems ok and it make sense, but it doesn't actually change the color,
    I have applied it in chart script it didn't change the color and also I tried on report scripts and it didn't work there either,
    could that be the version of Analytic Designer ( OpenText Analytics Designer
    Version: 24.4.0)?
    I have tried to change the color code into "#348c31" type of format but still no luck,
    I have an screen shot where and how I applied above code.
    thanks

  • Thanks for including the screenshot. Please try commenting out the line that starts with "beforeRendering". Uncomment the line below it with "function beforeDrwwDataPoint(dph,fill,icsc)

    I tested on the same version of the Designer that you are running.

    Jeff F.
    Customer Support Engineer I
    OpenText
  • Thanks Jeff, I have but still the same,
    /**
    * Called before chart instance is rendered.
    *
    * @param options
    * chart options
    * @param chart
    * chart instance
    */

    function beforeDrawDataPoint( dph, fill, icsc )
    {
    if(dph.getBaseDisplayValue() == "Low") {fill.set( 46, 184, 46, 255 );}
    if(dph.getBaseDisplayValue() == "Medium") {fill.set( 255, 255, 100, 255 );}
    if(dph.getBaseDisplayValue() == "High") {fill.set( 255, 26, 26, 255 );}

    },

  • edited April 29

    The code looks correct. I have a few questions:

    What is the "Output Format" in the chart editor "Select Chart Type" tab?

    What messages do you get in the Eclipse error log when you run the report? (Window > Show View > Error Log)

    What messages do you get in your browser? (Press the F12 key with the browser window active and select "Console")

    Jeff F.
    Customer Support Engineer I
    OpenText
  • HTML5,
    I get no error
    screenshot attached ,
    I can **** my report design too just in case and if possible remove it after viewing ?
    thanks

  • Sorry, i was certain you were using SVG charts. I must have confused this thread with another one. The code is different for HTML5 charts. I will create an example and post it later today.

    Jeff F.
    Customer Support Engineer I
    OpenText
  • Here is the new example. Delete the old code. The new code is in the chart editor Script tab. Sorry about the confusion with the chart type.

    Jeff F.
    Customer Support Engineer I
    OpenText
  • Perfect Jett not to worry at all, thanks for your help it work fine :)

Sign In or Register to comment.