Oops! I just realized that my solution requires the data to be evenly
spaced (it doesn't look at the domain values at all). Just wanted to make
you aware.
On Mon, Jul 27, 2015 at 5:26 PM Sergey Grabkovsky <[email protected]> wrote:

> No problem. It was a fun little problem. I think I included enough
> comments for someone to make sense of it.
> On Mon, Jul 27, 2015 at 5:24 PM Kostas Poulakidas <[email protected]>
> wrote:
>
>> WoW!
>>
>> You are fast!
>>
>> Give me some time to understand what you are doing and I will come back
>> to you.
>>
>> Thanks again.
>>
>>
>> Τη Δευτέρα, 27 Ιουλίου 2015 - 1:54:55 μ.μ. UTC-7, ο χρήστης Sergey έγραψε:
>>
>>> Dan is correct, there is no way to compute a trendline for a combination
>>> of series. You'll have to compute the average or the sum. You say that
>>> there's ambiguity when one series has a null value and another is non-null
>>> and you are correct, which means that there would be ambiguity whether we
>>> calculated or you did. I think that calculating the average (or sum) is the
>>> best thing you could do to get what you want. Here is an example of that,
>>> where I interpolate to get missing values:
>>> https://jsfiddle.net/gpogxs9b/1/
>>>
>>> It should support any number of nulls, including a column that only
>>> contains nulls (it will treat it as a column of zeros). When the first or
>>> last few rows are null, it will just use either the first good value or the
>>> last good value. This should be enough for your purposes.
>>>
>>> On Mon, Jul 27, 2015 at 4:22 PM Kostas Poulakidas <[email protected]>
>>> wrote:
>>>
>>>> Great it works like a charm!
>>>>
>>>> Also do you know if I can have *one* trendine for all the data series.
>>>> Just calculating the average is not a option as I don't always have
>>>> non-null values in both series, and I use interpolating nulls.
>>>>
>>>> Please check the thread here.
>>>>
>>>>
>>>> https://groups.google.com/forum/#!topic/google-visualization-api/F3XfJu6rLxc
>>>>
>>>>
>>>> Τη Δευτέρα, 27 Ιουλίου 2015 - 1:13:47 μ.μ. UTC-7, ο χρήστης Sergey
>>>> έγραψε:
>>>>
>>>>> Oh I'm sorry. I was too hasty in sending you the code. I actually
>>>>> meant this:
>>>>>
>>>>> options.trendlines = {};
>>>>> for (var i = 0; i < NUMBER_OF_TRENDLINES; i++) {
>>>>>   options.trendlines[i] = {
>>>>>     color: 'black',
>>>>>     lineWidth: 6
>>>>>   }
>>>>> }
>>>>>
>>>>> On Mon, Jul 27, 2015 at 4:10 PM Kostas Poulakidas <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hello Sergey,
>>>>>>
>>>>>> and thanks for the quick response.
>>>>>>
>>>>>> You got right what I am trying to do but the Chart doesn't show any
>>>>>> trendlines.
>>>>>> In your code you don't specify that the loop is referring to the
>>>>>> trendlines. Maybe this is the reason?
>>>>>>
>>>>>>
>>>>>> Τη Δευτέρα, 27 Ιουλίου 2015 - 12:53:53 μ.μ. UTC-7, ο χρήστης Sergey
>>>>>> έγραψε:
>>>>>>
>>>>>>> Hi Kostas,
>>>>>>>
>>>>>>> You can absolutely dynamically add trendlines! However, the chart
>>>>>>> doesn't automatically detect changes in the options or the DataTable
>>>>>>> (JavaScript makes it kind of difficult to monitor object properties), so
>>>>>>> you have to explicitly redraw the chart with the new options. I'm also 
>>>>>>> not
>>>>>>> really sure what you're trying to do with your temp string, since the
>>>>>>> 'trendlines' option expects a JavaScript object, and not a string; so 
>>>>>>> even
>>>>>>> if you were redrawing, what you're doing would not work. Also, options
>>>>>>> doesn't have a length property (since it is not an array), so your 
>>>>>>> entire
>>>>>>> if loops won't work properly.
>>>>>>>
>>>>>>> So a sketch of the fixed code would look something like:
>>>>>>> var options = {
>>>>>>>   width: 100,
>>>>>>>   height: 100
>>>>>>> };
>>>>>>>
>>>>>>> for (var i = 0; i < NUMBER_OF_TRENDLINES; i++) {
>>>>>>>   options[i] = {
>>>>>>>     color: 'black',
>>>>>>>     lineWidth: 6
>>>>>>>   }
>>>>>>> }
>>>>>>>
>>>>>>> chart.draw(data, options);
>>>>>>>
>>>>>>> On Mon, Jul 27, 2015 at 3:47 PM Kostas Poulakidas <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>> Hello, I have a list of the options the user want to represent in  a
>>>>>>>> LineChart. He selects the options and the he draw the Chart.
>>>>>>>> Representing the data is ok.
>>>>>>>>
>>>>>>>> And the result is smh like this https://jsfiddle.net/h7k273yb/
>>>>>>>>
>>>>>>>> My problem is that I can not dynamically  add trendiness .
>>>>>>>>
>>>>>>>> *I tried with a loop.*
>>>>>>>>
>>>>>>>>   var options= {
>>>>>>>>           width:100,
>>>>>>>>           height:100
>>>>>>>> };
>>>>>>>>
>>>>>>>>
>>>>>>>> var temp=" " ;
>>>>>>>>
>>>>>>>> for (i = 0; i < options.length; i++) {
>>>>>>>>   temp+=  i+": { \
>>>>>>>>          color: 'black',\
>>>>>>>>          lineWidth: 6,\
>>>>>>>>     }";
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> options.trendlines=temp;
>>>>>>>>
>>>>>>>>
>>>>>>>> *Also I tried with setOption*
>>>>>>>>
>>>>>>>> chart.setOption('trendlines', temp);
>>>>>>>>
>>>>>>>>
>>>>>>>> None of them worked! Any ideas??
>>>>>>>>
>>>>>>>> --
>>>>>>>> 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.
>>>>>>>>
>>>>>>>

-- 
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.
  • [visualization-api] dynam... Kostas Poulakidas
    • Re: [visualization-a... 'Sergey Grabkovsky' via Google Visualization API
      • Re: [visualizati... Kostas Poulakidas
        • Re: [visuali... 'Sergey Grabkovsky' via Google Visualization API
          • Re: [vis... Kostas Poulakidas
            • Re:... 'Sergey Grabkovsky' via Google Visualization API
              • ... Kostas Poulakidas
                • ... 'Sergey Grabkovsky' via Google Visualization API
                • ... 'Sergey Grabkovsky' via Google Visualization API
                • ... Kostas Poulakidas
                • ... 'Sergey Grabkovsky' via Google Visualization API
                • ... Kostas Poulakidas
                • ... 'Sergey Grabkovsky' via Google Visualization API
                • ... Kostas Poulakidas
                • ... 'Sergey Grabkovsky' via Google Visualization API
                • ... 'Sergey Grabkovsky' via Google Visualization API

Reply via email to