highcharts / highcharts-ios

iOS wrapper for Highcharts.
Other
126 stars 39 forks source link

date format is not working #251

Closed guptavirendra closed 4 years ago

guptavirendra commented 5 years ago

Hi, I had set below mentioned code for x Axis. class func getDateTimeLabel()->HIDateTimeLabelFormats { let label = HIDateTimeLabelFormats()

    let seconds = HISecond()
    seconds.main = "%l:%M:%S %p"
    label.second = seconds

    let minute = HIMinute()
    minute.main = "%l:%M %p"
    label.minute = minute

    let hour = HIHour()
    hour.main = "%m/%d/%y %l:%M %p"

    let day = HIDay()
    day.main = "%m/%d/%Y"
    label.day = day

    let week = HIWeek()
    week.main = "%m/%d/%Y"
    label.week = week

    let month = HIMonth()
    month.main =  "%b '%y"
    label.month = month

    let year = HIYear()
    year.main = "%Y"
    label.year = year

    return label
}

but it always shows 24 hours format. Please see attached screen shot. Please have a look on the urgent basis. As this was reported by client in production environment. Thanks in advance. Image-1 (3)

guptavirendra commented 5 years ago

Please respond asap

ihnatmoisieiev commented 5 years ago

Hello @guptavirendra,

please send your HIChartView options.

guptavirendra commented 5 years ago

just a min

guptavirendra commented 5 years ago

extension HIOptionProvidable { var options:HIOptions { let boost = HIBoost() boost.useGPUTranslations = NSNumber(value:true)

    let option = HIOptions()
    option.boost = boost
    let time =  HITime()
    time.timezone = TimeZone.autoupdatingCurrent.identifier // "Asia/Kolkata"
    option.time = time
    option.exporting = HIExporting()
    option.exporting.enabled = NSNumber(value:false)

    let credit = HICredits()
    credit.enabled = NSNumber(value:false)
    option.credits = credit
    return option
}

} /**/ options.chart = graphViewOption.getChart() options.xAxis = [graphViewOption.getxAxis()] options.yAxis = [graphViewOption.getyAxis()]

        options.series  = graphViewOption.getSeriess()
        options.legend  = graphViewOption.getLegend()
        options.tooltip = graphViewOption.getToolTip()
        options.title   = graphViewOption.getTitle()

/*****

func getAxisData() ->HIXAxis{

    let xaxis = HIXAxis()
    xaxis.startOnTick = true
    xaxis.endOnTick   = true
    xaxis.labels = HILabels()
    xaxis.labels.enabled  = NSNumber(value:false)
    xaxis.labels.rotation = NSNumber(integerLiteral: -45) // show rotation

    /* we have set xaxis type is date and time */
    if let type = self.type
    {
        xaxis.type = type
    }
    if shouldShowXlable == true
    {
       /* this will create x axis display format*/
        xaxis.dateTimeLabelFormats = HIDateTimeLabelProvider.getDateTimeLabel()
    }
    if startEndArray.count > 1
    {
        xaxis.min = self.getMinNumber()
        xaxis.max = self.getMaxNumber()
    }
    xaxis.tickColor = HIColor(rgba: 255, green: 255, blue: 255, alpha: 0.0)
    xaxis.lineColor = HIColor(rgba: 255, green: 255, blue: 255, alpha: 0.3)
    xAxis.labels.enabled = NSNumber(value: true)
    xAxis.dateTimeLabelFormats = HIDateTimeLabelProvider.getDateTimeLabel()
    xAxis.title = TitleProvider.getTitleForText(text:NSLocalizedString("Date", comment: "Date"))
    return xaxis
    }

//MARK: HIDateTimeLabelProvider /Date time as pe tooltip / class HIDateTimeLabelProvider { class func getDateTimeLabel()->HIDateTimeLabelFormats { let is24hClock = Locale.autoupdatingCurrent.uses24hClock() let label = HIDateTimeLabelFormats()

    let seconds = HISecond()
    seconds.main =  is24hClock == true ? "%H:%M:%S" : "%l:%M:%S %p"
    label.second = seconds

    let minute = HIMinute()
    minute.main = is24hClock == true ? "%H:%M" :"%l:%M %p"
    label.minute = minute

    let hour = HIHour()
    hour.main = is24hClock == true ? "%m/%d/%y %H:%M" : "%m/%d/%y %I:%M %p"

    let day = HIDay()
    day.main = "%m/%d/%Y"
    label.day = day

    let week = HIWeek()
    week.main = "%m/%d/%Y"
    label.week = week

    let month = HIMonth()
    month.main =  "%b '%y"
    label.month = month

    let year = HIYear()
    year.main = "%Y"
    label.year = year

    return label
}

}

