TeeChart For Point having Value as 0 - activex

I am plotting a Line Chart, The Problem is in my data some points have zero Value. If I do AddNull For that it don't show the X-axis Value for the same. Can anyone share a example of Using a AddNULL and Add in the same series Impact.
E.g I have a Series having 11 X- Pts, The Series Data is (0,0,0,0,0,10,0,0,0,0,0)
The Point with value 10 should be shown at 5th place but in my case it is displayed at Position 0.

I recommend you use method SetNull or AddNullXY to make null, the values you want and set the property TreatNull to DontPaint because the null values aren't visible. I have made a simple code for you, where I use method SetNull to add nulls in your series:
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scLine
TChart1.AddSeries scLine
TChart1.Series(0).asLine.Pointer.Visible = True
TChart1.Series(1).asLine.Pointer.Visible = True
Dim i As Integer
For i = 0 To 19
TChart1.Series(0).AddXY i, Rnd, "", vbBlue
If i = 5 Then
TChart1.Series(1).AddXY i, 10, "", vbRed
Else
TChart1.Series(1).AddXY i,0, "", vbRed
End If
Next i
For i = 0 To TChart1.Series(1).Count - 1
If i <> 5 Then
TChart1.Series(1).SetNull (i)
End If
Next i
TChart1.Series(1).asLine.TreatNulls = tnDontPaint
End Sub
Could you tell us if previous works as you want?
Thanks,

Related

highlightValue not working in chart with CombinedChartView :: Display marker programmatically is not working :: ChartIssue :: iOS Swift :: DanielGindi

Here is what i am doing!
chart.highlightValue(x: timeStampValue, dataSetIndex: totalCount)
==> In the above line,
timeStampValue is x axis value which i have set while filling up the array.
totalCount is total count of array of data which i am displaying in chart.
What i need to achieve is
When chart screen comes up, i need to display marker by default and for that, i am using "highlightValue" method of chart which is not working.
Please let me know the solution to show marker by default programatically.
NOTE: I am using marker whose UI is custom which is working fine when i tap manually at point in chart:
let marker = CustomMarkerView.viewFromXib()!
marker.chartView = chart
chart.marker = marker
chart.drawMarkers = true
Library used : https://github.com/danielgindi/Charts
Chart Data set :
let data = CombinedChartData()
data.lineData = LineChartData(dataSets:[viewModel.lineChartDataSet, viewModel.emptylineChartDataSet])
data.lineData.highlightEnabled = true
viewModel.lineChartDataSet.highlightColor = AssetsColor.highlightedColor.color
viewModel.lineChartDataSet.drawHorizontalHighlightIndicatorEnabled = false
viewModel.lineChartDataSet.highlightLineDashPhase = 2
viewModel.lineChartDataSet.highlightLineDashLengths = [5, 2.5]
you are using the wrong value for dataSetIndex param
based on your code, the datasets only contains 2 data
data.lineData = LineChartData(dataSets:[viewModel.lineChartDataSet, viewModel.emptylineChartDataSet])
dataSetIndex is not data count, in linechart dataset represent a line that has many data (x,y), so dataSetIndex is more like which line
so your code should be something like this
chart.highlightValue(x: timeStampValue, dataSetIndex: 0)
chart.highlightValue(x: timeStampValue, dataSetIndex: 0, dataIndex: 0)
When i added 1 more parameter which is dataIndex as 0 and it worked.
Here, dataSetIndex is set to 0 because it is CombinedChartView where i have merged 2 data set.

Am I able to use table.concat as a set of arguments?

I'm using LOVE2D to get used to lua a bit more, and I am trying to call a function to make a circle appear on screen, there's 5 arguments, and I have a table known as 'button' with the required arguments in it. I want to use table.concat to to fill in all the blank arguments but it won't let me. Is there anyway to do this?
function toRGB(r,g,b)
return r/255,g/255,b/255
end
function love.load()
button = {}
button.mode = "fill"
button.x = 0
button.y = 0
button.size = 30
end
function love.draw()
love.graphics.setColor(toRGB(60,60,60))
love.graphics.circle(table.concat(button))
end
table.concat returns a string. That's not what you want.
To get a list of table elements use table.unpack. But this function does only work with tables that have consecutive numeric indices starting from 1.
Also love.graphics.circle accesses its parameters by position, not by name. Hence you have to ensure that the expression list you put into that function has the right order.
So something like:
button = {"fill", 0, 0, 30}
love.graphics.circle(table.unpack(button))
would work.
If you're using other table keys as in your example you'll have to write a function that returns the values in the right order.
In the simplest case
button = {}
button.mode = "fill"
button.x = 0
button.y = 0
button.size = 30
button.unpack = function() return button.mode, button.x, button.y, button.size end
love.graphics.circle(button.unpack())
Or you can do something like this:
function drawCircle(params)
love.graphics.circle(params.mode, params.x, params.y, params.size)
end
drawCircle(button)
There are many other ways to achieve this.

DrawLine Tool of Teechart Line Disappears on Scroll Axis

