Someone asked this question http://community.qlik.com/message/209386#209386 on the recent "Ask the Experts - Visualization" event. It was an intriguing question because I've run up against this problem before. The orginal thread is locked, so I thought I would post a solution here. The orginal question was:
What is the best way of showing long values on x-axis for charts since qlikview can't do wrap text on values?
Most of the time, the best we could show our client is to make it at 45 degrees angle or make the dimension on y-axis, horizontal chart. It doesn't look nice.
This is not very qool... don't you think?
Any suggestions? Thanks!
There appears to be no way to get the wrap to look noce in the UI. So my solution is to use a script SUB to create a new field that's broken into segments based on the first space after a minmum segment length. And then use the new field as the chart. It may look a bit daunting, but the only thing you need to modify the CALL statement at the end.
SUB SplitString (vField, vTable, vSegLen, vSplitField)
It's all about the height and width of the chart. If you make the chart taller, you will see more lines in horizontal mode. If you make the chart wider, you will see more lines in the vertical mode. The number of lines will vary depending on number of dimensions and chart size. The diagonal is much more predictable.
I just tried to resize the chart with no luck - I resized the entire chart, and I also tried the internal element (with ctrl-shift) and I cant seem to display more than 1 lines in the labels, my labels are of the type "Mainstream Retired" or "Multi High Branch" so I expect 2 or 3 lines. Am I missing something
I see your code and I understand it, I am just not sure where or how to deploy it - is it on the load script? (my application uses a dynamix dimesnion that you can choose using a variable box, so I may need to adjust it to work with that)
am i right to assume that your code will have the same issue and I may end up with the diagonal ones
This was exactly the approach I needed. Just had to change a long 3-word value in the dimension to a 2 line value that doesn't go off the corner off the graph. I did like this to tweak that one long value and leave the others alone:
=if(EmailInquiryType='Screenings and HAs', Replace(EmailInquiryType,'Screenings and HAs','HA and '&chr(10)&'Screening'), EmailInquiryType)
Not that I want to dig up an old thread here but your solution was what I have been struggling with for a few days.
I ultimately wanted to create a field that would look nice on a bar chart as the text of the field is pretty long.
What I found by using this code was that this function was very elegant and simple it how it was designed to allow you to take any field from any table and create a new, easier to read, label. I made a couple of edits that I wanted to point out because I think they improve the reusability of the code.
In your code, if the field you were parsing was exactly the same as another entry, the end result would group them together thus producing double the text in a single field. I opted to create a new variable (vGroupByField) that you can pass to the function that is a unique field that you want to group by. This will eliminate the double-text and give the intended result. I also realized that you had hard-coded the group by field so I edited this as well. Take a look.
SUB SplitString (vField, vTable, vSegLen, vSplitField,vGroupByField)