Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can I set string values on the x axis with the ability to adjust the number of values something like "setTickCount()"

Can I set string values on the x axis with the ability to adjust the number of values something like "setTickCount()"

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 289 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    quant12345
    wrote on last edited by quant12345
    #1

    Created a candlestick chart with DateTime values on the x axis.
    As you can see in the picture, you get empty spaces on weekends.

    picture1
    I created an additional " QLineSeries()".
    On candles on the x axis indexes 0, 1, 2 ...... etc.
    "QLineSeries () "data in "DateTime" format.

    Made invisible:
    x axis of the candle chart and "QLineSeries()".
    creating the
    "QDateTimeAxis() "axis for "QLineSeries()".

    self._chart.axisX(self._candlestick_serie).setVisible(False)
    self._line_serie.setVisible(False)
    

    It turned out what you need, there are no empty spaces.
    picture2

    Can I make it easier by creating string values on the x axis?
    With the ability to adjust the number of displayed values, something like a function "setTickCount()"

    In C#, you can set the caption text along the X-axis.

    int INDEX = 0;
    foreach (DataPoint point in chart1.Series["price"].Points)
       {
       point.AxisLabel = nums[INDEX].ToString();//nums[INDEX] format array DateTime
       INDEX++;
       }
    

    English is not my native language, please be sympathetic)

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      quant12345
      wrote on last edited by
      #2

      I managed to put string values on the x axis(datetime data is converted to a string).
      Created on the x axis QBarCategoryAxis.
      Everything would be fine, but I can't adjust tick marks on the axis.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved