Adding a vertical line to an area chart

(5 posts) (2 voices)
  1. ajdjackson, Member


    I'm trying to add several vertical lines to an area chart.

    The code I'm using is:

    select 'dbr.chart', 'Area', 'Costs'; select 'dbr.chart.options','rotateNames',90; select 'dbr.chart.options','chartdirector', concat('$c->xAxis->addMark("',b_date,'", 0x995500, "Booked")');

    select * from costs_tmp;

    b_date is a declared varchar and has the format YYYY-MM which is the same as the area chart's x-axis data.

    I'm getting the following error: Error in ChartDirector-command: "$c->xAxis->addMark("2016-01", 0x995500, "Booked")"

    I would also like to set the line width 2 pixels by using setLineWidth(2), rotate the label by using setFontAngle(90) and put label to left of the line by using setAlignment(Left).

    Is this possible?

    Many thanks


  2. myDBR Team, Key Master

    You are missing the semicolon at the end of the statement.

    The addMark-commnd returns a textbox-object you can format.

    myDBR Team

  3. ajdjackson, Member


    Thanks for that. I would've been looking at that all day :)

    However although I don't get an error now I also do not get a line.

    Is there anything else I need to do?

    Also you say the addMark command returns a textbox object. How do I format it?

    Thanks again


  4. ajdjackson, Member


    I sorted it I think.

    Using the following I get a line:

    select 'dbr.chart', 'Area', 'Costs'; select 'dbr.chart.options','rotateNames',90; select 'dbr.chart.options','chartdirector', '$xMark1=$c->xAxis->addMark(13, 0x995500, "Booked");'; select 'dbr.chart.options','chartdirector', '$xMark1->setLineWidth(2);'; select 'dbr.chart.options','chartdirector', '$xMark1->setAlignment(Left);'; select 'dbr.chart.options','chartdirector', '$xMark1->setFontAngle(90);';

    select * from costs_tmp;

    As you can see I have placed the line at the 13th tick mark on the x-axis. If I supply the actual value of the x-axis label ie 2016-01 (which is the 13th interval) no line appears. Is this way I have to do it ie find the number of the interval instead of using the actual label?



  5. myDBR Team, Key Master

    There is no direct method for this. You can find out the position from your dataset or you can use axis->getTicks() and axis->getLabel() to find out the position of the label text.

    myDBR Team


You must log in to post.