4 Replies Latest reply: May 13, 2013 3:09 PM by perforsgren RSS

    AnyGantt: How to set different bar color depending on data value.

    perforsgren
      Need to have different colors for bars in a gantt resource chart.
      The color depends on certain data value not included in the visible part of the chart, so it must be provided 'extra' for the chart in some way without beeing visible.
      Have studied some examples but cannot figure out the mechanism for this, and the procedure to implement it.
      Any ideas?

      Apex 4.2.2

      Regards
      Per.
        • 1. Re: AnyGantt: How to set different bar color depending on data value.
          TexasApexDeveloper
          Similar question, for resource gantt chart, maybe it will help?? : http://apex.oracle.com/pls/apex/f?p=36648:50:12322431100530::NO:::

          Thank you,

          Tony Miller
          Ruckersville, VA
          • 2. Re: AnyGantt: How to set different bar color depending on data value.
            perforsgren
            Among the samples I can see that it has been implemented, but not how.
            To be more specific, this is my working SQL:

            select null link, ID resource_id, TASK_NAME resource_name, PARENT_ID parent_id, START_DATE actual_start, END_DATE actual_end
            from  "DISTURB"."APEX_GANTT_BIT_VIEW"
            where seq=:P3_SELECTED_DIST;

            Now, if I add another column to the statement I get a yellow error message telling that the statement is not valid.
            So this is part one of my question. How to add the new value if not providing another column to the graph?

            Part two will be how to use the added column to set color of the bar.
            I have seen some XML samples, but I can't see the link betw SQL and XML howand where to implement it.

            Regards
            /Per

            Edited by: perforsgren on May 9, 2013 5:46 PM
            • 3. Re: AnyGantt: How to set different bar color depending on data value.
              Hilary-Oracle
              Hi Per,

              You mention "+Among the samples I can see that it has been implemented, but not how.+" - in the Information region below the chart that Tony referred to (https://apex.oracle.com/pls/apex/f?p=36648:50) that I've stated the following:

              "The elements of the Timeline region have been customized via the Chart Attributes page, using the following settings: *Custom Colors*: #000000,#00FF00,#0033FF"

              So that's how I applied custom colours to that particular chart. However, that declarative option won't meet your requirements, where the colours you wish to apply are dependent on data not included in the chart series query. You mention "+Now, if I add another column to the statement I get a yellow error message telling that the statement is not valid.+". It is not possible to simply add an additional column to the chart series query. Each supported chart type expects the associated chart series query to use specific syntax - see About Creating SQL Queries for Charts in Chapter 10 of the APEX User's Guide, http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35125/bldapp_chrt.htm#BCEIJJID.

              So to answer your question "+How to add the new value if not providing another column to the graph?+", if you wish to customise your chart to that extent, then you will need to use custom XML. Depending on what exactly you're trying to achieve, this may require the generation of custom data for your chart. If you edit your chart, and take a look at the Custom XML region, you'll notice a substitution string, #DATA#, towards the end of the XML. When a chart is rendered, we use the chart series query to generate the necessary XML to represent the data on the chart, replacing the string #DATA# with the actual XML. The format of the data XML generated for gantt charts uses a bar style called "defaultStyle", and this handles the default appearance of the bars in the timeline region e.g.
              <period resource_id="1" start="2009.03.21 00.00.00" end="2009.09.21 00.00.00" style="defaultStyle"/>
              You'll see that the 'style="defaultStyle" ' attribute of the data corresponds to a segment of XML outlining what that style is e.g.
              <period_style name="defaultStyle">
              Now take a look at the Bar Style in Resource Project example in the AnyChart online documentation http://www.anychart.com/products/anygantt/docs/users-guide/bar-style.html#bar-style-application-resource-project. In that particular example, a number of different bar styles are used i.e.
              <periods>
                <period resource_id="server_1" start="2008.07.07" end="2008.07.8" style="Working" />
                <period resource_id="server_1" start="2008.07.8" end="2008.07.12" style="Maintance" />
              If you need to add a different bar style to particular rows of data on your chart, then you'll need to add new bar style XML for each colour you wish to use in the Custom XML on the Chart Attributes page, and then you'll also need to generate the data XML yourself, applying the necessary bar style to the relevant row of data. I've got an example of how custom data can be generated for a Resource Gantt here e.g. https://apex.oracle.com/pls/apex/f?p=36648:73 but keep in mind that particular example doesn't demo adding different styles to the data...but it can certainly give you an idea of what's entailed in the generation of custom data for your chart.

              I hope this helps.

              Regards,
              Hilary
              • 4. Re: AnyGantt: How to set different bar color depending on data value.
                perforsgren
                Hilary.

                I see the overall picture now.
                My original intention was to have a separate color for the parent, and another color for the children.
                The information is oriented in such a way that this would make the chart easy to read and understand, not to mention that a collapsed node would be easy to detect.
                I'll try to do something in the direction you explained.

                Many thanks for an excellent explanation.

                Regards
                /Per