Skip to content

Instantly share code, notes, and snippets.

@yuchuan1
Created July 6, 2022 11:22
Show Gist options
  • Save yuchuan1/24d9ec337378f73ac64c179d2b9c04e9 to your computer and use it in GitHub Desktop.
Save yuchuan1/24d9ec337378f73ac64c179d2b9c04e9 to your computer and use it in GitHub Desktop.
Echart legend using dataset
option = {
dataset: [
{
source: [
['Test1', 10],
['Test2', 20]
],
dimensions: ['Category', 'Value']
},
{
source: [
['Test1', 15],
['Test2', 25]
],
dimensions: ['Category', 'Value2']
}
],
legend: {}, //need this to show legend
xAxis: [{ type: 'category' }, { type: 'category' }],
yAxis: [{ position: 'left' }, { position: 'right' }],
series: [
{
name: 'legend1', //give a name to series
type: 'line',
encode: {
x: 'Category',
y: 'Value'
},
datasetIndex: 0,
yAxisIndex: 0
},
{
type: 'line',
name: 'legend2',
encode: {
x: 'Category',
y: 'Value2'
},
datasetIndex: 1,
yAxisIndex: 1
}
],
color: ['#c22e34', '#e7b603', '#0097da', '#2b821e', '#035daa', '#339ca8']
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment