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

Using Angular and chart.renderTo #3472

Open
reckoner opened this issue Jun 28, 2018 · 2 comments
Open

Using Angular and chart.renderTo #3472

reckoner opened this issue Jun 28, 2018 · 2 comments

Comments

@reckoner
Copy link

I am trying to use plottable with angular but I don't know what to put in the
chart.renderTo or how to set up the HTML app component.

Any hints appreciated!

import { Component } from '@angular/core';
import { Plots, Scales, Axes, Dataset, Components } from 'plottable';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';
  name = 'foo';
  chart: HTMLElement;

  onChangeFirst() {
    this.name = 'goo';
    const xScale = new Scales.Linear();
    const yScale = new Scales.Linear();
    const xAxis = new Axes.Numeric(xScale, 'bottom');
    const yAxis = new Axes.Numeric(yScale, 'left');
    const plot = new Plots.Line();
    plot.x(function(d) { return d.x; }, xScale);
    plot.y(function(d) { return d.y; }, yScale);

    const data = [
      { "x": 0, "y": 1 },
      { "x": 1, "y": 2 },
      { "x": 2, "y": 4 },
      { "x": 3, "y": 8 }
    ];

    const dataset = new Dataset(data);
    plot.addDataset(dataset);
    const chart = new Components.Table([
      [yAxis, plot],
      [null, xAxis]
    ]);
    // chart.renderTo(this.chart);
    chart.renderTo("svg#tutorial-result");       
  }

}
@Steven4294
Copy link

bumparoosky

@antoinebis
Copy link

News on this!?

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

3 participants