|
We have a problem by xAxis |
Posted by Steven on Jun-26-2017 19:36 |
|
Hi~~
We have a problem
I want to add DateTime for xAxis(), how to do it?
Our problem is that XAxis must increase over time, and data must follow by time
There may be no data in a certain time interval
The XAxis must be continuous and can not be skipped
I can't use addScatterLayer to do it
Waiting for your answer |
Re: We have a problem by xAxis |
Posted by Peter Kwan on Jun-27-2017 03:13 |
|
Hi Steven,
Since you mentioned DateTime, I assume you are using ChartDirector for .NET (as DateTime is a data type in .NET).
You can use an array of DateTime as the x-coordinate. If you use addScatterLayer, it only accepts an array of double. In this case, you can use Chart.CTime to convert the array of DateTime to an array of double. For example, in C#:
c.addScatterLayer(Chart.CTime(anArrayOfDateTime), yData, .....);
Another method is to add a line layer with data symbols, and set the line width to 0. In this way, you just see the symbols and is the same as a scatter layer. See the following for an example using a line layer. You can modify the code to set the line width to 0 for your case.
http://www.advsofteng.com/doc/cdnet.htm#unevenpoints.htm
Hope this can help.
Regards
Peter Kwan |
Re: We have a problem by xAxis |
Posted by Steven on Jun-27-2017 14:56 |
|
We need is point graphs.
Develop software is asp.net(VB).
You misunderstood what I mean.
It is not right to convert to numbers
I want to
ex.
Dim time1 as String = {"20:00","21:00","22:00","23:00","00:00","01:00","02:00"}
'cover day
c.xAxis().setLinearScale(time1)
I can do it and show it in x-Axis
However,I can't add data and DateTime to chart
DateTime = Date+Time ex.2017/06/27 20:10 ~ 2017/06/28 01:10
Thanks
|
Re: We have a problem by xAxis |
Posted by Peter Kwan on Jun-27-2017 16:30 |
|
Hi Steven,
For your case, the code is like:
'Set the x-axis scale from 2017-06-27 20:00 to 2017-06-28, 01:20, with a tick every 20 minutes
c.xAxis().setDateScale(New DateTime(2017, 6, 27, 20, 00, 00), New DateTime(2017, 6, 28, 1, 20), 20 * 60)
'Set the label format to hh:nn
c.xAxis().setLabelFormat("{value|hh:nn}")
Hope this can help.
Regards
Peter Kwan |
Re: We have a problem by xAxis |
Posted by Steven on Jun-28-2017 14:13 |
|
I can use the program you give to generate the X axis
Then how to add the data to the chart
I need to use the point chart
ex.
c.xAxis().setDateScale(New DateTime(2017, 6, 27, 20, 00, 00), New DateTime(2017, 6, 28, 1, 20, 00), 20 * 60)
c.xAxis().setLabelFormat("{value|hh:nn}")
c.addScatterLayer(??, data1, "point")
?? how to set up
Thanks |
Re: We have a problem by xAxis |
Posted by Peter Kwan on Jun-29-2017 00:14 |
|
Hi Steven,
You may just add the points to the position you want to points to be plotted. For example:
Dim dataY() As Double = {62, 69, 53}
Dim dataX() As DateTime = {New DateTime(2017, 6, 27, 20, 32, 12), New DateTime(2017, 6, 27, 23, 57, 32), New DateTime(2017, 6, 28, 1, 5, 0) }
c.addScatterLayer(Chart.CTime(dataX), dataY, "point")
Hope this can help.
Regards
Peter Kwan |
Re: We have a problem by xAxis |
Posted by Steven on Jul-03-2017 15:01 |
|
Sorry,you misunderstood.
My question is that the data can not be sorted by time in the original data.
ex.
I have some data to show
time{22:30,23:00,04:10,05:00}
data{10,20,15,20}
The chart will show the time from 23:00 to 04:00(with No Data or Data=0)
I wish
20│ ● ●
│
15│ ●
│
10│ ●
└┬─────┬─────┬─────┬─────┬─────┬─────┬────┬
22:00 23:00 00:00 01:00 02:00 03:00 04:00 05:00
Can do it?? |
Re: We have a problem by xAxis |
Posted by Peter Kwan on Jul-04-2017 02:02 |
|
Hi Steven,
I think the method I suggested should achieve what you need. I have attached an example created with the following code using your suggested data.
Dim dataX() As DateTime = { New DateTime(2017, 1, 1, 22, 30, 00), New DateTime(2017, 1, 1, 23, 00, 00), _
New DateTime(2017, 1, 2, 4, 10, 0), New DateTime(2017, 1, 2, 5, 0, 0)}
Dim dataY() As Double = {10, 20, 15, 20}
Dim c As XYChart = New XYChart(450, 200)
c.setPlotArea(55, 20, 350, 150, -1, -1, &Hc0c0c0, &Hc0c0c0, -1)
c.addScatterLayer(Chart.CTime(dataX), dataY)
c.xAxis().setLabelFormat("{value|hh:nn}")
c.xAxis().setRounding(True, True)
WebChartViewer1.Image = c.makeWebImage(Chart.PNG)
If you only need the time and not the date, the VB DateTime still requires you provided the date. In this case, you can just use any arbitrary date as the starting date. (I use 2017-01-01 as the starting date in the above example.) The label is formatted as "{value|hh:nn}" so you would not see the date in the chart.
Hope this can help.
Regards
Peter Kwan
|
Re: We have a problem by xAxis |
Posted by Steven on Jul-04-2017 10:37 |
|
Hi~~
Thank you very much
It is what we want(Figure 1)
However, we used the upper and lower limit of the line can not be used, you can tell me how to increase the upper and lower limits of the program?
We originally wrote the program
====================================================
Dim layer As LineLayer = c.addLineLayer()
layer.addDataSet(data_up, c.dashLineColor(&HFFA500, Chart.DashLine), "↑ OP")
layer.addDataSet(data_down, c.dashLineColor(&H800080, Chart.DashLine), "↓ DR")
====================================================
What we want (Figure 2)
Also, how to increase the time tips?
I know how to add a data field
WebChartViewer1.ImageMap = c.getHTMLImageMap("", "", "title='{date: {value} '")
How to add a time field
Thank you~~
|
Re: We have a problem by xAxis |
Posted by Peter Kwan on Jul-04-2017 14:33 |
|
Hi Steven,
For the upper and lower limit, you can use mark lines (Axis.addMark). See:
http://www.advsofteng.com/doc/cdnet.htm#markzone.htm
http://www.advsofteng.com/doc/cdnet.htm#markzone2.htm
For example:
Dim m As Mark = c.yAxis().addMark(1060, -1, "↑ OP", "Arial Bold", 10)
m.setMarkColors(c.dashLineColor(&HFFA500, Chart.DashLine), &H885200)
m.setLineWidth(2)
m.setAlignment(Chart.TopLeft)
You can also use LineLayers, but you need to specify both the x-coordinates and the y-coordinates of the end-points of the line. (In your code, the LineLayer does not have Layer.setXData to specify the x-coordinates.) So using Axis.addMark should be simpler.
For the tooltip, you may use:
'Display the x-coordinate using the format hh:nn, and the y-coordinate using the default format
WebChartViewer1.ImageMap = c.getHTMLImageMap("", "", "title='{x|hh:nn}: {value} '")
Hope this can help.
Regards
Peter Kwan |
Re: We have a problem by xAxis |
Posted by Steven on Jul-04-2017 19:55 |
|
Thank you for your patience, our problems are finally resolved, and wish you all the good health
Thanks again |
Re: We have a problem by xAxis |
Posted by steven on Aug-08-2017 16:26 |
|
Sorry, I asked the company to set the Y-axis fixed, not by c.addScatterLayer automatically set up, how to amend it? |
Re: We have a problem by xAxis |
Posted by Peter Kwan on Aug-08-2017 18:07 |
|
Hi Steven,
If you want the y-axis to be set by your charting code, instead of determined automatically, you can use Axis.setLinearScale. For example:
'Set y-axis scale from 0 to 2000, which a label every 200 units.
c.yAxis().setLinearScale(0, 2000, 200)
Hope this can help.
Regards
Peter Kwan |
Re: We have a problem by xAxis |
Posted by steven on Aug-10-2017 11:44 |
|
Thanks~~ |
|