Bar chart: numbers lay on each other

0
0

Here is an attachment that represents a bar chart with the issue. Numbers 0 and 1 are located at the same plays.

Attachment
  • You must to post comments
0
0

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace ChartJS_Issue
{
class AlertChartData
{
public int OpenAlerts;
public int ClosedAlerts;
public DateTime Date;
}

public class OverviewSubPanel
{
public OverviewSubPanel()
{
Wisej.Web.Ext.ChartJS.BarOptions barOptions1 = new Wisej.Web.Ext.ChartJS.BarOptions();
Wisej.Web.Ext.ChartJS.OptionScalesAxesX optionScalesAxesX1 = new Wisej.Web.Ext.ChartJS.OptionScalesAxesX();
Wisej.Web.Ext.ChartJS.OptionScalesAxesY optionScalesAxesY1 = new Wisej.Web.Ext.ChartJS.OptionScalesAxesY();

this.chartOverTime.ChartType = Wisej.Web.Ext.ChartJS.ChartType.Bar;
this.chartOverTime.Dock = Wisej.Web.DockStyle.Fill;
this.chartOverTime.Location = new System.Drawing.Point(0, 40);
this.chartOverTime.Name = “chartOverTime”;

barOptions1.DataLabel.Display = true;
barOptions1.Legend.Position = Wisej.Web.HeaderPosition.Bottom;

optionScalesAxesX1.Stacked = true;
barOptions1.Scales.xAxes = new Wisej.Web.Ext.ChartJS.OptionScalesAxesX[] { optionScalesAxesX1 };

optionScalesAxesY1.Stacked = true;
barOptions1.Scales.yAxes = new Wisej.Web.Ext.ChartJS.OptionScalesAxesY[] { optionScalesAxesY1 };

this.chartOverTime.Options = barOptions1;
this.chartOverTime.Size = new System.Drawing.Size(680, 215);
}

private Wisej.Web.Ext.ChartJS.ChartJS chartOverTime;

public void LoadChart()
{
this.chartOverTime = new Wisej.Web.Ext.ChartJS.ChartJS();
this.chartOverTime.DataSets.Clear();

var openAlertsDataset = new Wisej.Web.Ext.ChartJS.BarDataSet();
openAlertsDataset.BackgroundColor = new Color[] { System.Drawing.Color.FromArgb(128, Color.Red) };
openAlertsDataset.HoverBackgroundColor = null;
openAlertsDataset.Label = “Opened Alerts”;
this.chartOverTime.DataSets.Add(openAlertsDataset);

var closedAlertsDataset = new Wisej.Web.Ext.ChartJS.BarDataSet();
closedAlertsDataset.BackgroundColor = new Color[] { System.Drawing.Color.FromArgb(128, Color.Blue) };
closedAlertsDataset.HoverBackgroundColor = null;
closedAlertsDataset.Label = “Closed Alerts”;
this.chartOverTime.DataSets.Add(closedAlertsDataset);

var list = new List<AlertChartData>()
{
new AlertChartData
{
Date = DateTime.Now,
OpenAlerts = 1,
ClosedAlerts = 0
},
new AlertChartData
{
Date = DateTime.Now,
OpenAlerts = 1,
ClosedAlerts = 0
},
new AlertChartData
{
Date = DateTime.Now,
OpenAlerts = 0,
ClosedAlerts = 1
},
new AlertChartData
{
Date = DateTime.Now,
OpenAlerts = 0,
ClosedAlerts = 0
},
new AlertChartData
{
Date = DateTime.Now,
OpenAlerts = 1,
ClosedAlerts = 1
},
new AlertChartData
{
Date = DateTime.Now,
OpenAlerts = 0,
ClosedAlerts = 1
},
new AlertChartData
{
Date = DateTime.Now,
OpenAlerts = 1,
ClosedAlerts = 1
},
new AlertChartData
{
Date = DateTime.Now,
OpenAlerts = 0,
ClosedAlerts = 0
}
};

openAlertsDataset.Data = list.Select(n => (object)n.OpenAlerts).ToArray();
closedAlertsDataset.Data = list.Select(n => (object)n.ClosedAlerts).ToArray();
chartOverTime.Labels = list.Select(n => n.Date.ToString(“yyyy-MM-dd”)).ToArray();

}
}
}

  • You must to post comments
0
0

Thanks Dmitry. It would speed up our investigation if you could send us the code. Either post it here or send it to frankATiceteagroup.com Regards, Frank

  • You must to post comments
0
0

Here are screenshots of code that is responsible for bar chart drawing and a screenshot of a bar chart as a result.

 

  • You must to post comments
0
0

Dmitry,

can you please share some sample code ?
Could be an issue in ChartJS.

Thanks in advance,
Frank

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.