ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  getHTMLImageMap for mixed data types
Posted by Ben on Aug-22-2014 02:05
Attachments:
Hello,

I have a problem with mixed (but related) data types on a MultiChart, in a WinForm, in getHTMLImageMap.

In my code, if I use
chrFX.ImageMap = M.getHTMLImageMap("", "", "title='{xLabel}:{dataSetName}: {value}'")

Pic1 shows that the time comes out as the number of seconds.  I formatted my yAxis to show times with .yAxis.setDateScale("{value|hh:nn:ss}").

The other two yAxis are defaults.

If I switch to
chrFX.ImageMap = M.getHTMLImageMap("", "", "title='{xLabel}:{dataSetName}: {value|hh:nn:ss}'")

Then the time is correct, as in Pic2, but then my other data plots come up as times, as in Pic3, but that is expected since it is a generic formatter applied to all data.


My question is, how can I format the {value} in the mouse over for the proper data type?  I'm guessing a set of calls to the child charts, but I'm unsure the ordering of everything.


Thanks,
   Ben

PS, I know the code is messy, but I'm in the middle of swapping charting engines, and the methods of data entry between the two are quite different.  And yes, I'm working on getting a license for this type of code release (I have a dev license, but not a release license).
Pic1.PNG
Pic2.PNG
Pic3.PNG
Code.vb
Public Sub LPAllTubesChart( _
              ByRef adoDataTable As ADODB.Recordset, _
              ByVal strFieldsPane1() As String, _
              ByVal strFieldsPane2() As String, _
              ByVal strFieldsPane3() As String, _
              ByVal strFieldXLabel As String, _
              ByVal strChartTitle As String, _
              ByVal chrFX As ChartDirector.WinChartViewer)

    If Not adoDataTable.BOF Then adoDataTable.MoveFirst()

    Dim NumOfSeries As Integer = (strFieldsPane1.Length + _
                        strFieldsPane2.Length + strFieldsPane3.Length) / 2
    Dim NumOfPoints As Integer = adoDataTable.RecordCount
    Dim series As Integer

    Dim M As New ChartDirector.MultiChart(chrFX.Width, chrFX.Height)
    Dim PlotHeight As Integer = M.getHeight() - 55 - 20
    Dim SubOffset As Integer = 5
    Dim SubHeight As Integer = (PlotHeight \\ 3) - (SubOffset * 2)

    Dim C1 As New ChartDirector.XYChart(chrFX.Width, SubHeight)
    Dim C2 As New ChartDirector.XYChart(chrFX.Width, SubHeight)
    Dim C3 As New ChartDirector.XYChart(chrFX.Width, SubHeight + 20)
    C1.setPlotArea(70, 10, C1.getWidth() - 72, C1.getHeight() - 15, -1)
    C2.setPlotArea(70, 10, C2.getWidth() - 72, C2.getHeight() - 15, -1)
    C3.setPlotArea(70, 10, C3.getWidth() - 72, C3.getHeight() - 30, -1)

    M.addChart(0, 20, C1)
    M.addChart(0, 20 + SubHeight + SubOffset, C2)
    M.addChart(0, 20 + (SubHeight + SubOffset) * 2, C3)

    Dim DataX As New List(Of String)
    Dim DataY As New List(Of List(Of Double))
    For I As Integer = 1 To NumOfSeries
      DataY.Add(New List(Of Double))
    Next

    ' setup the chart chrFX to display the data from the adoDataset
    'With Chrt
    ' initialize the chart data
    '.ClearData(SoftwareFX.ChartFX.ClearDataFlag.AllData)
    '.Panes.Clear()
    M.addTitle(strChartTitle)
    '.Titles(0).Text = strChartTitle
    '.Titles(0).Font = New System.Drawing.Font(.Titles(0).Font, FontStyle.Bold)

    ' setup for 3 panes
    '.Axis(0).Pane = 0
    '.Axis(1).Pane = 1
    '.Axis(3).Pane = 2

    ' assign the series to the axes
    ' First Pane
    series = 0
    ' Second Pane
    For i As Integer = 0 To strFieldsPane2.Length / 2 - 1
      series += 1
    Next
    ' Third Pane
    For i As Integer = 0 To strFieldsPane3.Length / 2 - 1
      series += 1
    Next

    Dim minP1 As Double = Double.MaxValue, maxP1 As Double = Double.MinValue
    Dim minP2 As Double = Double.MaxValue, maxP2 As Double = Double.MinValue
    Dim minP3 As Double = Double.MaxValue, maxP3 As Double = Double.MinValue

    ' Axis-Y
    ' assign the data to chart
    Dim valueY As Double
    Dim valueX As String

    For point As Integer = 0 To NumOfPoints - 1
      ' Axis-X label
      valueX = adoDataTable.Fields(strFieldXLabel).Value
      DataX.Add(valueX)        '-----  .AxisX.Label(point) = valueX

      ' First Pane
      valueY = ChartDirector.Chart.CTime(CDate(adoDataTable.Fields(strFieldsPane1(0)).Value))
      series = 0
      DataY(series).Add(valueY) '-----  .Value(series, point) = valueY
      If minP1 > valueY Then minP1 = valueY
      If maxP1 < valueY Then maxP1 = valueY

      ' Second Pane
      '.Value(1, point) = adoDataTable.Fields("SiD").Value
      '.Value(2, point) = adoDataTable.Fields("SiI").Value
      '.Value(3, point) = adoDataTable.Fields("CLP").Value
      For i As Integer = 0 To strFieldsPane2.Length / 2 - 1
        valueY = adoDataTable.Fields(strFieldsPane2(i * 2)).Value
        series += 1
        DataY(series).Add(valueY)   '-----  .Value(series, point) = valueY
        If minP2 > valueY Then minP2 = valueY
        If maxP2 < valueY Then maxP2 = valueY
      Next

      ' Third Pane
      '.Value(4, point) = adoDataTable.Fields("Z1Temp").Value
      '.Value(5, point) = adoDataTable.Fields("Z2Temp").Value
      '.Value(6, point) = adoDataTable.Fields("Z3Temp").Value
      For i As Integer = 0 To strFieldsPane3.Length / 2 - 1
        valueY = adoDataTable.Fields(strFieldsPane3(i * 2)).Value
        series += 1
        DataY(series).Add(valueY)    '----- .Value(series, point) = valueY
        If minP3 > valueY Then minP3 = valueY
        If maxP3 < valueY Then maxP3 = valueY
      Next

      adoDataTable.MoveNext()
    Next
    C2.yAxis.setLinearScale(minP2, maxP2)
    C3.yAxis.setLinearScale(minP3, maxP3)


    series = 0
    Dim L As ChartDirector.Layer
    L = C1.addLineLayer
    L.addDataSet(DataY(series).ToArray(), -1, strFieldsPane1(1))

    L = C2.addLineLayer
    For i As Integer = 0 To strFieldsPane2.Length / 2 - 1
      series += 1
      L.addDataSet(DataY(series).ToArray(), -1, strFieldsPane2(i * 2 + 1))
    Next

    L = C3.addLineLayer
    For i As Integer = 0 To strFieldsPane3.Length / 2 - 1
      series += 1
      L.addDataSet(DataY(series).ToArray(), -1, strFieldsPane3(i * 2 + 1))
    Next


    C1.xAxis.setLabels(DataX.ToArray)
    C1.xAxis.setLabelFormat(" ")
    C2.xAxis.setLabels(DataX.ToArray)
    C3.xAxis.setLabels(DataX.ToArray)

    Call LPChartFormatEx(strFieldsPane1, strFieldsPane2, strFieldsPane3, strFieldXLabel, C1, C2, C3)

    chrFX.Chart = M
    chrFX.ImageMap = M.getHTMLImageMap("", "", "title='{xLabel}:{dataSetName}: {value}'")
    '    chrFX.ImageMap = M.getHTMLImageMap("", "", "title='{xLabel}:{dataSetName}: {value|hh:nn:ss}'")

  End Sub


 Private Sub LPChartFormatEx( _
            ByVal strFieldsPane1() As String, _
            ByVal strFieldsPane2() As String, _
            ByVal strFieldsPane3() As String, _
            ByVal strAxisXTitle As String, _
            ByVal ParamArray chrFX() As ChartDirector.XYChart)
    ' point value
    '.PointLabels = True
    '.AxisX.Staggered = True

    ' title
    With chrFX(0)
      .yAxis.setTitle("Times", "", 8)
      .yAxis.setDateScale("{value|hh:nn:ss}")
      .yAxis.setAutoScale(0.03, 0.03)
    End With
    With chrFX(1)
      .yAxis.setTitle("SCCM", "", 8)
      .yAxis.setAutoScale(0.03, 0.03)
    End With
    With chrFX(2)
      .yAxis.setTitle("Degree C", "", 8)
      .yAxis.setAutoScale(0.03, 0.03)
      .xAxis.setTitle("Entity", "", 8)
    End With

    ' grid lines
    '.Axis(0).Gridlines = True
    '.Axis(1).Gridlines = True
    '.Axis(3).Gridlines = True
    
  End Sub

  Re: getHTMLImageMap for mixed data types
Posted by Peter Kwan on Aug-23-2014 01:22
Hi Ben,

After you add a layer, you can use Layer.setHTMLImageMap to specify the image map
configuration for that layer. It is like:

L = C1.addLineLayer
L.setHTMLImageMap("", "", "title='{value}'")

The configuration in getHTMLImageMap only applies to layers that do not have their own
image map configured with setHTMLImageMap. With setHTMLImageMap, you can choose
different tooltip formats for different layers.

Hope this can help.

Regards
Peter Kwan

  Re: getHTMLImageMap for mixed data types
Posted by Ben on Aug-28-2014 02:34
Awesome!  That worked perfectly.  Thanks!