<!--

    Copyright © 2016-2019 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<table class="tb-legend">
    <thead>
        <tr class="tb-legend-header">
            <th colspan="2"></th>
            <th ng-if="legendConfig.showMin === true">{{ 'legend.min' | translate }}</th>
            <th ng-if="legendConfig.showMax === true">{{ 'legend.max' | translate }}</th>
            <th ng-if="legendConfig.showAvg === true">{{ 'legend.avg' | translate }}</th>
            <th ng-if="legendConfig.showTotal === true">{{ 'legend.total' | translate }}</th>
        </tr>
    </thead>
    <tbody>
        <tr class="tb-legend-keys" ng-repeat="legendKey in legendData.keys">
            <td><span class="tb-legend-line"  ng-style="{backgroundColor: legendKey.dataKey.color}"></span></td>
            <td class="tb-legend-label"
                ng-click="toggleHideData(legendKey.dataIndex)"
                ng-class="{ 'tb-hidden-label': legendData.keys[legendKey.dataIndex].dataKey.hidden, 'tb-horizontal': isHorizontal }">
                {{ legendKey.dataKey.label }}
            </td>
            <td class="tb-legend-value" ng-if="legendConfig.showMin === true">{{ legendData.data[legendKey.dataIndex].min }}</td>
            <td class="tb-legend-value" ng-if="legendConfig.showMax === true">{{ legendData.data[legendKey.dataIndex].max }}</td>
            <td class="tb-legend-value" ng-if="legendConfig.showAvg === true">{{ legendData.data[legendKey.dataIndex].avg }}</td>
            <td class="tb-legend-value" ng-if="legendConfig.showTotal === true">{{ legendData.data[legendKey.dataIndex].total }}</td>
        </tr>
    </tbody>
</table>
