Created
August 8, 2023 08:16
-
-
Save parth-patil/fc49258cd10f34fce538557c30d3e198 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
defmodule LbEcharts do | |
@moduledoc """ | |
Library to use Echarts in LiveBook | |
""" | |
use Kino.JS | |
asset "main.js" do | |
""" | |
export async function init(ctx, chart_data) { | |
await ctx.importJS("https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"); | |
ctx.root.innerHTML = ` | |
<div id="echart_window" style="width: 800px;height:500px;"></div>` | |
var myChart = echarts.init(document.getElementById('echart_window')); | |
// Specify the configuration items and data for the chart | |
var options = JSON.parse(chart_data); | |
// Display the chart using the configuration items and data just specified. | |
myChart.setOption(options); | |
} | |
""" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment