mirror of
https://github.com/bendtherules/opencharts.git
synced 2026-08-18 13:52:49 +00:00
CssCharts aka OpenCharts
Horizontal and vertical bar charts done
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
* {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.chart {
|
||||
width: 50vw;
|
||||
height: 50vh;
|
||||
margin: 25vh 25vw;
|
||||
background-color: #90ee90;
|
||||
position: relative;
|
||||
}
|
||||
.chart-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.axis {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
z-index: 4;
|
||||
}
|
||||
.axis .axis-x,
|
||||
.axis .axis-y {
|
||||
position: absolute;
|
||||
background-color: #d3d3d3;
|
||||
}
|
||||
.axis .axis-y {
|
||||
width: 1em;
|
||||
height: 100%;
|
||||
}
|
||||
.axis .axis-y .axis-line {
|
||||
left: 50%;
|
||||
}
|
||||
.axis .axis-y .axis-line .axis-line-container {
|
||||
margin: 0 -0.125em;
|
||||
height: 100%;
|
||||
width: 0.25em;
|
||||
}
|
||||
.axis .axis-x {
|
||||
height: 1em;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
}
|
||||
.axis .axis-x .axis-line {
|
||||
top: 50%;
|
||||
}
|
||||
.axis .axis-x .axis-line .axis-line-container {
|
||||
margin: -0.125em 0;
|
||||
height: 0.25em;
|
||||
width: 100%;
|
||||
}
|
||||
.axis-line {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
z-index: 5;
|
||||
}
|
||||
.axis-line-container {
|
||||
background-color: #000;
|
||||
}
|
||||
.scene {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
background-color: #008000;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-left: 1em;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
.scene .scene-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #add8e6;
|
||||
}
|
||||
.bar {
|
||||
width: 12.5%;
|
||||
height: 100%;
|
||||
margin: 0 6.25%;
|
||||
float: left;
|
||||
position: relative;
|
||||
}
|
||||
.bar .bar-inner {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
background-color: #ff0;
|
||||
}
|
||||
.part-1 .bar-inner {
|
||||
height: 40%;
|
||||
}
|
||||
.part-2 .bar-inner {
|
||||
height: 65%;
|
||||
}
|
||||
.part-3 .bar-inner {
|
||||
height: 90%;
|
||||
}
|
||||
.part-4 .bar-inner {
|
||||
height: 75%;
|
||||
}
|
||||
.clearfix {
|
||||
clear: both;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Vertical Bar Chart</title>
|
||||
<link rel="stylesheet" href="bar_ver.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="chart">
|
||||
<div class="chart-container">
|
||||
<div class="axis">
|
||||
<div class="axis-y">
|
||||
<div class="axis-line">
|
||||
<div class="axis-line-container"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="axis-x">
|
||||
<div class="axis-line">
|
||||
<div class="axis-line-container"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="scene">
|
||||
<div class="scene-container">
|
||||
<div class="bar part-1" data-val="50%">
|
||||
<div class="bar-inner"></div>
|
||||
</div>
|
||||
<div class="bar part-2" data-val="62%">
|
||||
<div class="bar-inner"></div>
|
||||
</div>
|
||||
<div class=" bar part-3" data-val="40%">
|
||||
<div class="bar-inner"></div>
|
||||
</div>
|
||||
<div class=" bar part-4" data-val="20%">
|
||||
<div class="bar-inner"></div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,117 @@
|
||||
full=100%
|
||||
half=50%
|
||||
*
|
||||
-webkit-box-sizing border-box
|
||||
-moz-box-sizing border-box
|
||||
box-sizing border-box
|
||||
|
||||
.chart
|
||||
width 50vw
|
||||
height 50vh
|
||||
margin 25vh 25vw
|
||||
background-color lightgreen
|
||||
position relative
|
||||
|
||||
.chart-container
|
||||
width full
|
||||
height full
|
||||
|
||||
axis-thick=1em
|
||||
axis-line-thick=.25em
|
||||
.axis
|
||||
width full
|
||||
height full
|
||||
position absolute
|
||||
z-index 4
|
||||
|
||||
.axis-x
|
||||
.axis-y
|
||||
position absolute
|
||||
background-color lightgray
|
||||
|
||||
.axis-y
|
||||
width axis-thick
|
||||
height full
|
||||
|
||||
.axis-line
|
||||
left half
|
||||
|
||||
.axis-line-container
|
||||
margin 0 -0.5*axis-line-thick
|
||||
height full
|
||||
width axis-line-thick
|
||||
|
||||
|
||||
.axis-x
|
||||
height axis-thick
|
||||
width full
|
||||
bottom 0
|
||||
|
||||
.axis-line
|
||||
top 50%
|
||||
|
||||
.axis-line-container
|
||||
margin -0.5*axis-line-thick 0
|
||||
height axis-line-thick
|
||||
width full
|
||||
|
||||
.axis-line
|
||||
width full
|
||||
height full
|
||||
position absolute
|
||||
z-index 5
|
||||
.axis-line-container
|
||||
background-color black
|
||||
|
||||
.scene
|
||||
position absolute
|
||||
z-index 1
|
||||
background-color green
|
||||
width full
|
||||
height full
|
||||
padding-left axis-thick
|
||||
padding-bottom axis-thick
|
||||
|
||||
.scene-container
|
||||
width full
|
||||
height full
|
||||
background-color lightblue
|
||||
|
||||
count_bar=4
|
||||
p_empty=50%
|
||||
p_bar_m=p_empty/count_bar
|
||||
p_bar_w=(full - p_empty)/count_bar
|
||||
// p_bar=p_bar/count_bar
|
||||
.bar
|
||||
width p_bar_w
|
||||
height full
|
||||
margin 0 (p_bar_m/2)
|
||||
// background-color lightgreen
|
||||
float left
|
||||
position relative
|
||||
|
||||
.bar-inner
|
||||
position absolute
|
||||
bottom 0
|
||||
width full
|
||||
background-color yellow
|
||||
|
||||
//automate this part
|
||||
.part-1
|
||||
.bar-inner
|
||||
height 40%
|
||||
|
||||
.part-2
|
||||
.bar-inner
|
||||
height 65%
|
||||
|
||||
.part-3
|
||||
.bar-inner
|
||||
height 90%
|
||||
|
||||
.part-4
|
||||
.bar-inner
|
||||
height 75%
|
||||
|
||||
.clearfix
|
||||
clear both
|
||||
Reference in New Issue
Block a user