Карусель Чартов с Чартистским Javascript - PullRequest
0 голосов
/ 12 марта 2019

Я не могу найти ни одного примера графиков диаграмм в карусели, которые бы были идеально интерактивными.

Скажите три слайда.1-й слайд: круговая диаграмма с одной стороны и гистограмма с другой стороны.2nd и 3rd одинаковы, но с разными, случайно сгенерированными данными.

Кто-нибудь знает, как это сделать?Даже простая версия?Я был бы чрезвычайно благодарен.

Я видел пример с CanvasJS, но есть ли один для Chartist?http://jsfiddle.net/canvasjs/fz66o4L0/

HTML

 <div class="item">
      <div id="chartContainer2" class="chart" style="width:100%; height:360px;"></div>
    </div>
    <div class="item">
      <div id="chartContainer3" class="chart" style="width:100%; height:360px;"></div>
    </div>
  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
  </a>
</div>
<!-- Carousel -->

CSS

.carousel-control {
  position: absolute;
  top: 150px;
  left: 15px;
  width: 40px;
  height: 40px;
  //margin-top: -20px;
  font-size: 60px;
  font-weight: 100;
  line-height: 30px;
  background-image: none !important;
  filter: none !important;
  text-align: center;
  -webkit-border-radius: 23px;
     -moz-border-radius: 23px;
          border-radius: 23px;  
}

.glyphicon{
    font-size: 60px;
    color: black;
    text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
}

JS

var chart;
var charts = [];
var width;
var height;

width = $('#carousel-example-generic').width();
height = $('#carousel-example-generic').height();

$('.carousel').carousel({
  interval: false,
});

chart = new CanvasJS.Chart("chartContainer1", {
  title: {
    text: "Column Chart"
  },
  width: width,
  height: height,
  data: [{
    type: "column",
    dataPoints: [{
      x: 10,
      y: 171
    }, {
      x: 20,
      y: 155
    }, {
      x: 30,
      y: 150
    }, {
      x: 40,
      y: 165
    }, {
      x: 50,
      y: 195
    }, {
      x: 60,
      y: 168
    }, {
      x: 70,
      y: 128
    }, {
      x: 80,
      y: 134
    }, {
      x: 90,
      y: 114
    }]
  }]
});
chart.render();
charts.push(chart);

chart = new CanvasJS.Chart("chartContainer2", {
  title: {
    text: "Line Chart"
  },
  width: width,
  height: height,
  data: [{
    type: "line",
    dataPoints: [{
      x: 10,
      y: 71
    }, {
      x: 20,
      y: 55
    }, {
      x: 30,
      y: 50
    }, {
      x: 40,
      y: 65
    }, {
      x: 50,
      y: 95
    }, {
      x: 60,
      y: 68
    }, {
      x: 70,
      y: 28
    }, {
      x: 80,
      y: 34
    }, {
      x: 90,
      y: 14
    }]
  }]
});
chart.render();
charts.push(chart);

chart = new CanvasJS.Chart("chartContainer3", {
  title: {
    text: "Area Chart"
  },
  width: width,
  height: height,
  data: [{
    type: "area",
    dataPoints: [{
      x: 10,
      y: 71
    }, {
      x: 20,
      y: 55
    }, {
      x: 30,
      y: 50
    }, {
      x: 40,
      y: 65
    }, {
      x: 50,
      y: 95
    }, {
      x: 60,
      y: 68
    }, {
      x: 70,
      y: 28
    }, {
      x: 80,
      y: 34
    }, {
      x: 90,
      y: 14
    }]
  }]
});
chart.render();
charts.push(chart);

$(window).resize(function() {
  for (var i = 0; i < charts.length; i++) {
    charts[i].options.width = $('.carousel').width();
    charts[i].options.height = $('.carousel').height();
    charts[i].render();
  }
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...