Possible to wrap chart labels into multiple lines?

(8 posts) (3 voices)


No tags yet.

  1. duane, Member


    I have some charts that I generate based on some survey results, and it automates the chart title based on the question and the labels based on the possible answers. Some of the answers are quite long - a sentence - and they thus make the chart quite wide with the graphical area squeezed at the right (e.g. bar chart) with a long 'label' to the left.

    So, I'm asking for advice. What would you do to make this more balanced. I don't want to cut/summarise the label as for the survey it is important the full context of the question and answer are displayed. I was thinking the label could be 'wrapped' onto two lines (since there is room as the bars are thick) but I don't see any way to do this. Is this possible? If so how? If not, what do you suggest?

  2. myDBR Team, Key Master

    You can have label wrap multiple lines if you add linefeed (char(10)) into the label.

    The easiest way would be to write a simple function which would take your label and desired width as a parameter and replace spaces with char(10) from desired places.

    select f_wrap_label( mylabel, 50 ), value
    from mytable;

    myDBR Team

  3. duane, Member

    FYI: I couldn't get the char(10) option to work, so I used \n instead and it seems to be working fine.

  4. Avatar, Member

    I wanted to bump this - what is the correct syntax to use as f_wrap_label is not recognised.

  5. myDBR Team, Key Master

    To use multiple lines in chart title, use a linefeed character (char(10), '\n') to separate the lines.

    Fot the cases where the title data is fully dynamic and you do not know in advance where the line breaks should be, we've added a new option 'titlewrap', which will wrap the title to desired length (word wrap or text wrap).

    Use word wrap:

    select 'dbr.chart.options', 'title.wrap', 10;

    Cut long words:

    select 'dbr.chart.options', 'title.wrap', 10, 1;

    myDBR Team

  6. Avatar, Member

    Thanks guys. I was being more specific to the labels within the chart (i.e. within the SQL I think?)

    EDIT: To be more specific I'm looking at bar charts here (so each options within the chart).

  7. myDBR Team, Key Master

    That might be useful, so we added a similar option for labels:

    Use word wrap:

    select 'dbr.chart.options', 'label.wrap', 10;

    Cut long words:

    select 'dbr.chart.options', 'label.wrap', 10, 1;

    myDBR Team

  8. Avatar, Member

    Perfect! This is exactly what I was looking.

    Thank you.


You must log in to post.