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] 
> <javascript:>> 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] 
>> <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> 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

Reply via email to