Last active
October 6, 2021 14:40
-
-
Save rjcorwin/6ab3728643a15058c37a2502d59959e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Plotly } from 'plotly' | |
// Copy plotly-styles.js to your project from this gist: https://gist.github.com/rjsteinert/751901de6aca5804b1024c6737e9dc97 | |
import { plotlyStyles } from './plotly-styles.js' | |
import { LitElement, html } from 'lit-element' | |
class LitElementBarChart extends LitElement { | |
static get styles() { | |
return [ | |
plotlyStyles | |
] | |
} | |
render() { | |
return html` | |
<style> | |
#myDiv { | |
width: 800px; | |
height: 800px; | |
} | |
</style> | |
<div id="myDiv"></div> | |
` | |
} | |
updated() { | |
this.data = [ | |
{ | |
x: ['giraffes', 'orangutans', 'monkeys'], | |
y: [20, 14, 23], | |
type: 'bar' | |
} | |
]; | |
Plotly.newPlot(this.shadowRoot.querySelector('#myDiv'), this.data); | |
} | |
} | |
customElements.define('lit-element-bar-chart', LitElementBarChart); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment