You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using version 3.11, check code below, using PieDataSet, converted script shows "type: bar"
//create dom id
id = "chart" + Guid.NewGuid().ToString("N") + DateTime.Now.Ticks.ToString();
//initialize chart
chart = new Chart()
{
Data = new Data(),
Options = new Options
{
Plugins = new Plugins()
{
Legend = new Legend()
{
Display = true,
Position = "left"
}
},
Responsive = true,
//setting this with a pie chart does not look good as it reduces the size of the pie chart a lot
// MaintainAspectRatio = false // Disable the aspect ratio
}
};
//create colors
colors = ColorUtils.GetColorsByRange(AI_Component_Data.SingleChartData.Values.Count());
var chartColors = new List<ChartColor>();
var backgroundChartColors = new List<ChartColor>();
foreach (var rgba in colors)
{
backgroundChartColors.Add(ChartColor.FromRgba(rgba.R, rgba.G, rgba.B, (float)rgba.A / 510f));
chartColors.Add(ChartColor.FromRgba(rgba.R, rgba.G, rgba.B, (float)rgba.A / 255f));
}
//set labels
chart.Data.Labels = AI_Component_Data.SingleChartData.Keys.ToList();
//create single data set
var dataset = new PieDataset()
{
Data = AI_Component_Data.SingleChartData.Values,
BackgroundColor = backgroundChartColors,
HoverBackgroundColor = chartColors,
};
chart.Data.Datasets = new List<Dataset>() { dataset };
var script = chart.CreateChartCode(id);
Using version 3.11, check code below, using PieDataSet, converted script shows "type: bar"
converts to this:
The text was updated successfully, but these errors were encountered: