Želim (ampak ne znam
Primer
x1 y1 x2 y2
1 1 3 1
4 2 4 7
...
Podatki bi bili v obliki tabele (poljubno št. vrstic) v Excelu, graf/slika pa bi se izrisala ob tabeli
Ravnokar mi je uspelo izrisati 10 daljic. Za vrsto grafikona je izbran graf xy raztreseni, podatke pa je potrebno za vsak graf (dalljico) ponovno označevati. Tako za x os naprimer določim območje A2; C2, za y os pa območje B2 in D2. Excel nato ustrezni vrednosti x pripiše ustrezen y (prvemu x ustreza prvi y...). Tako dobim točke - točka 1: T1(A2,B2); točka 2: T2(C2,D2). Med njima nariše graf - daljico.admin napisal/-a: Pravo vprašanje je kako bi vi narisali graf z 10 daljicami
Koda: Izberi vse
Sub RisiDaljice()
'
' Napisal: Matjaž Prtenjak
' www.matjazev.net
'
' Datum: 27.11.2008
'
Dim obmocje As Range
Set obmocje = Selection.CurrentRegion
' Območje mora imeti natanko 5 kolon.
' V prvi koloni je ime daljice
' V drugi in tretji koloni sta X in Y začetne točke daljice
' V tretji in četrti koloni sta X in Y končne točke daljice
Dim list As String
list = ActiveSheet.Name & "!"
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=obmocje, PlotBy:=xlRows
Dim daljica As Integer
Dim ime As String, x As String, x1 As String, y As String, y1 As String
For daljica = 1 To obmocje.Rows.Count - 1
ime = obmocje.Cells(1, 1).Offset(daljica, 0)
x = list & obmocje.Cells(1, 1).Offset(daljica, 1).Address(ReferenceStyle:=xlR1C1)
y = list & obmocje.Cells(1, 1).Offset(daljica, 2).Address(ReferenceStyle:=xlR1C1)
x1 = list & obmocje.Cells(1, 1).Offset(daljica, 3).Address(ReferenceStyle:=xlR1C1)
y1 = list & obmocje.Cells(1, 1).Offset(daljica, 4).Address(ReferenceStyle:=xlR1C1)
ActiveChart.SeriesCollection(daljica).Name = ime
ActiveChart.SeriesCollection(daljica).XValues = "=(" & x & "," & x1 & ")"
ActiveChart.SeriesCollection(daljica).Values = "=(" & y & "," & y1 & ")"
Next
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub
Koda: Izberi vse
ime x1 y1 x2 y2
t1 -3 -13 14 1
t2 -11 13 -4 4
t3 -7 10 -10 0
Koda: Izberi vse
x1 y1 x2 y2 barva
t1 -3 -13 14 1 <celico pobarvajte tako, kot zelite barvo črte>
t2 -11 13 -4 4 <celico pobarvajte tako, kot zelite barvo črte>
t3 -7 10 -10 0 <celico pobarvajte tako, kot zelite barvo črte>
Koda: Izberi vse
Sub RisiDaljice()
'
' Napisal: Matjaž Prtenjak
' www.matjazev.net
'
' Datum: 27.11.2008
'
Dim obmocje As Range
Set obmocje = Selection.CurrentRegion
' Območje mora imeti natanko 6 kolon.
' V prvi koloni je ime daljice
' V drugi in tretji koloni sta X in Y začetne točke daljice
' V četrti in peti koloni sta X in Y končne točke daljice
' Šesta kolona mora biti pobarvana
Dim list As String
list = "'" & ActiveSheet.Name & "'!"
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=obmocje, PlotBy:=xlRows
Dim daljica As Integer
Dim ime As String, x As String, x1 As String, y As String, y1 As String, ci As Integer
For daljica = 1 To obmocje.Rows.Count - 1
ime = obmocje.Cells(1, 1).Offset(daljica, 0)
x = list & obmocje.Cells(1, 1).Offset(daljica, 1).Address(ReferenceStyle:=xlR1C1)
y = list & obmocje.Cells(1, 1).Offset(daljica, 2).Address(ReferenceStyle:=xlR1C1)
x1 = list & obmocje.Cells(1, 1).Offset(daljica, 3).Address(ReferenceStyle:=xlR1C1)
y1 = list & obmocje.Cells(1, 1).Offset(daljica, 4).Address(ReferenceStyle:=xlR1C1)
ci = obmocje.Cells(1, 1).Offset(daljica, 5).Interior.ColorIndex
ActiveChart.SeriesCollection(daljica).Name = ime
ActiveChart.SeriesCollection(daljica).XValues = "=(" & x & "," & x1 & ")"
ActiveChart.SeriesCollection(daljica).Values = "=(" & y & "," & y1 & ")"
ActiveChart.SeriesCollection(daljica).Border.ColorIndex = ci
Next
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub