简体   繁体   English

图表以显示具有相同ID和日期的两行

[英]chart to display two rows of same ID and dates

I was trying to achieve below two scenarios: 1) In the chart when ID and dates are same but description is different, in such scenarios i want to show them in separate lines. 我试图实现以下两种情况:1)在ID和日期相同但描述不同的图表中,在这种情况下,我想将它们分开显示。
2) When there is no enough space to display the row label i want to display in other row.In my demo for the description "may text second data here" we can see the timeline but the label is not shown because there is no sufficient place to show the label. 2)当没有足够的空间来显示我要在其他行中显示的行标签时。在我的演示示例中,“可以在此处文本第二个数据”的描述中,我们可以看到时间线,但是由于没有足够的标签,因此未显示该标签显示标签的地方。

Reference : Google Timeline chart to display 2 rows of same names 参考: Google时间线图表可显示两行相同名称

I tried following from above link but could not succeed. 我尝试从上面的链接进行跟踪,但无法成功。 I cannot use groupByRowLabel: false as i want to show multiple timelines on the same row. 我无法使用groupByRowLabel: false因为我想在同一行上显示多个时间轴。

js code: js代码:

    $scope.display = function() {
     Array.prototype.forEach.call(container.getElementsByTagName('text'), function (label) {
    if (label.textContent.indexOf('|') > -1) {
    label.textContent = label.textContent.split('|')[1];
     alert(label.textContent);
  }
});
   }       
    $scope.myChart = chart1;

});

in scenario... 在情况下...
1) there simply isn't enough room to show two labels for the exact same date on the same row, 1)根本没有足够的空间在同一行上显示完全相同日期的两个标签,
one will always overwrite the other 一个总是会覆盖另一个

2) only way to know if a label doesn't display due to size, 2)唯一的方法来知道标签是否由于尺寸而无法显示,
is to inspect the chart elements on the chart's 'ready' event 检查图表的'ready'事件上的图表元素
for each row label, there should be a <text> element in the chart 对于每个行标签,图表中应该有一个<text>元素
if not, that row label is missing, 如果不是,则缺少该行标签,
at which point you would change the data and draw again 此时您将更改数据并再次绘制

something like this... 像这样的东西

var changesMade = false;
chart1.data.rows.forEach(function (row, index) {
  var labelFound = false;
  Array.prototype.forEach.call(container.getElementsByTagName('text'), function (label) {
    if (row.c[1].v === label.textContent) {
      labelFound = true;
    }
  });
  if (!labelFound) {
    row.c[0].v = row.c[0].v + ' ' + index;  // change row label to make it appear
    changesMade = true;
  }
});
if (changesMade) {
  // draw chart with changed data
}

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

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