Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get options with text to work #27

Open
wgtthompson opened this issue Aug 25, 2018 · 1 comment
Open

Can't get options with text to work #27

wgtthompson opened this issue Aug 25, 2018 · 1 comment

Comments

@wgtthompson
Copy link

wgtthompson commented Aug 25, 2018

I have created a new project using ng new my-project. I followed the directions so that the following template (app.component.html) shows a chart with data and responds appropriately to the options shown.

<ng-dygraphs 
   [data]=[[1,2],[2,3],[3,0],[4,1]]
   [options]={width:-1,stepPlot:true}>
</ng-dygraphs>

If I try to use any option that has a type of string then the Digraph chart will not display. For example, if I modify the template as shown below then the chart will not render. (see [options]={width:'auto',...)

<ng-dygraphs 
   [data]=[[1,2],[2,3],[3,0],[4,1]]
   [options]={width:'auto',stepPlot:true}>
</ng-dygraphs>

In addition, putting any spaces in the original template field options will generate an error in the JS console. I do not know if this is my error in syntax but the README.md file contains the following comments which will introduce this error:

<!-- data property needs to be  defined in your controller and in native array format http://dygraphs.com/data.html#array
  
  data = [[new Date("2008/05/07"), 75],
          [new Date("2008/05/08"), 70],
          [new Date("2008/05/09"), 80]
         ];
  
  options = {width: 'auto', labels: ['Date','Temperature'], xlabel: 'X label text', ylabel: 'Y label text', title: 'Working title :)', animatedZooms: true, pointSize: 4}
-->
@pierre-fromager
Copy link

Hi, the way you should go is to declare a public var in your app ts component (ex:dydatas and dyoptions) and provide it to the template as below.
<ng-dygraphs [data]="dydatas" [options]="dyoptions">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants