使用echarts的looker自定义可视化



Am正在创建自定义可视化,并使用echarts进行可视化。

我有一个来源和一切,但我无法使它发挥作用。有人能在这方面帮助如何在looker自定义可视化中实现以下功能吗

import * as echarts from 'echarts';
var ROOT_PATH = 'https://echarts.apache.org/examples';
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;
myChart.showLoading();
$.getJSON(ROOT_PATH + '/data/asset/data/les-miserables.json', function (graph) {
myChart.hideLoading();
graph.nodes.forEach(function (node) {
node.label = {
show: node.symbolSize > 30
};
});
option = {
title: {
text: 'Les Miserables',
subtext: 'Default layout',
top: 'bottom',
left: 'right'
},
tooltip: {},
legend: [{
// selectedMode: 'single',
data: graph.categories.map(function (a) {
return a.name;
})
}],
animationDuration: 1500,
animationEasingUpdate: 'quinticInOut',
series: [
{
name: 'Les Miserables',
type: 'graph',
layout: 'none',
data: graph.nodes,
links: graph.links,
categories: graph.categories,
roam: true,
label: {
position: 'right',
formatter: '{b}'
},
lineStyle: {
color: 'source',
curveness: 0.3
},
emphasis: {
focus: 'adjacency',
lineStyle: {
width: 10
}
}
}
]
};
myChart.setOption(option);
});
option && myChart.setOption(option);

演示url

在上面的片段中,他们正在传递json,但在我的需求中,我需要从选定的维度或度量中提取,并且我需要转换为looker自定义viz-

looker.plugins.visualizations.add({

});

请告诉我关于这个的任何建议

在传递给looker.plugins.visualizations.add的对象中,updateAsync方法(将用于生成echart选项和系列(是异步的,它会传递一个done回调,以便在准备好时调用。

因此,您可以调用json,处理数据,然后done()

最新更新