Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

License

NotificationsYou must be signed in to change notification settings

plotly/angular-plotly.js

 
 

Repository files navigation

angular-plotly-logo

Aplotly.js Angular component fromPlotly.

CircleCICoverage Status


Content

Installation

$ npm install angular-plotly.js plotly.js

Using theangular CLI to start a new project

$ ng new my-project$cd my-project$ npm install angular-plotly.js plotly.js --save

Quick start

Add thePlotlyModule into the main app module of your project

import{NgModule}from'@angular/core';import{CommonModule}from'@angular/common';import{PlotlyModule}from'angular-plotly.js';@NgModule({imports:[CommonModule,PlotlyModule],    ...})exportclassAppModule{}

Then use the<plotly-plot> component to display the graph

import{Component}from'@angular/core';@Component({selector:'plotly-example',template:'<plotly-plot [data]="graph.data" [layout]="graph.layout"></plotly-plot>',})exportclassPlotlyExampleComponent{publicgraph={data:[{x:[1,2,3],y:[2,6,3],type:'scatter',mode:'lines+points',marker:{color:'red'}},{x:[1,2,3],y:[2,5,3],type:'bar'},],layout:{width:320,height:240,title:'A Fancy Plot'}};}

You should see a plot like this:

Example plot

For a full description of Plotly chart types and attributes see the following resources:

API Reference

Basic Props

Warning: for the time being, this component maymutate itslayout anddata props in response to user input, going against React rules. This behaviour will change in the near future onceplotly/plotly.js#2389 is completed.

PropTypeDefaultDescription
[data]Array[]list of trace objects (seehttps://plot.ly/javascript/reference/)
[layout]Objectundefinedlayout object (seehttps://plot.ly/javascript/reference/#layout)
[frames]Arrayundefinedlist of frame objects (seehttps://plot.ly/javascript/reference/)
[config]Objectundefinedconfig object (seehttps://plot.ly/javascript/configuration-options/)
[revision]NumberundefinedWhen provided, causes the plot to updateonly when the revision is incremented.
(initialized)Function(figure, graphDiv)undefinedCallback executed after plot is initialized. See below for parameter information.
(update)Function(figure, graphDiv)undefinedCallback executed when when a plot is updated due to new data or layout, or when user interacts with a plot. See below for parameter information.
(purge)Function(figure, graphDiv)undefinedCallback executed when component unmounts, beforePlotly.purge strips thegraphDiv of all private attributes. See below for parameter information.
(error)Function(err)undefinedCallback executed when a plotly.js API method rejects
[divId]stringundefinedid assigned to the<div> into which the plot is rendered.
[className]stringundefinedapplied to the<div> into which the plot is rendered
[style]Object{position: 'relative', display: 'inline-block'}used to style the<div> into which the plot is rendered
[debug]BooleanfalseAssign the graph div towindow.gd for debugging
[useResizeHandler]BooleanfalseWhen true, adds a call toPlotly.Plot.resize() as awindow.resize event handler

Note: To make a plot responsive, i.e. to fill its containing element and resize when the window is resized, usestyle orclassName to set the dimensions of the element (i.e. usingwidth: 100%; height: 100% or some similar values) and setuseResizeHandler totrue while settinglayout.autosize totrue and leavinglayout.height andlayout.width undefined. This will implement the behaviour documented here:https://plot.ly/javascript/responsive-fluid-layout/

Event handler props

Event handlers for specificplotly.js events may be attached through the following props:

PropTypePlotly Event
(afterExport)Functionplotly_afterexport
(afterPlot)Functionplotly_afterplot
(animated)Functionplotly_animated
(animatingFrame)Functionplotly_animatingframe
(animationInterrupted)Functionplotly_animationinterrupted
(autoSize)Functionplotly_autosize
(beforeExport)Functionplotly_beforeexport
(buttonClicked)Functionplotly_buttonclicked
(click)Functionplotly_click
(clickAnnotation)Functionplotly_clickannotation
(deselect)Functionplotly_deselect
(doubleClick)Functionplotly_doubleclick
(framework)Functionplotly_framework
(hover)Functionplotly_hover
(legendClick)Functionplotly_legendclick
(legendDoubleClick)Functionplotly_legenddoubleclick
(relayout)Functionplotly_relayout
(restyle)Functionplotly_restyle
(redraw)Functionplotly_redraw
(selected)Functionplotly_selected
(selecting)Functionplotly_selecting
(sliderChange)Functionplotly_sliderchange
(sliderEnd)Functionplotly_sliderend
(sliderStart)Functionplotly_sliderstart
(transitioning)Functionplotly_transitioning
(transitionInterrupted)Functionplotly_transitioninterrupted
(unhover)Functionplotly_unhover

Development

To get started:

$ npm install

To see the demo app, run:

$ npm start

To run the tests:

$ npm runtest

License

© 2018 Plotly, Inc. MIT License.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors17


    [8]ページ先頭

    ©2009-2025 Movatter.jp