Can i set dynamic step size on stepped line chart in chart.js? - charts

In chart.js, the x-axis of the stepped line chart are fixed.
for example, I want to displays when x is less than 2, y is 10, x is between 2 and 10, y is 20, x is larger than 10, y is 5.
How can i do this with chart.js?

By default the closest you can come is by using a logarithmic scale, only downside is you can't choose the tick spacing but it will increase.
The only way to achieve what you want is by writing your own custom axis as described here in the docs: https://www.chartjs.org/docs/master/developers/axes.html

Related

How do I customize dual axis values?

I want to plot 2 variables in my worksheet.X variable vs Y variable. The Y variable is composed of 3 sub-variables y1,y2,y3 which when summed up result to Y. I have expressed y1,y2,y3 as percentages of Y say Y=45(100%) and y1=35%,y2=40%,y3=25%.How do I plot X vs Y with the Y axis value being 45 and not 100%?
I have been to plot the measure values of Y(y1,y2,y3) but now the axis values are automatically generated from 0 to 100%. What I want is the real axis values to be displayed 0 to 45.
I want the axis to be real values of Y(45) but the sub_variables (y1=35%,y2=40%,y3=25%)
There are a couple of things you can do here.
Click on the secondary axis and select "Synchronize axis". This
will ensure that the secondary axis is tied to the scope of the
primary axis.
You can manually edit either/both axis by right clicking on them and setting the axis values manually.
Beyond this, it might be how you are setting up your viz. If you could provide a picture/sample data it would be helpful.

Set y axis max value with Matlab

I'm trying to draw plots with Matlab and the problem is that i want to fix the maximum value of y-axis to 8 . To help you understand me, look at this first example :
you can see that the maximum y value is 8. but when i try to draw this graph :
its maximum y value is 6 . i want to fix it for all examples to 8.
how can i do it?
here's my code for now :
data=importdata('C:/Users/Eden/Desktop/Calcul_accel/fichier_final.txt');
fig = figure(1);
x=data(:,2)
y=data(:,3)
p=plot(x,y)
set(p,'Color','red');
xlabel('Time(milliseconds)','FontSize',12,'FontWeight','bold','Color','b');
ylabel('Acceleration(g unit)','FontSize',12,'FontWeight','bold','Color','b')
thank you very much
Use ylim if you just want to modify the y axis.
Therefore, do this once your plot is already open:
ylim([0 8]);
This overrides the auto-scaling of the axes so that y always spans between 0 to 8.
In general, #eigenchris mentioned to use axis, which allows you to change the dynamic range of what is viewable in a plot for both the x and y axes. However, since you only want to change how the y-axis is visualized, one call to ylim is enough.

Increase resolution in X-axis for an existing x-y graph in MATLAB

In MATLAB, I have an existing set of values for X,Y where X = [0,1,2, ... 255], and Y is in the range of -5 to 4.
When I plot this graph MATLAB, obviously interpolates these values.
I require to increase the resolution of the X-axis to X = [0, 0.25, 0.5, 0. 75, 1 .... 254.75, 255].
I am not looking for a simple averaging kind of operation. Rather I want it to be as good as MATLAB which does it very smoothly. Please guide me.
A few things to know:
Matlab doesn't interpolate if you haven't made it interpolate. The figure you see is scalable, so there is no interpolation, at most a line connecting between adjacent dots.
If you want to interpolate just use interp1....
fore example,
Xnew= 0:0.25:255;
Ynew=interp1(X,Y,Xnew,'spline');
plot(Xnew,Ynew);
should do.

How do I create a correctly scaled x-axis?

I'm using HighCharts line plots where my x-axis data is unevenly distributed:
[4, 10, 40, 100, 400, 1000, etc.]
Currently the x-values are placed evenly. I want the distance between x[5] and x[4] to be 10 times that between x[3] and x2. How do I do this?
In the GoogleCharts lingo, I need a continuous axis.
In the docs, I only see "linear", "logarithmic", and "datetime" for the axis type. ("linear" is the default and does not do what I want).
Since you didn't post your javascript generating the charts I'll have to guess, but I assume you are using categories within your xAxis. The categories are evenly distributed, so don't use them in this case.
If you change your series data block to specify x and y values (http://www.highcharts.com/ref/#series--data example 2) the xAxis will show correct proportions for your values. For example look at this fiddle.

SSRS 2008 - Line Chart - How to shade an area of the chart?

I have a line chart. The line represents the average thickness of material we apply to glass. The Y Axis represents the thickness and the X axis represents time. Say the range of values on the Y axis is between 1 and 10. The average thickness is say typically between 3 and 5, but must fall within a range, on the low side of 2 and on the high side of 7. I would like to shade the area of the graph between 2 and 7, to indicate the acceptable range of values. Can this be done?
Add a second value series, and change it to the "Range" chart type. This will allow you to set the high / low Y values discretely. Rather than choosing a field for these values, just edit the expression and set the static values (in your case, 2 and 7).
From there, edit the series "fill" properties - select Pattern, and find one that works for ya. There a good set of % fills (5 percent, 10 percent, etc.) midway down the list.
Hope this helps.