简体   繁体   English

Timeticker CSS在Visjs时间轴中不起作用

[英]Timeticker css not working in visjs timeline

I am using background areas example . 我正在使用背景区域示例 I have couple of problems 我有几个问题

  1. In doc under addCustomTime method description it is mentioned that id is added as classname but any changes to this class is not taking effect. doc的 addCustomTime方法描述下,提到将id作为类名添加,但是对该类的任何更改均未生效。
  2. How to center align content text in a background area with background area having a border? 如何将背景区域中的content文本与具有边框的背景区域居中对齐?
  3. Also how can I change css for setCurrentTime(time) marker? 另外,如何更改setCurrentTime(time)标记的CSS?

My css 我的CSS

.vis-current-time {
  color: black !important;
  border: 2px;
  cursor: hand;
}

.milestone-1 {
  color: green !important;
  border: 2px;
  cursor: hand;
}

.vis-item.vis-background.positive {
  background-color: rgba(0, 0, 200, 0.2);
  cursor: hand;
}

.vis-item.vis-background.negative {
  background-color: rgba(255, 0, 0, 0.2);
  cursor: hand;
}

.vis-item-overflow.vis-item-content {
  left: auto !important;
  text-align: center !important;
  color: #ff0000 !important;
}

Here is plunker link of my problem. 这是我的问题的庞克链接

Update 更新资料

I am able to center align content text to center. 我能够将content文本居中对齐。 I have also updated my plunker but borders are not taking effect 我也更新了插件,但边框没有生效

#visualization .vis-item.vis-background.positive .vis-item-content {
  width: 100%;
  text-align: center !important;
  border: 2px;
}
#visualization .vis-item.vis-background.negative .vis-item-content {
  width: 100%;
  text-align: center !important;
}

Here is the solution for you. 这是您的解决方案。

1) but any changes to this class is not taking effect: 1), 但对此类的任何更改均不会生效:

You have used the wrong values for that class, so that its not reflected. 您为该类使用了错误的值,因此它不会被反映出来。 To change the color you need to use the "background-color" and so on.. see the below CSS code. 要更改颜色,您需要使用“ background-color”等。.参见下面的CSS代码。

.milestone-1 {
  background-color: green;
  width: 5px;
  /* border: 2px solid red; */
}

2) How to center align content text 2)如何居中对齐内容文本

To center align the text apply the CSS for the ".vis-item-overflow" class. 为了使文本居中对齐,请将CSS应用于“ .vis-item-overflow”类。 No need to add any additional styles. 无需添加任何其他样式。

.vis-item-overflow {
  text-align: center;
}

3) Also how can I change css for setCurrentTime(time) marker 3)也如何更改setCurrentTime(time)标记的CSS

To apply the styles for current time marker you can use the ".vis-current-time" class like below: 要为当前时间标记应用样式,您可以使用“ .vis-current-time”类,如下所示:

.vis-current-time{
  background-color: black;
  width: 3px;
}

Here is the updated Demo : http://plnkr.co/edit/JVzCoYgltiy6DTL5SOAL?p=preview 这是更新的演示http : //plnkr.co/edit/JVzCoYgltiy6DTL5SOAL?p=preview

Hope this might helps you... 希望这可以帮助您...

To apply the tooltip for the whole box you need to add the below CSS style: 要将工具提示应用于整个框,您需要添加以下CSS样式:

.vis-background .vis-item-content {
    z-index: 11111;
    height: 100%;
    width: 100%;
}

Check the Demo: http://plnkr.co/edit/JVzCoYgltiy6DTL5SOAL?p=preview 检查演示: http : //plnkr.co/edit/JVzCoYgltiy6DTL5SOAL?p=preview

Answer for the previous comment: 回答之前的评论:

As per vis, we can't update the tooltip dynamically. 根据可见,我们无法动态更新工具提示。 They initially updated the title at once based on the user input, so we can't update dynamically. 他们最初会根据用户输入立即更新标题,因此我们无法动态更新。

As a workaround we can dynamically update the tooltip from the element. 解决方法是,我们可以从元素动态更新工具提示。 As per the previous update we already used the tooltipster plugin for tooltip. 根据先前的更新,我们已经使用了tooltipster插件作为tooltip。 By using this plugin's open event we can update the title dynamically. 通过使用此插件的open事件,我们可以动态更新标题。

 $('.tooltip .vis-item-content').tooltipster({
    functionBefore: function(origin, continueTooltip) {
      var currentTitle = origin.data("tooltipsterInitialTitle");
      origin.tooltipster("content", currentTitle + " --- Time :: " + new Date().toLocaleTimeString());
      continueTooltip();
    }
 });

Demo: http://plnkr.co/edit/JVzCoYgltiy6DTL5SOAL?p=preview 演示: http //plnkr.co/edit/JVzCoYgltiy6DTL5SOAL?p = preview

Update: 更新:

As per your comment you need to update the time for each second. 根据您的评论,您需要更新每秒的时间。 So you can update the time on particular interval until the tooltip gets visible. 因此,您可以按特定的时间间隔更新时间,直到显示工具提示为止。

  var timer;
  $('.tooltip .vis-item-content').tooltipster({
    position: 'bottom',
    functionBefore: function(origin, continueTooltip) {
      continueTooltip();
      updateTooltip(origin);
      timer = setInterval(function(){ updateTooltip(origin); }, 1000);
    },
    functionAfter: function() {
      clearInterval(timer);
    }
  });

  function updateTooltip(origin) {
    var newTooltip = getTooltipContent(origin);
    $(origin.tooltipster('elementTooltip')).children(".tooltipster-content").html(newTooltip);
  }
  function getTooltipContent(origin) {
    var currentTitle = origin.data("tooltipsterInitialTitle");
    return currentTitle + " --- Time :: " + new Date().toLocaleTimeString();
  }

Updated Demo: http://plnkr.co/edit/JVzCoYgltiy6DTL5SOAL?p=preview 更新的演示: http : //plnkr.co/edit/JVzCoYgltiy6DTL5SOAL?p=preview

I think this may helps you ... 我认为这可能对您有帮助...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM