Stacked Bar - Dynamically Changing Legend Colors

(3 posts) (2 voices)

Tags:

No tags yet.

  1. mleary2001, Member

    Good Morning, again,

    Is there a way to customize the legend colors, similar to the bar colors?

    I have the bars the way I need them, here. Now if I can just get the legend the way I need it, here.

    I have found that if I switch the ‘event_date’ and ‘Ignition’ fields in my query the legend appears the way I need it, but the elapsed times are summed.

    ————— This is the code to get the desired bar segments ———————————

    /* make the temp table in the database */
    CALL temp_table_procedure;

    /*myDBR chart code */
    select 'dbr.title', 'Elapsed Times Between Events - Chart';
    select 'dbr.chart', 'StackedBar';
    select 'dbr.chart.options', 'label_color', event_date, if (Ignition='On', '0x42B64A^', '0xE85854') from temp_table;

    SELECT
    Asset,
    event_date,
    Elapsed,
    Ignition
    FROM
    temp_table;

    ————————— Rearranging the Ignition and event_date fields produces the desired legend —————
    SELECT
    Asset,
    Ignition,
    Elapsed,
    event_date
    FROM
    temp_table;

    Thanks in advance,

    Mike

  2. myDBR Team, Key Master

    if you want to add explanation to the On and Off colors, you should hide the legend and draw your text boxes. (A legend in a chart is drawn based on the charts data's series-names. In your chart the series is the event_date.)

    Use something like this:

    select 'dbr.chart.options', 'padding_right', 100;
    select 'dbr.chart.options', 'chartdirector', '
    $b = $c->addText(580, 150, "");
    $b->setBackground(0x00FF00, 0x0);
    $b->setSize(10, 10);
    $c->addText(592, 148, "On");
    $b = $c->addText(580, 165, "");
    $b->setBackground(0xFF0000, 0x0);
    $b->setSize(10, 10);
    $c->addText(592, 163, "Off" );
    ';

    --
    myDBR Team

  3. mleary2001, Member

    That did the trick!

    Thanks again for the great support!

    Mike


Reply

You must log in to post.