I'm using the JS API to draw a LineChart that displays some query results
over time. Since I'm running many queries at once, I'd like to visualize
only the top few (say, 5) in the chart at once. However, since the query
results change over time, the set of top queries also changes. This seems
like a great use case for DataViews, and my current implementation does the
following:
1. Create one global DataTable with the history of all the query results.
2. Each time new query results come in:
1. Add the results as a new row to the DataTable
2. Determine which columns of the DataTable are the top 5
3. Create a new DataView including only those columns of the DataTable
4. Draw my LineChart with the DataView.
My problem is that whenever the position of a column in the top 5 columns
changes over time, it gets assigned a new color, so the color corresponding
to a given query on the LineChart doesn't remain constant. An example is
shown below. Note that in the first chart, group_2 (the second-best query)
is in red, whereas after an update (shown in the second chart), group_6 is
now the red line (it was the green line in the first chart), and group_2 is
now in purple.
<https://lh4.googleusercontent.com/-oVk0wfaLQGA/VC88mihaA7I/AAAAAAAAApA/Px_eBhVoxxE/s1600/Screen%2BShot%2B2014-10-03%2Bat%2B5.13.58%2BPM.png>
<https://lh3.googleusercontent.com/-UL6YGcaE328/VC88sEs7zxI/AAAAAAAAApI/Vfp69oQ_-NQ/s1600/Screen%2BShot%2B2014-10-03%2Bat%2B5.14.47%2BPM.png>
Ideally, I would like the color corresponding to a single query to remain
constant as long as it is in the top 5 queries, even if its position
changes. If a query drops below the top 5, then comes back later, it's fine
to assign it a new color. So far, the only solutions I have come up with
involve assigning a unique color to each query (impractical because I could
have hundreds of queries), or storing the old state of the top 5 queries
and implementing some convoluted logic to make sure that each query's
column is passed into the DataView in the order it was in when it first
entered the top 5.
I'm hoping there's some mechanism in the visualization API to help me out
with this--can anyone help?
Thanks in advance,
-- Daniel
--
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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.