Commit 999323fd authored by 晓彤's avatar 晓彤

柱状图

parent 59c99053
...@@ -6,17 +6,17 @@ body { ...@@ -6,17 +6,17 @@ body {
margin: 0px; margin: 0px;
} }
#global-svg { .global-svg {
background-color: #ffffff; background-color: #ffffff;
/* max-width: 1000px; */ /* max-width: 1000px; */
/* border: 1px solid red; */ /* border: 1px solid red; */
} }
#global-svg .path-g-container { .global-svg .path-g-container {
--stroke-length: 0; --stroke-length: 0;
} }
#global-svg .line { .global-svg .line {
stroke-dasharray: var(--stroke-length); stroke-dasharray: var(--stroke-length);
stroke-dashoffset: var(--stroke-length); stroke-dashoffset: var(--stroke-length);
/* animation-delay: .3s; */ /* animation-delay: .3s; */
...@@ -53,18 +53,18 @@ body { ...@@ -53,18 +53,18 @@ body {
} }
} }
#global-svg .line-1 { .global-svg .line-1 {
/* fill: transparent; */ /* fill: transparent; */
} }
#global-svg.animate .line { .global-svg.animate .line {
animation: 3s animate-line linear; animation: 3s animate-line linear;
animation-fill-mode: forwards; animation-fill-mode: forwards;
} }
#global-svg.animate .line-1 { .global-svg.animate .line-1 {
/* animation: 3s animate-line-bg linear; /* animation: 3s animate-line-bg linear;
animation-fill-mode: forwards; */ animation-fill-mode: forwards; */
} }
...@@ -93,12 +93,12 @@ body { ...@@ -93,12 +93,12 @@ body {
} }
/* 圆点动画 */ /* 圆点动画 */
#global-svg .point { .global-svg .point {
opacity: 0; opacity: 0;
position: relative; position: relative;
} }
#global-svg .point::after { .global-svg .point::after {
content: ''; content: '';
position: absolute; position: absolute;
width: 18px; width: 18px;
...@@ -106,18 +106,18 @@ body { ...@@ -106,18 +106,18 @@ body {
/* background-color: red; */ /* background-color: red; */
} }
#global-svg.animate .point { .global-svg.animate .point {
animation: .5s fade-in ease-in-out, .5s zoom-in ease-in-out; animation: .5s fade-in ease-in-out, .5s zoom-in ease-in-out;
animation-fill-mode: forwards; animation-fill-mode: forwards;
animation-delay: var(--delay); animation-delay: var(--delay);
} }
/* 数值动画 */ /* 数值动画 */
#global-svg .value-text { .global-svg .value-text {
opacity: 0; opacity: 0;
} }
#global-svg.animate .value-text { .global-svg.animate .value-text {
animation: .5s fade-in ease-in-out; animation: .5s fade-in ease-in-out;
animation-fill-mode: forwards; animation-fill-mode: forwards;
animation-delay: var(--delay); animation-delay: var(--delay);
...@@ -130,10 +130,10 @@ body { ...@@ -130,10 +130,10 @@ body {
transition: .25s opacity ease-in-outl transition: .25s opacity ease-in-outl
} }
#global-svg.animate .loading { .global-svg.animate .loading {
opacity: 0; opacity: 0;
} }
#global-svg .hover-circle, .hover-line { .global-svg .hover-circle, .hover-line {
opacity: 0; opacity: 0;
} }
This diff is collapsed.
...@@ -96,6 +96,15 @@ ...@@ -96,6 +96,15 @@
circlestroke: '#87CEFA', circlestroke: '#87CEFA',
linestroke: '#f6f6f6' linestroke: '#f6f6f6'
} }
},
{
type: 'bar', // bar: 柱状图
data: [0.75,0.1,0.7,1,0.26,0.3,0.9],
normalStyle: { // 柱状图常规样式
backgroundColor: '#953C96', // 柱状图颜色
width: 14, // 柱状宽度
borderRadius: 3 // 柱状圆角
},
} }
] ]
} }
......
...@@ -2,13 +2,18 @@ ...@@ -2,13 +2,18 @@
<html lang="en" dir="ltr"> <html lang="en" dir="ltr">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>折线demo</title> <title>demo</title>
<link rel="stylesheet" href="./chart/chart.css"> <link rel="stylesheet" href="./chart/chart.css">
</head> </head>
<body> <body>
<!-- 折线图 -->
<div style = 'width:100%;height:400px;'> <div style = 'width:100%;height:400px;'>
<div id = 'tongchart' width = '425' height = '236'></div> <div id = 'tongline' width = '425' height = '236'></div>
<!-- <div id = 'tongchart' width = '425' height = '236' style = 'width:425px;height:236px;'></div> --> </div>
<!-- 柱状图 -->
<div style = 'width:100%;height:400px;margin-top:100px;'>
<div id = 'tongbar' width = '425' height = '236'></div>
</div> </div>
</body> </body>
...@@ -17,7 +22,7 @@ ...@@ -17,7 +22,7 @@
let _width = document.body.clientWidth; let _width = document.body.clientWidth;
console.log(_width, '----'); console.log(_width, '----');
// document.querySelector('#tongchart').setAttribute('width', _width); // document.querySelector('#tongchart').setAttribute('width', _width);
var myChart = chart.init(document.getElementById('tongchart')); var myChart = chart.init(document.getElementById('tongline'));
var option = { var option = {
animateTime: 3, animateTime: 3,
xAxis: { xAxis: {
...@@ -61,20 +66,71 @@ ...@@ -61,20 +66,71 @@
{ {
type: 'line', type: 'line',
smooth: true, // 是否是平滑曲线 smooth: true, // 是否是平滑曲线
data: [0.8,0.1,0.7,1,0.26,0.3,0.9], data: [0.75,0.1,0.7,1,0.26,0.3,0.9],
normalStyle: { normalStyle: {
linestroke: '#2A9BC5', linestroke: '#87CEFA',
circlestroke: '#2A9BC5', circlestroke: '#87CEFA',
pathBgColor: '#2A9BC5' pathBgColor: '#87CEFA',
}, },
hoverStyle: { hoverStyle: {
circlestroke: '#87CEFA', circlestroke: '#87CEFA',
linestroke: '#f6f6f6' linestroke: '#f6f6f6'
} }
} },
] ]
} }
// 使用刚指定的配置项和数据显示图表。 // 使用刚指定的配置项和数据显示图表。
myChart.setOption(option); myChart.setOption(option, 'tongline');
// 设置柱状图
var myChartBar = chart.init(document.getElementById('tongbar'));
var optionbar = {
animateTime: 3,
xAxis: {
data: ['Mon','Tue','Wed','Thu','Fri','Sat', 'Sun'],
font: {
fontSize: 12,
color: 'rgba(40,40,40,0.3)',
hoverFontColor: 'rgba(40,40,40,1)'
},
outpadding: 10,
inpadding: 10,
},
yAxis: {
font: {
fontSize: 12,
color: 'rgba(40,40,40,0.3)'
},
yLineColor: '#F6F6F6', // '#F6F6F6',
min: 0,
max: 1,
totalLine: 5,
padding: 15
},
series: [
{
type: 'bar',
data: [0.75,0.1,0.7,1,0.26,0.3,0.9],
normalStyle: {
backgroundColor: '#2A9BC5',
width: 14,
borderRadius: 3
},
},
{
type: 'bar',
data: [0.75,0.1,0.7,1,0.26,0.3,0.9],
normalStyle: {
backgroundColor: '#953C96',
width: 14,
borderRadius: 3
},
}
]
}
myChartBar.setOption(optionbar, 'tongbar');
</script> </script>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment