核心情节自定义主题?

2023-12-23

我在 iPhone 应用程序中使用 Core-Plot 绘制趋势图,但尚未找到如何自定义背景。我可以使用内置主题创建主题,例如 kCPPlainWhiteTheme,但如何更改它们?或者创建一个新的?

我基本上需要做的就是使背景透明。

编辑/更新

我刚刚测试了这段代码,但它似乎不起作用:

    //CPTheme *theme = [CPTheme themeNamed:kCPPlainWhiteTheme];
    CPTheme *theme = [[CPTheme alloc]init];
    chartTrend5 = (CPXYGraph *)[theme newGraph];    
    chartView.hostedGraph = chartTrend5;
    chartTrend5.paddingLeft = 0.0;
    chartTrend5.paddingTop = 0.0;
    chartTrend5.paddingRight = 0.0;
    chartTrend5.paddingBottom = 0.0;
    chartTrend5.fill = nil;
    chartTrend5.borderLineStyle = nil;
    chartView.hostedGraph.fill = nil;

    chartTrend5PlotSpace = (CPXYPlotSpace *)chartTrend5.defaultPlotSpace;
    chartTrend5PlotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
                                                              length:CPDecimalFromFloat(5)];

    // range is 0-125, but since the frame heights is 90, 
    // we need to convert the points to this adjusted scale. The factor is 0.72 => (90/125)
    chartTrend5PlotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0)
                                                              length:CPDecimalFromFloat(90)];



    CPXYAxisSet *axisSet = (CPXYAxisSet *)chartTrend5.axisSet;

    CPXYAxis *x = axisSet.xAxis;
    x.majorIntervalLength =  CPDecimalFromFloat(100);
    //x.constantCoordinateValue = CPDecimalFromFloat(2);
    x.minorTicksPerInterval = 2;
    x.borderWidth = 0;
    x.labelExclusionRanges = [NSArray arrayWithObjects:
                              [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-1) 
                                                          length:CPDecimalFromFloat(800)], 
                              nil];;

    CPXYAxis *y = axisSet.yAxis;
    y.majorIntervalLength = CPDecimalFromFloat(100);
    y.minorTicksPerInterval = 1;
    //y.constantCoordinateValue = length:CPDecimalFromFloat(2);
    y.labelExclusionRanges = [NSArray arrayWithObjects:
                              [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(-26) 
                                                          length:CPDecimalFromFloat(100)], 
                              nil];





    CPScatterPlot *dataSourceLinePlot = [[[CPScatterPlot alloc] init] autorelease];
    dataSourceLinePlot.identifier = @"TrendChart";
    dataSourceLinePlot.dataLineStyle.lineWidth = 2.f;
    dataSourceLinePlot.dataLineStyle.lineColor = [CPColor colorWithComponentRed:(16/255.f) 
                                                                          green:(101/255.f) 
                                                                           blue:(122/255.f) 
                                                                          alpha:1];
    dataSourceLinePlot.dataSource = self;
    [chartTrend5 addPlot:dataSourceLinePlot];
    chartTrend5.fill = nil;
    // Put an area gradient under the plot above

    CPColor *areaColor = [CPColor colorWithComponentRed:(212/255.f) 
                                                  green:(233/255.f)
                                                   blue:(216/255.f)
                                                  alpha:1];

    CPGradient *areaGradient = [CPGradient gradientWithBeginningColor:areaColor 
                                                          endingColor:areaColor];
    areaGradient.angle = -90.0f;
    CPFill *areaGradientFill = [CPFill fillWithGradient:areaGradient];
    dataSourceLinePlot.areaFill = areaGradientFill;
    dataSourceLinePlot.areaBaseValue = CPDecimalFromString(@"5.25");

这里我设置了 fill 属性CPXYGraph *图表趋势5 and *CPXYPlotSpace *chartTrend5PlotSpace to nil.


除了埃里克建议的之外,您还可以尝试将填充设置为透明颜色。例如,我过去曾使用它为图表提供透明背景:

CPTTheme *theme = [CPTTheme themeNamed:kCPPlainWhiteTheme];
graph = (CPTXYGraph *)[theme newGraph];

graph.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
graph.plotAreaFrame.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

核心情节自定义主题? 的相关文章

随机推荐

  • DataTable 内的 Markdown 正在其周围添加段落

    当 DashTable 中使用 markdown 时 需要额外增加一个 p 添加标签使单元格和实习生所有行变大 import dash from dash import dash table app dash Dash app layout
  • 在三星上,Compose AlertDialog 始终采用全宽

    在我的配备 One UI 5 0 和 Android 13 的三星 Galaxy S22 上 撰写 AlertDialog 始终占据全宽 在其他设备上它的工作方式与预期一致 Compose版本是1 3 1 您只需下载即可重现此内容 我怀疑这
  • 为什么我的 WPF 应用程序禁用了拖放功能(即使当 AllowDrop 为 true 时)?

    我的 WPF 应用程序禁止从 Windows 资源管理器中删除文件 并显示停止标志光标 我尝试在主窗口和包含的控件上将AllowDrop属性 UIElement祖先的属性 设置为true 但完全没有运气 没有触发拖放事件 有什么想法或建议来
  • 区分具有未知功能的产品 - sympy

    我尝试了各种搜索 但找不到一个好的谷歌字符串来得出正确的结果 我有以下形式的产品 y x f x 其中 f 是 x 的未知函数 我希望 sympy 对 y 相对于 x 进行微分 有谁知道我该怎么做 怎么样 gt gt gt x sympy
  • jQuery .trigger('click') 在间隔函数内?

    这是一个改写的问题here https stackoverflow com questions 5031019 stuck on weird jquery error 经过一些测试后 我隔离了问题 但没有解决它的线索 无需阅读上一个问题 这
  • 为什么线程过程应该是静态的或成员函数

    为什么线程过程应该是静态的或成员函数 有什么正当理由吗 非静态成员变量有一个隐式的this编译器内部传递的参数 You have ClassInQuestion void threadFunc int 并且编译器内部创建了一个函数 void
  • DataTable.Merge 和 DataTable.ImportRow 不会更改 RowState

    我在 ADO NET 2 0 合并 导入数据时遇到问题 我需要将数据从一个通用表更新 插入到另一个表 并且两个表都保持相同的架构 以下代码在本地运行良好 但不会对数据库进行更改 OleDbDataAdapter localDA loadLo
  • mailgun 传入邮件事件获取附件 url

    我有一个节点端点 它接收 json 格式的传入电子邮件 其中包含来自 mailgun 的所有附件 附件位于 json 数组中 xxx com 用于隐私 attachments url https sw api mailgun net v3
  • 导航架构组件 - 将参数数据传递到 startDestination

    我有一个活动 A 启动活动 B 并向其传递一些意图数据 活动 B 托管来自新导航架构组件的导航图 我想将该意图数据作为参数传递给 startDestination 片段 如何做到这一点 好的 感谢 Google 团队的 Ian Lake 我
  • 正确传输和保护 Web 应用程序的用户密码

    我正在为我的硕士项目开发一个网络应用程序 这是一个供教授管理学生项目的系统 它使用Java作为服务器端代码 使用HSQLDB作为数据库 使用JSP作为表示层 并且运行在tomcat上 将存储的数据不包括任何敏感信息 学生 ID 财务信息等
  • FixIO 是做什么的?

    The System IO 文档 https hackage haskell org package base 4 5 0 0 docs System IO html包含一个神秘的 未记录的函数fixIO 它的来源 https hackag
  • 显示 Maven dependency:tree 中省略的版本?

    在 Eclipse 中 当我转到 Maven 依赖关系层次结构页面时 我得到的输出指出了哪些冲突导致版本被忽略 但是 如果我使用依赖 树 http maven apache org plugins maven dependency plug
  • purescript 中列表/数组中的类似记录类型

    有什么办法可以做类似的事情 first x 0 second x 1 y 1 both first second 这样both被推断为 x Int r 或类似的东西 我尝试过一些事情 x 3 Array forall r x Int r n
  • 无锁堆栈实现想法 - 目前已损坏

    我想出了一个想法 尝试实现一个无锁堆栈 该堆栈不依赖引用计数来解决 ABA 问题 并且还可以正确处理内存回收 它在概念上与 RCU 类似 并且依赖于两个功能 将列表条目标记为已删除 以及跟踪遍历列表的读者 前者很简单 它只使用指针的LSB
  • 找不到处理 market:// URI 的活动

    我有一个 bugsense 帐户 用于跟踪我公司 Android 应用程序的崩溃报告 我们的应用程序需要安装一个单独的应用程序 即服务 否则该应用程序将无法运行 我们通过检查是否安装了其他应用程序 服务 来处理此问题 如果没有安装 我们将用
  • 填写 ={ARRAYFORMULA()} 中的空白单元格

    我有一张包含稀疏数据的人性化工作表 PART FRUIT Alpha Apples Pears Beta Lemons Oranges 我想创建第二个自动更新的机器友好工作表 该工作表将填充 PART 列中的所有空单元格 PART FRUI
  • 如何在清单文件中注册应用程序类?

    如何在我的 Android 清单中注册我的应用程序类 网上看了很多教程 还是不太明白 我的应用程序类称为Monitor java 如何在下面的Manifest文件代码中注册它
  • InputMethodManager 在 web 视图中显示小键盘

    我正在使用 InputMethodManager 在需要时以编程方式显示软键盘 InputMethodManager imm InputMethodManager getSystemService Context INPUT METHOD
  • Joda时间的DateTime转换为java.util.Date奇怪问题

    我遇到了一个奇怪的问题 这是描述它的代码片段 DateTimeZone dtz DateTimeZone forOffsetHours 0 DateTime dt new DateTime dtz System out println dt
  • 核心情节自定义主题?

    我在 iPhone 应用程序中使用 Core Plot 绘制趋势图 但尚未找到如何自定义背景 我可以使用内置主题创建主题 例如 kCPPlainWhiteTheme 但如何更改它们 或者创建一个新的 我基本上需要做的就是使背景透明 编辑 更