ihnatmoisieiev commented 5 years ago

@guptavirendra thank you. What format do you want to get? You don't set xaxis.labels.format or xaxis.labels.formatter.

guptavirendra commented 5 years ago

I had set xAxis.dateTimeLabelFormats = /// object of this. HIDateTimeLabelFormats()

guptavirendra commented 5 years ago

I had to set Axis format on the basis of range. let say if there are data regarding decade then in that case i have to show Axis like: 2000 2001 2002 ..

if there are data regarding on year then like: jan 2019 feb 2019 mar2019

similarly if there are data for last 24 hours then like: if system data time is 12 hours format then

8 : 00 am 25/10/2019 10:00 am 2PM if date format is 24 hours then 8 :00 25/10/2019 10:00 14:00

if I use xaxis.labels.formattter or xaxis.labels.format then it always show same formt

guptavirendra commented 5 years ago

IMG_0099 IMG_0100 IMG_0101 IMG_0102 IMG_0103

Please see all images with different x axis range.

guptavirendra commented 5 years ago

Please do respond

guptavirendra commented 5 years ago

As per your documents I have used this /** For a datetime axis, the scale will automatically adjust to the appropriate unit. This member gives the default string representations used for each unit. For intermediate values, different units may be used, for example the day unit can be used on midnight and hour unit be used for intermediate values on the same axis. For an overview of the replacement codes, see dateFormat. Defaults to: { millisecond: '%H:%M:%S.%L', second: '%H:%M:%S', minute: '%H:%M', hour: '%H:%M', day: '%e. %b', week: '%e. %b', month: '%b \'%y', year: '%Y' }

Try it

ihnatmoisieiev commented 5 years ago

@guptavirendra what the rule you want to use? Also please check your is24hClock value.

guptavirendra commented 5 years ago

is24hClock value is working as expected but format was not set properly. If I have removed this then still was not working. On Fri, 25 Oct, 2019, 17:34 ihnatmoisieiev, notifications@github.com wrote:

@guptavirendra https://github.com/guptavirendra what the rule you want to use? Also please check your is24hClock value.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/highcharts/highcharts-ios/issues/251?email_source=notifications&email_token=AAGZVISM4AMKXGWFFYGUVNLQQLODRA5CNFSM4JE7TV4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECIESXQ#issuecomment-546326878, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGZVIVHUZ2T4PVBNY7LJ3TQQLODRANCNFSM4JE7TV4A .

guptavirendra commented 5 years ago

Actually my main concern about intermediate value in case of second screen shot date is displaying but intermediate value is autopopulated in my case for last 24 hours data there is only 1 date, that is working as expected but intermediate value is not populated as expected.

On Fri, 25 Oct, 2019, 17:36 Virendra Kumar, writeme.virendra@gmail.com wrote:

is24hClock value is working as expected but format was not set properly. If I have removed this then still was not working. On Fri, 25 Oct, 2019, 17:34 ihnatmoisieiev, notifications@github.com wrote:

@guptavirendra https://github.com/guptavirendra what the rule you want to use? Also please check your is24hClock value.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/highcharts/highcharts-ios/issues/251?email_source=notifications&email_token=AAGZVISM4AMKXGWFFYGUVNLQQLODRA5CNFSM4JE7TV4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECIESXQ#issuecomment-546326878, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGZVIVHUZ2T4PVBNY7LJ3TQQLODRANCNFSM4JE7TV4A .

guptavirendra commented 5 years ago

Hi, Can you please tell me working example of this property *@Property(nonatomic, readwrite) HIDateTimeLabelFormats dateTimeLabelFormats;** if my device time is set as 24 hours and 12 hours. My concern about intermediate value like 7:00 am, 9:00 am etc in 12 hours, 07:00, 9:00, ...., 14:00, 16:00 in 24 hours.

guptavirendra commented 5 years ago

Please do respond.

ihnatmoisieiev commented 4 years ago

Duplicate of https://github.com/highcharts/highcharts-ios/issues/254