Quantcast
Channel: InfluxDB - Grafana Labs Community Forums
Viewing all articles
Browse latest Browse all 199

Date order error in a Bar Chart

$
0
0

Hello

I would like to now why my bar chart display an error in order of dates :

As you can see, Saturday and sunday are between monday and thursday of this month.

It can also be used for other days and dates.

I give you the json configuration :


{
  "datasource": {
    "type": "influxdb",
    "uid": "b383168e-2097-4f5b-a983-0d137adfb3aa"
  },
  "fieldConfig": {
    "defaults": {
      "custom": {
        "lineWidth": 1,
        "fillOpacity": 80,
        "gradientMode": "none",
        "axisPlacement": "auto",
        "axisLabel": "",
        "axisColorMode": "text",
        "axisBorderShow": false,
        "scaleDistribution": {
          "type": "linear"
        },
        "axisCenteredZero": false,
        "hideFrom": {
          "tooltip": false,
          "viz": false,
          "legend": false
        },
        "thresholdsStyle": {
          "mode": "line"
        }
      },
      "color": {
        "mode": "palette-classic"
      },
      "mappings": [],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "text",
            "value": null
          }
        ]
      }
    },
    "overrides": [
      {
        "matcher": {
          "id": "byFrameRefID",
          "options": "B"
        },
        "properties": [
          {
            "id": "unit",
            "value": "kwatth"
          }
        ]
      },
      {
        "matcher": {
          "id": "byFrameRefID",
          "options": "D"
        },
        "properties": [
          {
            "id": "displayName",
            "value": "IPE"
          },
          {
            "id": "unit",
            "value": "Wh/m²/°C"
          },
          {
            "id": "color",
            "value": {
              "fixedColor": "dark-green",
              "mode": "fixed"
            }
          }
        ]
      }
    ]
  },
  "gridPos": {
    "h": 8,
    "w": 11,
    "x": 9,
    "y": 34
  },
  "id": 50,
  "targets": [
    {
      "datasource": {
        "type": "influxdb",
        "uid": "b383168e-2097-4f5b-a983-0d137adfb3aa"
      },
      "hide": true,
      "query": "import \"timezone\"\r\n\r\noption location = timezone.location(name: \"Europe/Paris\")\r\n\r\nfrom(bucket: \"GIN\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"Consommation\")\r\n  |> filter(fn: (r) => r[\"_field\"] == \"Chauffage_chambre1\" or r[\"_field\"] == \"Chauffage_chambre2\" or r[\"_field\"] == \"Chauffage_cuisine\" or r[\"_field\"] == \"Chauffage_entree\" or r[\"_field\"] == \"Chauffage_salledebain\")\r\n  |> difference(nonNegative: true, initialZero: true, columns: [\"_value\"])\r\n  |> filter(fn: (r) => r[\"_value\"] > 0.01)\r\n  |> aggregateWindow(every: ${Lisser}, fn: sum, createEmpty: false, offset: -1s)\r\n  |> pivot(rowKey:[\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\")\r\n  |> map(fn: (r) => ({\r\n      r with\r\n      total_chauffage: \r\n        (if exists r.Chauffage_chambre1 then r.Chauffage_chambre1 else 0.0) +\r\n        (if exists r.Chauffage_chambre2 then r.Chauffage_chambre2 else 0.0) +\r\n        (if exists r.Chauffage_cuisine then r.Chauffage_cuisine else 0.0) +\r\n        (if exists r.Chauffage_entree then r.Chauffage_entree else 0.0) +\r\n        (if exists r.Chauffage_salledebain then r.Chauffage_salledebain else 0.0)\r\n  }))\r\n  |> keep(columns: [\"_time\", \"total_chauffage\"])\r\n",
      "refId": "A"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "b383168e-2097-4f5b-a983-0d137adfb3aa"
      },
      "hide": true,
      "query": "import \"timezone\"\r\n\r\noption location = timezone.location(name: \"Europe/Paris\")\r\n\r\n// Requête pour les autres champs de chauffage\r\nchauffage_others = from(bucket: \"GIN\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"Consommation\")\r\n  |> filter(fn: (r) => r[\"_field\"] == \"Chauffage_chambre1\" or r[\"_field\"] == \"Chauffage_chambre2\" or r[\"_field\"] == \"Chauffage_cuisine\" or r[\"_field\"] == \"Chauffage_entree\" or r[\"_field\"] == \"Chauffage_salledebain\")\r\n  |> difference(nonNegative: true, initialZero: true, columns: [\"_value\"])\r\n  |> filter(fn: (r) => r[\"_value\"] > 0.01)\r\n  |> aggregateWindow(every: ${Lisser}, fn: sum, createEmpty: false, offset: -1s)\r\n\r\n// Requête pour Chauffage_salon avec conversion en kWh\r\nchauffage_salon = from(bucket: \"GIN\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"Consommation\" and r[\"_field\"] == \"Chauffage_salon\")\r\n  |> difference(nonNegative: true, initialZero: false, columns: [\"_value\"])\r\n  |> filter(fn: (r) => r[\"_value\"] > 0.01)\r\n  |> aggregateWindow(every: ${Lisser}, fn: sum, createEmpty: false, offset: -1s)\r\n  |> map(fn: (r) => ({ r with _value: r._value * 0.001 })) // Conversion en kWh\r\n\r\n// Union des deux requêtes\r\nunion(tables: [chauffage_others, chauffage_salon])\r\n  |> pivot(rowKey:[\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\")\r\n  |> map(fn: (r) => ({\r\n      r with\r\n      total_chauffage: \r\n        (if exists r.Chauffage_chambre1 then r.Chauffage_chambre1 else 0.0) +\r\n        (if exists r.Chauffage_chambre2 then r.Chauffage_chambre2 else 0.0) +\r\n        (if exists r.Chauffage_cuisine then r.Chauffage_cuisine else 0.0) +\r\n        (if exists r.Chauffage_entree then r.Chauffage_entree else 0.0) +\r\n        (if exists r.Chauffage_salledebain then r.Chauffage_salledebain else 0.0) +\r\n        (if exists r.Chauffage_salon then r.Chauffage_salon else 0.0)\r\n  }))\r\n  |> keep(columns: [\"_time\", \"total_chauffage\"])\r\n",
      "refId": "B"
    },
    {
      "datasource": {
        "type": "influxdb",
        "uid": "b383168e-2097-4f5b-a983-0d137adfb3aa"
      },
      "hide": true,
      "query": "import \"timezone\"\r\n\r\noption location = timezone.location(name: \"Europe/Paris\")\r\n\r\nfrom(bucket: \"GIN\")\r\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\r\n  |> filter(fn: (r) => r[\"_measurement\"] == \"Meteo\")\r\n  |> filter(fn: (r) => r[\"_field\"] == \"DJC\")\r\n  |> aggregateWindow(every: ${Lisser}, fn: sum, createEmpty: false, offset: -1s)",
      "refId": "C"
    },
    {
      "datasource": {
        "name": "Expression",
        "type": "__expr__",
        "uid": "__expr__"
      },
      "expression": "$B*1000/80/$C",
      "hide": false,
      "refId": "D",
      "type": "math"
    },
    {
      "datasource": {
        "name": "Expression",
        "type": "__expr__",
        "uid": "__expr__"
      },
      "expression": "$B*1000/80/$C",
      "hide": false,
      "refId": "E",
      "type": "math"
    }
  ],
  "title": "IPE",
  "transformations": [
    {
      "id": "configFromData",
      "options": {
        "configRefId": "E",
        "mappings": [
          {
            "fieldName": "E",
            "handlerKey": "threshold1",
            "reducerId": "mean"
          },
          {
            "fieldName": "Time",
            "reducerId": "mean"
          }
        ]
      }
    },
    {
      "id": "formatTime",
      "options": {
        "timeField": "Time",
        "outputFormat": "ddd DD  MMM",
        "useTimezone": true,
        "timezone": ""
      }
    }
  ],
  "type": "barchart",
  "options": {
    "orientation": "auto",
    "xTickLabelRotation": 0,
    "xTickLabelSpacing": 100,
    "showValue": "auto",
    "stacking": "none",
    "groupWidth": 0.7,
    "barWidth": 0.97,
    "barRadius": 0,
    "fullHighlight": false,
    "tooltip": {
      "mode": "single",
      "sort": "none"
    },
    "legend": {
      "showLegend": true,
      "displayMode": "list",
      "placement": "bottom",
      "calcs": []
    }
  }
}

The “format time” transformation changes nothing

the problem does not appear on a “time series”

Thanks for your help

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 199

Trending Articles