I am using c3 to draw some charts. Since c3 doesn't allow me to edit axis labels in the way I want, I am using jQuery to edit it after I load the chart. (FYI, I am trying to show 1-24, again 1-24 in the y axis instead of 1-48 hrs). Anyway I am unable to get this to work. I've put the code inside (document).ready
.
<!-- jQuery -->
<script src="../jquery/dist/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#c3-chart2").hide();
$('input[type="radio"]').click(function() {
if ($(this).attr("value") == "chart1") {
$("#c3-chart2").hide();
$("#c3-chart1").show();
}
if ($(this).attr("value") == "chart2") {
$("#c3-chart1").hide();
$("#c3-chart2").show();
}
});
$("#button").click(function() {
$("#c3-time-chart .c3-axis-y .tick text tspan").text("lol");
});
$("#c3-time-chart .c3-axis-y .tick text tspan").text("lol");
});
<body>
The chart ids are here
</body>
<!-- C3 and D3 Charts-->
<script src="../d3/d3.min.js" charset="utf-8"></script>
<script src="../c3/c3.min.js"></script>
<script src="../graphs/d3-test-data.js"></script>
<script src="../graphs/c3-test-data.js"></script>
I tried to change the labels from google chrome console and it worked. I also added a button that will change the labels when I click on it. Both of them works like a charm. But somehow, I am unable to do this automatically once the page is loaded. All the similar questions had answers like put the code in (document).ready
which I am already doing. Please help me with finding what the problem is.