Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/474.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
第三方应用程序中的Javascript表格单元格突出显示_Javascript_Highlighting_Splunk - Fatal编程技术网

第三方应用程序中的Javascript表格单元格突出显示

第三方应用程序中的Javascript表格单元格突出显示,javascript,highlighting,splunk,Javascript,Highlighting,Splunk,我使用的是Splunk版本7.0.1,我试图根据其他两个字段突出显示表格单元格的颜色。Splunk有一个在Javascript中使用硬编码值的示例,但我需要基于不同字段的值。我让脚本工作,但它随机突出显示了一些错误颜色的单元格。我似乎不明白为什么 平均响应时间应为: 如果该值大于或等于阈值,则为红色 如果该值大于或等于目标值但小于阈值,则为琥珀色 如果值小于目标值,则为绿色 我的桌子: Transaction Count "Average Response Time" Obj

我使用的是Splunk版本7.0.1,我试图根据其他两个字段突出显示表格单元格的颜色。Splunk有一个在Javascript中使用硬编码值的示例,但我需要基于不同字段的值。我让脚本工作,但它随机突出显示了一些错误颜色的单元格。我似乎不明白为什么

平均响应时间应为:

  • 如果该值大于或等于阈值,则为红色
  • 如果该值大于或等于目标值但小于阈值,则为琥珀色
  • 如果值小于目标值,则为绿色
我的桌子:

Transaction    Count   "Average Response Time"    Objective   Threshold
A/P - Close Module - FM1    1   7.52    2.00    6.00  **<-Colored Red and correctly**
...
A/P - Diagnosis- Run Search - FM1   2   4.01    100.00  100.00 **<- Colored Amber incorrectly**
<table id="response_time_highlight">
        <title>NOTE: An Objective and/or Threshold of 100 indicates that an Objective and/or Threshold have not been identified for this particular transaction type.</title>
        <search>
          <query>index=arm sourcetype="arm:transaction" region="$region$" sitename="$sitename$" transaction_status IN ( $transaction_status$ ) username IN ( $username$ ) workstation_name IN ( $workstation_name$ ) transaction_name IN ( $transaction_name$ ) 
| stats count avg(response_time) AS response_time BY transaction_name objective threshold 
| eval threshold=round(threshold,2) 
| eval objective=round(objective,2) 
| eval response_time=round(response_time,2) 
| fields transaction_name count response_time objective threshold 
| rename response_time AS "Average Response Time" transaction_name AS "Transaction Type" objective as Objective threshold as Threshold count as "Transaction Count"
| sort +transaction_name</query>
          <earliest>$search_time.earliest$</earliest>
          <latest>$search_time.latest$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">true</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    require([
        'underscore',
        'jquery',
        'splunkjs/mvc',
        'splunkjs/mvc/tableview',
        'splunkjs/mvc/simplexml/ready!'
    ], function (_, $, mvc, TableView) {

    var objective_value;
    var threshold_value;

    // Row Coloring Example with custom, client-side range interpretation
    var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
        canRender: function (cell) {
            // Enable this custom cell renderer for response_time field
            return _(['Average Response Time', 'Objective', 'Threshold']).contains(cell.field);
        },
        render: function ($td, cell) {
            // Add a class to the cell based on the returned value
            var value = parseFloat(cell.value);

            if (cell.field === 'Objective') {
                objective_value = value;
            }

            if (cell.field === 'Threshold') {
                threshold_value = value;
            }

            // Apply interpretation for number of historical searches
            if (cell.field === 'Average Response Time') {
                if (value >= threshold_value) {
                    $td.addClass('range-cell').addClass('range-severe');
                }
                else if (value >= objective_value) {
                    $td.addClass('range-cell').addClass('range-elevated');
                }
                else if (value < objective_value) {
                    $td.addClass('range-cell').addClass('range-low');
                }
            }
            // Update the cell content
            $td.text(value.toFixed(2)).addClass('numeric');
        }
    });
    mvc.Components.get('response_time_highlight').getVisualization(function (tableView) {
        // Add custom cell renderer, the table will re-render automatically.
        tableView.addCellRenderer(new CustomRangeRenderer());
    });
});
0 undefined undefined
8.64 100 100
7.52 2 6
0 2 6
7.52 2 6
1.11 10 25
2.28 2 6
2.92 2 6