What you need to do is not replace the data value itself, but just the
formatted representation. Each cell has two fields, v and f, for the value
and its formatted representation. So set the formatted representation to
be your link, but leave the value set to just the text without the link.
Sorting should only apply to the value, not the formatted representation.
Also, did you try using null instead of empty strings ('') for the value
that have no email address?
On Tue, Apr 18, 2017 at 1:25 PM, 'Ray Thomas' via Google Visualization API <
[email protected]> wrote:
> Taking the code at https://developers.google.com/chart/interactive/docs/
> reference#patternformatter as an example.
>
> The data looks like this
>
> data.addRows([
> ['John Lennon', '[email protected]'],
> ['Paul McCartney', '[email protected]'],
> ['George Harrison', '[email protected]'],
> ['Ringo Starr', '[email protected]']
> ]);
>
>
> But suppose the data looks like this:
>
> data.addRows([
> ['John Lennon', ''],
> ['Paul McCartney', '[email protected]'],
> ['George Harrison', ''],
> ['Ringo Starr', '[email protected]']
> ]);
>
>
> The formatter looks like this:
>
>
>
>
> *var formatter = new google.visualization.PatternFormat( '<a
> href="mailto:{1}">{0}</a>');// Apply formatter and set the formatted value of
> the first column.formatter.format(data, [0, 1]);*
>
>
> Is it possible to conditionally apply the PatternFormat so that if the
> email data is empty then the formatter is not applied?
>
> I know I could create a new column by stepping through the data, and
> creating and populating that with either the name or the name and an email
> link, but then the column sorting is not going to work properly because
> it's gong to sort on "<" as well as the name.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to google-visualization-api@
> googlegroups.com.
> Visit this group at https://groups.google.com/
> group/google-visualization-api.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/google-visualization-api/8a3c8237-16e3-4ebf-876c-
> 3e714d396350%40googlegroups.com
> <https://groups.google.com/d/msgid/google-visualization-api/8a3c8237-16e3-4ebf-876c-3e714d396350%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
[email protected] <[email protected]> 5CC, Cambridge MA
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJPprcowXwy%3DCptzw7NnwDWAuntpQByZ_gPkPCizNHpU8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.