I want to draw a circle on LbuttonDown on Series. What I am doing is I am using DrawLine tool and adding a line on OnMouseDownTchart Event. But the Issue is as soon as i do Scroll Axis the line disappears.
Thanks
Akshay
I'm trying to reproduce the problem with the code below but it seems to work fine for me here. It adds a line in a random position each time I click on the chart. And I can still scroll the chart dragging the same with the right mouse button.
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scPoint
Dim i As Integer
For i = 0 To 20
TChart1.Series(0).Add i, "", clTeeColor
Next i
TChart1.Tools.Add tcDrawLine
TChart1.Tools.Items(0).asDrawLine.EnableDraw = False
End Sub
Private Sub TChart1_OnMouseDown(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
With TChart1.Tools.Items(0).asDrawLine
.AddLine Rnd * 20, Rnd * 20, Rnd * 20, Rnd * 20
End With
End Sub
I'm using TeeChart ActiveX v2013.0.1.0.
Maybe you are doing something at OnMouseDown that enters in conflict with the scroll action.
If you still find problems with it, please, improve the question being more specific. Some code would be helpful. Also I'm not sure to understand what "LbuttonDown on Series" means.

How to get rid of the vacant weekend in the candlestick chart

I've read some articles about the weekend problem with teechart and the suggestions are the foolowing steps:
TChart1.Series(0).XValues.DateTime = False
Use continuous numbers as Xvalues
replace the X label with datetime.
The problem is: I draw the real time candlesticks according to the date,hour and minute and I must keep TChart1.Series(0).XValues.DateTime = True
So are there any ways to get rid of the null weekend (not only the weekend, even some time in a day as from 5:15 to 6:00 need to be removed) so that the candlesticks are shown continuously (the Xvalues must keep datetime style all the time)?
thanks.
(BTW, I use Teechart2011 Eval & VB6)
TeeChart draws each point according to its X and Y values in the associated axes.
You can work with Break Axis tool to obtain a discontinuous effect in an axis, but the easiest way to draw the points continuously in the horizontal axis is having continuous X values. So I'd suggest you to use the TChart1.Series(i).asCandle.AddCandle XVal, OpenVal, HighVal, LowVal, CloseVal, Label, clTeeColor function, being:
XVal: TChart1.Series(i).Count, instead of the date retrieved from the system
Label: the date retrieved from the system, converted to string
If this doesn't solve the problem because you still think you must have DateTime XValues, please explain why.
Taking your snipped of code from here, I've created a simple example that seems to work fine for me here. Find it below:
Private Sub Form_Load()
Dim month, day, year, hour, minute, second, nums As Integer
Dim tmpDate As Date
month = 6
day = 7
year = 2012
hour = 6
minute = 15
second = 0
nums = 10
TChart1.Aspect.View3D = False
TChart1.AddSeries scCandle
TChart1.Axis.Bottom.Labels.Angle = 90
For i = 1 To nums
tmpDate = (DateValue(day & "," & month & "," & year) + TimeValue(hour & ":" & minute & ":" & second))
If Not IsWeekend(tmpDate) Then
With TChart1.Series(0)
.asCandle.AddCandle .Count, 5, 15, 0, 10, tmpDate, clTeeColor
End With
End If
day = day + 1
Next i
End Sub
Public Function IsWeekend(InputDate As Date) As Boolean
Select Case Weekday(InputDate)
Case vbSaturday, vbSunday
IsWeekend = True
Case Else
IsWeekend = False
End Select
End Function

open flash chart rails x-axis issue

I am using open flash chart 2 (the plugin) in my rails application. Everything is looking smooth except for the range on my x axis. I am creating a line to represent cell phone plan cost over a specific amount of usage and I'm generate 8 values, 1-5 are below the allowed usage while 6-8 are demonstrations of the cost for usage over the limit.
The problem I'm encountering is how to set the range of the X axis in ruby on rails to something specific to the data. Right now the values being displayed are the indexes of the array that I'm giving. When I try to hand a hash to the values the chart doesn't even load at all.
So basically I need help getting a way to set the data for my line properly so that it displays correctly, right now it is treating every value as if it represents the x value of the index of the array.
Here is a screen shot which may be a better description than what I am saying: http://i163.photobucket.com/albums/t286/Xeno56/Screenshot.png Note that those values are correct just the range on the x-axis is incorrect, it should be something like 100, 200, 300, 400, 500, 600, 700
Code:
y = YAxis.new
y.set_range(0,100, 20)
x_legend = XLegend.new("Usage")
x_legend.set_style('{font-size: 20px; color: #778877}')
y_legend = YLegend.new("Cost")
y_legend.set_style('{font-size: 20px; color: #770077}')
chart =OpenFlashChart.new
chart.set_x_legend(x_legend)
chart.set_y_legend(y_legend)
chart.y_axis = y
line = Line.new
line.text = plan.name
line.width = 2
line.color = '#006633'
line.dot_size = 2
line.values = generate_data(plan)
chart.add_element(line)
def generate_data(plan)
values = []
#generate below threshold numbers
5.times do |x|
usage = plan.usage / 5 * x
cost = plan.cost
values << cost
end
#generate above threshold numbers
3.times do |x|
usage = plan.usage + ((plan.usage / 5) * x)
cost = plan.cost + (usage * plan.overage)
values << cost
end
return values
end
Also the other problem I'm having is I can't just add a few points as any values I give are taken as x being the elements position in the array and y being the value, whereas I need to be able to specify the x and y values for each point so I don't have to buffer my array with a bunch of null values
You have to create an XAxis Object to set the labels:
x = XAxis.new
x.labels = [100, 200, 300, 400, 500, 600, 700].collect(&:to_s)
chart.x_axis = x
From my experience there are many ways to do things with Open Flash Chart 2. mikezter example above is almost correct; however, this is how I set the XAxis labels.
x = XAxis.new
x.set_labels([100, 200, 300, 400, etc]).collect(&:to_s)
chart.x_axis = x
Note the only difference between my example and mikezter's is I use:
x.set_labels([array values etc])
instead of
x.labels = [array values etc]
I ended up ditching open flash chart 2 and going with Flotr

Resources