-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floating stacked bar charts on time-axis #164
Comments
Good question! Assuming you want something like this Configure the chart like this private readonly Random _rng = new Random();
private BarConfig _config;
protected override void OnInitialized()
{
_config = new BarConfig
{
Options = new BarOptions
{
Responsive = true,
Scales = new BarScales
{
XAxes = new List<CartesianAxis>
{
new BarTimeAxis
{
Display = AxisDisplay.True,
ScaleLabel = new ScaleLabel
{
Display = true,
LabelString = "Date"
},
Time = new TimeOptions
{
Unit = TimeMeasurement.Day
}
}
},
YAxes = new List<CartesianAxis>
{
new BarLinearCartesianAxis
{
Display = AxisDisplay.True,
ScaleLabel = new ScaleLabel
{
Display = true,
LabelString = "Value"
},
Ticks = new LinearCartesianTicks
{
BeginAtZero = true
}
}
}
}
}
};
var data = Enumerable.Range(0, 6)
.Select(i => new FloatingBarPoint(_rng.Next(10, 50), _rng.Next(60, 100)));
BarDataset<FloatingBarPoint> dataset = new BarDataset<FloatingBarPoint>(data)
{
BackgroundColor = "red",
BorderColor = "red",
Label = "Dataset"
};
_config.Data.Datasets.Add(dataset);
DateTime today = DateTime.Now;
var labels = Enumerable.Range(0, 6)
.Select(i => today.AddDays(i).ToString("o"));
foreach (var label in labels)
{
_config.Data.Labels.Add(label);
}
} The relevant issue for this (among others) is chartjs/Chart.js#6499. If this doesn't answer your question, please comment to reopen :) |
So it is a dataset of BarDataset. For example, one dataset only has data for 0.5, 1, 1.5, 2, 3, 4, 6, and 10 x-axis points. How do I create the Dataset with x-axis values? The floating bar chart has worked great to create box and whisker chart in combination with scatter points and lines. I just need to be able to get the bars to appear on the right x points. |
I think this is the required Javascript, is there a why to do this in Chartjs.blazor? I can remove one of the dataset values and the other bars continue to display without the deleted bar. So from https://codepen.io/kurkle/pen/gOadBzy the js: |
I see. Unfortunately, I don't think you can do this with ChartJs.Blazor (yet). Once ChartJs.Blazor upgrades to Chart.js 3.0, we will make |
Bummer. I'm not able to find a paid blazor charts product which does Box charts on a linear axis either. I did find a work around. I am using individual lines for the boxes and whiskers. I set the BorderWidth and use PointStyle line to get the right look. Would you know if there a limit to the number of datasets allowed on a chart? |
You can always fork and adjust this library, it's fully Open Source. You could probably also pay a freelancer to make the desired changes to this library if you don't have the time to do it yourself. Also, just so I understand correctly.. You're still talking about linear axis but as written in the linked issues, the time-axes is the one making trouble. I have adjusted the title accordingly but I'm not sure if we understand each other correctly. Could you maybe elaborate a bit on the linear-axis part?
No, I don't know but I highly doubt there is one. The only "limit" I can think of is the performance of your client (and browser). |
Time would work because the x-axis is in sec, but I was using double x-values on a linear x-axis. I also need to be able to use a logarithmic axis. |
I'm sorry, I don't think I understand.
I think these are the most common use-cases. Does that help you in any way? |
Describe your question
I'm trying to make box/whisker chart using floating bar chart. I've successful implemented on a category axis, but I need to do it on a linear axis.
Which Blazor project type is your question related to?
Which charts is this question related to?
floating bar charts
JavaScript equivalent
I think this is an example of how its done in JavaScript
https://codepen.io/kurkle/pen/gOadBzy
Additional context
Add any additional context, screenshots or code about the question here.
The text was updated successfully, but these errors were encountered: