Introduction #
SmartChart supports Redis as a data source, reading data directly by key name. Ideal for displaying real-time metrics computed by external systems (Spark, crawlers) and written to Redis. Supports JSON objects (dicts) and JSON 2D arrays (tables).
Use Cases #
Display data computed by external programs in real-time, such as Spark-computed data or crawler-scraped data, stored in Redis or NoSQL databases.
Usage #
Create a Redis connection pool, then create datasets normally. The SQL area writes Redis key names instead of SQL code.
E.g., if Redis stores key “MetricA” with data {"Changsha":1,"Shanghai":2}, just write:
MetricA
Result: {"Changsha":1,"Shanghai":2}
For table format, store a 2D array in Redis:
[["Province","Count"],["Changsha",1],["Shanghai",2]]
Data must be stored as strings in Redis. Use Python’s json.dumps to generate string format.
Multiple Keys #
Use semicolons to separate multiple keys:
MetricA;MetricB