{
    "title": "Value Display Configuration",
    "description": "A simple numeric value display widget for showing key metrics with labels and units. Use this widget to prominently display important numbers like sensor readings, KPIs, or any scalar value that already exists in the data — the widget performs NO aggregation (no count/sum/avg; the only reduction is averaging the latest N readings via advanced.averageLatest). Supports multiple value displays in one widget, each with its own label, unit, and formatting. Features include decimal precision control, data freshness validation via timestamps, averaging over recent values, and automatic pivot/split functionality for showing one value per distinct category. Ideal for dashboard KPI tiles, sensor readouts, or any scenario requiring clean numeric value presentation.",
    "aiSelection": {
        "dataShape": "One number per entry: dataseries[].data[].value, with an optional timestamp for freshness checks (advanced.maxLatency) and averaging over the latest N readings. Label, unit and decimal precision are set per entry. A pivot column produces one readout per distinct value. The subtitle can be bound as well, and shown as a local date and time when it holds a timestamp (subTitleType).",
        "useWhen": [
            "A figure should be the average of its latest N readings rather than the newest one (advanced.averageLatest).",
            "One readout per machine or site should be generated from a single column, for however many there are (multiChart with data[].pivot)."
        ],
        "notFor": [
            "Counting or aggregating rows — the widget performs NO aggregation (no count/sum/avg); it displays a value that already exists in the data or is embedded as a static number.",
            "A number that only means something against a minimum and maximum — use widget-gauge.",
            "How the number is changing — use widget-linechart.",
            "Its share of a total — use widget-doughnut when the parts are a fixed set that arrive as columns of one row (or as one value each); when the parts are rows of the result (one row per cause or program), use widget-linechart with dataseries[].type: 'bar'.",
            "A figure, or several figures that belong together, shown in their context — a KPI card, the current readings of one machine, one shift's output and scrap — use widget-markdown, laid out in HTML, with valueType 'number' and precision for the decimals, a bound tsp with maxLatency to hide stale readings, and text sized to the tile with container units (cqh, cqw).",
            "Several fields of many entities side by side — use widget-table.",
            "Text rather than a figure — use widget-label."
        ]
    },
    "type": "object",
    "properties": {
        "title": {
            "title": "Title",
            "description": "The main heading displayed above the value displays. Use to identify the metric group (e.g., 'Temperature Readings', 'Production Counts').",
            "type": "string",
            "order": 1
        },
        "subTitle": {
            "title": "Subtitle",
            "description": "Secondary text displayed below the title. Use for additional context like location, time period, or data source. Can be bound to a timestamp column, e.g. to say since when a total has been counting; set Subtitle Type to 'timestamp' so it reads as a date and time rather than a raw number.",
            "type": "string",
            "order": 2
        },
        "subTitleType": {
            "title": "Subtitle Type",
            "description": "How the subtitle is shown. 'text' (the default) shows it exactly as given. 'timestamp' reads it as a point in time — Unix epoch milliseconds, which is how a bound timestamp column arrives, or an ISO 8601 string — and shows it as a date and time in the viewer's own time zone and locale. A value that is not a point in time is shown as given.",
            "type": "string",
            "enum": ["text", "timestamp"],
            "dataDrivenDisabled": true,
            "order": 2
        },
        "dataseries": {
            "title": "Value Displays",
            "description": "Array of value display configurations. Each entry creates a labeled numeric display with optional unit and styling. Add multiple entries to show several related metrics together.",
            "type": "array",
            "dataDrivenDisabled": true,
            "order": 2,
            "items": {
                "type": "object",
                "properties": {
                    "label": {
                        "title": "Label",
                        "description": "Display text identifying this value. Should clearly describe what the number represents (e.g., 'Current Temperature', 'Total Orders', 'CPU Usage').",
                        "type": "string",
                        "required": true,
                        "order": 1
                    },
                    "unit": {
                        "title": "Unit",
                        "description": "The measurement unit displayed after the value. Examples: '°C', 'km/h', '%', 'kWh', 'pcs'. Can be bound to data for dynamic units.",
                        "type": "string",
                        "dataDrivenDisabled": false,
                        "order": 2
                    },
                    "precision": {
                        "title": "Decimals",
                        "description": "Number of decimal places to display. Default is 0 (whole numbers). Set to 1-3 for measurements requiring decimal precision (e.g., temperature: 2, percentages: 1).",
                        "type": "number",
                        "dataDrivenDisabled": true,
                        "order": 3
                    },
                    "value": {
                        "title": "Value",
                        "description": "The numeric value to display. Bind to a data source column containing the metric. Only shown when Multi Chart mode is disabled.",
                        "type": "number",
                        "condition": {
                            "relativePath": "../multiChart",
                            "showIfValueIn": [false]
                        },
                        "order": 5
                    },
                    "multiChart": {
                        "title": "Multi Chart",
                        "description": "Enable to automatically create one value display per distinct pivot value in the data. When enabled, use the data array with pivot column instead of a single value.",
                        "type": "boolean",
                        "dataDrivenDisabled": true,
                        "order": 6
                    },
                    "data": {
                        "title": "Data",
                        "description": "Data array for Multi Chart mode. Each row should contain a value and optionally a timestamp and pivot column for splitting into multiple displays.",
                        "type": "array",
                        "condition": {
                            "relativePath": "../multiChart",
                            "showIfValueIn": [true]
                        },
                        "order": 7,
                        "items": {
                            "type": "object",
                            "properties": {
                                "tsp": {
                                    "title": "Timestamp",
                                    "description": "The time of the reading. A bound timestamp column arrives as epoch milliseconds; a static value can be an ISO 8601 string, such as '2023-11-04T22:47:52Z'. Used with Maximum Latency to hide stale readings.",
                                    "type": "string",
                                    "order": 1
                                },
                                "value": {
                                    "title": "Value",
                                    "description": "The numeric value from this data row. In Multi Chart mode, the latest value per pivot group is displayed.",
                                    "type": "number",
                                    "required": true,
                                    "order": 1
                                },
                                "pivot": {
                                    "title": "Split Data by",
                                    "description": "Column used to group data into separate value displays. Each unique value creates its own display. Example: with columns [city, timestamp, temperature], setting pivot to 'city' shows one temperature value per city.",
                                    "type": "string",
                                    "order": 2
                                }
                            }
                        }
                    },
                    "styling": {
                        "title": "Styling",
                        "description": "Visual styling options for the label and value text colors.",
                        "type": "object",
                        "order": 8,
                        "properties": {
                            "labelColor": {
                                "title": "Label Color",
                                "description": "Color of the label text above or beside the value.",
                                "type": "color",
                                "color": true,
                                "order": 4
                            },
                            "valueColor": {
                                "title": "Value Color",
                                "description": "Color of the numeric value and unit text.",
                                "type": "color",
                                "color": true,
                                "order": 5
                            }
                        }
                    },
                    "advanced": {
                        "title": "Advanced Settings",
                        "description": "Advanced data processing options for averaging and freshness validation.",
                        "type": "object",
                        "order": 9,
                        "properties": {
                            "averageLatest": {
                                "title": "Average Latest Values",
                                "description": "Calculate and display the average of the N most recent values instead of just the latest. Useful for smoothing noisy sensor data. Leave empty to show the raw latest value. When using pivot/split, averaging is applied per group.",
                                "type": "number",
                                "dataDrivenDisabled": true,
                                "order": 6
                            },
                            "maxLatency": {
                                "title": "Maximum Latency",
                                "description": "Maximum age in seconds of the newest reading. When the newest data row's Timestamp is older, the readout shows no number, also while no new data arrives, so outdated values are never shown as current. Needs Multi Chart with a Timestamp in the data rows: a single Value carries no time. Leave it empty for no limit.",
                                "type": "number",
                                "dataDrivenDisabled": true,
                                "order": 7
                            }
                        }
                    }
                }
            }
        }
    }
}
