diff --git a/apps/plotly_examples/python-scripts/generate_plotly_schema.py b/apps/plotly_examples/python-scripts/generate_plotly_schema.py index 1f0503a12e..150771a554 100644 --- a/apps/plotly_examples/python-scripts/generate_plotly_schema.py +++ b/apps/plotly_examples/python-scripts/generate_plotly_schema.py @@ -334,10 +334,6 @@ def call_llm_detailed_plotly_schema(scenario: str, id: int, suffix: str): def get_chart_type_from_image(): directory_path = os.path.join('..', 'tests', 'Plotly.spec.ts-snapshots') files = glob.glob(os.path.join(directory_path, '*')) - print(f'Processing files: {files}') - dir_path = 'C:\\Users\\srmukher\\Documents\\fluentui-charting-contrib\\apps\\plotly_examples\\tests\\Plotly.spec.ts-snapshots' - - files = glob.glob(os.path.join(dir_path, '*')) chart_types = {} @@ -345,36 +341,38 @@ def get_chart_type_from_image(): # Extract the file number from the file path file_name = os.path.basename(file_path) file_number = file_name.split('-')[3] - print('file_number:', file_number) - - with open(file_path, 'rb') as image_file: - response_format={ "type": "json_object" } - messages = [ - { - "role": "system", - "content": "You are an image data analyst having expertize in predicting data visualizations." - } - , - { - "role": "user", - "content": f"""Refer the image {image_file} and predict the chart type that best fits the data among 'Area', 'Line', 'Donut', 'Pie', 'Guage', 'Horizontal Bar tWithAxis', 'Vertical Bar', 'Vertical Stacked Bar ', 'Grouped Vertical Bar', 'Heatmap', 'Sankey'. Mark the chart type as 'Others' if none of the above types match. Provide the output in the form of a json object. Categorize the images correctly based on the chart type. - For example: {{"chart_type": "Area"}}""" - } - ] - response = call_llm(messages, response_format) - data = json.loads(response) - retry_count = 0 - while 'chart_type' not in data and retry_count < 3: + # padding the file_number with zeros making it a 3 digit number + if file_number.isdigit(): + file_number = file_number.zfill(3) + + with open(file_path, 'rb') as image_file: + response_format={ "type": "json_object" } + messages = [ + { + "role": "system", + "content": "You are an image data analyst having expertize in predicting data visualizations." + } + , + { + "role": "user", + "content": f"""Refer the image {image_file} and predict the chart type that best fits the data among 'Area', 'Line', 'Donut', 'Pie', 'Guage', 'Horizontal Bar tWithAxis', 'Vertical Bar', 'Vertical Stacked Bar ', 'Grouped Vertical Bar', 'Heatmap', 'Sankey'. Mark the chart type as 'Others' if none of the above types match. Provide the output in the form of a json object. Categorize the images correctly based on the chart type. + For example: {{"chart_type": "Area"}}""" + } + ] response = call_llm(messages, response_format) data = json.loads(response) - retry_count += 1 - if retry_count == 3: - print(f"Failed to get chart type for file {file_number}") - continue - chart_type = data['chart_type'] - - # Map the file number and chart type - chart_types[file_number] = chart_type + retry_count = 0 + while 'chart_type' not in data and retry_count < 3: + response = call_llm(messages, response_format) + data = json.loads(response) + retry_count += 1 + if retry_count == 3: + print(f"Failed to get chart type for file {file_number}") + continue + chart_type = data['chart_type'] + + # Map the file number and chart type + chart_types[file_number] = chart_type chart_types_json = json.dumps(chart_types, indent=2) diff --git a/apps/plotly_examples/src/components/aggregated_chart_types.json b/apps/plotly_examples/src/components/aggregated_chart_types.json index be426ab51c..30c7d0c34d 100644 --- a/apps/plotly_examples/src/components/aggregated_chart_types.json +++ b/apps/plotly_examples/src/components/aggregated_chart_types.json @@ -1,6 +1,6 @@ { - "1": "Area", - "10": "Area", + "001": "Area", + "010": "Area", "100": "VerticalStackedBar", "101": "Line", "102": "Donut", @@ -11,7 +11,7 @@ "107": "Line", "108": "Line", "109": "VerticalStackedBar", - "11": "Line", + "011": "Line", "110": "Pie", "111": "Line", "112": "GroupedVerticalBar", @@ -22,7 +22,7 @@ "117": "Others", "118": "GroupedVerticalBar", "119": "Line", - "12": "Donut", + "012": "Donut", "120": "Pie", "121": "VerticalStackedBar", "122": "Line", @@ -33,7 +33,7 @@ "127": "GroupedVerticalBar", "128": "Line", "129": "Donut", - "13": "HorizontalBarWithAxis", + "013": "HorizontalBarWithAxis", "130": "VerticalStackedBar", "131": "Line", "132": "Pie", @@ -44,7 +44,7 @@ "137": "VerticalStackedBar", "138": "Donut", "139": "GroupedVerticalBar", - "14": "VerticalStackedBar", + "014": "VerticalStackedBar", "140": "Line", "141": "Donut", "142": "VerticalStackedBar", @@ -55,7 +55,7 @@ "147": "Heatmap", "148": "VerticalStackedBar", "149": "Line", - "15": "Pie", + "015": "Pie", "150": "Heatmap", "151": "Heatmap", "152": "VerticalStackedBar", @@ -66,7 +66,7 @@ "157": "Line", "158": "GroupedVerticalBar", "159": "Others", - "16": "Sankey", + "016": "Sankey", "160": "GroupedVerticalBar", "161": "Line", "162": "Pie", @@ -77,7 +77,7 @@ "167": "Line", "168": "Line", "169": "Others", - "17": "Heatmap", + "017": "Heatmap", "170": "VerticalStackedBar", "171": "Pie", "172": "GroupedVerticalBar", @@ -88,7 +88,7 @@ "177": "Heatmap", "178": "GroupedVerticalBar", "179": "Line", - "18": "Gauge", + "018": "Gauge", "180": "Pie", "181": "Others", "182": "VerticalStackedBar", @@ -99,7 +99,7 @@ "187": "GroupedVerticalBar", "188": "Line", "189": "Pie", - "19": "Area", + "019": "Area", "190": "HorizontalBarWithAxis", "191": "Pie", "192": "Heatmap", @@ -110,8 +110,8 @@ "197": "VerticalStackedBar", "198": "Heatmap", "199": "GroupedVerticalBar", - "2": "Line", - "20": "Line", + "002": "Line", + "020": "Line", "200": "Line", "201": "Heatmap", "202": "VerticalStackedBar", @@ -122,7 +122,7 @@ "207": "Line", "208": "Line", "209": "Pie", - "21": "Donut", + "021": "Donut", "210": "GroupedVerticalBar", "211": "Line", "212": "GroupedVerticalBar", @@ -133,7 +133,7 @@ "217": "Line", "218": "Heatmap", "219": "GroupedVerticalBar", - "22": "HorizontalBarWithAxis", + "022": "HorizontalBarWithAxis", "220": "Line", "221": "VerticalStackedBar", "222": "Others", @@ -144,7 +144,7 @@ "227": "Line", "228": "Donut", "229": "VerticalStackedBar", - "23": "Pie", + "023": "Pie", "230": "Donut", "231": "Line", "232": "VerticalStackedBar", @@ -155,7 +155,7 @@ "237": "VerticalStackedBar", "238": "Heatmap", "239": "Line", - "24": "Sankey", + "024": "Sankey", "240": "VerticalStackedBar", "241": "Line", "242": "VerticalStackedBar", @@ -166,7 +166,7 @@ "247": "Line", "248": "VerticalStackedBar", "249": "Line", - "25": "Heatmap", + "025": "Heatmap", "250": "Others", "251": "VerticalStackedBar", "252": "Line", @@ -177,7 +177,7 @@ "257": "Others", "258": "Line", "259": "Others", - "26": "Gauge", + "026": "Gauge", "260": "Line", "261": "Donut", "262": "Donut", @@ -188,7 +188,7 @@ "267": "Line", "268": "Pie", "269": "GroupedVerticalBar", - "27": "GroupedVerticalBar", + "027": "GroupedVerticalBar", "270": "GroupedVerticalBar", "271": "Pie", "272": "GroupedVerticalBar", @@ -199,7 +199,7 @@ "277": "Line", "278": "Line", "279": "Line", - "28": "Area", + "028": "Area", "280": "Line", "281": "Line", "282": "Line", @@ -210,7 +210,7 @@ "287": "Line", "288": "Line", "289": "Line", - "29": "Line", + "029": "Line", "290": "Line", "291": "Line", "292": "GroupedVerticalBar", @@ -221,84 +221,84 @@ "297": "Line", "298": "Line", "299": "GroupedVerticalBar", - "3": "Donut", - "30": "Donut", + "003": "Donut", + "030": "Donut", "300": "GroupedVerticalBar", "301": "GroupedVerticalBar", "302": "GroupedVerticalBar", - "31": "HorizontalBarWithAxis", - "32": "VerticalStackedBar", - "33": "Pie", - "34": "Sankey", - "35": "Heatmap", - "36": "Gauge", - "37": "Area", - "38": "Line", - "39": "Donut", - "4": "HorizontalBarWithAxis", - "40": "HorizontalBarWithAxis", - "41": "VerticalStackedBar", - "42": "Pie", - "43": "Sankey", - "44": "Heatmap", - "45": "Gauge", - "46": "Area", - "47": "Line", - "48": "Donut", - "49": "HorizontalBarWithAxis", - "5": "GroupedVerticalBar", - "50": "VerticalStackedBar", - "51": "Pie", - "52": "Sankey", - "53": "Heatmap", - "54": "Gauge", - "55": "Area", - "56": "Line", - "57": "Donut", - "58": "HorizontalBarWithAxis", - "59": "GroupedVerticalBar", - "6": "Pie", - "60": "Pie", - "61": "Sankey", - "62": "Heatmap", - "63": "Gauge", - "64": "Area", - "65": "Line", - "66": "Donut", - "67": "HorizontalBarWithAxis", - "68": "VerticalStackedBar", - "69": "Pie", - "7": "Sankey", - "70": "Sankey", - "71": "Heatmap", - "72": "Gauge", - "73": "Area", - "74": "Line", - "75": "Donut", - "76": "HorizontalBarWithAxis", - "77": "VerticalStackedBar", - "78": "Pie", - "79": "Sankey", - "8": "Heatmap", - "80": "Heatmap", - "81": "Gauge", - "82": "Donut", - "83": "GroupedVerticalBar", - "84": "Line", - "85": "Line", - "86": "GroupedVerticalBar", - "87": "Others", - "88": "Heatmap", - "89": "Others", - "9": "Gauge", - "90": "VerticalStackedBar", - "91": "VerticalStackedBar", - "92": "Pie", - "93": "Line", - "94": "VerticalStackedBar", - "95": "Line", - "96": "Pie", - "97": "Line", - "98": "VerticalStackedBar", - "99": "Heatmap" + "031": "HorizontalBarWithAxis", + "032": "VerticalStackedBar", + "033": "Pie", + "034": "Sankey", + "035": "Heatmap", + "036": "Gauge", + "037": "Area", + "038": "Line", + "039": "Donut", + "004": "HorizontalBarWithAxis", + "040": "HorizontalBarWithAxis", + "041": "VerticalStackedBar", + "042": "Pie", + "043": "Sankey", + "044": "Heatmap", + "045": "Gauge", + "046": "Area", + "047": "Line", + "048": "Donut", + "049": "HorizontalBarWithAxis", + "005": "GroupedVerticalBar", + "050": "VerticalStackedBar", + "051": "Pie", + "052": "Sankey", + "053": "Heatmap", + "054": "Gauge", + "055": "Area", + "056": "Line", + "057": "Donut", + "058": "HorizontalBarWithAxis", + "059": "GroupedVerticalBar", + "006": "Pie", + "060": "Pie", + "061": "Sankey", + "062": "Heatmap", + "063": "Gauge", + "064": "Area", + "065": "Line", + "066": "Donut", + "067": "HorizontalBarWithAxis", + "068": "VerticalStackedBar", + "069": "Pie", + "007": "Sankey", + "070": "Sankey", + "071": "Heatmap", + "072": "Gauge", + "073": "Area", + "074": "Line", + "075": "Donut", + "076": "HorizontalBarWithAxis", + "077": "VerticalStackedBar", + "078": "Pie", + "079": "Sankey", + "008": "Heatmap", + "080": "Heatmap", + "081": "Gauge", + "082": "Donut", + "083": "GroupedVerticalBar", + "084": "Line", + "085": "Line", + "086": "GroupedVerticalBar", + "087": "Others", + "088": "Heatmap", + "089": "Others", + "009": "Gauge", + "090": "VerticalStackedBar", + "091": "VerticalStackedBar", + "092": "Pie", + "093": "Line", + "094": "VerticalStackedBar", + "095": "Line", + "096": "Pie", + "097": "Line", + "098": "VerticalStackedBar", + "099": "Heatmap" } \ No newline at end of file