-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploying to asf-site from @ 5230bff 🚀
- Loading branch information
Showing
118 changed files
with
542 additions
and
201 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,11 @@ | |
/* position: sticky should not have overflow parents.*/ | ||
overflow-x: hidden; | ||
}</style><link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/[email protected]/lib/theme-chalk/index.css"><link rel="stylesheet" href="https://echarts.apache.org/examples/css/example-bundle.css?_v_=d6a06b7a78"><script type="text/javascript" src="https://fastly.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script></head><!--[if lte IE 8]><body class="lower-ie"><div id="lowie-main"><img src="https://echarts.apache.org/en/images/forie.png?_v_=20200710_1" alt="ie tip"></div></body><![endif]--> | ||
<!--[if (gt IE 8)|!(IE)]><body></body><![endif]--><noscript><div class="no-script"><strong>We're sorry, but Apache ECharts website doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></div></noscript><div id="apache-banner"><div class="txt"><p>Please visit the official Apache ECharts Website at</p><a id="a2" href="https://echarts.apache.org/en/index.html">https://echarts.apache.org</a></div><a href="https://echarts.apache.org" target="_blank" onclick="logApache()" class="btn btn-main"><div>Visit Official Website</div></a><a href="javascript:;" onclick="closeApacheBanner(true)" class="close-btn">x</a></div><div id="main"><div id="ec-example-main"></div></div><script type="text/javascript" src="https://fastly.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script><script type="text/javascript" src="https://echarts.apache.org/en/js/common.js?_v_=85b684f192"></script><script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script><script src="https://fastly.jsdelivr.net/npm/[email protected]/lib/index.js"></script><script src="https://echarts.apache.org/examples/js/example-bundle.js?_v_=05e6978877"></script><script type="text/javascript">window.EC_WWW_CDN_PAY_ROOT = 'https://echarts.apache.org'; | ||
<!--[if (gt IE 8)|!(IE)]><body></body><![endif]--><noscript><div class="no-script"><strong>We're sorry, but Apache ECharts website doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></div></noscript><div id="apache-banner"><div class="txt"><p>Please visit the official Apache ECharts Website at</p><a id="a2" href="https://echarts.apache.org/en/index.html">https://echarts.apache.org</a></div><a href="https://echarts.apache.org" target="_blank" onclick="logApache()" class="btn btn-main"><div>Visit Official Website</div></a><a href="javascript:;" onclick="closeApacheBanner(true)" class="close-btn">x</a></div><div id="main"><div id="ec-example-main"></div></div><script type="text/javascript" src="https://fastly.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script><script type="text/javascript" src="https://echarts.apache.org/en/js/common.js?_v_=85b684f192"></script><script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script><script src="https://fastly.jsdelivr.net/npm/[email protected]/lib/index.js"></script><script src="https://echarts.apache.org/examples/js/example-bundle.js?_v_=e3c6f6bbb2"></script><script type="text/javascript">window.EC_WWW_CDN_PAY_ROOT = 'https://echarts.apache.org'; | ||
</script><script type="text/javascript">window.globalArgsExtra = { | ||
page: 'view', | ||
locale: 'en' | ||
};</script><script type="text/javascript">window.globalArgsExtra.version = '1703176879402'; | ||
};</script><script type="text/javascript">window.globalArgsExtra.version = '1703229377175'; | ||
window.globalArgsExtra.cdnRoot = EC_WWW_CDN_PAY_ROOT + '/examples'; | ||
echartsExample.init('#ec-example-main', window.globalArgsExtra); | ||
|
||
|
101 changes: 101 additions & 0 deletions
101
examples/examples/js/bar-stack-normalization-and-variation.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
title: Stacked Bar Normalization and Variation | ||
titleCN: 堆叠柱状图的归一化和变化 | ||
category: bar | ||
difficulty: 3 | ||
*/ | ||
// There should not be negative values in rawData | ||
const rawData = [ | ||
[100, 302, 301, 334, 390, 330, 320], | ||
[320, 132, 101, 134, 90, 230, 210], | ||
[220, 182, 191, 234, 290, 330, 310], | ||
[150, 212, 201, 154, 190, 330, 410], | ||
[820, 832, 901, 934, 1290, 1330, 1320] | ||
]; | ||
const totalData = []; | ||
for (let i = 0; i < rawData[0].length; ++i) { | ||
let sum = 0; | ||
for (let j = 0; j < rawData.length; ++j) { | ||
sum += rawData[j][i]; | ||
} | ||
totalData.push(sum); | ||
} | ||
const grid = { | ||
left: 100, | ||
right: 100, | ||
top: 50, | ||
bottom: 50 | ||
}; | ||
const gridWidth = myChart.getWidth() - grid.left - grid.right; | ||
const gridHeight = myChart.getHeight() - grid.top - grid.bottom; | ||
const categoryWidth = gridWidth / rawData[0].length; | ||
const barWidth = categoryWidth * 0.6; | ||
const barPadding = (categoryWidth - barWidth) / 2; | ||
const series = [ | ||
'Direct', | ||
'Mail Ad', | ||
'Affiliate Ad', | ||
'Video Ad', | ||
'Search Engine' | ||
].map((name, sid) => { | ||
return { | ||
name, | ||
type: 'bar', | ||
stack: 'total', | ||
barWidth: '60%', | ||
label: { | ||
show: true, | ||
formatter: (params) => Math.round(params.value * 1000) / 10 + '%' | ||
}, | ||
data: rawData[sid].map((d, did) => | ||
totalData[did] <= 0 ? 0 : d / totalData[did] | ||
) | ||
}; | ||
}); | ||
const color = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de']; | ||
const elements = []; | ||
for (let j = 1, jlen = rawData[0].length; j < jlen; ++j) { | ||
const leftX = grid.left + categoryWidth * j - barPadding; | ||
const rightX = leftX + barPadding * 2; | ||
let leftY = grid.top + gridHeight; | ||
let rightY = leftY; | ||
for (let i = 0, len = series.length; i < len; ++i) { | ||
const points = []; | ||
const leftBarHeight = (rawData[i][j - 1] / totalData[j - 1]) * gridHeight; | ||
points.push([leftX, leftY]); | ||
points.push([leftX, leftY - leftBarHeight]); | ||
const rightBarHeight = (rawData[i][j] / totalData[j]) * gridHeight; | ||
points.push([rightX, rightY - rightBarHeight]); | ||
points.push([rightX, rightY]); | ||
points.push([leftX, leftY]); | ||
leftY -= leftBarHeight; | ||
rightY -= rightBarHeight; | ||
elements.push({ | ||
type: 'polygon', | ||
shape: { | ||
points | ||
}, | ||
style: { | ||
fill: color[i], | ||
opacity: 0.25 | ||
} | ||
}); | ||
} | ||
} | ||
option = { | ||
legend: { | ||
selectedMode: false | ||
}, | ||
grid, | ||
yAxis: { | ||
type: 'value' | ||
}, | ||
xAxis: { | ||
type: 'category', | ||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] | ||
}, | ||
series, | ||
graphic: { | ||
elements | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
title: Stacked Bar Normalization | ||
titleCN: 堆叠柱状图的归一化 | ||
category: bar | ||
difficulty: 3 | ||
*/ | ||
// There should not be negative values in rawData | ||
const rawData = [ | ||
[100, 302, 301, 334, 390, 330, 320], | ||
[320, 132, 101, 134, 90, 230, 210], | ||
[220, 182, 191, 234, 290, 330, 310], | ||
[150, 212, 201, 154, 190, 330, 410], | ||
[820, 832, 901, 934, 1290, 1330, 1320] | ||
]; | ||
const totalData = []; | ||
for (let i = 0; i < rawData[0].length; ++i) { | ||
let sum = 0; | ||
for (let j = 0; j < rawData.length; ++j) { | ||
sum += rawData[j][i]; | ||
} | ||
totalData.push(sum); | ||
} | ||
const grid = { | ||
left: 100, | ||
right: 100, | ||
top: 50, | ||
bottom: 50 | ||
}; | ||
const series = [ | ||
'Direct', | ||
'Mail Ad', | ||
'Affiliate Ad', | ||
'Video Ad', | ||
'Search Engine' | ||
].map((name, sid) => { | ||
return { | ||
name, | ||
type: 'bar', | ||
stack: 'total', | ||
barWidth: '60%', | ||
label: { | ||
show: true, | ||
formatter: (params) => Math.round(params.value * 1000) / 10 + '%' | ||
}, | ||
data: rawData[sid].map((d, did) => | ||
totalData[did] <= 0 ? 0 : d / totalData[did] | ||
) | ||
}; | ||
}); | ||
option = { | ||
legend: { | ||
selectedMode: false | ||
}, | ||
grid, | ||
yAxis: { | ||
type: 'value' | ||
}, | ||
xAxis: { | ||
type: 'category', | ||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] | ||
}, | ||
series | ||
}; |
109 changes: 109 additions & 0 deletions
109
examples/examples/ts/bar-stack-normalization-and-variation.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
title: Stacked Bar Normalization and Variation | ||
titleCN: 堆叠柱状图的归一化和变化 | ||
category: bar | ||
difficulty: 3 | ||
*/ | ||
// There should not be negative values in rawData | ||
const rawData = [ | ||
[100, 302, 301, 334, 390, 330, 320], | ||
[320, 132, 101, 134, 90, 230, 210], | ||
[220, 182, 191, 234, 290, 330, 310], | ||
[150, 212, 201, 154, 190, 330, 410], | ||
[820, 832, 901, 934, 1290, 1330, 1320] | ||
]; | ||
const totalData: number[] = []; | ||
for (let i = 0; i < rawData[0].length; ++i) { | ||
let sum = 0; | ||
for (let j = 0; j < rawData.length; ++j) { | ||
sum += rawData[j][i]; | ||
} | ||
totalData.push(sum); | ||
} | ||
|
||
const grid = { | ||
left: 100, | ||
right: 100, | ||
top: 50, | ||
bottom: 50 | ||
}; | ||
const gridWidth = myChart.getWidth() - grid.left - grid.right; | ||
const gridHeight = myChart.getHeight() - grid.top - grid.bottom; | ||
const categoryWidth = gridWidth / rawData[0].length; | ||
const barWidth = categoryWidth * 0.6; | ||
const barPadding = (categoryWidth - barWidth) / 2; | ||
|
||
const series = [ | ||
'Direct', | ||
'Mail Ad', | ||
'Affiliate Ad', | ||
'Video Ad', | ||
'Search Engine' | ||
].map((name, sid) => { | ||
return { | ||
name, | ||
type: 'bar', | ||
stack: 'total', | ||
barWidth: '60%', | ||
label: { | ||
show: true, | ||
formatter: (params) => Math.round(params.value * 1000) / 10 + '%' | ||
}, | ||
data: rawData[sid].map((d, did) => | ||
totalData[did] <= 0 ? 0 : d / totalData[did] | ||
) | ||
}; | ||
}); | ||
|
||
const color = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de']; | ||
const elements = []; | ||
for (let j = 1, jlen = rawData[0].length; j < jlen; ++j) { | ||
const leftX = grid.left + categoryWidth * j - barPadding; | ||
const rightX = leftX + barPadding * 2; | ||
let leftY = grid.top + gridHeight; | ||
let rightY = leftY; | ||
for (let i = 0, len = series.length; i < len; ++i) { | ||
const points = []; | ||
const leftBarHeight = (rawData[i][j - 1] / totalData[j - 1]) * gridHeight; | ||
points.push([leftX, leftY]); | ||
points.push([leftX, leftY - leftBarHeight]); | ||
const rightBarHeight = (rawData[i][j] / totalData[j]) * gridHeight; | ||
points.push([rightX, rightY - rightBarHeight]); | ||
points.push([rightX, rightY]); | ||
points.push([leftX, leftY]); | ||
|
||
leftY -= leftBarHeight; | ||
rightY -= rightBarHeight; | ||
|
||
elements.push({ | ||
type: 'polygon', | ||
shape: { | ||
points | ||
}, | ||
style: { | ||
fill: color[i], | ||
opacity: 0.25 | ||
} | ||
}); | ||
} | ||
} | ||
|
||
option = { | ||
legend: { | ||
selectedMode: false | ||
}, | ||
grid, | ||
yAxis: { | ||
type: 'value' | ||
}, | ||
xAxis: { | ||
type: 'category', | ||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] | ||
}, | ||
series, | ||
graphic: { | ||
elements | ||
} | ||
}; | ||
|
||
export {}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
title: Stacked Bar Normalization | ||
titleCN: 堆叠柱状图的归一化 | ||
category: bar | ||
difficulty: 3 | ||
*/ | ||
// There should not be negative values in rawData | ||
const rawData = [ | ||
[100, 302, 301, 334, 390, 330, 320], | ||
[320, 132, 101, 134, 90, 230, 210], | ||
[220, 182, 191, 234, 290, 330, 310], | ||
[150, 212, 201, 154, 190, 330, 410], | ||
[820, 832, 901, 934, 1290, 1330, 1320] | ||
]; | ||
const totalData: number[] = []; | ||
for (let i = 0; i < rawData[0].length; ++i) { | ||
let sum = 0; | ||
for (let j = 0; j < rawData.length; ++j) { | ||
sum += rawData[j][i]; | ||
} | ||
totalData.push(sum); | ||
} | ||
|
||
const grid = { | ||
left: 100, | ||
right: 100, | ||
top: 50, | ||
bottom: 50 | ||
}; | ||
|
||
const series = [ | ||
'Direct', | ||
'Mail Ad', | ||
'Affiliate Ad', | ||
'Video Ad', | ||
'Search Engine' | ||
].map((name, sid) => { | ||
return { | ||
name, | ||
type: 'bar', | ||
stack: 'total', | ||
barWidth: '60%', | ||
label: { | ||
show: true, | ||
formatter: (params) => Math.round(params.value * 1000) / 10 + '%' | ||
}, | ||
data: rawData[sid].map((d, did) => | ||
totalData[did] <= 0 ? 0 : d / totalData[did] | ||
) | ||
}; | ||
}); | ||
|
||
option = { | ||
legend: { | ||
selectedMode: false | ||
}, | ||
grid, | ||
yAxis: { | ||
type: 'value' | ||
}, | ||
xAxis: { | ||
type: 'category', | ||
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] | ||
}, | ||
series | ||
}; | ||
|
||
export {}; |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.