Advertisement
madmicio

apex_test

Feb 10th, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import { LitElement, html } from "https://unpkg.com/lit-element@2.0.1/lit-element.js?module";
  2. import ApexCharts from "https://cdn.jsdelivr.net/npm/apexcharts";
  3.  
  4. class NetatmoChartCard extends LitElement {
  5.  
  6. static get properties() {
  7. return {
  8. hass: {},
  9. config: {},
  10. };
  11. }
  12.  
  13. render() {
  14. return html`
  15. <div id="chart"></div>
  16. `;
  17. }
  18.  
  19. setConfig(config) {
  20. this.config = config;
  21. }
  22.  
  23. firstUpdated() {
  24. this._renderChart();
  25. }
  26.  
  27. _renderChart() {
  28. const options = {
  29. chart: {
  30. type: 'line',
  31. height: 350
  32. },
  33. series: [{
  34. name: 'temperature',
  35. data: [30, 40, 45, 50, 49, 60, 70]
  36. }],
  37. xaxis: {
  38. categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul']
  39. }
  40. };
  41.  
  42. const chart = new ApexCharts(this.shadowRoot.querySelector('#chart'), options);
  43. chart.render();
  44. }
  45.  
  46. }
  47.  
  48. customElements.define('netatmo-chart-card', NetatmoChartCard);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement