1
votes

I would like to display indicators(h3/p tags) in my code on charts in BS carousel. Looks like it`s not working, hiding behind charts. How do we make it display?

Below are my problems of which I need solutions to.

  1. Display indicators(h3,p tags).
  2. Animation not working for all the slides, working only for active one.
  3. Remove black color display in the slides and keep white background.

Below is the tag for indicators that I tried.

<ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>

Complete HTML Code:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css" />
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
   <script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'></script>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>google.charts.load('current', { packages: ['corechart'] });</script>
     <script language='JavaScript'>function drawChart(ExecutedCount, NonExecutedCount, DivID) { var data = google.visualization.arrayToDataTable([['Status', 'Outcome', { role: 'style' }], ['Executed', ExecutedCount, '#8BC34A'], ['Not Executed', NonExecutedCount, '#ff4c4c']]); var groupData = google.visualization.data.group(data, [{ column: 0, modifier: function () { return 'total' }, type: 'string' }], [{ column: 1, aggregation: google.visualization.data.sum, type: 'number' }]); var formatPercent = new google.visualization.NumberFormat({ pattern: '#,##0.0%' }); var formatShort = new google.visualization.NumberFormat({ pattern: 'short' }); var view = new google.visualization.DataView(data); view.setColumns([0, 1, 2, { calc: function (dt, row) { var amount = formatShort.formatValue(dt.getValue(row, 1)); var percent = formatPercent.formatValue(dt.getValue(row, 1) / groupData.getValue(0, 1)); return amount + ' (' + percent + ')'; }, type: 'string', role: 'annotation' }]); var options = { 'legend': 'none', tooltip: { trigger: 'none' }, 'width': 650, 'height': 400, animation: { duration: 1500, startup: true } }; var chart = new google.visualization.ColumnChart(document.getElementById(DivID)); chart.draw(view, options); } google.charts.setOnLoadCallback(function () { drawChart(70, 5, 'GChart_0'); }); google.charts.setOnLoadCallback(function () { drawChart(80, 10, 'GChart_1'); }); google.charts.setOnLoadCallback(function () { drawChart(90, 15, 'GChart_2'); });</script>
    <link rel='icon' type='Icon.ico' href='Icon.ico' />
</head>
<body>
<div class="container">
  <h2>Carousel Example</h2>
  <div id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>
    <!-- Wrapper for slides -->
    <div class="carousel-inner">
      <div align="center" class="item active" id='GChart_0' style='width:800; height:500;border-style:groove;border-width: 1px;'>
      <h3 style="background-color: gold;">Los Angeles</h3>
        <script type='text/javascript'>drawChart(70, 5, 'GChart_0');</script>
         <p background-color: gold;>LA is always so much fun!</p>
      </div>
      <div align="center" class="item" id='GChart_1' style='width:800; height:500;border-style:groove;border-width: 1px;'>
      <h3>NY</h3>
        <script type='text/javascript'>drawChart(80, 10, 'GChart_1');</script>
         <p>NY is always so much fun!</p>
      </div>    
      <div align="center" class="item" id='GChart_2' style='width:800; height:500;border-style:groove;border-width: 1px;'>
      <h3>California</h3>
            <script type='text/javascript'>drawChart(90, 15, 'GChart_2');</script>
             <p>California is always so much fun!</p>
      </div>  
    </div>
    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
</div>
</body>
</html>

Indicators should be displayed with position mentioned, animation should work for all the slides and remove/change default slide colors. Kindly check and help.

2

2 Answers

1
votes

Indicators are available in their position. But due to white of indicator it is not showing.

Try to apply the below CSS.

<style>
  .carousel-indicators li {
    background-color: #ccc !important;
  }
  .carousel-indicators .active {
    background-color: #000 !important;
  }
</style>

You can see the working example here - Example

0
votes

Currently its white background on active and white border on indicator so you are not able to see it, So just add below Code

   .carousel-indicators .active {
        background-color: #000000;
    }

    .carousel-indicators li {
        border: 1px solid #020202;
    }