Skip to content

Instantly share code, notes, and snippets.

@viniciusmelocodes
Created September 19, 2018 20:24
Show Gist options
  • Select an option

  • Save viniciusmelocodes/3a7ec5872592ff31a04506da7022da62 to your computer and use it in GitHub Desktop.

Select an option

Save viniciusmelocodes/3a7ec5872592ff31a04506da7022da62 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src='http://code.jquery.com/jquery-2.1.4.min.js'></script>
<script src="https://cdn.zingchart.com/zingchart.min.js"></script>
<style>
html,
body,
#myChart {
width: 100%;
height: 100%;
}
.zc-ref {
display: none;
}
</style>
</head>
<body>
<div class="container">
<form>
Number:
<select id="mySelect">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</form>
<form>
Number:
<select id="mySelect1">
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</form>
<button id="updateBar">Update</button>
</div>
<div id='myChart'></div>
<script>
// updateBar
document.getElementById('updateBar').addEventListener('click', function() {
//
var x = 2;
var y = 6;
var z = x + y / 3.254;
zingchart.THEME = "classic";
var bgColors = ["#1976d2", "#424242", "#388e3c"]; // ie, chrome, ff
var myConfig = {
"globals": {
"font-family": "Helvetica"
},
"type": "bar",
"background-color": "white",
"title": {
"color": "#606060",
"background-color": "white",
"text": "Barras"
},
"scale-y": {
"line-color": "none",
"tick": {
"line-color": "none"
},
"guide": {
"line-style": "solid"
},
"item": {
"color": "#606060"
}
},
"scale-x": {
"values": [
"Internet Explorer",
"Chrome",
"Firefox"
],
"line-color": "#C0D0E0",
"line-width": 1,
"tick": {
"line-width": 1,
"line-color": "#C0D0E0"
},
"guide": {
"visible": false
},
"item": {
"color": "#606060"
}
},
"crosshair-x": {
"marker": {
"visible": false
},
"line-color": "none",
"line-width": "0px",
"scale-label": {
"visible": false
},
"plot-label": {
"text": "%data-browser: %v",
"multiple": true,
"font-size": "12px",
"color": "#606060",
"background-color": "white",
"border-width": 3,
"alpha": 0.9,
"callout": true,
"callout-position": "bottom",
"shadow": 0,
"placement": "node-top",
"border-radius": 4,
"offsetY": -20,
"padding": 8,
"rules": [{
"rule": "%i==0",
"border-color": "#1976d2"
}, {
"rule": "%i==1",
"border-color": "#424242"
}, {
"rule": "%i==2",
"border-color": "#388e3c"
}, {
"rule": "%i==3",
"border-color": "#ffa000"
}, {
"rule": "%i==4",
"border-color": "#7b1fa2"
}, {
"rule": "%i==5",
"border-color": "#c2185b"
}]
}
},
"plot": {
"data-browser": [
"<span style='font-weight:bold;color:#1976d2;'>Internet Explorer</span>",
"<span style='font-weight:bold;color:#424242;'>Chrome</span>",
"<span style='font-weight:bold;color:#388e3c;'>Firefox</span>"
],
"value-box": {
"text": "%v",
"text-decoration": "underline",
"color": "#606060"
},
"tooltip": {
"visible": false
},
"animation": {
"effect": "7"
},
"rules": [{
"rule": "%i==0",
"background-color": "#1976d2"
}, {
"rule": "%i==1",
"background-color": "#424242"
}, {
"rule": "%i==2",
"background-color": "#388e3c"
}, {
"rule": "%i==3",
"background-color": "#ffa000"
}, {
"rule": "%i==4",
"background-color": "#7b1fa2"
}, {
"rule": "%i==5",
"background-color": "#c2185b"
}]
},
"series": [{
"values": [
x,
y,
z
]
}]
};
zingchart.render({
id: 'myChart',
data: myConfig,
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment