当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript svg.brush方法代码示例

本文整理汇总了TypeScript中d3.svg.brush方法的典型用法代码示例。如果您正苦于以下问题:TypeScript svg.brush方法的具体用法?TypeScript svg.brush怎么用?TypeScript svg.brush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在d3.svg的用法示例。


在下文中一共展示了svg.brush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getAnnotationBrush

export function getAnnotationBrush(this: TimeseriesChart) {
  const focusXScale = this.focusXScale;

  const annotateBrush = d3.svg
    .brush()
    .x(focusXScale)
    .on('brushend', brushend.bind(this));

  // cast a reference to this so we get the latest state when brushend() gets called
  function brushend(this: TimeseriesChart) {
    const { selectedJob } = this.props;

    // TS TODO make this work with the actual types.
    const extent = annotateBrush.extent() as any;

    const timestamp = extent[0].getTime();
    const endTimestamp = extent[1].getTime();

    if (timestamp === endTimestamp) {
      this.closeFlyout();
      return;
    }

    const annotation: Annotation = {
      timestamp,
      end_timestamp: endTimestamp,
      annotation: this.state.annotation.annotation || '',
      job_id: selectedJob.job_id,
      type: ANNOTATION_TYPE.ANNOTATION,
    };

    this.showFlyout(annotation);
  }

  return annotateBrush;
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:36,代码来源:timeseries_chart_annotations.ts


注:本文中的d3.svg.brush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。